Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2766491pxj; Sun, 6 Jun 2021 13:19:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAgXJYMNKKCW6D+PbxiVnlN0j1czFj55Vz8HBkOhS7wu4kIJRama19vrsc863f3QCIADfj X-Received: by 2002:a17:906:a1d2:: with SMTP id bx18mr14672422ejb.423.1623010777415; Sun, 06 Jun 2021 13:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623010777; cv=none; d=google.com; s=arc-20160816; b=L+Z8mGTlHml75ZktCjFKsqyVZTJrP3G/ikMYphB8Z3WwNNouxD5UeOHnqVl6DalpXu f7akA/7SVoqG+/lCOp4IcsPAFI091ibkNTU9kz8eKikKpITC56KfvttSw5iqzz0pgyc6 OL+i4WpQqnrro/APOJ3TMz/bQ1TE4FzVXuTxabRoza8cMK0MXeywypM78uGvZsNMpwzk 9oNdgs6xwrDOeKw5rZcarYZZSQBnkzybd8/P56pEuxTB1KoTwpIQ1zcvxh0iyI5jMTi7 +b98xAEQGmJ4rkXJHbR2+K+FyhiDR5MhJFY49R0Wb966lCepr5zW/v+L1Lu2IWTvvntd JNnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=3DTPS7gGKCZ012x2K+MasTosYYRMe3DftIWLgVRAtk8=; b=JSLXup/V3d5kAPBfyZYtKKSRgqGDaWv0Yb61KpWuY0APK3YrGRHS44q6N3izI43d+I LMN94xI4MuIektzCETTrAmNzCx9ehBdtrD+T8dj0yQcpOd3M974OzYHgCWl0onVK47YG 7CeSg6gXGRsOl3TjT+pdhKnVB3DrNzaSUs5qA9enDLA84cusR3zd1a7PlRzrLTgK3+nP hMP90V7/OXlvL8rZIZmNyEmW4PHw8ew+WB29h2gqY+AUjbfoz9F3UCD1QIraqOBerwCC XpjoVpuHO64jIwglLkDH8E+fnWSzwrPdnjb/+iBfXv/A19EyiO0ZLpp/2my0Crl0DDvc MO3Q== ARC-Authentication-Results: i=1; mx.google.com; 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 n2si7263772edb.238.2021.06.06.13.19.15; Sun, 06 Jun 2021 13:19:37 -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; 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 S229991AbhFFUSA (ORCPT + 99 others); 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-kernel@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