Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4914879imm; Wed, 30 May 2018 14:48:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIP6qyWjv5kLGYxWYeY39qYOMDzoivxJNpXyZtudT6Pv/pvY9rL1w46JcgV8LQuudVGRfGx X-Received: by 2002:a63:803:: with SMTP id 3-v6mr3570643pgi.406.1527716911292; Wed, 30 May 2018 14:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527716911; cv=none; d=google.com; s=arc-20160816; b=DPur78NlH13JnCuQO0Zgpcy6lyzg5Iw0PHp1LOMgkVGLqV+UzTqTech7VJeHHN++C1 RRVk+JtwiJlURQZsvJ6Mj66rb61W1fnIHuq891RWW2jUAFRoO9tY4+BbhaOdb7qNCda5 zIqv0g9OZIYgqYgt6ZlgTmJlcPDCJHl8Ir9+57/MsRrIwtVtaf8s7CSxIwJ/RBvEkwCJ 4aBVoL/yXVXM8Zkl4weq/84fx77J5UICtV9QiqUgr/oIQhmEpW+14F+Vzg9vhyAv9ASJ k9dDbkNRkG/Zwu+Za7EG6p81hbDeMi55kFxL0sO2NhFk8jwz28qo/xUxk3O6t2u0z2U8 pPEQ== 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=uC+/yhZRU2pd5OBiuPUgQAb8N78/uzhjS/3GbcoDSBo=; b=Wx6E+pNy0qG89wsP6nfdH4LAl9/jbWF19mFB2rQRHSYkZpqNS6HqjqSV1BFGjQztM/ e4YNuVxCZqxWY5F0NaSfBIHb72vL4ZLPMnHrgi/HjXjPPYlfpm4nTgubZTWqUrsV5zad tqww0zVPCa88+xV88Iz/HsZ+IJ++FQBh5Ore2klSDNbffbZDDV0VGoLGi6AcH7uH8ImG Bb9Nqt4qYiLBrHlhGJ0rKpuTAv9jK3f9KBQFFcJoqawfgq1mnD5zBigsuc4O9trrf/Sp 7BxwQSb6d88L4778gubZ5lHv6b5Sztr636EtZo1GTS+0mQSxmtdcmM4U8G/qRGr2K3Pp Gk+Q== 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 s7-v6si27561147pgr.670.2018.05.30.14.48.16; Wed, 30 May 2018 14:48:31 -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 S932370AbeE3Vrm (ORCPT + 99 others); Wed, 30 May 2018 17:47:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55858 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932240AbeE3Vrh (ORCPT ); Wed, 30 May 2018 17:47:37 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4ULdkhp093581 for ; Wed, 30 May 2018 17:47:36 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ja0dw2rcn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 30 May 2018 17:47:36 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 May 2018 17:47:34 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e17.ny.us.ibm.com (146.89.104.204) 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 17:47:29 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4ULlSWD11928006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 May 2018 21:47:28 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 628BFB2067; Wed, 30 May 2018 18:49:08 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2D72CB2064; Wed, 30 May 2018 18:49:08 -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 18:49:08 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id A6EDB16C6348; Wed, 30 May 2018 14:49:12 -0700 (PDT) Date: Wed, 30 May 2018 14:49:12 -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: <20180530194554.GM7063@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: 18053021-0040-0000-0000-0000043716AE 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.01040001; UDB=6.00530820; IPR=6.00819134; MB=3.00021384; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-30 21:47:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18053021-0041-0000-0000-0000083D3CB8 Message-Id: <20180530214912.GN7063@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-1805300230 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 04:28:56PM -0400, Alan Stern wrote: > On Wed, 30 May 2018, Paul E. McKenney wrote: > > > > > 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. ;-) > > It shouldn't be all that bad. The dependencies are generated by herd, > meaning that the code would have to be changed to make control > dependencies extend beyond the ends of "if" statements. I don't think > the necessary changes would be tremendously big, especially since the > LISA front end already behaves this way. That was my thought. > > > > 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. > > I have no idea what sort of scripting/smallish modifications could do > the job. You could ask Luc, if you're not afraid of giving him an > aneurysm. :-) Two "if" keywords, one that carries control dependencies past the end of the "if" (assembly-language style) and another that does not. The script then rewrites the "if" statements to one style or the other depending on the contents of the "then" and "else" clauses. > > > > 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... > > The fact is, herd was never meant to act like a compiler. Some > disagreements are inevitable. Agreed, the bit about identical stores at the beginnings of "then" and "else" is one example. But we should fix the ones that are more straightforward. Thanx, Paul