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 BAEF4C4743D for ; Sun, 6 Jun 2021 20:13:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A11AA613AF for ; Sun, 6 Jun 2021 20:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229885AbhFFUPP (ORCPT ); Sun, 6 Jun 2021 16:15:15 -0400 Received: from mail-lf1-f43.google.com ([209.85.167.43]:44591 "EHLO mail-lf1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbhFFUPO (ORCPT ); Sun, 6 Jun 2021 16:15:14 -0400 Received: by mail-lf1-f43.google.com with SMTP id r198so19214152lff.11 for ; Sun, 06 Jun 2021 13:13:13 -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=g9Dgzkc6mzoKadrti0reRjEb/MNcsn0/HLVhWdAcN2E=; b=elCGeQWQ76a+XOXQPuapVBLMfPQKtXSartHcDBKR3BXRhLQUQ1oigbVKib9h/4m4qI uhVlgq6rpANSWCwav3vtsQ98Pq9CRLAd5IFkrs0e5UJuq047ZkqZ2jZTnt7Z6iLKI4dC yKLcJ7tRcQNXK+WF2+PHQlsrWV/8w+4ygZ/OU= 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=g9Dgzkc6mzoKadrti0reRjEb/MNcsn0/HLVhWdAcN2E=; b=Ei1tosNIsN5PWUG9C7qSwGp1LmPxqX55Lc6bEjMl/6m9wKBKuL4vk/8NkzxV7gMZOn eFHcPZ4CM7guOaEe4qyKt+cle1g6PTLCRoBLCxdzHO5zVlCRf29xqzpIqiBC4CyCYZ99 pEC0CcusvJS/iXkArupI/OeRIM/AUe6ZP9ANpzFyrypmfGZRsrAMZsPzbGM69tA3EB5d lD/0PmY/CD6pxYSsjYckl5mfmB9Bd3p+Gn5EzobJHyeZkEpAmXM854Kq9l91tOiDv5lc psmWb9aki2mXPDkJqOXghdF0fV50HS9mnNOYveN320YLwvyrbjI1IYYga7rUWCFREfhV n0rA== X-Gm-Message-State: AOAM530K3V41IUe0ELxspAXa/Tq8beUt13MiuMaqO3WxhVIWVRy5dyQ6 amEkgDnf03D4xKsr4nocGSyNRCWKbj+mpjSxD3U= X-Google-Smtp-Source: ABdhPJx/6QFi1YqS264zdlNWU15q05X+wDqKKL9CMLf5ezLC46GO/s+uAHmfjrBpwp1fGiohbR5HxQ== X-Received: by 2002:a05:6512:2356:: with SMTP id p22mr9659103lfu.392.1623010332606; Sun, 06 Jun 2021 13:12:12 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id h186sm759934lfd.185.2021.06.06.13.12.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Jun 2021 13:12:10 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id w33so22572685lfu.7 for ; Sun, 06 Jun 2021 13:12:09 -0700 (PDT) X-Received: by 2002:a19:7d04:: with SMTP id y4mr9324319lfc.201.1623010329434; Sun, 06 Jun 2021 13:12:09 -0700 (PDT) MIME-Version: 1.0 References: <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> <20210606195242.GA18427@gate.crashing.org> In-Reply-To: <20210606195242.GA18427@gate.crashing.org> From: Linus Torvalds Date: Sun, 6 Jun 2021 13:11:53 -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-toolchains@vger.kernel.org On Sun, Jun 6, 2021 at 12:56 PM Segher Boessenkool wrote: > > Yes, I know. But it is literally the *only* way to *always* get a > conditional branch: by writing one. The thing is, I don't actually believe you. The barrier() thing can work - all we need to do is to simply make it impossible for gcc to validly create anything but a conditional branch. If either side of the thing have an asm that cannot be combined, gcc simply doesn't have any choice in the matter. There's no other valid model than a conditional branch around it (of some sort - doing an indirect branch that has a data dependency isn't wrong either, it just wouldn't be something that a sane compiler would generate because it's obviously much slower and more complicated). We are very used to just making the compiler generate the code we need. That is, fundamentally, what any use of inline asm is all about. We want the compiler to generate all the common cases and all the regular instructions. The conditional branch itself - and the instructions leading up to it - are exactly those "common regular instructions" that we'd want the compiler to generate. That is in fact more true here than for most inline asm, exactly because there are so many different possible combinations of conditional branches (equal, not equal, less than,..) and so many ways to generate the code that generates the condition. So we are much better off letting the compiler do all that for us - it's very much what the compiler is good at. Linus