Received: by 10.223.185.116 with SMTP id b49csp1522139wrg; Wed, 21 Feb 2018 21:26:57 -0800 (PST) X-Google-Smtp-Source: AH8x227Flpje3y4bYh8TIuBfMlZIp8G1WzieeUmL71n76ZzSW+RXOKrNW53tm/yz2qEAljH56kEK X-Received: by 10.99.137.195 with SMTP id v186mr4655762pgd.90.1519277216897; Wed, 21 Feb 2018 21:26:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519277216; cv=none; d=google.com; s=arc-20160816; b=mJl7g7oASlrmYVssgiJVysOJbCEQiIyri/wSPtORybGhdo+8X3P25t1pMAOXa7Ulgt AfABwGAoJrvmDsrNolPvyk6PabneZ+GNSPtxBcC8Vb47m8k5ln/r8WpVs5rzsvHnSBrR oHSxjdCRwcyccG78C9vzCYoZf1A225q4zbMsAIHWLHmzz6c5tuQFal4wOTeaYqtbWtQ+ zQaCiEjpq82nsxZTeK0ma8b27d8MxoKuRQvMav6MNGH+n42ZBUZ+ob1Lm0RMhlJZaOYo TR0hEi4VNK/b7jcXZsVygaFCQZBdc6WtLtr0R+SC6lHvvzBC2J8n/XucTDVcDTipyPhk ZLxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=8lxxnJVHx/pBqGFfali+TGm+PhgN0NXl2HAyS1lAyg4=; b=T3oWbSYkG+4nGJXXcQi87aW41L+mE3amQwycqkZZjB1AE5skswX5p6hPnr/ZVYQPdJ OADwpnkIkajOxXaw+bpY6A/LOzDC1K2Dr5Bk8OuQUgLVXFtFwSIdm3tmNBYEUtmIgjRm ikB8AHelVBw8wc6Ge+1eop+o5PObIozDAnwxDbKfIuUBU3hSwhQSHvT4CkcX8/btTomY G0LdsbkHkZ+LyT0Al+022xQ1YznK0JqCumISx8VNk0Ea8g63D9/ufgik65hJqVZmzkr5 d3rGDFXmNWYsNbt/yX4qXLSXdIAVjydMOjle9LArJgF4NMFIjBDuycekjFHJZcU0rSyf zMSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m9Ynxat0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p10si2682317pfd.250.2018.02.21.21.26.41; Wed, 21 Feb 2018 21:26:56 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m9Ynxat0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752338AbeBVFYh (ORCPT + 99 others); Thu, 22 Feb 2018 00:24:37 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52419 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbeBVFYf (ORCPT ); Thu, 22 Feb 2018 00:24:35 -0500 Received: by mail-wm0-f66.google.com with SMTP id t3so1462970wmc.2; Wed, 21 Feb 2018 21:24:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8lxxnJVHx/pBqGFfali+TGm+PhgN0NXl2HAyS1lAyg4=; b=m9Ynxat0YjTBQysfO8j6YTpQs9Z/Hj9pCY9hQ20C9qsdLPTHsiXxlgkxdm0vv2MF8w ZFxx23D/DSIEgu6o4Ac6/G5GUxXOUtjgnYo9DL7u2qH8mkab/kcZXvJ/bVdAbRWthNUg E3JwoKIDDTIjXutv+14gkV3cBQhycT1QhPn6wSkShixRh4NXt1ziyCWfhaQ6F5QVdar/ 3P8aVkw1YJ6zsXW8tg/1VNhSM58RS/GsEPh0AlbSreHr0g2q4gtaKodhmxkNjD4K+XbO jN+RQBebCnV9YIcYSpouYpdiKELWsXOPqzf0YnGeRWjxwr5Zt2/5j9xUsdFUqPQo/pyP Y0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8lxxnJVHx/pBqGFfali+TGm+PhgN0NXl2HAyS1lAyg4=; b=ijpw4VI3Wd+H1ZNrX1vrsewkfJuNJcACXsRHyv5GZDzXu46Lbp+L/jze/9WKdnSaYp Q6Icd4kJcaaVFD6W+W3KOyemmeMZjW8xbDI2HbESF6RO90U0XlI1HrkpUv1DVQ2126Vn EGWe4am1DIRM1SyeyzpG3afJFvk36ekQ0Z/lNoN2Sf1zrxpKWtw+A91c2hKuT8Ah6xKx 9HMzJJwRrr4GkQu+7tuKD6V49xB51E+q7iO9ccXs4ej3BJtkgnnjezAvW5s9HmvwoM5Q G2CeB0vaUoyO920vZqXxwqPqpRhX27z2b3Hh4nona1hzGrmItsD1AuAvu9rUeTjimrNN Eptw== X-Gm-Message-State: APf1xPBQ62J685JgRyS09/NhyjstXOZdu6HrL/QofF1pN5RWTuwyvCAW IwWlXKWPxdhrYqwes4P7V98= X-Received: by 10.80.159.1 with SMTP id b1mr7764042edf.132.1519277073573; Wed, 21 Feb 2018 21:24:33 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id f6sm4329420edl.9.2018.02.21.21.24.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 21:24:32 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id B4D3520BE6; Thu, 22 Feb 2018 00:24:28 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Thu, 22 Feb 2018 00:24:28 -0500 X-ME-Sender: Received: from localhost (unknown [45.32.128.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 0D5BA7E3CE; Thu, 22 Feb 2018 00:24:28 -0500 (EST) Date: Thu, 22 Feb 2018 13:27:46 +0800 From: Boqun Feng To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, mingo@kernel.org, stern@rowland.harvard.edu, parri.andrea@gmail.com, will.deacon@arm.com, peterz@infradead.org, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, nborisov@suse.com, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: Re: [PATCH RFC tools/lkmm 10/12] tools/memory-model: Add a S lock-based external-view litmus test Message-ID: <20180222052746.vofmqbpnmfahck3z@tardis> References: <20180220232405.GA19274@linux.vnet.ibm.com> <1519169112-20593-10-git-send-email-paulmck@linux.vnet.ibm.com> <20180222032349.klcuiq23f52sfop6@tardis> <20180222041357.GB2855@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mtzlcjcxkatg5c6c" Content-Disposition: inline In-Reply-To: <20180222041357.GB2855@linux.vnet.ibm.com> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --mtzlcjcxkatg5c6c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Feb 21, 2018 at 08:13:57PM -0800, Paul E. McKenney wrote: > On Thu, Feb 22, 2018 at 11:23:49AM +0800, Boqun Feng wrote: > > On Tue, Feb 20, 2018 at 03:25:10PM -0800, Paul E. McKenney wrote: > > > From: Alan Stern > > >=20 > > > This commit adds a litmus test in which P0() and P1() form a lock-bas= ed S > > > litmus test, with the addition of P2(), which observes P0()'s and P1(= )'s > > > accesses with a full memory barrier but without the lock. This litmus > > > test asks whether writes carried out by two different processes under= the > > > same lock will be seen in order by a third process not holding that l= ock. > > > The answer to this question is "yes" for all architectures supporting > >=20 > > Hmm.. it this true? Our spin_lock() is RCpc because of PowerPC, so > > spin_lock()+spin_unlock() pairs don't provide transitivity, and that's > > why we have smp_mb__after_unlock_lock(). Is there something I'm missing? > > Or there is an upcomming commit to switch PowerPC's lock implementation? >=20 > The PowerPC lock implementation's unlock-lock pair does not order writes > from the previous critical section against reads from the later critical > section, but it does order other combinations of reads and writes. Ah.. right! Thanks for the explanation ;-) > Some have apparently said that RISC-V 's unlock-lock pair also does not > order writes from the previous critical section against writes from the > later critical section. And no, I don't claim to have yet gotten my > head around RISC-V memory ordering. ;-) >=20 Me neither. Now I remember this: we have a off-list(accidentally) discussion about this, and IIRC at that moment riscv people confirmed that riscv's unlock-lock pair doesn't order write->write, but that was before their memory model draft posted for discussions, so things may change now...=20 Besides, I think the smp_mb() on P2 can be relaxed to smp_rmb(), no? Regards, Boqun > Thanx, Paul >=20 > > [Cc ppc maintainers] > >=20 > > Regards, > > Boqun > >=20 > > > the Linux kernel, but is "no" according to the current version of LKM= M. > > >=20 > > > A patch to LKMM is under development. > > >=20 > > > Signed-off-by: Alan Stern > > > Signed-off-by: Paul E. McKenney > > > --- > > > .../ISA2+pooncelock+pooncelock+pombonce.litmus | 41 ++++++++++++= ++++++++++ > > > 1 file changed, 41 insertions(+) > > > create mode 100644 tools/memory-model/litmus-tests/ISA2+pooncelock+p= ooncelock+pombonce.litmus > > >=20 > > > diff --git a/tools/memory-model/litmus-tests/ISA2+pooncelock+pooncelo= ck+pombonce.litmus b/tools/memory-model/litmus-tests/ISA2+pooncelock+poonce= lock+pombonce.litmus > > > new file mode 100644 > > > index 000000000000..7a39a0aaa976 > > > --- /dev/null > > > +++ b/tools/memory-model/litmus-tests/ISA2+pooncelock+pooncelock+pomb= once.litmus > > > @@ -0,0 +1,41 @@ > > > +C ISA2+pooncelock+pooncelock+pombonce.litmus > > > + > > > +(* > > > + * Result: Sometimes > > > + * > > > + * This test shows that the ordering provided by a lock-protected S > > > + * litmus test (P0() and P1()) are not visible to external process P= 2(). > > > + * This is likely to change soon. > > > + *) > > > + > > > +{} > > > + > > > +P0(int *x, int *y, spinlock_t *mylock) > > > +{ > > > + spin_lock(mylock); > > > + WRITE_ONCE(*x, 1); > > > + WRITE_ONCE(*y, 1); > > > + spin_unlock(mylock); > > > +} > > > + > > > +P1(int *y, int *z, spinlock_t *mylock) > > > +{ > > > + int r0; > > > + > > > + spin_lock(mylock); > > > + r0 =3D READ_ONCE(*y); > > > + WRITE_ONCE(*z, 1); > > > + spin_unlock(mylock); > > > +} > > > + > > > +P2(int *x, int *z) > > > +{ > > > + int r1; > > > + int r2; > > > + > > > + r2 =3D READ_ONCE(*z); > > > + smp_mb(); > > > + r1 =3D READ_ONCE(*x); > > > +} > > > + > > > +exists (1:r0=3D1 /\ 2:r2=3D1 /\ 2:r1=3D0) > > > --=20 > > > 2.5.2 > > >=20 >=20 >=20 --mtzlcjcxkatg5c6c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAlqOVM8ACgkQSXnow7UH +riMhwf+Okl3Jyf184VnXOuDWBLDyJSDhKDU59yU2c8TNQTsbfDGwasPmuzjAeeZ /O+tdW3Uv4XtjaEs8tsf/RGTznSE9dYe2SNW9yUsafFIoiE7KwjYnqNnkctEk7Ge +0SFZVgjaHyxZDrPmKGI/fUv7Cwr8JoqTohrp/ayx32bN7kWAm6JgbPOZchxemZn dXCWUsU5aRZaf8NVLdXNwFpzSQfTiBtC+w6re8sB6JBsYy5+z7hE2XBiGM3ZIcgU BSd3mGH2LLNghBXnTN+YuWvoaiDzRpD9nav48qL4hqJofqvWdMaRfx1JLNLrHAvY g3mH/PlcW+8ai+HoXFI046U+yJcPEA== =bZBc -----END PGP SIGNATURE----- --mtzlcjcxkatg5c6c--