linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Davidlohr Bueso <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dave@stgolabs.net, will.deacon@arm.com,
	paulmck@linux.vnet.ibm.com, akpm@linux-foundation.org,
	mingo@kernel.org, hpa@zytor.com, peterz@infradead.org,
	dbueso@suse.de, linux-kernel@vger.kernel.org,
	torvalds@linux-foundation.org, tglx@linutronix.de
Subject: [tip:locking/core] locking/mcs: Use acquire/release semantics
Date: Tue, 6 Oct 2015 09:19:27 -0700	[thread overview]
Message-ID: <tip-3552a07a9c4aea32cc092fadf10a186c84ed8a61@git.kernel.org> (raw)
In-Reply-To: <1443643395-17016-5-git-send-email-dave@stgolabs.net>

Commit-ID:  3552a07a9c4aea32cc092fadf10a186c84ed8a61
Gitweb:     http://git.kernel.org/tip/3552a07a9c4aea32cc092fadf10a186c84ed8a61
Author:     Davidlohr Bueso <dave@stgolabs.net>
AuthorDate: Wed, 30 Sep 2015 13:03:14 -0700
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 6 Oct 2015 17:28:23 +0200

locking/mcs: Use acquire/release semantics

As of 654672d4ba1 (locking/atomics: Add _{acquire|release|relaxed}()
variants of some atomic operations) and 6d79ef2d30e (locking, asm-generic:
Add _{relaxed|acquire|release}() variants for 'atomic_long_t'), weakly
ordered archs can benefit from more relaxed use of barriers when locking
and unlocking, instead of regular full barrier semantics. While currently
only arm64 supports such optimizations, updating corresponding locking
primitives serves for other archs to immediately benefit as well, once the
necessary machinery is implemented of course.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul E.McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/1443643395-17016-5-git-send-email-dave@stgolabs.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/locking/mcs_spinlock.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h
index fd91aaa..5b9102a 100644
--- a/kernel/locking/mcs_spinlock.h
+++ b/kernel/locking/mcs_spinlock.h
@@ -67,7 +67,7 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
 	node->locked = 0;
 	node->next   = NULL;
 
-	prev = xchg(lock, node);
+	prev = xchg_acquire(lock, node);
 	if (likely(prev == NULL)) {
 		/*
 		 * Lock acquired, don't need to set node->locked to 1. Threads
@@ -98,7 +98,7 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)
 		/*
 		 * Release the lock by setting it to NULL
 		 */
-		if (likely(cmpxchg(lock, node, NULL) == node))
+		if (likely(cmpxchg_release(lock, node, NULL) == node))
 			return;
 		/* Wait until the next pointer is set */
 		while (!(next = READ_ONCE(node->next)))

  reply	other threads:[~2015-10-06 16:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30 20:03 [PATCH -tip v3 0/5] locking: Use acquire/release semantics Davidlohr Bueso
2015-09-30 20:03 ` [PATCH 1/5] asm-generic: Add _{relaxed|acquire|release}() variants for inc/dec atomics Davidlohr Bueso
2015-10-01  6:39   ` Peter Zijlstra
2015-10-05 17:32     ` Will Deacon
2015-10-05 19:48       ` Peter Zijlstra
2015-10-06  9:01         ` Will Deacon
2015-10-06 16:18   ` [tip:locking/core] locking/asm-generic: " tip-bot for Davidlohr Bueso
2015-09-30 20:03 ` [PATCH 2/5] locking/mutex: Use acquire/release semantics Davidlohr Bueso
2015-10-06 16:18   ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2015-09-30 20:03 ` [PATCH 3/5] locking/rtmutex: " Davidlohr Bueso
2015-10-06 16:19   ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2015-09-30 20:03 ` [PATCH 4/5] locking/mcs: " Davidlohr Bueso
2015-10-06 16:19   ` tip-bot for Davidlohr Bueso [this message]
2015-09-30 20:03 ` [PATCH 5/5] locking/rwsem: " Davidlohr Bueso
2015-10-06 16:19   ` [tip:locking/core] " tip-bot for Davidlohr Bueso
2015-09-30 20:37 ` [PATCH -tip v3 0/5] locking: " Thomas Gleixner
2015-10-13 17:04 ` [PATCH 6/5] locking/qspinlock: " Davidlohr Bueso
2015-10-13 17:59   ` 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=tip-3552a07a9c4aea32cc092fadf10a186c84ed8a61@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=will.deacon@arm.com \
    /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;
as well as URLs for NNTP newsgroup(s).