diff options
| -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 | ||
