]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
[PATCH] fix scheduler deadlock
authorAnton Blanchard <anton@samba.org>
Thu, 23 Mar 2006 10:59:20 +0000 (02:59 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 23 Mar 2006 15:38:02 +0000 (07:38 -0800)
commite9028b0ff2bad1954568604dc17725692c8524d6
treedbff742d39520574e5985930333f1d421282e080
parent5be0e9511990dc307670dc66a42073db96b20f26
[PATCH] fix scheduler deadlock

We have noticed lockups during boot when stress testing kexec on ppc64.
Two cpus would deadlock in scheduler code trying to grab already taken
spinlocks.

The double_rq_lock code uses the address of the runqueue to order the
taking of multiple locks.  This address is a per cpu variable:

if (rq1 < rq2) {
spin_lock(&rq1->lock);
spin_lock(&rq2->lock);
} else {
spin_lock(&rq2->lock);
spin_lock(&rq1->lock);
}

On the other hand, the code in wake_sleeping_dependent uses the cpu id
order to grab locks:

for_each_cpu_mask(i, sibling_map)
spin_lock(&cpu_rq(i)->lock);

This means we rely on the address of per cpu data increasing as cpu ids
increase.  While this will be true for the generic percpu implementation it
may not be true for arch specific implementations.

One way to solve this is to always take runqueues in cpu id order. To do
this we add a cpu variable to the runqueue and check it in the
double runqueue locking functions.

Signed-off-by: Anton Blanchard <anton@samba.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/sched.c