linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Cc: mingo@kernel.org, stern@rowland.harvard.edu,
	parri.andrea@gmail.com, will.deacon@arm.com,
	peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com,
	dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr,
	akiyks@gmail.com,
	Andrea Parri <andrea.parri@amarulasolutions.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Ingo Molnar <mingo@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH tools/memory-model 05/17] arm64: Remove smp_mb() from arch_spin_is_locked()
Date: Mon, 16 Apr 2018 09:12:33 -0700	[thread overview]
Message-ID: <1523895165-17576-5-git-send-email-paulmck@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180416161209.GA6895@linux.vnet.ibm.com>

From: Andrea Parri <andrea.parri@amarulasolutions.com>

Commit 38b850a73034f ("arm64: spinlock: order spin_{is_locked,unlock_wait}
against local locks") added an smp_mb() to arch_spin_is_locked(), in order
"to ensure that the lock value is always loaded after any other locks have
been taken by the current CPU", and reported one example (the "insane case"
in ipc/sem.c) relying on such guarantee.

It is however understood that spin_is_locked() is not required to provide
such an ordering guarantee (a guarantee that is currently not provided by
all the implementations/archs), and that callers relying on such ordering
should instead insert suitable memory barriers before acting on the result
of spin_is_locked().

Following a recent auditing [1] of the callers of {,raw_}spin_is_locked(),
revealing that none of them are relying on the ordering guarantee anymore,
this commit removes the leading smp_mb() from the primitive thus reverting
38b850a73034f.

[1] https://marc.info/?l=linux-kernel&m=151981440005264&w=2
    https://marc.info/?l=linux-kernel&m=152042843808540&w=2
    https://marc.info/?l=linux-kernel&m=152043346110262&w=2

Signed-off-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
---
 arch/arm64/include/asm/spinlock.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
index ebdae15d665d..26c5bd7d88d8 100644
--- a/arch/arm64/include/asm/spinlock.h
+++ b/arch/arm64/include/asm/spinlock.h
@@ -122,11 +122,6 @@ static inline int arch_spin_value_unlocked(arch_spinlock_t lock)
 
 static inline int arch_spin_is_locked(arch_spinlock_t *lock)
 {
-	/*
-	 * Ensure prior spin_lock operations to other locks have completed
-	 * on this CPU before we test whether "lock" is locked.
-	 */
-	smp_mb(); /* ^^^ */
 	return !arch_spin_value_unlocked(READ_ONCE(*lock));
 }
 
-- 
2.5.2

  parent reply	other threads:[~2018-04-16 16:12 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 16:12 [PATCH tools/memory-model 0/17] Memory-model changes Paul E. McKenney
2018-04-16 16:12 ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 01/17] tools/memory-model: Rename link and rcu-path to rcu-link and rb Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 02/17] tools/memory-model: Redefine rb in terms of rcu-fence Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 03/17] docs/memory-barriers.txt: Fix broken DMA vs MMIO ordering example Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 04/17] locking: Document the semantics of spin_is_locked() Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` Paul E. McKenney [this message]
2018-04-16 16:12   ` [PATCH tools/memory-model 05/17] arm64: Remove smp_mb() from arch_spin_is_locked() Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 06/17] locking: Clean up comment and #ifndef for {,queued_}spin_is_locked() Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 07/17] kokr/doc: READ_ONCE() now implies smp_barrier_depends() Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 08/17] kokr/doc: De-emphasize smp_read_barrier_depends Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 09/17] kokr/Documentation/memory-barriers.txt: Cross-reference "tools/memory-model/" Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 10/17] kokr/memory-barriers: Fix description of data dependency barriers Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 11/17] kokr/locking/memory-barriers: De-emphasize smp_read_barrier_depends() some more Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 12/17] tools/memory-model: Update required version of herdtools7 Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 13/17] memory-model: Fix cheat sheet typo Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 14/17] tools/memory-order: Improve key for SELF and SV Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 15/17] tools/memory-order: smp_mb__after_atomic() orders later RMW operations Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 16/17] tools/memory-model: Model 'smp_store_mb()' Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney
2018-04-16 16:12 ` [PATCH tools/memory-model 17/17] tools/memory-model: Fix coding style in 'linux-kernel.def' Paul E. McKenney
2018-04-16 16:12   ` Paul E. McKenney

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=1523895165-17576-5-git-send-email-paulmck@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=akiyks@gmail.com \
    --cc=andrea.parri@amarulasolutions.com \
    --cc=boqun.feng@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=dhowells@redhat.com \
    --cc=j.alglave@ucl.ac.uk \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.maranget@inria.fr \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=parri.andrea@gmail.com \
    --cc=peterz@infradead.org \
    --cc=stern@rowland.harvard.edu \
    --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).