Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1403301imm; Tue, 3 Jul 2018 10:29:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdShcId7cYIsLQQnjIsLpGmzWFeEvelOendO4SU+vtaar57Pnr5+IPr0y7mKq9x2r8tAUeh X-Received: by 2002:a62:6659:: with SMTP id a86-v6mr13846802pfc.31.1530638964673; Tue, 03 Jul 2018 10:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530638964; cv=none; d=google.com; s=arc-20160816; b=zo9zkM3uWwj3kuAx34DhaHtWEj9igkvNYB8HWW8OW01Uco5aui+mFxkRCv/nR65VtV 5WvUv3aI/gv7UmiAeFYb5qngSBDt7iejQk66G3SWQGBwK2MoC25xmHthIujAsd4Rf7N+ Iw9oSyB0tIVwvpvxcH7USh1Ks1/NUXttH8l6X+Ym5XyYoSNq+wliwUO/XcXxxzC/feAn svfinpjAj71JB3YHvfTAqTbeAALGFPEm527EbnllW5q+03UYyLTVFRjq1tEeSvOLtIAc NaJLZyJPbNp5DWdz2TGLAoKnUfI+GAxPsUj/csKwlbyA+W1aP1BwCPwVqYd6rsOctneC HRRg== 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:arc-authentication-results; bh=jraJOgsbrttX+0dWz7t9F9KJWZd2JYtm12O/sEAbh7M=; b=z5oV/21EDvYrsSaAPrsIVJZTLUBzkFJDr3MO64hhkpZTkv9qoWmO26St02TKLVIuFq JObug0hQRS6mW/C5eayalqy4NsMpCB33LufrtvjNnU7JRu81DSywrtkiNbgH7y4BBER2 WhgLAkUH8Ea2zPVtPbeUfRrikbeGfJASrjzFEryJdDPCdu7W9ylpXHTwgqYenXDbvCFh WHoplC9BeIQzCT9z+nSz7l1UJo95UFuuIj/Q3giIJNQfuAeQH9KK4LYMWl67IwQcqF2X D83smeHGr/U2xGePvIXZaKQ7emJvBC9HupouZ19/PajtPVa/D4ujOVuDqDVZSp2/nRhP 4RNA== 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 f40-v6si1537782plb.504.2018.07.03.10.29.10; Tue, 03 Jul 2018 10:29:24 -0700 (PDT) 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 S934229AbeGCR2T (ORCPT + 99 others); Tue, 3 Jul 2018 13:28:19 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:37852 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S933677AbeGCR2S (ORCPT ); Tue, 3 Jul 2018 13:28:18 -0400 Received: (qmail 5601 invoked by uid 2102); 3 Jul 2018 13:28:17 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 3 Jul 2018 13:28:17 -0400 Date: Tue, 3 Jul 2018 13:28:17 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Will Deacon , Andrea Parri cc: LKMM Maintainers -- Akira Yokosawa , Boqun Feng , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Kernel development list Subject: Re: [PATCH 2/2] tools/memory-model: Add write ordering by release-acquire and by locks In-Reply-To: <20180625081920.GA5619@andrea> 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 Will: On Mon, 25 Jun 2018, Andrea Parri wrote: > On Fri, Jun 22, 2018 at 07:30:08PM +0100, Will Deacon wrote: > > > > I think the second example would preclude us using LDAPR for load-acquire, > > > I don't think it's a moot point. We want new architectures to implement > > acquire/release efficiently, and it's not unlikely that they will have > > acquire loads that are similar in semantics to LDAPR. This patch prevents > > them from doing so, > > By this same argument, you should not be a "big fan" of rfi-rel-acq in ppo ;) > consider, e.g., the two litmus tests below: what am I missing? This is an excellent point, which seems to have gotten lost in the shuffle. I'd like to see your comments. In essence, if you're using release-acquire instructions that only provide RCpc consistency, does store-release followed by load-acquire of the same address provide read-read ordering? In theory it doesn't have to, because if the value from the store-release is forwarded to the load-acquire then: LOAD A STORE-RELEASE X, v LOAD-ACQUIRE X LOAD B could be executed by the CPU in the order: LOAD-ACQUIRE X LOAD B LOAD A STORE-RELEASE X, v thereby accessing A and B out of program order without violating the requirements on the release or the acquire. Of course PPC doesn't allow this, but should we rule it out entirely? > C MP+fencewmbonceonce+pooncerelease-rfireleaseacquire-poacquireonce > > {} > > P0(int *x, int *y) > { > WRITE_ONCE(*x, 1); > smp_wmb(); > WRITE_ONCE(*y, 1); > } > > P1(int *x, int *y, int *z) > { > r0 = READ_ONCE(*y); > smp_store_release(z, 1); > r1 = smp_load_acquire(z); > r2 = READ_ONCE(*x); > } > > exists (1:r0=1 /\ 1:r1=1 /\ 1:r2=0) > > > AArch64 MP+dmb.st+popl-rfilq-poqp > "DMB.STdWW Rfe PodRWPL RfiLQ PodRRQP Fre" > Generator=diyone7 (version 7.49+02(dev)) > Prefetch=0:x=F,0:y=W,1:y=F,1:x=T > Com=Rf Fr > Orig=DMB.STdWW Rfe PodRWPL RfiLQ PodRRQP Fre > { > 0:X1=x; 0:X3=y; > 1:X1=y; 1:X3=z; 1:X6=x; > } > P0 | P1 ; > MOV W0,#1 | LDR W0,[X1] ; > STR W0,[X1] | MOV W2,#1 ; > DMB ST | STLR W2,[X3] ; > MOV W2,#1 | LDAPR W4,[X3] ; > STR W2,[X3] | LDR W5,[X6] ; > exists > (1:X0=1 /\ 1:X4=1 /\ 1:X5=0) There's also read-write ordering, in the form of the LB pattern: P0(int *x, int *y, int *z) { r0 = READ_ONCE(*x); smp_store_release(z, 1); r1 = smp_load_acquire(z); WRITE_ONCE(*y, 1); } P1(int *x, int *y) { r2 = READ_ONCE(*y); smp_mp(); WRITE_ONCE(*x, 1); } exists (0:r0=1 /\ 1:r2=1) Would this be allowed if smp_load_acquire() was implemented with LDAPR? If the answer is yes then we will have to remove the rfi-rel-acq and rel-rf-acq-po relations from the memory model entirely. Alan PS: Paul, is the patch which introduced rel-rf-acq-po currently present in any of your branches? I couldn't find it.