Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753699AbdLUQPb (ORCPT ); Thu, 21 Dec 2017 11:15:31 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33602 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752267AbdLUQO5 (ORCPT ); Thu, 21 Dec 2017 11:14:57 -0500 Date: Thu, 21 Dec 2017 08:15:02 -0800 From: "Paul E. McKenney" To: afzal mohammed Cc: Alan Stern , Peter Zijlstra , parri.andrea@gmail.com, will.deacon@arm.com, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, linux-kernel@vger.kernel.org, elena.reshetova@intel.com Subject: Re: Prototype patch for Linux-kernel memory model Reply-To: paulmck@linux.vnet.ibm.com References: <20171114075925.apzztfksn4f4y5ue@hirez.programming.kicks-ass.net> <20171114171505.GS3624@linux.vnet.ibm.com> <20171115163749.GA8555@linux.vnet.ibm.com> <20171220113145.GA5082@afzalpc> <20171220164538.GL7829@linux.vnet.ibm.com> <20171221033055.GA3944@afzalpc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171221033055.GA3944@afzalpc> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17122116-0052-0000-0000-000002956F5E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008238; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00963503; UDB=6.00487446; IPR=6.00743490; BA=6.00005752; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018658; XFM=3.00000015; UTC=2017-12-21 16:14:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17122116-0053-0000-0000-000052FA042E Message-Id: <20171221161502.GX7829@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-21_07:,, 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-1712210221 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2549 Lines: 66 On Thu, Dec 21, 2017 at 09:00:55AM +0530, afzal mohammed wrote: > Hi, > > On Wed, Dec 20, 2017 at 08:45:38AM -0800, Paul E. McKenney wrote: > > On Wed, Dec 20, 2017 at 05:01:45PM +0530, afzal mohammed wrote: > > > > > +It is tempting to assume that CPU0()'s store to x is globally ordered > > > > +before CPU1()'s store to z, but this is not the case: > > > > + > > > > + /* See Z6.0+pooncerelease+poacquirerelease+mbonceonce.litmus. */ > > > > + void CPU0(void) > > > > + { > > > > + WRITE_ONCE(x, 1); > > > > + smp_store_release(&y, 1); > > > > + } > > > > + > > > > + void CPU1(void) > > > > + { > > > > + r1 = smp_load_acquire(y); > > > > + smp_store_release(&z, 1); > > > > + } > > > > + > > > > + void CPU2(void) > > > > + { > > > > + WRITE_ONCE(z, 2); > > > > + smp_mb(); > > > > + r2 = READ_ONCE(x); > > > > + } > > > > + > > > > +One might hope that if the final value of r1 is 1 and the final value > > > > +of z is 2, then the final value of r2 must also be 1, but the opposite > > > > +outcome really is possible. > > > > > > As there are 3 variables to have the values, perhaps, it might be > > > clearer to have instead of "the opposite.." - "the final value need > > > not be 1" or was that a read between the lines left as an exercise to > > > the idiots ;) > > > > Heh! Good catch, thank you! How about the following for the paragraph > > immediately after that litmus test? > > > > One might hope that if the final value of r0 is 1 and the final > > value of z is 2, then the final value of r1 must also be 1, > > but it really is possible for r1 to have the final value of 0. > > The reason, of course, is that in this version, CPU2() is not > > part of the release-acquire chain. This situation is accounted > > for in the rules of thumb below. > > > > I also fixed r1 and r2 to match the names in the actual litmus test. > > Since it is now mentioned that r1 can have final value of 0, though it > is understood, it might make things crystal clear and for the sake of > completeness to also show the non-automatic variable x being > initialized to 0. Here we rely on the C-language and Linux-kernel convention that global variables that are not explicitly initialized are initialized to zero. (Also the documented behavior of the litmus tests and the herd tool that uses them.) So that part should be OK as is. Nevertheless, thank you for your review and comments! Have you installed and run the herd tool? Doing so would allow you to experiment with changes to the litmus tests. Thanx, Paul