From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753321AbbJFQUw (ORCPT ); Tue, 6 Oct 2015 12:20:52 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34935 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbbJFQUt (ORCPT ); Tue, 6 Oct 2015 12:20:49 -0400 Date: Tue, 6 Oct 2015 09:19:27 -0700 From: tip-bot for Davidlohr Bueso Message-ID: 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 Reply-To: tglx@linutronix.de, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, dbueso@suse.de, akpm@linux-foundation.org, mingo@kernel.org, peterz@infradead.org, hpa@zytor.com, will.deacon@arm.com, paulmck@linux.vnet.ibm.com, dave@stgolabs.net In-Reply-To: <1443643395-17016-5-git-send-email-dave@stgolabs.net> References: <1443643395-17016-5-git-send-email-dave@stgolabs.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/mcs: Use acquire/release semantics Git-Commit-ID: 3552a07a9c4aea32cc092fadf10a186c84ed8a61 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 3552a07a9c4aea32cc092fadf10a186c84ed8a61 Gitweb: http://git.kernel.org/tip/3552a07a9c4aea32cc092fadf10a186c84ed8a61 Author: Davidlohr Bueso AuthorDate: Wed, 30 Sep 2015 13:03:14 -0700 Committer: Ingo Molnar 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 Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Thomas Gleixner Cc: Andrew Morton Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Paul E.McKenney Cc: Peter Zijlstra Cc: Will Deacon 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 --- 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)))