Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4858256imm; Wed, 30 May 2018 13:29:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJKaADPXkNSSmcX+r6NzqS4wQ825ZIqiDXIojkVR7P+PbUSo0mP1amcnxAQxFZLmMj0R3xb X-Received: by 2002:a17:902:59ce:: with SMTP id d14-v6mr4296919plj.253.1527712184235; Wed, 30 May 2018 13:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527712184; cv=none; d=google.com; s=arc-20160816; b=bo+Ql8kdZ3s8XZePYdP9pym7GViOYBiP2X/7oeoVX1bOL/qn7UgJ8FWVMAV8H7NFWH wQY61wQxcBkbRCsfkl3WZEzKt8KRt/8m1o+eyHauKPYpJjznrngbZ7m9DIJQeEZLupeO UoMvk4F/y/f3pqe0Heym0hGwBl0u9wh4qA9ZE0UHKZR3SycoYnOdbrpj0lr9RdF8YjLy P9Fw/tHYQPEa9xlsT89A6bYrmSEBnVP/HBMgtNXbfv/n8JJ/JBD7xb2wVT6aE7Hiq2uS LjCck7/demXvwk5dHaSkKKraBfuwHb4Mp5sXQbJU3T4WGFJYBaK50CaQtQuUvajZ7wt1 deQA== 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=MxcE4INeTZaJy2HUG96LjClTDlzVAmLdSjOIfvHuCq8=; b=kM/hJXrn9C++8L+TVjXNONb7X1sM7ZyehrWetpDPRq3yjcwc3+x1ByyVrJrcIvA9ut VepvVSYbMe6GHMsB85lVwZBtQ7WiCuGFIKO7266CheGMEbjaOTYz7lCX4fNv1n4xUyub /j/b8BiPvKlpXVjuy6We+cc80T7tLaHJyC85GtYAepAji8EpSfX08gUcqpUawyIXJnpQ oEbaKx/OSYr6MUw6RoB0GHmL/Xwufs3FmgFAkt5cIN3EqLe3Hot4fjQY1NuH4NxUz91W 5CzetY0jf5ABKc2ETVS+IA4LWMXePDFHIExYEEoWoFT94wu26WXjniB9+nBTaDyTFhlx TNyw== 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 e11-v6si26406753pgs.476.2018.05.30.13.29.29; Wed, 30 May 2018 13:29: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 S932313AbeE3U27 (ORCPT + 99 others); Wed, 30 May 2018 16:28:59 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:37456 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753718AbeE3U25 (ORCPT ); Wed, 30 May 2018 16:28:57 -0400 Received: (qmail 18964 invoked by uid 2102); 30 May 2018 16:28:56 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 30 May 2018 16:28:56 -0400 Date: Wed, 30 May 2018 16:28:56 -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: <20180530194554.GM7063@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: > > > 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. > > > 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. :-) > > > 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. Alan