Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1209293pxj; Fri, 4 Jun 2021 08:37:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFBnDWMkx1Gi0LWSH+HL42LYMMf3MQ5bqFmfNkaJqcB+TheD1dDFsIWwLN4fTNHcuDJr6j X-Received: by 2002:a17:906:2510:: with SMTP id i16mr4669465ejb.218.1622821057711; Fri, 04 Jun 2021 08:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622821057; cv=none; d=google.com; s=arc-20160816; b=RrSLum4Y9cOIzKjAWpHzVF06r56VX8oXq17XAiIewHXG8ruf506abPuAxQQrOHKnuz XYnP/1OU5C4J+0Jg43niHwnuLHFiIqUMZ9yZZsGbrTJP6EjoBRTwKp8M1NRYWrG3BD9i 7tATpXo1av3mzvCdgiTWye7kGIGqgu3clXtbSCcdjzEgB5NGqmef23SHe/fNgQA03zZk QKya6aDwc1QG/h0qS58JON8P54YSHmxr3OmMq1wZNQXnaTajBs2P1kQ9NqiIBi91tU4y d5k0DTyFpK3pJmBOHyx0VzGcWYHlPfIVhIyA1EfBl969++IwpegCJyiYCljcMQ0Te+H8 Z55A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Mi4h1EEj55vDYROvG0Zzv4dJU2LitGNXoF87iMe5XkM=; b=jkbCovnepU3SunmZChzlcGAtX4fSLFOLVky8EHXQYuzZlbAaNufyosF683ZA/MPAJ/ 7dxFI4xzdsjTpwnTc6M9j9eISwSpIB+n3kmPgI+u8Ap6XMhFiaU4ifohQLRLJj0NxsNs IMIGxMgy/E5ORm/P3lrtCuDNE0PVx1nwubnH+EB+4JsviLEYPHnj0MhKTyCivGMzsPht N4uiPeylCW/KKiKFRqHWYofuLKvc3CtuDokeJguCxLPYeQYjbUEfJ60PwVRLzrNAyCUu i17cL4vLz7Co2QYaPrbcHjh0JxxP4gNM0kj4MKWfsWDijlrNK9uxe9SLEklJxXNFSsVD OLRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw19si4872295ejb.748.2021.06.04.08.37.11; Fri, 04 Jun 2021 08:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbhFDPh5 (ORCPT + 99 others); Fri, 4 Jun 2021 11:37:57 -0400 Received: from netrider.rowland.org ([192.131.102.5]:33153 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S229924AbhFDPh4 (ORCPT ); Fri, 4 Jun 2021 11:37:56 -0400 Received: (qmail 1682974 invoked by uid 1000); 4 Jun 2021 11:36:09 -0400 Date: Fri, 4 Jun 2021 11:36:09 -0400 From: Alan Stern To: Peter Zijlstra Cc: Will Deacon , Linus Torvalds , paulmck@kernel.org, parri.andrea@gmail.com, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, linux-kernel@vger.kernel.org, linux-toolchains@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [RFC] LKMM: Add volatile_if() Message-ID: <20210604153609.GF1676809@rowland.harvard.edu> References: <20210604104359.GE2318@willie-the-truck> <20210604134422.GA2793@willie-the-truck> <20210604151356.GC2793@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 04, 2021 at 05:22:04PM +0200, Peter Zijlstra wrote: > On Fri, Jun 04, 2021 at 04:13:57PM +0100, Will Deacon wrote: > > > In fact, maybe it's actually necessary to bundle the load and branch > > together. I looked at some of the examples of compilers breaking control > > dependencies from memory-barriers.txt and the "boolean short-circuit" > > example seems to defeat volatile_if: > > > > void foo(int *x, int *y) > > { > > volatile_if (READ_ONCE(*x) || 1 > 0) > > WRITE_ONCE(*y, 42); > > } > > Yeah, I'm not too bothered about this. Broken is broken. > > If this were a compiler feature, the above would be a compile error. But > alas, we're not there yet :/ and the best we get to say at this point > is: don't do that then. This is an example of a "syntactic" dependency versus a "semantic" dependency. We shouldn't expect syntactic control dependencies to be preserved. As a rule, people don't write non-semantic dependencies on purpose. But they can occur in some situations, thanks to definitions the programmer isn't aware of. One example would be: (In some obscure header file): #define NUM_FOO 1 (Then in real code): if (READ_ONCE(*x) % NUM_FOO) ... Alan