Received: by 10.223.185.116 with SMTP id b49csp8235166wrg; Thu, 1 Mar 2018 20:43:53 -0800 (PST) X-Google-Smtp-Source: AG47ELtRrYaj9Z+UXZz1osP5fNQBsl/G2IyXifoGdqbwcdHOnH8LLmHPiZlz6mp1gvvE6uOCDtPD X-Received: by 2002:a17:902:b101:: with SMTP id q1-v6mr4135688plr.287.1519965833402; Thu, 01 Mar 2018 20:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519965833; cv=none; d=google.com; s=arc-20160816; b=DsYVJiW2+cnO7EjFKg/PpZxjWT8hNrHMIg1+Miz2pK5F4StpLnh+3GW9AuD8j/dKpS ye/IuamBmxFi16FS3IyrVb+sdml1xn6bht4aVpuZmhyIOBlDyuR/gZSZeO/ak9F1554O tBsK5pkvHEnsXhO1CZGp0/Iv69dRQHz2aPJhGhIAkvPjmoZXEw+Ef4bpPtKGT91JkMc8 FFgnoJJmGnEr7FvAReh58HgIqqQvSC1ZhtKC4O6zhypsNMGf49TApeNwEt/LoGThTsHy UM2Oy+ktAzQbiwjdNKwD6u6eYqeTQRafic2mzuzfLX6cALc73goW4cHQta879H7coPkA rHAw== 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=VYudZeYZJC4+uWYpU40TEX1Nr00H5lm6B5hKeJjYUe8=; b=dkqi5EQARP7mFOnp1SHA9EbiLV2kPlGWnaAEz7cOnO8KhhANIqbHL5NdKdQWq6Bk+y FIIDIhtXY2l9da23IBLTis2psV9IWXCr0RA+E9Gr8TTWnBVupmSzLjT8iHS0sAvrH5If 0Yg3ckuHUrgRC2U7/fTF8/aifw+oNA+dfONg55iOP3DLyIwWzvJqHuO1sr5bvCtN2XAn gGqry4dY0JK4F/d0QXfuIWXDRpJHNX0QJWkeylnrFhxAFSKefJbHZOBECB9nIJLDLmc+ LJCaV0ypbIawh4Dpg9aSeNE34+/wgVtIO68dQxWS4ch4lXI/3UtbCt9dFScphjeq5Sv3 RPxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gJ628WaG; 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 s194si3455461pgc.597.2018.03.01.20.43.38; Thu, 01 Mar 2018 20:43:53 -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=gJ628WaG; 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 S1164613AbeCBE2P (ORCPT + 99 others); Thu, 1 Mar 2018 23:28:15 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52266 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164199AbeCBE2M (ORCPT ); Thu, 1 Mar 2018 23:28:12 -0500 Received: by mail-wm0-f65.google.com with SMTP id t3so757725wmc.2 for ; Thu, 01 Mar 2018 20:28:12 -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=VYudZeYZJC4+uWYpU40TEX1Nr00H5lm6B5hKeJjYUe8=; b=gJ628WaGn0V2OBsFYi6oq4wBEV22vf/yNNR1ib1lCjAcixu6r5VLjJ2+Pj1HiEyExp jPyJ20KxpdFRXHfDbGipwNKiknWgmdxHKM8vxpDRQX02mwe7u2O8l5wyVL/9uCFzCekq 1dxB5a/o0SFRl8xreTYQpfXFmGHS8Ru0SD1IfxFVwxGZEER+hnoRgp08Bc7NaSBBskjR EIzriGtJKekFriAlxxHdOxyvMIfjxMuhZAIHr31t8xQKLgwyylBKOKzft/nSQVT5qac+ 7XH7VJwNaTiAqgAb7nDUFQan9CIp7eDRmn2yvmAgcS/N5k0Z0ETBlW0AMWzjoVhCeaQT SRqw== 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=VYudZeYZJC4+uWYpU40TEX1Nr00H5lm6B5hKeJjYUe8=; b=Xe0DItSNIJZCM8hcgG8q9FzQQOocJufHsdXGMxxJZGtQMj5Es9vJFSHDFp9cPrB5E8 DVYD/DBcX2R4DSUB4z2C+ICWLcQyVWDYNbXCoULe6FGSJMbO/mJ1jD8Jd7PEh8+sJfRU SZUqeZPXPgKz7S7A4PY+fZ11nGIloghP7Rr+hOZ2KlDfka9f9pQtrf1Ma8o6JwICKN6l VrCeEk/zbO4J9hUgv1SVtQfN+VBwzq0aWOo+ezbrfcwlx6gdWBD7SMzJhOZBDaNw0KPc KLoxl5IDCIbZ06WZ6DBqDzb71Iv7Zq0LSB4LEdUn5XRtNvSxF//QDnQ+6pUWuMesOvqo WjmQ== X-Gm-Message-State: APf1xPAjyvFWuAN4qlEnhBQBZcYVbE+zFMPbcSHWfrBZXWVG9xHcrzLa hJpVHuMyoR0Mtivf1pJvLeT9F4S1 X-Received: by 10.80.245.200 with SMTP id x8mr5746705edm.253.1519964891467; Thu, 01 Mar 2018 20:28:11 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id k7sm5154257edb.69.2018.03.01.20.28.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 20:28:10 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 767E020D7D; Thu, 1 Mar 2018 23:28:07 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Thu, 01 Mar 2018 23:28:07 -0500 X-ME-Sender: Received: from localhost (unknown [45.32.128.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 75F4F24838; Thu, 1 Mar 2018 23:28:06 -0500 (EST) Date: Fri, 2 Mar 2018 12:31:41 +0800 From: Boqun Feng To: "Paul E. McKenney" Cc: Alan Stern , LKMM Maintainers -- Akira Yokosawa , Andrea Parri , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Will Deacon , Kernel development list Subject: Re: [PATCH 2/2 v2 RFC] tools/memory-model: redefine rb in terms of rcu-fence Message-ID: <20180302043141.fgmjyysrws55pi7q@tardis> References: <20180301015531.olvuu5g35eta5xhr@tardis> <20180301174906.GC3777@linux.vnet.ibm.com> <20180301183758.GA31761@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hya3soutqch7sd5d" Content-Disposition: inline In-Reply-To: <20180301183758.GA31761@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 --hya3soutqch7sd5d Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 01, 2018 at 10:37:58AM -0800, Paul E. McKenney wrote: > On Thu, Mar 01, 2018 at 09:49:06AM -0800, Paul E. McKenney wrote: > > On Thu, Mar 01, 2018 at 10:49:05AM -0500, Alan Stern wrote: > > > On Thu, 1 Mar 2018, Boqun Feng wrote: > > >=20 > > > > > +let rec rcu-fence =3D gp | > > > > > + (gp ; rcu-link ; rscs) | > > > > > + (rscs ; rcu-link ; gp) | > > > > > + (gp ; rcu-link ; rcu-fence ; rcu-link ; rscs) | > > > > > + (rscs ; rcu-link ; rcu-fence ; rcu-link ; gp) | > > > > > + (rcu-fence ; rcu-link ; rcu-fence) > > > > > + > > > > > +(* rb orders instructions just as pb does *) > > > > > +let rb =3D prop ; rcu-fence ; hb* ; pb* > > > > > =20 > > > > > irreflexive rb as rcu > > > >=20 > > > > I wonder whether we can simplify things as: > > > >=20 > > > > let rec rcu-fence =3D > > > > (gp; rcu-link; rscs) | > > > > (rscs; rcu-link; gp) | > > > > (gp; rcu-link; rcu-fence; rcu-link; rscs) | > > > > (rscs; rcu-link; rcu-fence; rcu-link; gp) > > > > =09 > > > > (* gp and rcu-fence; rcu-link; rcu-fence removed *) > > > > =09 > > > > let rb =3D prop; rcu-fence; hb*; pb* > > > >=20 > > > > acycle rb as rcu > > > >=20 > > > > In this way, "rcu-fence" is defined as "any sequence containing as = many > > > > grace periods as RCU read-side critical sections (joined by rcu-lin= k)." > > > > Note that "rcu-link" contains "gp", so we don't miss the case where > > > > there are more grace periods. And since we use "acycle" now, so we = don't > > > > need "rcu-fence; rcu-link; rcu-fence" to build "rcu-fence" recursiv= ely. > > >=20 > > > Would this definition of rcu-fence work for a sequence such as (leavi= ng > > > out the intermediate rcu-link parts): > > >=20 > > > gp gp gp rscs rscs gp rscs rscs > > >=20 > > > ? I don't think it would. Yes, if you had a cycle of that form then= =20 Right.=20 > > > your "rcu" axiom would detect it, but at some point we might want to= =20 > > > use rcu-fence for some other purpose, one that doesn't involve cycles. OK, and I've not yet found another simple way to express rcu-fence for purposes other than cycle-checking. So I'm OK to leave it as it is except removing the redundant "gp" in rcu-fence definition. But I will continue to search for a easier and sufficient way to define these things ;-)=20 > >=20 > > Let's see, that would map to this: > >=20 > > auto/RW-G+RW-G+RW-G+RW-R+RW-R+RW-G+RW-R+RW-R.litmus > >=20 > > And no, there is no such automatically generated litmus test. Let's > > try reversing the "gp" and "rscs", which should have the same effect > > courtesy of symmetry: > >=20 > > auto/RW-R+RW-R+RW-R+RW-G+RW-G+RW-R+RW-G+RW-G.litmus > >=20 > > And that one doesn't exist, either. So much for random test generation= ! :-/ > >=20 > > Clearly time to add them. And here is what herd has to say about them: > >=20 > > l$ sh scripts/checklitmus.sh /tmp/auto/C-RW-G+RW-G+RW-G+RW-R+RW-R+RW-G+= RW-R+RW-R.litmus > > Herd options: -conf linux-kernel.cfg > > Observation /tmp/auto/C-RW-G+RW-G+RW-G+RW-R+RW-R+RW-G+RW-R+RW-R Sometim= es 1 255 > > ^^^ Unexpected non-Never verification > > 0inputs+32outputs (0major+2605minor)pagefaults 0swaps > > $ sh scripts/checklitmus.sh /tmp/auto/C-RW-R+RW-R+RW-R+RW-G+RW-G+RW-R+R= W-G+RW-G.litmus > > Herd options: -conf linux-kernel.cfg > > Observation /tmp/auto/C-RW-R+RW-R+RW-R+RW-G+RW-G+RW-R+RW-G+RW-G Sometim= es 1 255 > > ^^^ Unexpected non-Never verification > > 0inputs+32outputs (0major+2620minor)pagefaults 0swaps > >=20 > > In other words, they are in fact misclassified as "Sometimes" when they > > should be "Never". I have my diffs below in case I misapplied Boqun's > > change. > >=20 > > With Alan's original formulation, these two litmus tests are correctly > > handled: > >=20 > > $ sh scripts/checklitmus.sh /tmp/auto/C-RW-G+RW-G+RW-G+RW-R+RW-R+RW-G+R= W-R+RW-R.litmus > > Herd options: -conf linux-kernel.cfg > > Observation /tmp/auto/C-RW-G+RW-G+RW-G+RW-R+RW-R+RW-G+RW-R+RW-R Never 0= 255 > > 1.61user 0.00system 0:01.63elapsed 98%CPU (0avgtext+0avgdata 9572maxres= ident)k > > $ sh scripts/checklitmus.sh /tmp/auto/C-RW-R+RW-R+RW-R+RW-G+RW-G+RW-R+R= W-G+RW-G.litmus > > Herd options: -conf linux-kernel.cfg > > Observation /tmp/auto/C-RW-R+RW-R+RW-R+RW-G+RW-G+RW-R+RW-G+RW-G Never 0= 255 > > 1.84user 0.01system 0:01.92elapsed 96%CPU (0avgtext+0avgdata 10112maxre= sident)k >=20 > And as Andrea pointed out off-list, I did indeed mess up Boqun's change. > I forgot to change the "irreflexive" into "acyclic". Applying that change > makes everything work. >=20 > Please accept my apologies for my confusion! >=20 np, also I should have provided a proper patch for your testing. For this Alan's patch, feel free to add: Reviewed-by: Boqun Feng Regards, Boqun > Thanx, Paul >=20 > > > > I prefer this because we already treat "gp" as "strong-fence", which > > > > already is a "rcu-link". > > >=20 > > > That's a good point; it had not occurred to me. > >=20 > > And if I remove the "gp" but leave the last line, it does properly > > classify the two new litmus tests. > >=20 > > Thanx, Paul > >=20 > > > > Also, recurisively extending rcu-fence with > > > > itself is exactly calculating the transitive closure, which we can = avoid > > > > by using a "acycle" rule. Besides, it looks more consistent with hb= and > > > > pb. > > >=20 > > > That _had_ occurred to me. But I couldn't see any way to do it while= =20 > > > still defining rcu-fence correctly. > >=20 > > ------------------------------------------------------------------------ > >=20 > > diff --git a/tools/memory-model/linux-kernel.cat b/tools/memory-model/l= inux-kernel.cat > > index 1e5c4653dd12..75d3c225146c 100644 > > --- a/tools/memory-model/linux-kernel.cat > > +++ b/tools/memory-model/linux-kernel.cat > > @@ -106,12 +106,11 @@ let rcu-link =3D hb* ; pb* ; prop > > * Any sequence containing at least as many grace periods as RCU read-= side > > * critical sections (joined by rcu-link) acts as a generalized strong= fence. > > *) > > -let rec rcu-fence =3D gp | > > +let rec rcu-fence =3D > > (gp ; rcu-link ; rscs) | > > (rscs ; rcu-link ; gp) | > > (gp ; rcu-link ; rcu-fence ; rcu-link ; rscs) | > > - (rscs ; rcu-link ; rcu-fence ; rcu-link ; gp) | > > - (rcu-fence ; rcu-link ; rcu-fence) > > + (rscs ; rcu-link ; rcu-fence ; rcu-link ; gp) > > =20 > > (* rb orders instructions just as pb does *) > > let rb =3D prop ; rcu-fence ; hb* ; pb* >=20 --hya3soutqch7sd5d Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAlqY06kACgkQSXnow7UH +riSPQgAmzgfU7ZJyU9vIARnoZtMRfQGFR7qLpP6r6fERm6n4h82Y9oevGqWdNG/ LyHzRLnNZxnHCyEEPMmgXtRPDNGGAlqRe4orN1HowKhlNiHWEJmE8e3u0Hi2WMM/ /QynUr3seS21OGLr7dmGyJ8VAtjF+MwgiBKbAEzM+8TZ60E7CDGaZ6QwmAIVHDfJ lbDUkyjH62tBNUL++DUNTgDkQDcoK9spW+4Smpow5AqDLfHroZhYOmo2cnNXwG0P xyR3wk0go10eaknfU+o7VM95+nAsK0KovNoPWlF/VZACQwaem1p4r+Oh51YCp7A7 K9DlBiYVAw/FLlMvbJqAXEeaAQts5w== =RfcT -----END PGP SIGNATURE----- --hya3soutqch7sd5d--