Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2739620pxj; Sun, 6 Jun 2021 12:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHWEDekfF3TgUVE/P+fomNs/VZ1mG7MbBmZBWLMLaeBHW7vuFSc7TABLEmZegNeUWrjzBL X-Received: by 2002:a17:906:5949:: with SMTP id g9mr14398536ejr.296.1623007054901; Sun, 06 Jun 2021 12:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623007054; cv=none; d=google.com; s=arc-20160816; b=as+GECR9s0bEJl8H4lk2YaeEXvBECatSk9218fhTFHlLv6jJsD0sHbiEMtDBu7oAF3 Jer3HLrw8p6tYKTaL3YhJZRtAi5LPA1biBi7SzKzp0V07ZLZNp575WjwffcizxH98jKB yN59rg8Zr/wFl/3IjZ/Z1cBPD5B9l5AMwWRpbOkxl8EKq/CL3c91GmTiTiMSR9/Y030x FobrwcE8BB/QargzB9FrIrnDiVegaV2VjjMQL3gjrtEz/Xze39lPOFqLnkts8jRLd2Lx E/lmMDeyHEhwQu1MobwGkQgAnsbK7g+VWiZtXJINOLsaAsK4IfXnFNUOCe/S5S4PjqjE wdtQ== 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=gHgAQkAieh4qUXmhgbng6cjs4ZgIQXhezHfQ9/PV7Nw=; b=lF7d89rCYHLaSdg6xU6a6ylvnOcl5K62+TKd6yxXmHmi8niX0jMKvofu/cdepR+kQt g8iTzand/de71pdHL9OhmOVHhwglnHfw3F1J4LHJLAzW6HqY2MsqnFOnUyj3xGfm/43d uT+4+dFZvG0Kf8shRscwQvlgRclFJ7zomrovk+DmtCITZppLqqLZYdEDrtG8SgfjNGIa mEH1uEnaoO1OJTyvgLBb9yPmL+OkEsGxD+5+0JzEG0a23ePHPSqxucxQbrj9fDS9TpH+ qrXcuI3CfXdW9QrDVrOselsjgxVDmh1sEqjN4sSK/nIlwXjFqSGsBY5FloXiKVMdopgS 5OHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kkj7nPcF; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o4si10185944eje.262.2021.06.06.12.17.11; Sun, 06 Jun 2021 12:17:34 -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=@kernel.org header.s=k20201202 header.b=kkj7nPcF; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbhFFTRa (ORCPT + 99 others); Sun, 6 Jun 2021 15:17:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:57352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230340AbhFFTRT (ORCPT ); Sun, 6 Jun 2021 15:17:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 532AB61287; Sun, 6 Jun 2021 19:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623006929; bh=wvJiq1aGB+9WeuKZmWAPp0jOhE+zr1mmCVbd1NGNGRA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=kkj7nPcFYhr1VThzJW/TU+bNYpzdLKj6i9sie9zIil+K0cEyI9g16ci+In9LCUNjZ 8aVyEiDB6g7mz6Y5Lz86BaXOc95NzCy8Ixq3HLprgtWlG+/OK7/0Y2/j8b2GjSVFOy 8dRsgrKOGGkZuAJIKp8042ayAXHtW/ins+nCOuzbzsa7O8Sk9UN9ivQ+ywiw7wtT2m gq7RekJk7T0gvYWXbiKeMKgcx6spjoGrgK4yy7EdBscPjMs4Z5/UrkZ6hmLmW3cfyO B9OkooxTjqUr7VvwF7SV7wGtPiSBzZRPKHNGpa+9fAH5yeRxAnpp5HVU2ev85ZNend TZB5vp9SW01KQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 1F6B05C014A; Sun, 6 Jun 2021 12:15:29 -0700 (PDT) Date: Sun, 6 Jun 2021 12:15:29 -0700 From: "Paul E. McKenney" To: Jakub Jelinek Cc: Linus Torvalds , Alan Stern , Segher Boessenkool , 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: <20210606191529.GM4397@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.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: <20210606185922.GF7746@tucnak> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 06, 2021 at 08:59:22PM +0200, Jakub Jelinek wrote: > 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. This does seem to do the trick: https://godbolt.org/z/K5j3bYqGT So thank you for that! Thanx, Paul > 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 >