lkml.org 
[lkml]   [2010]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH 1/1] mutex: prevent optimistic spinning from spinning longer than neccessary (Repost)
From
Date
On Fri, 2010-08-20 at 15:19 +0200, Ingo Molnar wrote:

>
> Thanks! The performance results you've posted so far IMO more than justifies
> its inclusion.
>
> Ingo

Thanks to everyone for your review. I've updated the patch to add
comments explaining the change per suggestion from Andrew.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
diff --git a/kernel/sched.c b/kernel/sched.c
index 41541d7..3747d04 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3865,8 +3865,15 @@ 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 lock has switched to a different owner,
+ * we 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?



\
 
 \ /
  Last update: 2010-08-20 19:05    [W:0.082 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site