diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-20 13:30:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-20 13:30:57 -0400 |
commit | fb34438914188cc271d07a5fc2903489b6e9ab2d (patch) | |
tree | 0cba437bc0e71e4014f0d47bc7c2a5780fe89294 /include | |
parent | 0e665d5d1125f9f4ccff56a75e814f10f88861a2 (diff) | |
parent | 0bce9c46bf3b15f485d82d7e81dabed6ebcc24b1 (diff) |
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull a mutex fix from Ingo Molnar.
Fix the fastpath_lock failure contention flag for xchg-based mutexes.
* 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
mutex: Place lock in contended state after fastpath_lock failure
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/mutex-xchg.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/include/asm-generic/mutex-xchg.h b/include/asm-generic/mutex-xchg.h index 580a6d35c700..c04e0db8a2d6 100644 --- a/include/asm-generic/mutex-xchg.h +++ b/include/asm-generic/mutex-xchg.h | |||
@@ -26,7 +26,13 @@ static inline void | |||
26 | __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) | 26 | __mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *)) |
27 | { | 27 | { |
28 | if (unlikely(atomic_xchg(count, 0) != 1)) | 28 | if (unlikely(atomic_xchg(count, 0) != 1)) |
29 | fail_fn(count); | 29 | /* |
30 | * We failed to acquire the lock, so mark it contended | ||
31 | * to ensure that any waiting tasks are woken up by the | ||
32 | * unlock slow path. | ||
33 | */ | ||
34 | if (likely(atomic_xchg(count, -1) != 1)) | ||
35 | fail_fn(count); | ||
30 | } | 36 | } |
31 | 37 | ||
32 | /** | 38 | /** |
@@ -43,7 +49,8 @@ static inline int | |||
43 | __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) | 49 | __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *)) |
44 | { | 50 | { |
45 | if (unlikely(atomic_xchg(count, 0) != 1)) | 51 | if (unlikely(atomic_xchg(count, 0) != 1)) |
46 | return fail_fn(count); | 52 | if (likely(atomic_xchg(count, -1) != 1)) |
53 | return fail_fn(count); | ||
47 | return 0; | 54 | return 0; |
48 | } | 55 | } |
49 | 56 | ||