Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2732793pxj; Sun, 6 Jun 2021 12:01:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0AAR4cOX3cFzcdny1/t82KeTl3Z/FoDHO4WhMWeQevItUkbWl4fkWRXx7SSYHCTBIKEq0 X-Received: by 2002:a05:6402:31a2:: with SMTP id dj2mr9039518edb.206.1623006088687; Sun, 06 Jun 2021 12:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623006088; cv=none; d=google.com; s=arc-20160816; b=ggEOBy1t7W1mwcoIPN41FP4ch6cCli1wmZWWo1DfDbvooNBJI8EeTN3cuxrGgSoLUo XN3k2z29weqZuk+1ctddF310Q6pWC7s9ZCA5kXObU3H0PckoV0Z84nUmGlfA5huwA0q4 ziuKnCCejbb2fzSXbYCG0DxsOxAcL35AeEl0RIDSwdCu23yyBu2iHIrsJlCCf1zLs+l9 zX9RhsZJer6ATEaoMvw3KQ+AarCK/aEtFCc0iC54dbsALYFk3YIBEIF0QqZe+ygesA/1 BNM+P4couVUaoPTzhlNeruvHVwZ6TVW/cIENK4KnqM9u7vGeS1rfsqk1bu5qkUCLJn5p X2JA== 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=KXWrX6wBq5TioPWpDxBNh/+AQclSH0iG9b0SVz2qp/k=; b=FQqLRPoL1H0GqD+XQOCq0GBxq/is/FE6p4/pr0bkvMUPE6qk5Lxre/QG8qI9No7UrM 76daexS2wNrE0Mv8bvR1/COMbvR1uGs3rgTxVTQv//4m6Q/Zaaxw6n2CM5018XvdY20a pSTtzUwc7sJlkUptNyNrl/PrQxbvvi9kSUFa59txkA4e6pkupIVw9fBk6wRz6jqCDWNP yrEkhDaI7E7HIw9dp64ahTJCgTF8MnNTQ248A05iVZSM9bvNwYGXan8b8bkxxRt89bul WfPVO6TRktIKUyJDkKS2UpzXgma86I/hlsf2aEIsFrre1Hb44zffdhHnWZy/ZzhBcaGW VqQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Zh/1SiIC"; 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=redhat.com 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.01.04; Sun, 06 Jun 2021 12:01:28 -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=@redhat.com header.s=mimecast20190719 header.b="Zh/1SiIC"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229885AbhFFTBc (ORCPT + 99 others); Sun, 6 Jun 2021 15:01:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26149 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbhFFTB3 (ORCPT ); Sun, 6 Jun 2021 15:01:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623005979; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=KXWrX6wBq5TioPWpDxBNh/+AQclSH0iG9b0SVz2qp/k=; b=Zh/1SiICwaDxP8lMk5KLH6HBrA1YXbd93dGVloeykjlCEwiykWH9T6l0KKDUHO3r5dHkn8 aP6Kub6RYyIGKk3Cyoo19Xm8UPCm0DO8T2TmtZvq8woGwGqd47UYDtqV6TEFKVFE66mj7O oegfjuPNt9aTY6Of7qSiWaDDdJkHDzg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-2EurjrPUNo--k71WjI_Ddw-1; Sun, 06 Jun 2021 14:59:36 -0400 X-MC-Unique: 2EurjrPUNo--k71WjI_Ddw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 550FD8015F5; Sun, 6 Jun 2021 18:59:33 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-147.ams2.redhat.com [10.36.112.147]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9710E5D9C0; Sun, 6 Jun 2021 18:59:32 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 156IxSJQ4093308 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 6 Jun 2021 20:59:28 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 156IxMY94093305; Sun, 6 Jun 2021 20:59:22 +0200 Date: Sun, 6 Jun 2021 20:59:22 +0200 From: Jakub Jelinek To: Linus Torvalds Cc: Alan Stern , Segher Boessenkool , "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 Subject: Re: [RFC] LKMM: Add volatile_if() Message-ID: <20210606185922.GF7746@tucnak> Reply-To: Jakub Jelinek 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 05, 2021 at 08:41:00PM -0700, Linus Torvalds wrote: > Something like this *does* seem to work: > > #define ____barrier(id) __asm__ __volatile__("#" #id: : :"memory") > #define __barrier(id) ____barrier(id) > #define barrier() __barrier(__COUNTER__) > > which is "interesting" or "disgusting" depending on how you happen to feel. I think just #define barrier() __asm__ __volatile__("" : : "i" (__COUNTER__) : "memory") should be enough (or "X" instead of "i" if some arch uses -fpic and will not accept small constants in PIC code), for CSE gcc compares that the asm template string and all arguments are the same. As for volatile, that is implicit on asm without any output operands and it is about whether the inline asm can be DCEd, not whether it can be CSEd. Jakub