aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-08-24 12:21:02 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-24 12:21:02 -0700
commit3b6c5507a69861e80c26f21d04601c674cbeec3d (patch)
tree339c0761121f5a20d0573c3af3177af87e00e09f
parentguard page for stacks that grow upwards (diff)
parentmutex: Improve the scalability of optimistic spinning (diff)
downloadlinux-dev-3b6c5507a69861e80c26f21d04601c674cbeec3d.tar.xz
linux-dev-3b6c5507a69861e80c26f21d04601c674cbeec3d.zip
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
-rw-r--r--kernel/sched.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 41541d79e3c8..09b574e7f4df 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3865,8 +3865,16 @@ int mutex_spin_on_owner(struct mutex *lock, struct thread_info *owner)
/*
* Owner changed, break to re-assess state.
*/
- if (lock->owner != owner)
+ if (lock->owner != owner) {
+ /*
+ * If the lock has switched to a different owner,
+ * we likely have heavy contention. Return 0 to quit
+ * optimistic spinning and not contend further:
+ */
+ if (lock->owner)
+ return 0;
break;
+ }
/*
* Is that owner really running on that cpu?