Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1361429pxj; Fri, 4 Jun 2021 12:21:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkTqyHO+Pc0LlKxlsSTG5RSiFoVc5sfpjwdilp83MEF/tpH6fwj5Lk1TILUH7lrQhZdbNf X-Received: by 2002:a17:906:a1d2:: with SMTP id bx18mr5611834ejb.423.1622834507092; Fri, 04 Jun 2021 12:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622834507; cv=none; d=google.com; s=arc-20160816; b=nfj7da83haQ4NFrio1usFtcx3h4CgDoCaWgkk9PUYCzwbs6zOzox0RLzLWsxshY5Z1 AgX1PPIk/LEx0LGIxbnlsY2uVKLagSFRyViL9i2i3M7Q0Gv9ivnymh9uIhM9WC9OJGUb YH8DPBw0P5upCZXqz+tvPRPq8oRuCfvnGkMnLVfPetXTRd+KpXbaI1o03nKLsZCVr1j5 chj7QSISDh4wsIod6ubtrY7xkbm2KCKGdoLLmFykZiEREZcpmR6YQ6q1kKGQ/hMS+B/W w53KVU/0h841AHUyhM5H+ASns3mlfG8vKWDn5+nEtXeI0G4DkEzvp5+NbNgmgxh2md60 E7oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EyRvp1Le9j8ZjSEQazCeGMLQ42i99SaZFsOsJn9QM9I=; b=xay68ZW38/0VFmO2XRyv8DHgebbtSvVAXvIiZ3nnVyL7mc3tkpYPEiw5DY/c0Trkpc Ptty94sOuXCrVMYCmL1flZlFeosB79XIwnfVHr4aSpCKcM2CAnuV/xzA2B0WSACtYyKH 7TJpvk7yqj0DcM9AQX5g2ooEbmo6UZ5WVnD2gtUevUPFyjEuxGCengMhddr09icxPj15 /9pX+P2Rfk49EM965FehkDfUBJ3J7VJRqDSmv2/NUjlu3QXseFUcBxiZh7h8P/YwhnwA IeTy0C5m1GwPVmZnoW6QyerFR90Yye4ESByVGMGpK68POavwJ3mcKAg62yEoNIxfsbCg Qddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=EFA8lMXi; 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 s18si6210093eji.591.2021.06.04.12.21.23; Fri, 04 Jun 2021 12:21:47 -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=@linux-foundation.org header.s=google header.b=EFA8lMXi; 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 S230414AbhFDTUv (ORCPT + 99 others); Fri, 4 Jun 2021 15:20:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFDTUu (ORCPT ); Fri, 4 Jun 2021 15:20:50 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1C7C061766 for ; Fri, 4 Jun 2021 12:19:03 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id e11so12878259ljn.13 for ; Fri, 04 Jun 2021 12:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EyRvp1Le9j8ZjSEQazCeGMLQ42i99SaZFsOsJn9QM9I=; b=EFA8lMXiHBSq1dsiYMglygqx4CgloOEOXJtJ7wOE2XEc/t799BU2wssV18vK1QVykb N5m/kaGAIK6/8vPFgK33FPSW0AO7mleVxmFFPR86Vc6dayz+cvyiOGmfDv0sXk0dvLwa 9ZKMQSlGztBR3jKI7oxQbnJFCI/E5MCf7IJRg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EyRvp1Le9j8ZjSEQazCeGMLQ42i99SaZFsOsJn9QM9I=; b=rZsrH5S4QysdISHD3vRvI3bOe6p6tIfxj81nncQBQ88UtQgnPhxecWmhP4amHd0Hne s93c87bL/tHgBedcoFlZ8LLcEHTkIJUjv8pE74oIYl4iU8aEUn6HieqlHFAN+dMBrp/9 bdqGvYCbEsUdBYinlLUoJPqFr9+DtrtVFr3iHyc2taHF3X/lppeAfaKXeXE7qFa977PR U2lgOVzWbkU+32lNAowv35aALE0Jbx8Tytn9bAJXBnESRmeRBcZZq/kdbh0yaaZr0RBM /L/tJEvCG6UwKahWUu9ZmjTP8lBfU5eHdxl480HN1EUVIh7FUOL81mT3lI/gdu0Ga3Q5 xPwQ== X-Gm-Message-State: AOAM530Wx4nzoDjOg7nOy8QMUrXt2eiAiHoRZNKjCyc6BmAWIMKLkzSt /9l3+kzkcV4PnAhNIIgseJdJxvef9/RcJZS0GxQ= X-Received: by 2002:a2e:6e13:: with SMTP id j19mr4549807ljc.116.1622834341933; Fri, 04 Jun 2021 12:19:01 -0700 (PDT) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com. [209.85.208.178]) by smtp.gmail.com with ESMTPSA id t184sm474780lff.2.2021.06.04.12.19.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 12:19:00 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id c11so12910270ljd.6 for ; Fri, 04 Jun 2021 12:19:00 -0700 (PDT) X-Received: by 2002:a2e:a443:: with SMTP id v3mr4455147ljn.251.1622834339906; Fri, 04 Jun 2021 12:18:59 -0700 (PDT) MIME-Version: 1.0 References: <20210604104359.GE2318@willie-the-truck> <20210604134422.GA2793@willie-the-truck> <20210604151356.GC2793@willie-the-truck> <20210604155154.GG1676809@rowland.harvard.edu> <20210604182708.GB1688170@rowland.harvard.edu> In-Reply-To: From: Linus Torvalds Date: Fri, 4 Jun 2021 12:18:43 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] LKMM: Add volatile_if() To: Alan Stern Cc: Peter Zijlstra , Will Deacon , "Paul E. McKenney" , Andrea Parri , Boqun Feng , Nick Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Linux Kernel Mailing List , linux-toolchains@vger.kernel.org, linux-arch Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 4, 2021 at 12:09 PM Linus Torvalds wrote: > > Again, semantics do matter, and I don't see how the compiler could > actually break the fundamental issue of "load->conditional->store is a > fundamental ordering even without memory barriers because of basic > causality", because you can't just arbitrarily generate speculative > stores that would be visible to others. This, after all, is why we trust that the *hardware* can't do it. Even if the hardware mis-speculates and goes down the wrong branch, and speculatively does the store when it shouldn't have, we don't care: we know that such a speculative store can not possibly become semantically visible (*) to other threads. For all the same reasons, I don't see how a compiler can violate causal ordering of the code (assuming, again, that the test is _meaningful_ - if we write nonsensical code, that's a different issue). If we have compilers that create speculative stores that are visible to other threads, we need to fix them. Linus (*) By "semantically visible" I intend to avoid the whole timing/cache pattern kind of non-semantic visibility that is all about the spectre leakage kind of things.