From: Darren Hart <dvhltc@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Eric Dumazet <eric.dumazet@gmail.com>,
"Peter W. Morreale" <pmorreale@novell.com>,
Rik van Riel <riel@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Gregory Haskins <ghaskins@novell.com>,
Sven-Thorsten Dietrich <sdietrich@novell.com>,
Chris Mason <chris.mason@oracle.com>,
John Cooper <john.cooper@third-harmonic.com>,
Chris Wright <chrisw@sous-sol.org>, Avi Kivity <avi@redhat.com>,
Darren Hart <dvhltc@us.ibm.com>
Subject: [PATCH 6/6] futex: Add aggressive adaptive spinning argument to FUTEX_LOCK
Date: Mon, 5 Apr 2010 13:23:59 -0700 [thread overview]
Message-ID: <1270499039-23728-7-git-send-email-dvhltc@us.ibm.com> (raw)
In-Reply-To: <1270499039-23728-1-git-send-email-dvhltc@us.ibm.com>
Aggresive adaptive spinning (aas) allows for more than spinner in the
adaptive loop at a given time. In some scenarios this yields better
results than the default single spinner mode.
Signed-off-by: Darren Hart <dvhltc@us.ibm.com>
---
kernel/futex.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index af61dcd..ddbd158 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2462,6 +2462,9 @@ static int trylock_futex_adaptive(u32 __user *uaddr, ktime_t *timeout)
* @flags: futex flags (FLAGS_SHARED, FLAGS_CLOCKRT, FLAGS_ADAPTIVE, etc.)
* @detect: detect deadlock (1) or not (0)
* @time: absolute timeout
+ * @aas: aggressive adaptive spinning (1) allow multiple spinners (0) allow
+ * only one spinner. Only valid in conjunction with the FLAGS_ADAPTIVE
+ * flag.
*
* futex_(un)lock() define a futex value policy and implement a full mutex. The
* futex value stores the owner's TID or'd with FUTEX_WAITERS and/or
@@ -2476,12 +2479,14 @@ static int trylock_futex_adaptive(u32 __user *uaddr, ktime_t *timeout)
* 0 - On success
* <0 - On error
*/
-static int futex_lock(u32 __user *uaddr, int flags, int detect, ktime_t *time)
+static int futex_lock(u32 __user *uaddr, int flags, int detect, ktime_t *time,
+ int aas)
{
struct hrtimer_sleeper timeout, *to = NULL;
- struct futex_hash_bucket *hb;
struct futex_q q = FUTEX_Q_INIT;
+ struct futex_hash_bucket *hb;
int ret = 0;
+ u32 uval;
if (refill_pi_state_cache())
return -ENOMEM;
@@ -2497,6 +2502,14 @@ static int futex_lock(u32 __user *uaddr, int flags, int detect, ktime_t *time)
retry:
#ifdef CONFIG_SMP
if (flags & FLAGS_ADAPTIVE) {
+ if (!aas) {
+ ret = get_user(uval, uaddr);
+ if (ret)
+ goto out;
+ if (uval & FUTEX_WAITERS)
+ goto skip_adaptive;
+ }
+
preempt_disable();
ret = trylock_futex_adaptive(uaddr, time);
preempt_enable();
@@ -2512,6 +2525,8 @@ retry:
goto out;
}
#endif
+
+skip_adaptive:
q.key = FUTEX_KEY_INIT;
ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &q.key);
if (unlikely(ret != 0))
@@ -2852,7 +2867,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
flags |= FLAGS_ADAPTIVE;
case FUTEX_LOCK:
if (futex_cmpxchg_enabled)
- ret = futex_lock(uaddr, flags, val, timeout);
+ ret = futex_lock(uaddr, flags, val, timeout, val3);
break;
default:
ret = -ENOSYS;
--
1.6.3.3
next prev parent reply other threads:[~2010-04-05 20:25 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-05 20:23 [PATCH V2 0/6][RFC] futex: FUTEX_LOCK with optional adaptive spinning Darren Hart
2010-04-05 20:23 ` [PATCH 1/6] futex: replace fshared and clockrt with combined flags Darren Hart
2010-04-05 20:23 ` [PATCH 2/6] futex: add futex_q static initializer Darren Hart
2010-04-05 20:23 ` [PATCH 3/6] futex: refactor futex_lock_pi_atomic Darren Hart
2010-04-05 20:23 ` [PATCH 4/6] futex: Add FUTEX_LOCK with optional adaptive spinning Darren Hart
2010-04-06 16:55 ` Thomas Gleixner
2010-04-07 17:26 ` Darren Hart
2010-04-07 19:59 ` Thomas Gleixner
2010-04-08 3:25 ` Darren Hart
2010-04-08 23:10 ` Peter W. Morreale
2010-04-09 5:41 ` Darren Hart
2010-04-09 13:13 ` Peter W. Morreale
2010-04-05 20:23 ` [PATCH 5/6] futex: handle timeout inside adaptive lock spin Darren Hart
2010-04-06 8:27 ` Thomas Gleixner
2010-04-07 17:31 ` Darren Hart
2010-04-07 18:44 ` Gregory Haskins
2010-04-07 23:15 ` Darren Hart
2010-04-05 20:23 ` Darren Hart [this message]
2010-04-08 5:58 ` [PATCH 6/6] futex: Add aggressive adaptive spinning argument to FUTEX_LOCK Darren Hart
2010-04-05 20:48 ` [PATCH V2^W V4 0/6][RFC] futex: FUTEX_LOCK with optional adaptive spinning Darren Hart
2010-04-05 21:15 ` [PATCH V2 " Avi Kivity
2010-04-05 21:54 ` Darren Hart
2010-04-05 22:21 ` Avi Kivity
2010-04-05 22:59 ` Darren Hart
2010-04-06 13:28 ` Avi Kivity
2010-04-06 13:35 ` Peter Zijlstra
2010-04-06 13:41 ` Avi Kivity
2010-04-06 14:09 ` Peter Zijlstra
2010-04-06 16:10 ` Avi Kivity
2010-04-06 16:53 ` Alan Cox
2010-04-06 13:51 ` Alan Cox
2010-04-06 15:28 ` Darren Hart
2010-04-06 16:06 ` Avi Kivity
2010-04-06 16:14 ` Thomas Gleixner
2010-04-06 16:20 ` Avi Kivity
2010-04-07 6:18 ` john cooper
2010-04-08 3:33 ` Darren Hart
2010-04-09 5:52 ` john cooper
2010-04-06 16:54 ` Alan Cox
2010-04-06 18:15 ` Thomas Gleixner
2010-04-06 16:44 ` Alan Cox
2010-04-06 17:34 ` Ulrich Drepper
2010-04-10 23:35 ` Alan Cox
2010-04-10 23:53 ` Ulrich Drepper
2010-04-06 19:31 ` Thomas Gleixner
2010-04-06 20:02 ` Ulrich Drepper
2010-04-06 23:16 ` Thomas Gleixner
2010-04-06 23:36 ` Darren Hart
2010-04-07 6:08 ` drepper
2010-04-08 3:41 ` Darren Hart
2010-04-08 4:29 ` drepper
2010-04-07 5:33 ` Avi Kivity
2010-04-06 21:22 ` Darren Hart
2010-04-05 23:15 ` Darren Hart
2010-04-05 23:29 ` Chris Wright
2010-04-06 13:30 ` Avi Kivity
2010-04-06 8:48 ` Peter Zijlstra
2010-04-06 14:47 ` Ulrich Drepper
2010-04-06 14:51 ` Peter Zijlstra
2010-04-06 15:33 ` Darren Hart
2010-04-06 15:37 ` Peter Zijlstra
2010-04-06 15:29 ` Peter Zijlstra
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=1270499039-23728-7-git-send-email-dvhltc@us.ibm.com \
--to=dvhltc@us.ibm.com \
--cc=avi@redhat.com \
--cc=chris.mason@oracle.com \
--cc=chrisw@sous-sol.org \
--cc=eric.dumazet@gmail.com \
--cc=ghaskins@novell.com \
--cc=john.cooper@third-harmonic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=pmorreale@novell.com \
--cc=riel@redhat.com \
--cc=rostedt@goodmis.org \
--cc=sdietrich@novell.com \
--cc=tglx@linutronix.de \
/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®