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.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 E1D6FC4743D for ; Sun, 6 Jun 2021 20:16:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9C89613CB for ; Sun, 6 Jun 2021 20:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbhFFUSA (ORCPT ); Sun, 6 Jun 2021 16:18:00 -0400 Received: from gate.crashing.org ([63.228.1.57]:56064 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbhFFUR7 (ORCPT ); Sun, 6 Jun 2021 16:17:59 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 156KBtmj012529; Sun, 6 Jun 2021 15:11:55 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 156KBs1g012528; Sun, 6 Jun 2021 15:11:54 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Sun, 6 Jun 2021 15:11:54 -0500 From: Segher Boessenkool To: Linus Torvalds Cc: Jakub Jelinek , 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 Subject: Re: [RFC] LKMM: Add volatile_if() Message-ID: <20210606201154.GB18427@gate.crashing.org> 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> <20210606185922.GF7746@tucnak> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Sun, Jun 06, 2021 at 12:22:44PM -0700, Linus Torvalds wrote: > On Sun, Jun 6, 2021 at 11:59 AM Jakub Jelinek wrote: > > > > I think just > > #define barrier() __asm__ __volatile__("" : : "i" (__COUNTER__) : "memory") > > should be enough > > Oh, I like that. Much better. > > It avoids all the issues with comments etc, and because it's not using > __COUNTER__ as a string, it doesn't need the preprocessor games with > double expansion either. > > So yeah, that seems like a nice solution to the issue, and should make > the barriers all unique to the compiler. __COUNTER__ is a preprocessor thing as well, and it may not do all that you expect. Ex.: === #define fm() __COUNTER__ int gm(void) { return fm(); } int hm(void) { return fm(); } int fi(void) { return __COUNTER__; } int gi(void) { return fi(); } int hi(void) { return fi(); } === The macro version here works as you would hope, but the inlined one has the same number everywhere. Segher