Files
linux/kernel
Tony Breeds 3aff03b26e mutex: Fix optimistic spinning vs. BKL
commit fd6be105b8 upstream.

Currently, we can hit a nasty case with optimistic
spinning on mutexes:

    CPU A tries to take a mutex, while holding the BKL

    CPU B tried to take the BLK while holding the mutex

This looks like a AB-BA scenario but in practice, is
allowed and happens due to the auto-release on
schedule() nature of the BKL.

In that case, the optimistic spinning code can get us
into a situation where instead of going to sleep, A
will spin waiting for B who is spinning waiting for
A, and the only way out of that loop is the
need_resched() test in mutex_spin_on_owner().

This patch fixes it by completely disabling spinning
if we own the BKL. This adds one more detail to the
extensive list of reasons why it's a bad idea for
kernel code to be holding the BKL.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
LKML-Reference: <20100519054636.GC12389@ozlabs.org>
[ added an unlikely() attribute to the branch ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-07-05 11:10:31 -07:00
..
2009-09-21 14:29:21 +02:00
2009-12-18 14:03:52 -08:00
2010-07-05 11:10:27 -07:00
2009-09-18 09:48:52 -07:00
2009-08-29 14:10:07 +02:00
2009-09-19 13:13:17 -07:00
2010-07-05 11:10:31 -07:00
2009-10-29 08:56:20 +10:30
2010-05-26 14:29:18 -07:00
2009-10-07 08:11:20 +02:00
2009-09-23 07:39:41 -07:00
2009-12-18 14:03:13 -08:00
2009-09-23 18:13:10 -07:00
2009-11-02 16:02:39 +01:00