Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4823592imm; Wed, 30 May 2018 12:45:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgqZ1sB7ovbQUs6Or7ZjByGGzrWvsQORn1FB9kO7Tjy3HTYOLYDYOFZIBkSyS+Nx8V/WKy X-Received: by 2002:a17:902:189:: with SMTP id b9-v6mr4147627plb.204.1527709500360; Wed, 30 May 2018 12:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527709500; cv=none; d=google.com; s=arc-20160816; b=BESf6WdLnYAY/ZuP+I8aGDs42Wq43NqqtQ0to2cjmzDuit1Sic1iIn8SHaxH7Y3tWS DkMNzF7us2ZeTSV6s9xSXDYhu6taOznqad/VoYKq6qy/QJTxKdzjAppMkptqylJmyYvg 4N7JsxZk+qEmXPXFPvIVQAFtvLipkukl1ahct66QMQRDxrjjqrdIuOz7XMOrHES9TW7L u8zZzoKb/5/qO5mfEzLfnGjWV0oEwtRdPANrGh5LiVZSey86JSXK7zHdK9aaLrUeYZ9e 0clIlZTq7k6iYB6fqGIIS4kd2IWxmhiUXnTyGtxxQI5p3VH8T+18yCmlZLr8vfd+aBk9 UrDQ== 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=7TL7N+TIeSi7WqwuvnYiQPc9kV9C40l1ghV1j71ka00=; b=lvPvhK50F29av56ixK9uQH8QHY0YyH/9jBwJ6uBd1EWmIjJMw7rEg7N39wedtlSr/G tarVtUaxNZ6IgeriZa0NSxIHzs+Mv26zBQTU8ovN52oGui2D9AuCoVwFXU1bRTllKzvI DWRHM+leAAdEE9t7Bt85ExRysyhqUu3drj0o6QECJ09B0dJFXkGZZJUwOGw/tt+Z9Lrj CDLlK0No371mC5AVqWOgMCi/089Ywlp01IZgJek1egzxoW/jhOsONXHSuFuGcuTAPU7x /EqtyCicUW0nYPaomf0ond6AiNj57MKwxl2JSKTHwH8LnKutjBc/6ADg9EJXJ22O6YWq 9UYA== 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 d16-v6si1989532pls.327.2018.05.30.12.44.45; Wed, 30 May 2018 12:45:00 -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 S932161AbeE3ToV (ORCPT + 99 others); Wed, 30 May 2018 15:44:21 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47472 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932076AbeE3ToR (ORCPT ); Wed, 30 May 2018 15:44:17 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4UJhuUE090171 for ; Wed, 30 May 2018 15:44:17 -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 2ja131kf8m-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 30 May 2018 15:44:17 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 May 2018 15:44:15 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) 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) Wed, 30 May 2018 15:44:11 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4UJiAip9568630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 May 2018 19:44:10 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FA74B2066; Wed, 30 May 2018 16:45:50 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09BB4B2067; Wed, 30 May 2018 16:45:50 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.143.195]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 30 May 2018 16:45:49 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 54B7A16C6191; Wed, 30 May 2018 12:45:54 -0700 (PDT) Date: Wed, 30 May 2018 12:45:54 -0700 From: "Paul E. McKenney" To: Alan Stern Cc: Linus Torvalds , 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: <20180530183826.GI7063@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: 18053019-2213-0000-0000-000002B04AE6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009099; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000264; SDB=6.01039960; UDB=6.00532201; IPR=6.00819093; MB=3.00021381; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-30 19:44:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18053019-2214-0000-0000-00005A4D5271 Message-Id: <20180530194554.GM7063@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-30_09:,, 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-1805300210 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 30, 2018 at 03:08:43PM -0400, Alan Stern wrote: > On Wed, 30 May 2018, Paul E. McKenney wrote: > > > On Wed, May 30, 2018 at 09:59:28AM -0500, Linus Torvalds wrote: > > > On Wed, May 30, 2018 at 9:29 AM Alan Stern > > > wrote: > > > > > > > > > > > > > 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. > > > > > > > Your listing is slightly misleading. > > > > > > No. You're confused. > > > > > > You're confused because you're conflating two *entirely* different things. > > > > > > You're conflating the static source code with the dynamic execution. They > > > are NOT THE SAME. > > > > I am going to go out on a limb and assert that Linus is talking about > > what gcc and hardware do, while Alan is talking about what the tool and > > memory model do. > > Indeed. The very first line Linus quoted in his first reply to me > (elided above) was: > > Putting this into herd would be extremely difficult, if not impossible, > because it involves analyzing code that was not executed. > > It should be clear from this that I was talking about herd. Not gcc or > real hardware. > > (After rereading his message a few times, I'm not sure exactly what > Linus was talking about...) From what I could see, real compilers and real hardware. ;-) > > In a perfect world, these would be the same, but it > > appears that the world might not be perfect just now. > > > > My current guess is that we need to change the memory-model tool. If > > that is the case, here are some possible resolutions: > > > > 1. Make herd's C-language control dependencies work the same as its > > assembly language, so that they extend beyond the end of the > > "if" statement. I believe that this would make Roman's case > > work, but it could claim that other situations are safe that > > are actually problematic due to compiler optimizations. > > > > The fact that the model currently handles only READ_ONCE() > > and WRITE_ONCE() and not unmarked reads and writes make this > > option more attractive than it otherwise be, compilers not > > being allowed to reorder volatile accesses, but we are likely > > to introduce unmarked accesses sometime in the future. > > Preserving the order of volatile accesses isn't sufficient. The > compiler is still allowed to translate > > r1 = READ_ONCE(x); > if (r1) { > ... > } > WRITE_ONCE(y, r2); > > into something resembling > > r1 = READ_ONCE(x); > WRITE_ONCE(y, r2); > if (r1) { > ... > } > > (provided the "..." part doesn't contain any volatile accesses, > barriers, or anything affecting r2), which would destroy any run-time > control dependency. The CPU could then execute the write before the > read. True, but almost all current litmus tests do have at least one volatile access in their "if" statements. I am guessing that this has the same memory-model tooling issues as #2 below, but I am as usual happy to be proven wrong. ;-) > > 2. Like #1 above, but only if something in one of the "if"'s > > branches would prevent the compiler from reordering > > (smp_mb(), synchronize_rcu(), value-returning non-relaxed > > RMW atomic, ...). Easy for me to say, but I am guessing > > that much violence would be needed to the tooling to make > > this work. ;-) > > This would be my preference. But I'm afraid it isn't practical at the > moment. I bet that some combination of scripting and smallish modifications to tooling could make it happen in reasonably short term. Might be more difficult to make something more future-proof, though, agreed. > > If I understand Alan correctly, there is not an obvious way to make > > this change within the confines of the memory model's .bell and .cat > > files. > > No way at all. It would require significant changes to herd's internal > workings and its external interface -- my original point. I was afraid of that. ;-) Though truth be told, I was expecting an issue like this to crop up sooner rather than later, so I was actually getting a bit nervous about the fact that it had not yet shown itself... Thanx, Paul