Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp847948imm; Wed, 6 Jun 2018 06:55:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5H1OMsF1Ydvy9x9x1sahFVoECyDDu3Y2tfBBixRrYOZOVKmZuupVjRN5nx2Gim8wackaH X-Received: by 2002:a17:902:903:: with SMTP id 3-v6mr3347092plm.377.1528293303844; Wed, 06 Jun 2018 06:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528293303; cv=none; d=google.com; s=arc-20160816; b=Rbed1sZn3ajxqGQ8qrBQoK2HwSkLTW+YzRFUbVwKdJrajVKSI4Y92ArfyvNp1owJU2 S5VBhNF6OfeCyDgdfO09okLWXQy0uqCe85dudC60AC7JVJar1r72bjhKsH4pHdOq01KQ D4KU7IBwXGMfVRj9mLaEe2pQC4z039IacRIDiGjJN6+cwkeXIA5cy3WQMrmBHBOZQYYo EGxpGL4eZdCzGpXywN123spr8RkCg3btjE3Tytc4lH3mUXC6bP/8+wWF5tGE6ntmXf80 anVqx+e0vfTRWghnDkW5/I6DdGjdrYCjQFOF6BC2yTnbYFePvx83UjA8oVcBYgNOTYOD 1CyA== 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=565J7pHBiGAgHbsAPTueciPLpwcJg37dl+9AzQtOnMM=; b=vTBXVh1+uKxgHG+HCjtppw0vC56keETiQUeAVpNh7bXfj31E/FxgVfvb0ICgzjjo01 fPvuWpunaN1tqe5tCGq6XsMmFjBOE8uIsTmn3C5zbERcTkpV6gChSY7TuRZ4AbhCLuyN 9qjIQEWe1zKknc3jyhGT9UWqZRYUnx6YIvrdIe+Yi/7dHNaw5Ku25wh9zjD/e55ujOEc 8DbIt3Ep/nHIyG1v3HoUn8tdGRiQQgWRgSbyE65MTvWuhb6arJS0BsxzsDIqm7CKVLJz hXjTKB13TXoqAUzUvlBL9EtRjOKJqo+BX87anB7ouyTLHbCFXbxI5fiNLKfkks2cmjXo xl9g== 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 b37-v6si52153309plb.377.2018.06.06.06.54.49; Wed, 06 Jun 2018 06:55:03 -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 S1752221AbeFFNyI (ORCPT + 99 others); Wed, 6 Jun 2018 09:54:08 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:35352 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752213AbeFFNyG (ORCPT ); Wed, 6 Jun 2018 09:54:06 -0400 Received: (qmail 1579 invoked by uid 2102); 6 Jun 2018 09:54:05 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 6 Jun 2018 09:54:05 -0400 Date: Wed, 6 Jun 2018 09:54:05 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Roman Penyaev cc: "Paul E. McKenney" , 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 Subject: Re: LKMM litmus test for Roman Penyaev's rcu-rr In-Reply-To: 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, 6 Jun 2018, Roman Penyaev wrote: > > 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. Well, for one thing, we're talking about C11, not C99. For another, as far as I understand it, the standard means the program should behave _as if_ the side effects are completed in the order stated. It doesn't mean that the generated code has to behave that way literally. And in particular, the standard is referring to the behavior of a single thread, not the interaction between multiple concurrent threads. Alan