mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Davidlohr Bueso <davidlohr@hp.com>
To: peterz@infradead.org, mingo@kernel.org
Cc: jason.low2@hp.com, davidlohr@hp.com, aswin@hp.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH -tip/master 2/7] locking/mutex: Document quick lock release when unlocking
Date: Sun, 27 Jul 2014 22:18:39 -0700	[thread overview]
Message-ID: <1406524724-17946-2-git-send-email-davidlohr@hp.com> (raw)
In-Reply-To: <1406524724-17946-1-git-send-email-davidlohr@hp.com>

When unlocking, we always want to reach the slowpath with the lock's counter
indicating it is unlocked. -- as returned by the asm fastpath call or by
explicitly setting it. While doing so, at least in theory, we can optimize
and allow faster lock stealing.

This is not immediately obvious and deserves to be documented.

Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
---
 kernel/locking/mutex.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index ad0e333..7a9be39 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -676,7 +676,8 @@ EXPORT_SYMBOL_GPL(__ww_mutex_lock_interruptible);
 #endif
 
 /*
- * Release the lock, slowpath:
+ * Release the lock, slowpath.
+ *  At this point, the lock counter is 0 or negative.
  */
 static inline void
 __mutex_unlock_common_slowpath(struct mutex *lock, int nested)
@@ -684,9 +685,16 @@ __mutex_unlock_common_slowpath(struct mutex *lock, int nested)
 	unsigned long flags;
 
 	/*
-	 * some architectures leave the lock unlocked in the fastpath failure
+	 * As a performance measurement, release the lock before doing other
+	 * wakeup related duties to follow. This allows other tasks to acquire
+	 * the lock sooner, while still handling cleanups in past unlock calls.
+	 * This can be done as we do not enforce strict equivalence between the
+	 * mutex counter and wait_list.
+	 *
+	 *
+	 * Some architectures leave the lock unlocked in the fastpath failure
 	 * case, others need to leave it locked. In the later case we have to
-	 * unlock it here
+	 * unlock it here.
 	 */
 	if (__mutex_slowpath_needs_to_unlock())
 		atomic_set(&lock->count, 1);
-- 
1.8.1.4


  reply	other threads:[~2014-07-28  5:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28  5:18 [PATCH -tip/master 1/7] locking/mutex: Unify arguments in lock/unlock slowpaths Davidlohr Bueso
2014-07-28  5:18 ` Davidlohr Bueso [this message]
2014-07-30 15:10   ` [PATCH -tip/master 2/7] locking/mutex: Document quick lock release when unlocking Jason Low
2014-07-30 18:20     ` Davidlohr Bueso
2014-07-28  5:18 ` [PATCH -tip/master 3/7] locking/mcs: Remove obsolete comment Davidlohr Bueso
2014-07-28 16:49   ` Jason Low
2014-07-28 16:53     ` Davidlohr Bueso
2014-07-28 16:57       ` Peter Zijlstra
2014-07-28 17:19         ` Jason Low
2014-07-28 16:54     ` Peter Zijlstra
2014-07-28 17:49       ` Jason Low
2014-07-28 18:50         ` Peter Zijlstra
2014-07-28 21:02           ` Jason Low
2014-07-30 15:11   ` Jason Low
2014-07-28  5:18 ` [PATCH -tip/master 4/7] locking/mutex: Refactor optimistic spinning code Davidlohr Bueso
2014-07-28  9:08   ` Peter Zijlstra
2014-07-28 16:39     ` Jason Low
2014-07-28 16:41       ` Davidlohr Bueso
2014-07-29  2:55   ` [PATCH -tip/master v2] " Davidlohr Bueso
2014-07-29  3:41     ` Jason Low
2014-07-29  4:31       ` Davidlohr Bueso
2014-07-29  4:51   ` [PATCH -tip/master v3] " Davidlohr Bueso
2014-07-30 15:18   ` [PATCH -tip/master 4/7] " Jason Low
2014-07-28  5:18 ` [PATCH -tip/master 5/7] locking/mutex: Use MUTEX_SPIN_ON_OWNER when appropriate Davidlohr Bueso
2014-07-30 15:19   ` Jason Low
2014-07-28  5:18 ` [PATCH 6/7] locking: Move docs into Documentation/locking/ Davidlohr Bueso
2014-07-28  5:18 ` [PATCH -tip/master 7/7] Documentation: Update locking/mutex-design.txt disadvantages Davidlohr Bueso
2014-07-28 18:09   ` Jason Low

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=1406524724-17946-2-git-send-email-davidlohr@hp.com \
    --to=davidlohr@hp.com \
    --cc=aswin@hp.com \
    --cc=jason.low2@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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®