From: Davidlohr Bueso <dave@stgolabs.net>
To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Davidlohr Bueso <dave@stgolabs.net>,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH 5/8] locking/mutex: Introduce ww_mutex_set_context_slowpath
Date: Sun, 28 Dec 2014 01:11:20 -0800 [thread overview]
Message-ID: <1419757883-4423-6-git-send-email-dave@stgolabs.net> (raw)
In-Reply-To: <1419757883-4423-1-git-send-email-dave@stgolabs.net>
... which is equivalent to the fastpath counter part.
This mainly allows getting some ww specific code out
of generic mutex paths.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
kernel/locking/mutex.c | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index caa3c9f..5b6df69 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -155,7 +155,7 @@ static __always_inline void ww_mutex_lock_acquired(struct ww_mutex *ww,
*/
static __always_inline void
ww_mutex_set_context_fastpath(struct ww_mutex *lock,
- struct ww_acquire_ctx *ctx)
+ struct ww_acquire_ctx *ctx)
{
unsigned long flags;
struct mutex_waiter *cur;
@@ -191,6 +191,30 @@ ww_mutex_set_context_fastpath(struct ww_mutex *lock,
spin_unlock_mutex(&lock->base.wait_lock, flags);
}
+/*
+ * after acquiring lock in the slowpath or when we lost out in contested
+ * slowpath, set ctx and wake up any waiters so they can recheck.
+ *
+ * Callers must hold the mutex wait_lock.
+ */
+static __always_inline void
+ww_mutex_set_context_slowpath(struct ww_mutex *lock,
+ struct ww_acquire_ctx *ctx)
+{
+ struct mutex_waiter *cur;
+
+ ww_mutex_lock_acquired(lock, ctx);
+ lock->ctx = ctx;
+
+ /*
+ * Give any possible sleeping processes the chance to wake up,
+ * so they can recheck if they have to back off.
+ */
+ list_for_each_entry(cur, &lock->base.wait_list, list) {
+ debug_mutex_wake_waiter(lock->base, cur);
+ wake_up_process(cur->task);
+ }
+}
#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
/*
@@ -576,23 +600,8 @@ skip_wait:
if (ww_ctx) {
struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
- struct mutex_waiter *cur;
- /*
- * This branch gets optimized out for the common case,
- * and is only important for ww_mutex_lock.
- */
- ww_mutex_lock_acquired(ww, ww_ctx);
- ww->ctx = ww_ctx;
-
- /*
- * Give any possible sleeping processes the chance to wake up,
- * so they can recheck if they have to back off.
- */
- list_for_each_entry(cur, &lock->wait_list, list) {
- debug_mutex_wake_waiter(lock, cur);
- wake_up_process(cur->task);
- }
+ ww_mutex_set_context_slowpath(ww, ww_ctx);
}
spin_unlock_mutex(&lock->wait_lock, flags);
--
2.1.2
next prev parent reply other threads:[~2014-12-28 9:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-28 9:11 [PATCH 0/8] locking: Various updates Davidlohr Bueso
2014-12-28 9:11 ` [PATCH 1/8] Documentation/memory-barriers.txt: Fix smp typo Davidlohr Bueso
2014-12-31 2:02 ` Paul E. McKenney
2014-12-28 9:11 ` [PATCH 2/8] locking/mutex: Get rid of use_ww_cxt param in common paths Davidlohr Bueso
2014-12-28 16:23 ` Peter Zijlstra
2014-12-28 18:12 ` Davidlohr Bueso
2014-12-28 9:11 ` [PATCH 3/8] locking/mutex: Checking the stamp is ww only Davidlohr Bueso
2014-12-28 9:11 ` [PATCH 4/8] locking/mutex: Delete useless comment Davidlohr Bueso
2014-12-28 9:11 ` Davidlohr Bueso [this message]
2014-12-28 9:11 ` [PATCH 6/8] locking/mcs: Better differentiate between mcs variants Davidlohr Bueso
2015-01-14 14:13 ` Ingo Molnar
2015-01-14 15:55 ` Davidlohr Bueso
2015-01-14 14:16 ` Ingo Molnar
2014-12-28 9:11 ` [PATCH 7/8] locking: Use [READ,ASSIGN]_ONCE() for non-scalar types Davidlohr Bueso
2014-12-28 16:30 ` Peter Zijlstra
2014-12-28 9:11 ` [PATCH 8/8] locking/osq: No need for load/acquire when acquire-polling Davidlohr Bueso
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=1419757883-4423-6-git-send-email-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.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®