Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4796118imm; Wed, 30 May 2018 12:09:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIZcZ3q2xiVYaOfyH5jNJaoCNxEhJH9KwLJbDI4Me/C46pvBHQI0Rklp47cqrm1F9D3DhT1 X-Received: by 2002:a62:bd18:: with SMTP id a24-v6mr3837479pff.30.1527707384608; Wed, 30 May 2018 12:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527707384; cv=none; d=google.com; s=arc-20160816; b=IV0I3p+jxPpxyRGn8KJDgXE02dYP8AU1tbjU5xpsC/jkJqOuu/WPqMXquRZ/U/Obje 7P7i7DSIvupFQiNPFirkCpFiDkoGHmZxnVosG8UnS+LHCQO/E2ZehBm0z4JVqUiust95 n8G1rrVUGIchHoYKNBehsMOx6l1d063SmBb8z2+SAKHrmfpbWgEXaDKn7OvREzg/csjl YIVyG3me8NotBLkqCVoHg/0/NH5U55bqiZcmORx7m0xN7pNUYL13vDLeQGtWtwPnTiSm MUYf1TD2ATHlQAEpUnLpZk3IIudqij93hktbcE5amlSS37EG0yfl9VK/jDZX+bTde/7V wyXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=y0kRBntxbBlE4TWDnnmoeDZfp4XYeL9WlLpTbA+vBWI=; b=fN7Hcs70HqdmrpXpUBY0JKqT/eIw5KJ+c4K2hc/mqLOb0FxSEw2SBuwe0yDBLlcpbO iPRyAZ9QcwKEltntVZ+KoeU0yxD0Gjpi1ZaqEDisjCPqRK9lBrlyEdA5mVi1yvOGM+8s bo9qifLxJ/1Gyuz0+S7HdZ+ldofjzJmdU4Ij+o06bc2Q2Xf5Qm69HCeD6ueBn24kCUtP lmFzwnKPQUE5y8qTHdAMBBE60P+Yn2nZfAqH0Cvtf1jNrqqP/wiHwVsomZzuN1gxRGpA ff0p6qDRAPjAGBy0DMB7XtoXi+uEJZwTcJ15t1jpYfMiKiBRtrnvDq+AryfggPkH7pQT EK8Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o89-v6si10254821pfi.165.2018.05.30.12.09.30; Wed, 30 May 2018 12:09:44 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932148AbeE3TIp (ORCPT + 99 others); Wed, 30 May 2018 15:08:45 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:37244 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932119AbeE3TIo (ORCPT ); Wed, 30 May 2018 15:08:44 -0400 Received: (qmail 5157 invoked by uid 2102); 30 May 2018 15:08:43 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 30 May 2018 15:08:43 -0400 Date: Wed, 30 May 2018 15:08:43 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Paul E. McKenney" cc: Linus Torvalds , Linux Kernel Mailing List , linux-arch , , 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 In-Reply-To: <20180530183826.GI7063@linux.vnet.ibm.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...) > 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. > 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. > 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. Alan