Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751918AbbGMRue (ORCPT ); Mon, 13 Jul 2015 13:50:34 -0400 Received: from foss.arm.com ([217.140.101.70]:58869 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbbGMRuc (ORCPT ); Mon, 13 Jul 2015 13:50:32 -0400 Date: Mon, 13 Jul 2015 18:50:29 +0100 From: Will Deacon To: Peter Zijlstra Cc: "linux-arch@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Benjamin Herrenschmidt , Paul McKenney Subject: Re: [RFC PATCH v2] memory-barriers: remove smp_mb__after_unlock_lock() Message-ID: <20150713175029.GO2632@arm.com> References: <1436789704-10086-1-git-send-email-will.deacon@arm.com> <20150713131143.GY19282@twins.programming.kicks-ass.net> <20150713140915.GD2632@arm.com> <20150713142109.GE2632@arm.com> <20150713155447.GB19282@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150713155447.GB19282@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2048 Lines: 57 On Mon, Jul 13, 2015 at 04:54:47PM +0100, Peter Zijlstra wrote: > However I think we should look at the insides of the critical sections; > for example (from Documentation/memory-barriers.txt): > > " *A = a; > RELEASE M > ACQUIRE N > *B = b; > > could occur as: > > ACQUIRE N, STORE *B, STORE *A, RELEASE M" > > This could not in fact happen, even though we could flip M and N, A and > B will remain strongly ordered. > > That said, I don't think this could even happen on PPC because we have > load_acquire and store_release, this means that: > > *A = a > lwsync > store_release M > load_acquire N > lwsync > *B = b > > And since the store to M is wrapped inside two lwsync there must be > strong store order, and because the load from N is equally wrapped in > two lwsyncs there must also be strong load order. > > In fact, no store/load can cross from before the first lwsync to after > the latter and the other way around. > > So in that respect it does provide full load-store ordering. What it > does not provide is order for M and N, nor does it provide transitivity, > but looking at our documentation I'm not at all sure we guarantee that > in any case. So if I'm following along, smp_mb__after_unlock_lock *does* provide transitivity when used with UNLOCK + LOCK, which is stronger than your example here. I don't think we want to make the same guarantee for general RELEASE + ACQUIRE, because we'd end up forcing most architectures to implement the expensive macro for a case that currently has no users. In which case, it boils down to the question of how expensive it would be to implement an SC UNLOCK operation on PowerPC and whether that justifies the existence of a complicated barrier macro that isn't used outside of RCU. Will -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/