From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A3F7C4743E for ; Sun, 6 Jun 2021 18:49:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3010161408 for ; Sun, 6 Jun 2021 18:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230173AbhFFSus (ORCPT ); Sun, 6 Jun 2021 14:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbhFFSum (ORCPT ); Sun, 6 Jun 2021 14:50:42 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B14C061766 for ; Sun, 6 Jun 2021 11:48:52 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id w15so18886974ljo.10 for ; Sun, 06 Jun 2021 11:48:52 -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=RJCua1TpemFOI3glAj3fgLbjj5CxdDpoZVGdK1bpooE=; b=eQFMVtzND83RNvBKe4gAJD9EpVFbNqfEo6XBgSpWhwW0OiuPD/lGFputn9h6YanwSf ohx5NvMs8hu1wCWtc40QJv5O8HrmCChBxr1RnmVvLasDZe1r9HwPa/xSxXQQPQwSwk+2 CLsnEdpEEjSfN0HlTs+pdvfGZCV/grDccJwew= 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=RJCua1TpemFOI3glAj3fgLbjj5CxdDpoZVGdK1bpooE=; b=TZh47XdXQOI9uM6iLqvoaAZy2OyoS2ipB2rlMATG3oC+hMvILbr9nuRCktFOaBw3Pb yQwlK2MKG2cl7N2su6eX2VH1HzmqkhK9go7JjVckcyd+61eZTaltgmRf2Rr9J/b+mzVI l1QnbL0RGATJwtQTxaB8YLnk2ObME1FVIVOcO4KHHuhXOVlexZ5qpy3O7kIBcjnfNpLU mvHqahcyvRpB6bsKGUPtkbdndt/5BulYjbTYShtCy0R4s7WH0tyIn7fHGN4b9nMZioHO j+GaG5/d0o5iyk1nPQK7193HhXvBQ4M5tM0bldIUagBWZVbdRBC+LBXmwkwaGcw3CC75 FzAw== X-Gm-Message-State: AOAM530o8A69N8IEWPlX9fJbRxWedaxGrhjTR5M+AbCgiJcsnBZCh2f/ 33RJbaGXBShWzeVqIbGXAOxx6qLbDKTPG4ZaZwY= X-Google-Smtp-Source: ABdhPJwdhH8ZdjZczp8yCod+qXaWymzxs+GxWnNCzupNPFu7FW5WL4YdCKZQP5bwr5lKEjsFUzGKkw== X-Received: by 2002:a2e:878b:: with SMTP id n11mr9666192lji.225.1623005330801; Sun, 06 Jun 2021 11:48:50 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id c125sm1218806lfd.199.2021.06.06.11.48.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Jun 2021 11:48:49 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id a2so22314467lfc.9 for ; Sun, 06 Jun 2021 11:48:48 -0700 (PDT) X-Received: by 2002:ac2:43b9:: with SMTP id t25mr9503593lfl.253.1623005328455; Sun, 06 Jun 2021 11:48:48 -0700 (PDT) MIME-Version: 1.0 References: <20210604205600.GB4397@paulmck-ThinkPad-P17-Gen-1> <20210604214010.GD4397@paulmck-ThinkPad-P17-Gen-1> <20210605145739.GB1712909@rowland.harvard.edu> <20210606001418.GH4397@paulmck-ThinkPad-P17-Gen-1> <20210606012903.GA1723421@rowland.harvard.edu> <20210606115336.GS18427@gate.crashing.org> <20210606184021.GY18427@gate.crashing.org> In-Reply-To: <20210606184021.GY18427@gate.crashing.org> From: Linus Torvalds Date: Sun, 6 Jun 2021 11:48:32 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] LKMM: Add volatile_if() To: Segher Boessenkool Cc: Alan Stern , "Paul E. McKenney" , Peter Zijlstra , Will Deacon , 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 Sun, Jun 6, 2021 at 11:43 AM Segher Boessenkool wrote: > > You truly should have written a branch in tthe asm if you truly wanted > a branch instruction. That's exactly what I don't want to do, and what the original patch by PeterZ did. Why? Because then we need to write that stupid pointless branch for every single architecture. And to work well, it needs "asm goto", which is so recent that a lot of compilers don't support it (thank God for clang dragging gcc kicking and screaming to implement it at all - I'd asked for it over a decade ago). So you get bad code generation in a lot of cases, which entirely obviates the _point_ of this all - which is that we can avoid an expensive operation (a memory barrier) by just doing clever code generation. So if we can't get the clever code generation, it's all pretty much moot, imnsho. A working barrier "just fixes it". I suspect the best we can do is to just work around the gcc badness with that __COUNTER__ trick of mine. The lack of a reliable comment character is the biggest issue with that trick. Linus