Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I mean is their any way we can set up cpu affinity for particular user, for all his currently running process or for process which he will start later?

share|improve this question
Which version of Red Hat is this? – ewwhite Jul 1 '12 at 2:08
up vote 4 down vote accepted

Yes, this is possible.

I would execute the user's processes into a cgroup comprised of the CPU core(s) you wish to use. Depending on your version of RHEL (5 versus 6), you could use CPU shields via cpusets/cset in EL5 or try the cgroup approach documented in EL6. The latter example uses an /etc/cgrules.conf file which defines rules for cgroup resources (e.g. all of the processes belonging to Jerome will run in a specified cgroup). The former allows you to execute processes directly into a CPU shield.

For your example using cset, I would simply execute a bash shell for the user into the right CPU shield. All of their child proceses will be contained within. See here.

share|improve this answer
Thanks a lot , this is what i was looking for – Amit Singh Jul 2 '12 at 19:52
Good. Please accept the answer. – ewwhite Jul 17 '12 at 21:13

The following small bash-script will do it:

u=username # do not set this to root!
c=logical processor number you want to bind to
for p in $(pgrep -u $u)
    taskset -cp $c $p

Children of the bound processes will stay bound to that cpu-set.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.