]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
[PATCH] fix scheduler deadlock
authorAnton Blanchard <anton@samba.org>
Thu, 23 Mar 2006 10:59:20 +0000 (02:59 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 28 Mar 2006 06:47:31 +0000 (22:47 -0800)
commit4ceb2fc75f15f1a8d4d791e4398b2e06f4f34f47
tree81b5f1a2cf582325903b01c565959b12eee03cf3
parent375dcda41ce22c756ae9535c133875495c859be3
[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>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/sched.c