From: Tim Chen <tim.c.chen@linux.intel.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
peterz@infradead.org, "Andrew Morton" <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, "Andi Kleen" <ak@linux.intel.com>,
"Tony Luck" <tony.luck@intel.com>
Subject: Re: [PATCH 1/1] mutex: prevent optimistic spinning from spinning longer than neccessary (Repost)
Date: Fri, 20 Aug 2010 09:54:35 -0700 [thread overview]
Message-ID: <1282323276.9675.6.camel@schen9-DESK> (raw)
In-Reply-To: <20100820131920.GC3321@elte.hu>
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?
prev parent reply other threads:[~2010-08-20 17:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 22:00 Tim Chen
2010-08-19 11:05 ` Ingo Molnar
2010-08-19 22:24 ` Tim Chen
2010-08-20 13:19 ` Ingo Molnar
2010-08-20 16:54 ` Tim Chen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282323276.9675.6.camel@schen9-DESK \
--to=tim.c.chen@linux.intel.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®