Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp588098imm; Wed, 6 Jun 2018 02:41:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKITFVbV8ndCBLaquu+a+D2Eat2BxJ2eGG3sMyX/8MeALdB9BT1oKp2IxOtj4RSL+U7ZZokI X-Received: by 2002:a65:630b:: with SMTP id g11-v6mr1945026pgv.303.1528278108548; Wed, 06 Jun 2018 02:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528278108; cv=none; d=google.com; s=arc-20160816; b=bSqxfGjA4JoEtKVgyGwTlnIGD2IPKX2LN0cm4MUhnqxZTp/HgpvK3+AP4KAX1C9SNh MWuOc/LmHTZq9es4YQRLJ2/5dE4ZNQfT9EfHi2mkFI+Jt+obi5YY9d3ZYrdaXoIv8EwX jzSLVm9786aA13Rln0ibybd6ipiwSCCUIp7ORWGtZfY5/M1CSqxg8sE173p4tPSZW1rA L4k+KlTbJKgz7mnaSAD9WQomIewYyD4Np4RBGKmIjAyiNiarEGM1B6Z959sOMEMJzUW0 Zi9k+kTePfaxYbTR+GgsMQWIvtz2S/KvxEguTrNu2zvQhbubLmcigGWtRefOXePUYkoO qWJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=SKzdty2ZkNpZjM63UQfPui2NRot/k2I4dYmICWsPLWM=; b=DSRhDWVyb8kWulA3BqKIRZTiR2eaG7H9L0V4l+Mj9gMENnAdrLLsVVtwlqEdmz3IbX nWVEtmNAH3/6V8HRToC3y8h5lsgsPOjmJpz0qsS9JqbiwhPA3/+EuZSUXM7T1wTquk9m pMI3VhCNx5/hDFvfBwTptB8jguqOTrHydBdal/C1qntTbocTkR3nlFD7ptwDjy60MFwh 0tYp2KUMGuclEvGd1VtxEcUQOFkYX8wXjrk5DnJaqXD3wM3g2VTxP0YDwB8vjumkNQs7 5svYKcPwIuIYCJDx2mNoa2Y84W3LpFK/m4zSbDVM0zgP9kk+TSVMge8HjECadnEkKKEE 03jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@profitbricks-com.20150623.gappssmtp.com header.s=20150623 header.b=LblwiefC; 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 13-v6si23910964ple.274.2018.06.06.02.41.34; Wed, 06 Jun 2018 02:41:48 -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; dkim=pass header.i=@profitbricks-com.20150623.gappssmtp.com header.s=20150623 header.b=LblwiefC; 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 S932567AbeFFJkg (ORCPT + 99 others); Wed, 6 Jun 2018 05:40:36 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:36429 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932518AbeFFJke (ORCPT ); Wed, 6 Jun 2018 05:40:34 -0400 Received: by mail-io0-f194.google.com with SMTP id d73-v6so6875817iog.3 for ; Wed, 06 Jun 2018 02:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=SKzdty2ZkNpZjM63UQfPui2NRot/k2I4dYmICWsPLWM=; b=LblwiefCvpQFKTi5CltglbnTUMCNv7RZIzb+mlsJagH/AJWsIySRt6H43aGMyY7g52 C4jpt1Wm5N2p6io3OLIMuSD8yOojgURJDwDnYcM6gZA8eNiQdaI9LlpXREbGdlK/GBCF zQYPKTAj9aNLyQ/XN4aG7IyYdE6et1z490AgXMP3xF5xhGM+v8pI0aoq3f+u6yL3l1oc 5uy9Xp6X+z5TkpL8npWE/z6m4Ht/LSZSPjYL5OcWIoPDdTYgJ7XGpek+tJtfo8TPWXk/ qUW2qHrQbmIsYWcBHqbJaRPEIsSGKvgMTtZhZHQFF2qjxEd32j7bfiob3fJCJmzeQ+QM q0wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=SKzdty2ZkNpZjM63UQfPui2NRot/k2I4dYmICWsPLWM=; b=tn9fQmV0mrghDxv06tnTTaA6jaLpghXuZ8vntaFHkuS56MMHy6mqoKqhUhEquCgNP0 XOU2cp26VVrrW8C/NvFuuu8cJAx16T3Ymh3EetU64Ji8BRMcFS1uatk0TIGPsCnCW//L 0Aokrb8+hrsiAJAGITw8tyfzJYCS6Nd/CJCauA9HRwFEmFHHhbsaP8vb6GG1L2WVSia2 QOzLiYmshXdnXH3cir4mgUgF4K/wp1UI0MSqHB5xh619q7zGmz0MtngdPLYPg5Ai4iUy 4rGiaDXO1nMsUEz47VJEEuBp0cs8t55vhlKy59c3kXOQnRTlehYluoJPAJRZEAmQ/Hbb wrZQ== X-Gm-Message-State: APt69E3gZyiXjvG6ni9UMw7UT/UGQ/BWJHqIJyJrPMCezBXEbEtFYK/4 1IhE5qtrpVxz9D7A+YI9U4lQ4kjeBoi0dEGg5t06dg== X-Received: by 2002:a6b:1fc2:: with SMTP id f185-v6mr2247878iof.74.1528278034153; Wed, 06 Jun 2018 02:40:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:e719:0:0:0:0:0 with HTTP; Wed, 6 Jun 2018 02:40:13 -0700 (PDT) In-Reply-To: References: <20180530183826.GI7063@linux.vnet.ibm.com> From: Roman Penyaev Date: Wed, 6 Jun 2018 11:40:13 +0200 Message-ID: Subject: Re: LKMM litmus test for Roman Penyaev's rcu-rr To: Alan Stern Cc: "Paul E. McKenney" , 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 Content-Type: text/plain; charset="UTF-8" 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 9:08 PM, 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...) > >> 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) { > ... > } Hi Alan, According to the standard C99 Annex C "the controlling expression of a selection statement (if or switch)" are the sequence points, just like a volatile access (READ_ONCE or WRITE_ONCE). "5.1.2.3 Program execution" states: "At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place." So in the example we have 3 sequence points: "READ_ONCE", "if" and "WRITE_ONCE", which it seems can't be reordered. Am I mistaken interpreting standard? Could you please clarify. -- Roman