# cpuset For all processes PLEASE HELP



## DigiSoft (Jan 13, 2010)

Ok so I have core 2 duo processor and I have gaming server installed.

Now what I want is to set EVERYTHING to run on CPU0 and the gaming server to run on CPU1.

How can I do this.

cpuset is very slow process for doing it manual and there are new processes created all the time so I can't keep truck on them and set them to CPU0.

Can I set some option so when the system boots by default all the processes would be assigned to CPU).

Thank you.


----------



## DutchDaemon (Jan 13, 2010)

Something you could try:

Start everything, _except the game server_. Everything now running is by default in 'set 1'.

Run `# cpuset -l 0 -s 1`

Almost everything will immediately switch to the first CPU (cpu0) (it may take a while).

Start the game server and assign it to the other CPU (cpu1) using cpuset.

I'm not sure if there are automatic ways to do this (something done at boot time), but this is just what I got from cpuset(1), specifically this example:


```
Modify the cpuset all threads are in by default to contain only the first
     4 CPUs, leaving the rest idle:
           cpuset -l 0-3 -s 1
```


----------



## DigiSoft (Jan 13, 2010)

It works but when I try to run the server with cpuset 0
I get this 

cpuset: setaffinity: Resource deadlock avoided


----------



## DigiSoft (Jan 13, 2010)

Sorry for double post but I couldn't edit my post.

Ok I've managed to set the server id to cpuset -l 0 -s 0 -p 35056


----------



## DutchDaemon (Jan 13, 2010)

Can't you use `# cpuset -l 1 -p <pid_of_game_server>`? The other processes should already be confined to the first CPU (cpu0) by the previous `# cpuset -l 0 -s 1` command.


----------



## DutchDaemon (Jan 13, 2010)

Anyway  Whatever works for you


----------



## DigiSoft (Jan 13, 2010)

I must use
cpuset -l 1 -s 1 -p 35056

is it ok?


----------



## SirDice (Jan 13, 2010)

DigiSoft said:
			
		

> I must use
> cpuset -l 1 -s 1 -p 35056
> 
> is it ok?


If 35056 is the game server's PID. You can also use something like this:
`# cpuset -l 1 -s 1 -p `pgrep gameserver_exe``


----------



## DigiSoft (Jan 13, 2010)

SirDice said:
			
		

> If 35056 is the game server's PID. You can also use something like this:
> `# cpuset -l 1 -s 1 -p `pgrep gameserver_exe``



Thank you great reply. Also thanks DutchDaemon

I have 2 questions

1. Does this command cpuset -l 0 -s 1 forces all new processes to run on cpu 0

2. Why do I have 2 or 3 processes that still run on cpu 1


----------



## DutchDaemon (Jan 13, 2010)

From what I understand: before you apply the cpuset command to _anything_, _everything_ will be affected by `# cpuset -l 0 -s 1`. The manual appears to suggest that "the cpuset all threads are in by default" is set 1 (-s 1). Assigning that set to cpu0, and then starting the game server on cpu1 should give you the desired 'separation of CPUs'. I'm not sure why some processes stick to the CPU they were launched on, but do note that cpuset is very new. You could try restarting the processes that refuse to move over to their assigned CPU (if they're restartable, that is ), or simply run cpuset against their PID.


----------



## DigiSoft (Jan 13, 2010)

My friend I must tell you that my lag on the server dropped completely when I separated the processes. THANK you so much.

getty is stucked on CPU 0 and I don't know why


----------



## DutchDaemon (Jan 13, 2010)

Log out and log back in? Who knows


----------



## DigiSoft (Jan 13, 2010)

It doesn't matter. It uses 0 resources.


----------



## cgigeek (Oct 17, 2012)

Not sure if it helps anyone,
similar issue, default all running on -s 1
had to use -s 0 for it to isolate that one to that CPU.
Which makes no sense, should be 2 so next one as of now will be -1?
I am thinking there is a command to create the group (which the set it tags)
So ideally you would create the group then do the assignment, will post more if I find more.


----------

