High priority tasks break SMP balancer?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Date: Friday, November 9, 2007 - 6:34 pm

I've been investigating a problem recently, in which N runnable
CPU-bound tasks on an N-way machine run on only N-1 CPUs. The
remaining CPU is almost 100% idle. I have seen it occur with both the
CFS and O(1) schedulers.

I've traced this down to what seems to be a quirk in the SMP balancer,
whereby a high-priority thread which spends most of its time sleeping
can artificially inflate the CPU load average calculated for one
processor. Most of the time this CPU is idle (nr_running==0) yet its
CPU load average is much higher than that of any other CPU.

Please find attached a sample program which demonstrates this
behaviour on a 2-way SMP machine. It creates three threads: two are
CPU bound and run at the default priority, the third spends most of
its time sleeping and runs at an elevated priority. It wakes up
frequently (using /dev/rtc) and randomly generates some CPU load.

On my machine (2-way Opteron with a vanilla 2.6.23.1 kernel) this test
program will reliably put the scheduler into a state where one CPU has
both of the busy-looping processes in its runqueue, and the other CPU
is usually idle. The usually-idle CPU will have a very high cpu_load,
as reported by /proc/sched_debug.

Your mileage may vary. On some machines, this test program will only
enter the "bad" state for a few seconds. Sometimes we bounce back and
forth between good and bad states every few seconds. In all cases,
removing the priority elevation fixes the balancing problem.

Is this a behaviour any of the scheduler developers are aware of? I
would be very greatful if anyone could shed some light on the root
cause behind the inflated cpu_load average. If this turns out to be a
real bug, I would be happy to work on a patch.

Thanks in advance,
Micah Dowty
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 9, 6:34 pm)
Re: High priority tasks break SMP balancer?, Cyrus Massoumi, (Fri Nov 9, 7:56 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 9, 8:11 pm)
Re: High priority tasks break SMP balancer?, Kyle Moffett, (Thu Nov 15, 2:48 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Thu Nov 15, 3:14 pm)
Re: High priority tasks break SMP balancer?, David Newall, (Fri Nov 16, 3:13 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 16, 5:38 pm)
Re: High priority tasks break SMP balancer?, Christoph Lameter, (Thu Nov 15, 4:07 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Thu Nov 15, 4:24 pm)
Re: High priority tasks break SMP balancer?, Christoph Lameter, (Thu Nov 15, 5:28 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Thu Nov 15, 5:35 pm)
Re: High priority tasks break SMP balancer?, Christoph Lameter, (Thu Nov 15, 10:31 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Thu Nov 15, 10:44 pm)
Re: High priority tasks break SMP balancer?, Ingo Molnar, (Fri Nov 16, 2:07 am)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Fri Nov 16, 6:48 am)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 16, 6:14 pm)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Fri Nov 16, 7:26 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 16, 9:03 pm)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Sat Nov 17, 3:10 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Mon Nov 19, 2:51 pm)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Mon Nov 19, 6:22 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Mon Nov 19, 7:05 pm)
Re: High priority tasks break SMP balancer?, Ingo Molnar, (Tue Nov 20, 1:57 am)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Tue Nov 20, 2:06 pm)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Tue Nov 20, 5:47 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Thu Nov 22, 3:46 am)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Thu Nov 22, 8:53 am)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Mon Nov 26, 3:44 pm)
Re: High priority tasks break SMP balancer?, Dmitry Adamushko, (Tue Nov 27, 5:21 am)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Tue Nov 27, 1:13 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 16, 6:48 am)
Re: High priority tasks break SMP balancer?, Christoph Lameter, (Fri Nov 16, 6:12 pm)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Fri Nov 16, 5:19 am)
Re: High priority tasks break SMP balancer?, Ingo Molnar, (Fri Nov 16, 6:45 am)
Re: High priority tasks break SMP balancer?, Micah Dowty, (Wed Nov 14, 2:39 pm)