Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have some highly floating point intensive processes doing very little I/O. One is called "xspec", which calculates a numerical model and returns a floating point result back to a master process every second (via stdout). It is niced at the 19 level. I have another simple process "cpufloattest" which just does numerical computations in a tight loop. It is not niced.

I have a 4-core i7 system with hyperthreading disabled. I have started 4 of each type of process. Why is the Linux scheduler (Linux 3.4.2) not properly limiting the CPU time taken up by the niced processes?

Cpu(s): 56.2%us,  1.0%sy, 41.8%ni,  0.0%id,  0.0%wa,  0.9%hi,  0.1%si,  0.0%st
Mem:  12297620k total, 12147472k used,   150148k free,   831564k buffers
Swap:  2104508k total,    71172k used,  2033336k free,  4753956k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                         
32399 jss       20   0 44728  32m  772 R 62.7  0.3   4:17.93 cpufloattest                                    
32400 jss       20   0 44728  32m  744 R 53.1  0.3   4:14.17 cpufloattest                                    
32402 jss       20   0 44728  32m  744 R 51.1  0.3   4:14.09 cpufloattest                                    
32398 jss       20   0 44728  32m  744 R 48.8  0.3   4:15.44 cpufloattest                                    
 3989 jss       39  19 1725m 690m 7744 R 44.1  5.8   1459:59 xspec                                           
 3981 jss       39  19 1725m 689m 7744 R 42.1  5.7   1459:34 xspec                                           
 3985 jss       39  19 1725m 689m 7744 R 42.1  5.7   1460:51 xspec                                           
 3993 jss       39  19 1725m 691m 7744 R 38.8  5.8   1458:24 xspec                                           

The scheduler does what I expect if I start 8 of the cpufloattest processes, with 4 of them niced (i.e. 4 with most of the CPU, and 4 with very little)

share|improve this question
xspec is using less CPU than cpufloattest. How much less CPU, exactly, were you expecting to be used? – womble Jul 5 '12 at 16:26
I'd like a niced 19 process to have minimal impact on a niced zero. If I run 8 cpufloattest, that is the case. The snapshot above is just a snapshot. It's pretty even overall between the nice 0 and nice 19. – xioxox Jul 5 '12 at 16:36
up vote 6 down vote accepted

I've discovered what's causing this problem. It's due to the "autogroup" feature of the CFS scheduler. If I do

echo 0 > /proc/sys/kernel/sched_autogroup_enabled 

Then everything behaves as you'd expect. The nice 19 processes drop to near zero CPU usage when nice 0 processes are running.

I'll try to find exactly what the autogrouping is doing to break my usage case and update this answer.

Edit... I chatted to some kernel people on IRC who just said I should disable it if it doesn't work for my workload and that it was just a crazy patch that Linus liked. I'm not sure why autogrouping doesn't like my workload, but this answer is here for people who run into similar problems.

share|improve this answer

Might not be exactly what you are looking for, but have you tried command cpulimit? It's available least in Debian/Ubuntu repositories.

With cpulimit you can tune how many percent of overall CPU time any process is allowed to take. Another possibility for you might be using cgroups, but cpulimit is more straight-forward and simple to use.

share|improve this answer
That's an interesting tool - thanks - but it just limits the total cpu percentage used by a process. What I really want is idle scheduling - allowing a process to use all the CPU available providing nothing else is running. I've also tried SCHED_IDLE - doesn't work. – xioxox Jul 6 '12 at 7:31

Just reduce xspec to single process, so you will have 4:1 or 3:1 this would run just well.

share|improve this answer
This isn't technically possible. The question is why is this happening? – xioxox Jul 5 '12 at 17:02
Maybe because these processes doesnt do any pauses. Also make sure you renice all threads and that it's the case. – Andrew Smith Jul 5 '12 at 21:10

I think you mean to set the priority higher? In which case you would want to use a negative value..

In your output, cpufloattest has a higher priority than xspec.

EDIT: You can use taskset to set a process to use a specific processor, though, that's not necessary in this case.

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.