Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2764970pxj; Sun, 6 Jun 2021 13:16:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeZstkDtsVakjqMrVmTBJyPmNXoEqgU/oUxunaJp861jGShD+nQmRqIvYagMU+o7yeL+6J X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr16432411edd.111.1623010571733; Sun, 06 Jun 2021 13:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623010571; cv=none; d=google.com; s=arc-20160816; b=gYIA4BrnkEEUs3fmQcypLqpmj+70ijXAyVrVVcoXabgR+9AyMukLUcIk2cc4WQs4U8 giZTQndxjWuNXGFDhnT9y9/IcK2u0bnzv+RbUtdQFivbOr2D0Bs3aUB+HiOmGbLFTUQL 3OJVCzIUddVA+AvJiJJ0eSdvEWOzpvz+dNa6MBmptlGxIGYI1yFafQ4pmdZ4izIO2WSV hXZgZ4h44cXHFnYSOQgRJ+9zczl6RgUiuM/8c6OJk4dWRNIhN4r7k54oxTC75JWgBjtR BqwIfPC1H8CDKOijxMZ5qfNqQioSIQU41CwJZlGOToVief+4maNt0d5yqAIDRVGOADyD Af0g== 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=g9Dgzkc6mzoKadrti0reRjEb/MNcsn0/HLVhWdAcN2E=; b=ox9I8hTPX8Sa0TjSHqbxu6Z5eAW/JI7hI51LLKPFsGhtINYFnrIa7OXdndT4rAEia1 3GShnr6vcxHwSYCBt7VODe/CK6P6ys4elNO6WPNijfyd8AEc84gSO/Shx9hvWd6A5VCp 8n/RFdDyamVcsscnSC9HNaZjeC4P2kI88QJqLqxhvJCFFUXmvIgGrr8KSXkso/0M/Wg8 SgL+bb2Dyf8YUn40U4Ma4ggSRJbjOsjP7SSG5U8y8p3NxeBPtOynmqX57wzM8kiJ/fRU 5Aazya8SXBKLwLcZ7cyCT0yH03a6mVEya2v+BCqg4kK73pf2w7c6sl9LJSJAxr5TRTrO vYHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=elCGeQWQ; 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 w4si10617745edu.173.2021.06.06.13.15.49; Sun, 06 Jun 2021 13:16:11 -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=elCGeQWQ; 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 S230177AbhFFUPD (ORCPT + 99 others); Sun, 6 Jun 2021 16:15:03 -0400 Received: from mail-lj1-f177.google.com ([209.85.208.177]:44957 "EHLO mail-lj1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbhFFUPC (ORCPT ); Sun, 6 Jun 2021 16:15:02 -0400 Received: by mail-lj1-f177.google.com with SMTP id d2so14945498ljj.11 for ; Sun, 06 Jun 2021 13:13:12 -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=CyCv3bSADIL+IzQGKDCwQsJn2LvYC/EpDVMFptRcnSg9gYdj2MluuVGApSKlkTYz/n yMj220ZrP8e2hWw4I6uSsWDaLaWrlxOEMlehJn6LABMC/WPKa8wSaI/u47UWedhBAYMR V58JETZ9uwYPwCsN6MuYnpeJ821ZxCXp0ndRfMPXa7fyJo3VcGJOitRr65ckREeyG+I5 +yE2wJyNAGNamT4R/8pvZ7HLvlr/moX4Xe3BoefT4UbeWZ+6oO8ARSEJcpsjuezEomDl UXRmYBsu/BkAERCvp+n94fU53J2wfc9uOxTfGmVSkkHRbzIhdHp6Que6ah7Md0U4LbcX Betw== X-Gm-Message-State: AOAM531E77Ac4H0ouRJIENex8snQAtQRrsYcABMPat3OWli75ediSm4h 5L3xynp8pDgTJA61myli4TGunRXwckrM8dCXIkI= X-Received: by 2002:a2e:a544:: with SMTP id e4mr12371493ljn.265.1623010331404; Sun, 06 Jun 2021 13:12:11 -0700 (PDT) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com. [209.85.167.43]) by smtp.gmail.com with ESMTPSA id v20sm1241460lfa.49.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-f43.google.com with SMTP id r198so19214027lff.11 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-kernel@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