Skip to content

Commit

Permalink
Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Aug 20, 2012
2 parents 0e665d5 + 0bce9c4 commit fb34438
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions include/asm-generic/mutex-xchg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ static inline void
__mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *))
{
if (unlikely(atomic_xchg(count, 0) != 1))
fail_fn(count);
/*
* We failed to acquire the lock, so mark it contended
* to ensure that any waiting tasks are woken up by the
* unlock slow path.
*/
if (likely(atomic_xchg(count, -1) != 1))
fail_fn(count);
}

/**
Expand All @@ -43,7 +49,8 @@ static inline int
__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
{
if (unlikely(atomic_xchg(count, 0) != 1))
return fail_fn(count);
if (likely(atomic_xchg(count, -1) != 1))
return fail_fn(count);
return 0;
}

Expand Down

0 comments on commit fb34438

Please sign in to comment.