From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751754AbdHCPnw (ORCPT ); Thu, 3 Aug 2017 11:43:52 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34401 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751600AbdHCPnu (ORCPT ); Thu, 3 Aug 2017 11:43:50 -0400 Date: Fri, 4 Aug 2017 01:43:26 +1000 From: Nicholas Piggin To: Will Deacon Cc: Peter Zijlstra , torvalds@linux-foundation.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, linux-kernel@vger.kernel.org, mingo@kernel.org, stern@rowland.harvard.edu Subject: Re: [PATCH -v2 3/4] locking: Introduce smp_mb__after_spinlock(). Message-ID: <20170804014326.7ea32fdb@roar.ozlabs.ibm.com> In-Reply-To: <20170803152820.GD20783@arm.com> References: <20170802113837.280183420@infradead.org> <20170802114030.120586651@infradead.org> <20170803152820.GD20783@arm.com> Organization: IBM X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 Aug 2017 16:28:20 +0100 Will Deacon wrote: > 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 > > Cc: Nicholas Piggin > > Cc: Ingo Molnar > > Cc: Will Deacon > > Cc: Linus Torvalds > > Cc: Michael Ellerman > > Cc: Oleg Nesterov > > Cc: Benjamin Herrenschmidt > > Cc: Paul McKenney > > Signed-off-by: Peter Zijlstra (Intel) > > --- > > 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 Yeah this looks good to me. I don't think there would ever be a reason to use smp_mb__before_spinlock() rather than smp_mb__after_spinlock().