From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933181AbcIELev (ORCPT ); Mon, 5 Sep 2016 07:34:51 -0400 Received: from merlin.infradead.org ([205.233.59.134]:58542 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932209AbcIELer (ORCPT ); Mon, 5 Sep 2016 07:34:47 -0400 Date: Mon, 5 Sep 2016 13:34:35 +0200 From: Peter Zijlstra To: "Paul E. McKenney" Cc: Linus Torvalds , Will Deacon , Oleg Nesterov , Benjamin Herrenschmidt , Michael Ellerman , linux-kernel@vger.kernel.org, Nicholas Piggin , Ingo Molnar , Alan Stern Subject: Re: Question on smp_mb__before_spinlock Message-ID: <20160905113435.GZ10153@twins.programming.kicks-ass.net> References: <20160905093753.GN10138@twins.programming.kicks-ass.net> <20160905103714.GZ3663@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160905103714.GZ3663@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 05, 2016 at 03:37:14AM -0700, Paul E. McKenney wrote: > On Mon, Sep 05, 2016 at 11:37:53AM +0200, Peter Zijlstra wrote: > > Hi all, > > > > So recently I've had two separate issues that touched upon > > smp_mb__before_spinlock(). > > > > > > 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, the former of > > which already defined smp_mb__before_spinlock() as a smp_mb(), the > > latter does not, Will? > > > > The second issue I wondered about is spinlock transitivity. All except > > powerpc have RCsc locks, and since Power already does a full mb, would > > it not make sense to put it _after_ the spin_lock(), which would provide > > the same guarantee, but also upgrades the section to RCsc. > > > > That would make all schedule() calls fully transitive against one > > another. > > > > > > That is, would something like the below make sense? > > Looks to me like you have reinvented smp_mb__after_unlock_lock()... Will said the same, but that one doesn't in fact do the first bit, as ARM64 also needs a full barrier for that, while it doesn't need that to upgrade to RCsc.