Skip to content

Commit 3b6c550

Browse files
committed
Merge branch 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: mutex: Improve the scalability of optimistic spinning
2 parents 8ca3eb0 + 9d0f4dc commit 3b6c550

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

kernel/sched.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3865,8 +3865,16 @@ int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner)
38653865
/*
38663866
* Owner changed, break to re-assess state.
38673867
*/
3868-
if (lock->owner != owner)
3868+
if (lock->owner != owner) {
3869+
/*
3870+
* If the lock has switched to a different owner,
3871+
* we likely have heavy contention. Return 0 to quit
3872+
* optimistic spinning and not contend further:
3873+
*/
3874+
if (lock->owner)
3875+
return 0;
38693876
break;
3877+
}
38703878

38713879
/*
38723880
* Is that owner really running on that cpu?

0 commit comments

Comments
 (0)