From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 21C911953AF for ; Wed, 5 Jun 2024 13:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717594824; cv=none; b=WCj00FI7PfBB3/gFVJJxTcDR7v4GSjbcRUWVpFtL9eDzM9IIKyPIqshQvlWyqKsn/OJh/T7JisBe6hdRysBD2Q7z0Z55SUWq7E8uGAX81TJU85CUwFlrhfqNMwnY/mnuGfT6XaHqNXgKwQpCIolFk/G6Rk9TuK03efs/i9dF+44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717594824; c=relaxed/simple; bh=pg3gmQ+DfMSb375BdyrwTTkQKJuMPFxzyCHhzTRTFHM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BB/FWS1F7ux1epeUs0pWjTCsJElbup4ru2yJURGSHCg/7+7w73HVjS3771ZJREY4U+DvBLQeay6XRiCBfZwIFadxg7SEr8a3CfASdfDcYqG3SvyPw0vMnPh7oQj/UqDtNPqUa1X5weOdCoP1DBcBetueb/KbKBkadWJbIiLHRYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 196501 invoked by uid 1000); 5 Jun 2024 09:40:20 -0400 Date: Wed, 5 Jun 2024 09:40:20 -0400 From: Alan Stern To: Boqun Feng Cc: Jonas Oberhauser , paulmck@kernel.org, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, dlustig@nvidia.com, joel@joelfernandes.org, urezki@gmail.com, quic_neeraju@quicinc.com, frederic@kernel.org, linux-kernel@vger.kernel.org, Viktor Vafeiadis Subject: Re: [PATCHv2 3/4] tools/memory-model: Define effect of Mb tags on RMWs in tools/... Message-ID: References: <20240604152922.495908-1-jonas.oberhauser@huaweicloud.com> <20240604160440.498332-1-jonas.oberhauser@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jun 04, 2024 at 09:28:42PM -0700, Boqun Feng wrote: > On Tue, Jun 04, 2024 at 06:04:40PM +0200, Jonas Oberhauser wrote: > > --- a/tools/memory-model/linux-kernel.cat > > +++ b/tools/memory-model/linux-kernel.cat > > @@ -34,6 +34,16 @@ let R4rmb = R \ Noreturn (* Reads for which rmb works *) > > let rmb = [R4rmb] ; fencerel(Rmb) ; [R4rmb] > > let wmb = [W] ; fencerel(Wmb) ; [W] > > let mb = ([M] ; fencerel(Mb) ; [M]) | > > + (* > > + * full-barrier RMWs (successful cmpxchg(), xchg(), etc.) act as > > + * though there were enclosed by smp_mb(). > > + * The effect of these virtual smp_mb() is formalized by adding > > + * Mb tags to the read and write of the operation, and providing > > + * the same ordering as though there were additional po edges > > + * between the Mb tag and the read resp. write. > > + *) > > + ([M] ; po ; [Mb & R]) | > > + ([Mb & W] ; po ; [M]) | > > I couldn't help suggestting: > > ([M] ; po ; [Mb & domain(rmw)]) | > ([Mb & range(rmw)] ; po ; [M]) | > > , it's a bit more clear to me, but maybe the comment above is good > enough? We may want to use the patch's approach for other things besides RMW. For instance, it would be a good way to implement smp_store_mb() -- compare it to the existing implementation in the .def file. Alan