From: Davidlohr Bueso <dave@stgolabs.net>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Will Deacon <will.deacon@arm.com>,
"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/5] locking/mcs: Use acquire/release semantics
Date: Mon, 21 Sep 2015 13:17:56 -0700 [thread overview]
Message-ID: <1442866676-10359-6-git-send-email-dave@stgolabs.net> (raw)
In-Reply-To: <1442866676-10359-1-git-send-email-dave@stgolabs.net>
As such, weakly ordered archs can benefit from more relaxed use
of barriers when locking/unlocking.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
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)))
--
2.1.4
prev parent reply other threads:[~2015-09-21 20:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 20:17 [PATCH 0/5] locking: Use acquire/release semantics Davidlohr Bueso
2015-09-21 20:17 ` [PATCH 1/5] asm-generic: Add _{relaxed|acquire|release}() variants for inc/dec atomics Davidlohr Bueso
2015-09-21 20:17 ` [PATCH 2/5] locking/mutex: Use acquire/release semantics Davidlohr Bueso
2015-09-21 20:17 ` [PATCH 3/5] locking/rtmutex: " Davidlohr Bueso
2015-09-22 15:33 ` Thomas Gleixner
2015-09-22 15:55 ` Davidlohr Bueso
2015-09-24 1:06 ` [PATCH v2] " Davidlohr Bueso
2015-09-27 10:37 ` Thomas Gleixner
2015-09-28 19:49 ` Davidlohr Bueso
2015-09-29 20:57 ` Thomas Gleixner
2015-09-21 20:17 ` [PATCH 4/5] locking/rwsem: " Davidlohr Bueso
2015-09-21 20:39 ` Linus Torvalds
2015-09-24 1:09 ` [PATCH v2] " Davidlohr Bueso
2015-09-21 20:17 ` Davidlohr Bueso [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=1442866676-10359-6-git-send-email-dave@stgolabs.net \
--to=dave@stgolabs.net \
--cc=akpm@linux-foundation.org \
--cc=dbueso@suse.de \
--cc=linux-kernel@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).