Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp692674imp; Wed, 20 Feb 2019 07:25:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYoYKdINJ5lFXTUAcauTHHtA4ZJwyh9d4UpiKIGHAzKZahe2QupBw/6/r3pIdCjGmSo+CsS X-Received: by 2002:a63:295:: with SMTP id 143mr28661183pgc.362.1550676315428; Wed, 20 Feb 2019 07:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550676315; cv=none; d=google.com; s=arc-20160816; b=uE0FNuP6Bqcqo3y71toDst+Wfq0uYa4paEFLtStDzJxRV3ZrtwilA6imxjdE5C/T48 US+7iY8BG3PNnMZdkJhgcQPUW74YI13Z3mpZQclwwv0Xf/bjyj2O69vvRwrWys6rwYf9 57v3hDFvxm4Y5ADYOPb9Eev1kSl3qjWkB07ILgN4E58FJPWJ7UVUWtSkjtJrNLuVBm2i rGAA3BOkpPm6LNT9+wXEVYi7kvihUkDb06yKnGD8wJaLO0vpy98xlC2ZLKYcWCwJH3eX FcyFdlQB7VZYbByBAXcVbhzqmWx/EcZBTBvMhSPdDxIluvSX5eP2KdH6Ee9QcYwJXY7G t8Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=uDh/6zhR9Lw/8iHYyfCkh7spOxNKDGBlf1cr+swj38U=; b=yqXLwBvcSlY+rqXMKyRHcLxY0L4Mq5M3nsc6hhx18b/T8zTlh4Md0q/0P+5EZwY6vo mP1FAg2G8mf3ZqvcWg3zC2ItQsgVLSXmGNSp9RnGs0AfZHNKTz1S52Mc6EfRUlFax+ce /Z2Ko6PnsIg2wOlTdIzFQCl1EYnAJ5WIMJS9+trnw7h8j1gj+Oug09ca9XvBrtt3W6Dq y4Bdyd0FfMhNIZcRuKdY8dskDyZZ1ojBad4QSp5U8AWVt/X/o+fLcTaAU1vcJFvElzWG iwZ39dXO0CMg3D4RwH3KBphEMGN+llruv+w7/bIIS6M/sLTvQ4sFbfqd+cJgZRa98s/z MlTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 126si19097587pff.77.2019.02.20.07.24.59; Wed, 20 Feb 2019 07:25:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727423AbfBTPW6 (ORCPT + 99 others); Wed, 20 Feb 2019 10:22:58 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:48522 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727174AbfBTPW6 (ORCPT ); Wed, 20 Feb 2019 10:22:58 -0500 Received: (qmail 2906 invoked by uid 2102); 20 Feb 2019 10:22:57 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 20 Feb 2019 10:22:57 -0500 Date: Wed, 20 Feb 2019 10:22:57 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Andrea Parri cc: linux-kernel@vger.kernel.org, , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig Subject: Re: [RFC PATCH] tools/memory-model: Remove (dep ; rfi) from ppo In-Reply-To: <1550617057-4911-1-git-send-email-andrea.parri@amarulasolutions.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 Feb 2019, Andrea Parri wrote: > Remove this subtle (and, AFAICT, unused) ordering: we can add it back, > if necessary, but let us not encourage people to rely on this thing. > > For example, the following "exists" clause can be satisfied with this > change: > > C dep-rfi > > { } > > P0(int *x, int *y) > { > WRITE_ONCE(*x, 1); > smp_store_release(y, 1); > } > > P1(int *x, int *y, int *z) > { > int r0; > int r1; > int r2; > > r0 = READ_ONCE(*y); > WRITE_ONCE(*z, r0); > r1 = smp_load_acquire(z); > r2 = READ_ONCE(*x); > } > > exists (1:r0=1 /\ 1:r2=0) > > Signed-off-by: Andrea Parri > Cc: Alan Stern > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Nicholas Piggin > Cc: David Howells > Cc: Jade Alglave > Cc: Luc Maranget > Cc: "Paul E. McKenney" > Cc: Akira Yokosawa > Cc: Daniel Lustig > --- > tools/memory-model/Documentation/explanation.txt | 28 ------------------------ > tools/memory-model/linux-kernel.cat | 2 +- > 2 files changed, 1 insertion(+), 29 deletions(-) > > diff --git a/tools/memory-model/Documentation/explanation.txt b/tools/memory-model/Documentation/explanation.txt > index 68caa9a976d0c..965e11744d090 100644 > --- a/tools/memory-model/Documentation/explanation.txt > +++ b/tools/memory-model/Documentation/explanation.txt > @@ -1019,34 +1019,6 @@ section for more details). The kernel includes a workaround for this > problem when the loads come from READ_ONCE(), and therefore the LKMM > includes address dependencies to loads in the ppo relation. > > -On the other hand, dependencies can indirectly affect the ordering of > -two loads. This happens when there is a dependency from a load to a > -store and a second, po-later load reads from that store: > - > - R ->dep W ->rfi R', > - > -where the dep link can be either an address or a data dependency. In > -this situation we know it is possible for the CPU to execute R' before > -W, because it can forward the value that W will store to R'. But it > -cannot execute R' before R, because it cannot forward the value before > -it knows what that value is, or that W and R' do access the same > -location. However, if there is merely a control dependency between R > -and W then the CPU can speculatively forward W to R' before executing > -R; if the speculation turns out to be wrong then the CPU merely has to > -restart or abandon R'. > - > -(In theory, a CPU might forward a store to a load when it runs across > -an address dependency like this: > - > - r1 = READ_ONCE(ptr); > - WRITE_ONCE(*r1, 17); > - r2 = READ_ONCE(*r1); > - > -because it could tell that the store and the second load access the > -same location even before it knows what the location's address is. > -However, none of the architectures supported by the Linux kernel do > -this.) > - > Two memory accesses of the same location must always be executed in > program order if the second access is a store. Thus, if we have If we do decide to remove the (dep;rfi) term, I would prefer not to erase this discussion from explanation.txt completely. Instead, we should explain that the operational model predicts this ordering but it has been left out of the LKMM for practical (not technical) reasons. Alan