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=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 90E5BC4743F for ; Sun, 6 Jun 2021 18:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71FBB61408 for ; Sun, 6 Jun 2021 18:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbhFFTBd (ORCPT ); Sun, 6 Jun 2021 15:01:33 -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