Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3875725imm; Tue, 29 May 2018 15:52:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXjAEvujkOt9wAbpLliOoUJkorpyV16kFkvP3KdyBtrvr5OTa8n1Ysr9UaCM88tjH+MWzd X-Received: by 2002:aa7:8084:: with SMTP id v4-v6mr293215pff.105.1527634348625; Tue, 29 May 2018 15:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527634348; cv=none; d=google.com; s=arc-20160816; b=CxRUQ6Mh7TABlilluZSCNntFoNtVlmIBzfh45IkiPjwM+ayPDW6Tog1cjD9UO+REs2 Q/7cC+bVixyjjCNY5lSf03tEvEO9qZNS5dwGHhR7rm4roRdeCIptq7+9xqM7CtQXveKM PGYTzZHaL3XOR2EykEvVsO1q3Y4yMj1vuyU+niR+ybxaQ9jxCja31ARc45YqgX1Vqnnw nDpfWfugDyoEqHWNHS5CH+EPJjxwcpWdYOcIxChFeH/Md+EAmDeEkJAJu6EC5WIJpnxr OtpFlqcsmIwb4l1eOAJNI5gVW7Jam8cxV5CW7WaNEjJRkJq7xymaqghxwA/MwE8efxxT VPQA== 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=xjnkwHNmMyBN2b1Upe9qVBunq91xsxZDoF76aKvBaH0=; b=i6RBCMK3cp4jZkdx+923rom/iQwh00F1tTB2zixMQcoQk5Cg5AA0XphNNFTVHGgGqt xFv0dTBUhkXzbd9wPZqT915qdaho0vlQbIHpR5XiYaq8YYd0FE073clPm8/vZlpitHEl iysZIu3zKp45+QhVl3nd/1LrphF8N5jbypZLRMgybKb8jSVRwZwFUN99qYefuJxEFD8i 6R6JGL1gnuVHZcb35ZmNacqZi4U0FVL0mlK0m45ooxGqzNu5gq7wWZWaQb3X6m9J4QY9 Ze0PkEpJ5DQSrRR1ZW0pzsSYxeh1F+SG4iP1rnbGwAebs/PNn1NeAI1AqDxcWcUtG3KX 5SMg== 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 e92-v6si32795703pld.601.2018.05.29.15.52.13; Tue, 29 May 2018 15:52:28 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967758AbeE2Wvs (ORCPT + 99 others); Tue, 29 May 2018 18:51:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51952 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935818AbeE2Wvq (ORCPT ); Tue, 29 May 2018 18:51:46 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4TMn8gr079747 for ; Tue, 29 May 2018 18:51:45 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j9ewmj6dt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 May 2018 18:51:45 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 May 2018 18:51:44 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 29 May 2018 18:51:39 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4TMpc6S66322586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 29 May 2018 22:51:38 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B9A7B2066; Tue, 29 May 2018 19:53:19 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 081E9B2065; Tue, 29 May 2018 19:53:19 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.153.176]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 29 May 2018 19:53:18 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 14F8A16C62E4; Tue, 29 May 2018 15:53:21 -0700 (PDT) Date: Tue, 29 May 2018 15:53:21 -0700 From: "Paul E. McKenney" To: Linus Torvalds Cc: Alan Stern , Linux Kernel Mailing List , linux-arch , andrea.parri@amarulasolutions.com, Will Deacon , Peter Zijlstra , Boqun Feng , Nick Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Ingo Molnar , Roman Pen Subject: Re: LKMM litmus test for Roman Penyaev's rcu-rr Reply-To: paulmck@linux.vnet.ibm.com References: <20180529190332.GO3803@linux.vnet.ibm.com> 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: 18052922-2213-0000-0000-000002AF3E5E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009097; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000264; SDB=6.01039566; UDB=6.00530826; IPR=6.00818694; MB=3.00021364; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-29 22:51:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052922-2214-0000-0000-00005A499796 Message-Id: <20180529225321.GQ3803@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-29_10:,, 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1805290242 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 29, 2018 at 04:10:02PM -0500, Linus Torvalds wrote: > On Tue, May 29, 2018 at 3:49 PM Alan Stern > wrote: > > > Putting this into herd would be extremely difficult, if not impossible, > > because it involves analyzing code that was not executed. One (ugly) way to handle it, assuming we are correct about what it happening, would be to place ordering on the other side of the "if" that is at least as strong as on the first side. Probably some example that completely breaks this approach, though... > Does it? > > Can't we simplify the whole sequence as basically > > A > if (!B) > D > > for that "not B" case, and just think about that. IOW, let's ignore the > whole "not executed" code. > > If B depends on A like you state, then that already implies that the write > in D cannot come before the read of A. > > You fundamentally cannot do a conditional write before the read that the > write condition depends on. So *any* write after a conditional is dependent > on the read. > > So the existence of C - whether it has a barrier or not - is entirely > immaterial at run-time. > > Now, the *compiler* can use the whole existence of that memory barrier in C > to determine whether it can re-order the write to D or not, of course, but > that's a separate issue, and then the whole "code that isn't executed" is > not the issue any more. The compiler obviously sees all code, whether > executing or not. > > Or am I being stupid and missing something entirely? That's possible. This will take some analysis, both to make sure that I got Roman's example correct and to get to the bottom of exactly what LKMM thinks can be reordered. I am shifting timezones eastward, so I am not going to dig into it today. But here are a couple of things that take some getting used to: 1. The "if (r1 == x)" would likely be "if (r1 == &x)" in the Linux kernel. 2. Unless there is something explicit stopping the reordering, the herd tool assumes that the compiler can reorder unrelated code completely across the entirety of an "if" statement. It might well have decided that it could do so in this case, due to the fact that the "if" statement isn't doing anything with x (just with its address). But yes, given that r1 comes from the load from *c, it would be difficult (at best) to actually apply that optimization in this case. But let's find out what is really happening. Easy to speculate, but much harder to speculate correctly. ;-) Thanx, Paul