Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2733983pxj; Sun, 6 Jun 2021 12:04:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzfNoJkHPGqX0jLSxaVMxoNJsHZnnsjIxRgT4NNURrT84OBkJXfuTdzGWP20CJdnKmVCQv X-Received: by 2002:a17:906:1982:: with SMTP id g2mr14811717ejd.184.1623006249824; Sun, 06 Jun 2021 12:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623006249; cv=none; d=google.com; s=arc-20160816; b=i006mL42Vk3QoRJs03+O+qmCs99wDMDjmpbalvT1EOJP2IQvOYKSMl4D260RYky/DN vsH6uZWGPXx57AoIT/unYNaZtzEGEs5z6l/TLRejWwGhLjfnGbTnqC+Pjbm4AgMfPv4t GTc9HzZV7LydNZPNcFKtj31rNuGd7jBWSoNTaUMB42CEDL0+CdvF26HadeFcPBPEE8hp AEbQHqM1HQJsbymP5Dp7RwEAJ8SsgZ05cvSrIgonFL0Q6wVAFRyR9/Po52WpdkGBYMYV 0i+tod28D62uEXQv94bE45NMMhhhW3vgGSiRnEzLEVV8WLPPOZ7ECBEsR5pc4GxOc4a1 R3kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Oty3pNGAGssTyyh7Z/ppCuS+4noQ9wBrr81gg+wW3QQ=; b=T2m7vSMHZdKqM8/FIhXrvcPYdWAC/B6pdMwIDZSqben+Kk7J636TwvjR8ey3UylE2v 6QAcdnQ6eKdY+HnYPnaq3YEdhFQadwlmFJsC1Z/6XpeZVuLQ85YACRJHWIR+Sx9NFZmt 7qVY+JgYd/7hdwSOORMPLadH4eP73SQsmUtIJ+4lm1INzTW44Pj7zvl0tCMDhA6pjCLE iVN4TI9h38P2PUsDcMb9iCLuVHqWzTjpPu1Zl6dJzRTXuXEVu163uptYXNDl9i1yCiij pKJgBpK2NbmYEXj6stFcbJ7wzgBAtJL4eoLrmeggtopgrTVWKScq7inykbVj4kYVow09 Dw0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WR8UrFej; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si10085551edt.551.2021.06.06.12.03.43; Sun, 06 Jun 2021 12:04:09 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WR8UrFej; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbhFFTDd (ORCPT + 99 others); Sun, 6 Jun 2021 15:03:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:46490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbhFFTDc (ORCPT ); Sun, 6 Jun 2021 15:03:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7FB2961242; Sun, 6 Jun 2021 19:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623006101; bh=UD3d62ix8ea/AUYQ+cmn/M6Fqg8QN4yqiHh5zNX5+RQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=WR8UrFejD170GPHmeIKJTHA2xXvauQPEb29SbNZrIACn3nPvAm7NtWjk6X0LuTrsF 1bDfC11OTnq/qdf8P6M4AqiUqrIHEzDz5gqfu2WcfF4vPGaS8AUuw/a65DV23MoCo0 w3tv1VtgbLxzLREG9prrrJCca85jGqxYrQFbwBFpknJV5Y2b33DsmkJjMWVZ1wL3na F4VADgGqkjxyh4RZajgOkgEpzsaQuMO4UGS9I5rAfOdBAbqYdSZDqiHD98FBP3pl8Y GEXCZE01qwhMd1kIk/JSY1lsurCy/mKsIQCc81YgKzbcEv7B7qJh0krxsX2AQqUvzs +6XkpRpdMVYXQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 536BF5C014A; Sun, 6 Jun 2021 12:01:41 -0700 (PDT) Date: Sun, 6 Jun 2021 12:01:41 -0700 From: "Paul E. McKenney" To: Segher Boessenkool Cc: Peter Zijlstra , Linus Torvalds , will@kernel.org, stern@rowland.harvard.edu, 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: <20210606190141.GK4397@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20210604153518.GD18427@gate.crashing.org> <20210604164047.GH18427@gate.crashing.org> <20210604185526.GW4397@paulmck-ThinkPad-P17-Gen-1> <20210604195301.GM18427@gate.crashing.org> <20210604204042.GZ4397@paulmck-ThinkPad-P17-Gen-1> <20210606113651.GR18427@gate.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210606113651.GR18427@gate.crashing.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 06, 2021 at 06:36:51AM -0500, Segher Boessenkool wrote: > On Fri, Jun 04, 2021 at 01:40:42PM -0700, Paul E. McKenney wrote: > > On Fri, Jun 04, 2021 at 02:53:01PM -0500, Segher Boessenkool wrote: > > > On Fri, Jun 04, 2021 at 11:55:26AM -0700, Paul E. McKenney wrote: > > > > On Fri, Jun 04, 2021 at 11:40:47AM -0500, Segher Boessenkool wrote: > > > > > My point is that you ask compiler developers to paint themselves into a > > > > > corner if you ask them to change such fundamental C syntax. > > > > > > > > Once we have some experience with a language extension, the official > > > > syntax for a standardized version of that extension can be bikeshedded. > > > > Committees being what they are, what we use in the meantime will > > > > definitely not be what is chosen, so there is not a whole lot of point > > > > in worrying about the exact syntax in the meantime. ;-) > > > > > > I am only saying that it is unlikely any compiler that is used in > > > production will want to experiment with "volatile if". > > > > That unfortunately matches my experience over quite a few years. But if > > something can be implemented using existing extensions, the conversations > > often get easier. Especially given many more people are now familiar > > with concurrency. > > This was about the syntax "volatile if", not about the concept, let's > call that "volatile_if". And no, it was not me who brought this up :-) I agree that it is likely that the syntax "volatile if" would be at best a very reluctantly acquired taste among most of the committee. But some might point to the evolving semantics of "auto" as a counter-example, to say nothing of the celebrated spaceship operator. Me, I am not all that worried about the exact syntax. > > > > Which is exactly why these conversations are often difficult. There is > > > > a tension between pushing the as-if rule as far as possible within the > > > > compiler on the one hand and allowing developers to write code that does > > > > what is needed on the other. ;-) > > > > > > There is a tension between what users expect from the compiler and what > > > actually is promised. The compiler is not pushing the as-if rule any > > > further than it always has: it just becomes better at optimising over > > > time. The as-if rule is and always has been absolute. > > > > Heh! The fact that the compiler has become better at optimizing > > over time is exactly what has been pushing the as-if rule further. > > > > The underlying problem is that it is often impossible to write large > > applications (such as the Linux kernel) completely within the confines of > > the standard. Thus, most large applications, and especially concurrent > > applications, are vulnerable to either the compiler becoming better > > at optimizing or compilers pushing the as-if rule, however you want to > > say it. > > Oh definitely. But there is nothing the compiler can do about most > cases of undefined behaviour: it cannot detect it, and there is no way > it *can* be handled sanely. Take for example dereferencing a pointer > that does not point to an object. Almost. The compiler's use of provenance allows detection in some cases. For a stupid example, please see https://godbolt.org/z/z9cWvqdhE. Less stupidly, this sort of thing can be quite annoying to people trying to use ABA-tolerant concurrent algorithms. See for example P1726R4 [1] (update in progress) and for an even more controversial proposal, P2188R1 [2]. The Lifo Singly Linked Push algorithm described beginning on page 14 of [1] is a simple example of an ABA-tolerant algorithm that was already in use when I first programmed a computer. ;-) Thanx, Paul [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1726r4.pdf [2] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2188r1.html