From: Will Deacon <will.deacon@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: torvalds@linux-foundation.org, oleg@redhat.com,
paulmck@linux.vnet.ibm.com, benh@kernel.crashing.org,
mpe@ellerman.id.au, npiggin@gmail.com,
linux-kernel@vger.kernel.org, mingo@kernel.org,
stern@rowland.harvard.edu
Subject: Re: [PATCH -v2 3/4] locking: Introduce smp_mb__after_spinlock().
Date: Thu, 3 Aug 2017 16:28:20 +0100 [thread overview]
Message-ID: <20170803152820.GD20783@arm.com> (raw)
In-Reply-To: <20170802114030.120586651@infradead.org>
On Wed, Aug 02, 2017 at 01:38:40PM +0200, Peter Zijlstra wrote:
> Since its inception, our understanding of ACQUIRE, esp. as applied to
> spinlocks, has changed somewhat. Also, I wonder if, with a simple
> change, we cannot make it provide more.
>
> The problem with the comment is that the STORE done by spin_lock isn't
> itself ordered by the ACQUIRE, and therefore a later LOAD can pass over
> it and cross with any prior STORE, rendering the default WMB
> insufficient (pointed out by Alan).
>
> Now, this is only really a problem on PowerPC and ARM64, both of
> which already defined smp_mb__before_spinlock() as a smp_mb().
>
> At the same time, we can get a much stronger construct if we place
> that same barrier _inside_ the spin_lock(). In that case we upgrade
> the RCpc spinlock to an RCsc. That would make all schedule() calls
> fully transitive against one another.
>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/arm64/include/asm/spinlock.h | 2 ++
> arch/powerpc/include/asm/spinlock.h | 3 +++
> include/linux/atomic.h | 3 +++
> include/linux/spinlock.h | 36 ++++++++++++++++++++++++++++++++++++
> kernel/sched/core.c | 4 ++--
> 5 files changed, 46 insertions(+), 2 deletions(-)
>
> --- a/arch/arm64/include/asm/spinlock.h
> +++ b/arch/arm64/include/asm/spinlock.h
> @@ -367,5 +367,7 @@ static inline int arch_read_trylock(arch
> * smp_mb__before_spinlock() can restore the required ordering.
> */
> #define smp_mb__before_spinlock() smp_mb()
> +/* See include/linux/spinlock.h */
> +#define smp_mb__after_spinlock() smp_mb()
>
> #endif /* __ASM_SPINLOCK_H */
Acked-by: Will Deacon <will.deacon@arm.com>
Will
next prev parent reply other threads:[~2017-08-03 15:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 11:38 [PATCH -v2 0/4] Getting rid of smp_mb__before_spinlock Peter Zijlstra
2017-08-02 11:38 ` [PATCH -v2 1/4] mm: Rework {set,clear,mm}_tlb_flush_pending() Peter Zijlstra
2017-08-02 13:00 ` Mel Gorman
2017-08-02 13:05 ` Peter Zijlstra
2017-08-02 13:52 ` Mel Gorman
2017-08-02 14:16 ` Peter Zijlstra
2017-08-02 13:00 ` ARC stuff (was Re: [PATCH -v2 1/4] mm: Rework {set,clear,mm}_tlb_flush_pending()) Vineet Gupta
2017-08-02 13:17 ` Peter Zijlstra
2017-08-11 14:15 ` Peter Zijlstra
2017-08-03 15:27 ` [PATCH -v2 1/4] mm: Rework {set,clear,mm}_tlb_flush_pending() Will Deacon
2017-08-11 9:45 ` Peter Zijlstra
2017-08-02 11:38 ` [PATCH -v2 2/4] overlayfs: Remove smp_mb__before_spinlock() usage Peter Zijlstra
2017-08-02 11:38 ` [PATCH -v2 3/4] locking: Introduce smp_mb__after_spinlock() Peter Zijlstra
2017-08-03 15:28 ` Will Deacon [this message]
2017-08-03 15:43 ` Nicholas Piggin
2017-08-02 11:38 ` [PATCH -v2 4/4] locking: Remove smp_mb__before_spinlock() Peter Zijlstra
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=20170803152820.GD20783@arm.com \
--to=will.deacon@arm.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=stern@rowland.harvard.edu \
--cc=torvalds@linux-foundation.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