Received: by 10.223.185.116 with SMTP id b49csp6818167wrg; Wed, 28 Feb 2018 16:31:07 -0800 (PST) X-Google-Smtp-Source: AH8x224iUuNezmPt8N/CyNKlfMQFqLlK7Zgoq6Nq4cJ2xhgncA1mBMRUVk69YfqnnxraffW7YTxd X-Received: by 10.99.115.73 with SMTP id d9mr16157539pgn.354.1519864267228; Wed, 28 Feb 2018 16:31:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519864267; cv=none; d=google.com; s=arc-20160816; b=e+eMpkRIdRIBI6/g/82BLr5laKSmv4VCb1zPEkBGlJ7uOmkNZsoCETBZSHMYmHnkaE p/wHIDEIYlmrKotRd2GJbSdeHLXG+ZLkinryJ81xr3gVFKXX1b6a1nRl9FUmRBt2+kMp dpJjz0ZBntzT1luX3NjJRmbfuIuPgBe41F7U9zOTWK/d0dOLv3eb2/lyJOV2JEiiHrtN h8i9x7E3NvnxX2D/MCSC+L7IkONVzd3irVdAXmXJykzUYM9OD4bASIEYyL5EPvgwz+3m aDezIMwnD2X2XDE8J5BOMvO66oUt8jeVq3LgHU0llyd1In27EaZw1oHjgY82QTlKbuMa QFJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=1EDEIndsoOnggoZ8YsZ5lCqrzcq23vBB5/5MFypRsTw=; b=Tl7hIKmeOLSFdQ4BRqG5ZFmXQwJOdogDeRnP1I9Xmt0VQNQ8DeT0xkb0V2unj23n04 58GvBNH2z1170GCpnUWn7/T0iXPIUELmbnAlRp6IsebL4lhiwcyBKfZmgr4W92GR85gl XyDmDUP+V2kHjYx4CiwqzpeDVy9PCJwmUCeAo/OqxChSW7ODrJ68ILqwZW5GzOLYg920 DLvUT3TIEbroy+0ZNdVmshKakKVkoPM/brZWjVjdBaKoUIYzxMHM9wCnPqVHBkY1MkmB wHJrZDoSlcLmLbJt8fzTPmnwyvQ7Afl8QUfwhkkXY2zTWmTzxXMgwwSzkdeiOR21xprV C85g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15-v6si2097784pls.127.2018.02.28.16.30.52; Wed, 28 Feb 2018 16:31:07 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965311AbeCAAaM (ORCPT + 99 others); Wed, 28 Feb 2018 19:30:12 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35426 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965274AbeCAAaK (ORCPT ); Wed, 28 Feb 2018 19:30:10 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w210StVh119024 for ; Wed, 28 Feb 2018 19:30:10 -0500 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ge4wfveef-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 28 Feb 2018 19:30:09 -0500 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 28 Feb 2018 19:30:07 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 28 Feb 2018 19:30:04 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w210U0uu36569336; Thu, 1 Mar 2018 00:30:04 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2A40B2058; Wed, 28 Feb 2018 20:32:20 -0500 (EST) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.216]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 89601B205A; Wed, 28 Feb 2018 20:32:20 -0500 (EST) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id C372716C2EB7; Wed, 28 Feb 2018 16:30:33 -0800 (PST) Date: Wed, 28 Feb 2018 16:30:33 -0800 From: "Paul E. McKenney" To: Alan Stern Cc: LKMM Maintainers -- Akira Yokosawa , Andrea Parri , Boqun Feng , David Howells , Jade Alglave , Luc Maranget , Nicholas Piggin , Peter Zijlstra , Will Deacon , Kernel development list Subject: Re: [PATCH 1/2 RFC] tools/memory-model: rename link and rcu-path to rcu-link and rb Reply-To: paulmck@linux.vnet.ibm.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18030100-0008-0000-0000-000002DD3A46 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008604; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00996540; UDB=6.00506635; IPR=6.00775862; MB=3.00019786; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-01 00:30:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030100-0009-0000-0000-0000386B3A27 Message-Id: <20180301003033.GV3777@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-28_13:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803010005 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 28, 2018 at 03:13:45PM -0500, Alan Stern wrote: > This patch makes a simple non-functional change to the RCU portion of > the Linux Kernel Memory Consistency Model by renaming the "link" and > "rcu-path" relations to "rcu-link" and "rb". > > The name "link" was an unfortunate choice, because it was too generic > and subject to confusion with other meanings of the same word, which > occur quite often in LKMM documentation. The name "rcu-path" is not > very appropriate, because the relation is analogous to the > happens-before (hb) and propagates-before (pb) relations -- although > that fact won't become apparent until the second patch in this series. > > Signed-off-by: Alan Stern Tested-by: Paul E. McKenney > --- > > Index: usb-4.x/tools/memory-model/linux-kernel.cat > =================================================================== > --- usb-4.x.orig/tools/memory-model/linux-kernel.cat > +++ usb-4.x/tools/memory-model/linux-kernel.cat > @@ -100,22 +100,22 @@ let rscs = po ; crit^-1 ; po? > * one but two non-rf relations, but only in conjunction with an RCU > * read-side critical section. > *) > -let link = hb* ; pb* ; prop > +let rcu-link = hb* ; pb* ; prop > > (* Chains that affect the RCU grace-period guarantee *) > -let gp-link = gp ; link > -let rscs-link = rscs ; link > +let gp-link = gp ; rcu-link > +let rscs-link = rscs ; rcu-link > > (* > * A cycle containing at least as many grace periods as RCU read-side > * critical sections is forbidden. > *) > -let rec rcu-path = > +let rec rb = > gp-link | > (gp-link ; rscs-link) | > (rscs-link ; gp-link) | > - (rcu-path ; rcu-path) | > - (gp-link ; rcu-path ; rscs-link) | > - (rscs-link ; rcu-path ; gp-link) > + (rb ; rb) | > + (gp-link ; rb ; rscs-link) | > + (rscs-link ; rb ; gp-link) > > -irreflexive rcu-path as rcu > +irreflexive rb as rcu > Index: usb-4.x/tools/memory-model/Documentation/explanation.txt > =================================================================== > --- usb-4.x.orig/tools/memory-model/Documentation/explanation.txt > +++ usb-4.x/tools/memory-model/Documentation/explanation.txt > @@ -27,7 +27,7 @@ Explanation of the Linux-Kernel Memory C > 19. AND THEN THERE WAS ALPHA > 20. THE HAPPENS-BEFORE RELATION: hb > 21. THE PROPAGATES-BEFORE RELATION: pb > - 22. RCU RELATIONS: link, gp-link, rscs-link, and rcu-path > + 22. RCU RELATIONS: rcu-link, gp-link, rscs-link, and rb > 23. ODDS AND ENDS > > > @@ -1451,8 +1451,8 @@ they execute means that it cannot have c > the content of the LKMM's "propagation" axiom. > > > -RCU RELATIONS: link, gp-link, rscs-link, and rcu-path > ------------------------------------------------------ > +RCU RELATIONS: rcu-link, gp-link, rscs-link, and rb > +--------------------------------------------------- > > RCU (Read-Copy-Update) is a powerful synchronization mechanism. It > rests on two concepts: grace periods and read-side critical sections. > @@ -1509,8 +1509,8 @@ y, which occurs before the end of the cr > propagate to P1 before the end of the grace period, violating the > Guarantee. > > -In the kernel's implementations of RCU, the business about stores > -propagating to every CPU is realized by placing strong fences at > +In the kernel's implementations of RCU, the requirements for stores > +to propagate to every CPU are fulfilled by placing strong fences at > suitable places in the RCU-related code. Thus, if a critical section > starts before a grace period does then the critical section's CPU will > execute an smp_mb() fence after the end of the critical section and > @@ -1523,19 +1523,19 @@ executes. > What exactly do we mean by saying that a critical section "starts > before" or "ends after" a grace period? Some aspects of the meaning > are pretty obvious, as in the example above, but the details aren't > -entirely clear. The LKMM formalizes this notion by means of a > -relation with the unfortunately generic name "link". It is a very > -general relation; among other things, X ->link Z includes cases where > -X happens-before or is equal to some event Y which is equal to or > -comes before Z in the coherence order. Taking Y = Z, this says that > -X ->rfe Z implies X ->link Z, and taking Y = X, it says that X ->fr Z > -and X ->co Z each imply X ->link Z. > +entirely clear. The LKMM formalizes this notion by means of the > +rcu-link relation. rcu-link encompasses a very general notion of > +"before": Among other things, X ->rcu-link Z includes cases where X > +happens-before or is equal to some event Y which is equal to or comes > +before Z in the coherence order. When Y = Z this says that X ->rfe Z > +implies X ->rcu-link Z. In addition, when Y = X it says that X ->fr Z > +and X ->co Z each imply X ->rcu-link Z. > > -The formal definition of the link relation is more than a little > +The formal definition of the rcu-link relation is more than a little > obscure, and we won't give it here. It is closely related to the pb > relation, and the details don't matter unless you want to comb through > a somewhat lengthy formal proof. Pretty much all you need to know > -about link is the information in the preceding paragraph. > +about rcu-link is the information in the preceding paragraph. > > The LKMM goes on to define the gp-link and rscs-link relations. They > bring grace periods and read-side critical sections into the picture, > @@ -1543,32 +1543,33 @@ in the following way: > > E ->gp-link F means there is a synchronize_rcu() fence event S > and an event X such that E ->po S, either S ->po X or S = X, > - and X ->link F. In other words, E and F are connected by a > - grace period followed by an instance of link. > + and X ->rcu-link F. In other words, E and F are linked by a > + grace period followed by an instance of rcu-link. > > E ->rscs-link F means there is a critical section delimited by > an rcu_read_lock() fence L and an rcu_read_unlock() fence U, > and an event X such that E ->po U, either L ->po X or L = X, > - and X ->link F. Roughly speaking, this says that some event > - in the same critical section as E is connected by link to F. > - > -If we think of the link relation as standing for an extended "before", > -then E ->gp-link F says that E executes before a grace period which > -ends before F executes. (In fact it says more than this, because it > -includes cases where E executes before a grace period and some store > -propagates to F's CPU before F executes and doesn't propagate to some > -other CPU until after the grace period ends.) Similarly, > -E ->rscs-link F says that E is part of (or before the start of) a > -critical section which starts before F executes. > + and X ->rcu-link F. Roughly speaking, this says that some > + event in the same critical section as E is linked by rcu-link > + to F. > + > +If we think of the rcu-link relation as standing for an extended > +"before", then E ->gp-link F says that E executes before a grace > +period which ends before F executes. (In fact it covers more than > +this, because it also includes cases where E executes before a grace > +period and some store propagates to F's CPU before F executes and > +doesn't propagate to some other CPU until after the grace period > +ends.) Similarly, E ->rscs-link F says that E is part of (or before > +the start of) a critical section which starts before F executes. > > Putting this all together, the LKMM expresses the Grace Period > Guarantee by requiring that there are no cycles consisting of gp-link > -and rscs-link connections in which the number of gp-link instances is > ->= the number of rscs-link instances. It does this by defining the > -rcu-path relation to link events E and F whenever it is possible to > -pass from E to F by a sequence of gp-link and rscs-link connections > -with at least as many of the former as the latter. The LKMM's "rcu" > -axiom then says that there are no events E such that E ->rcu-path E. > +and rscs-link links in which the number of gp-link instances is >= the > +number of rscs-link instances. It does this by defining the rb > +relation to link events E and F whenever it is possible to pass from E > +to F by a sequence of gp-link and rscs-link links with at least as > +many of the former as the latter. The LKMM's "rcu" axiom then says > +that there are no events E with E ->rb E. > > Justifying this axiom takes some intellectual effort, but it is in > fact a valid formalization of the Grace Period Guarantee. We won't > @@ -1585,10 +1586,10 @@ rcu_read_unlock() fence events delimitin > question, and let S be the synchronize_rcu() fence event for the grace > period. Saying that the critical section starts before S means there > are events E and F where E is po-after L (which marks the start of the > -critical section), E is "before" F in the sense of the link relation, > -and F is po-before the grace period S: > +critical section), E is "before" F in the sense of the rcu-link > +relation, and F is po-before the grace period S: > > - L ->po E ->link F ->po S. > + L ->po E ->rcu-link F ->po S. > > Let W be the store mentioned above, let Z come before the end of the > critical section and witness that W propagates to the critical > @@ -1600,12 +1601,12 @@ some event X which is po-after S. Symbo > > The fr link from Y to W indicates that W has not propagated to Y's CPU > at the time that Y executes. From this, it can be shown (see the > -discussion of the link relation earlier) that X and Z are connected by > -link, yielding: > +discussion of the rcu-link relation earlier) that X and Z are related > +by rcu-link, yielding: > > - S ->po X ->link Z ->po U. > + S ->po X ->rcu-link Z ->po U. > > -These formulas say that S is po-between F and X, hence F ->gp-link Z > +The formulas say that S is po-between F and X, hence F ->gp-link Z > via X. They also say that Z comes before the end of the critical > section and E comes after its start, hence Z ->rscs-link F via E. But > now we have a forbidden cycle: F ->gp-link Z ->rscs-link F. Thus the > @@ -1635,13 +1636,13 @@ time with statement labels added to the > } > > > -If r2 = 0 at the end then P0's store at X overwrites the value > -that P1's load at Z reads from, so we have Z ->fre X and thus > -Z ->link X. In addition, there is a synchronize_rcu() between Y and > -Z, so therefore we have Y ->gp-link X. > +If r2 = 0 at the end then P0's store at X overwrites the value that > +P1's load at Z reads from, so we have Z ->fre X and thus Z ->rcu-link X. > +In addition, there is a synchronize_rcu() between Y and Z, so therefore > +we have Y ->gp-link X. > > If r1 = 1 at the end then P1's load at Y reads from P0's store at W, > -so we have W ->link Y. In addition, W and X are in the same critical > +so we have W ->rcu-link Y. In addition, W and X are in the same critical > section, so therefore we have X ->rscs-link Y. > > This gives us a cycle, Y ->gp-link X ->rscs-link Y, with one gp-link > >