Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2152802lqb; Mon, 27 May 2024 09:24:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVWhyWu8ga2S/6ux7/DMqozhfsqTo36QO44kXOq7YO6KnrbE/aZD2qNAdHjSxmKaa2ZFHLBcbJGxpyGyq7G2kvtT5G3LjoEOWewVqwAQ== X-Google-Smtp-Source: AGHT+IHL8NxZUSmq4ib4QeFXm65tc9232PvCyxFBRKy5B7YuouGEvyJdIsnjhGx9tNjkr4fwMcE8 X-Received: by 2002:a17:903:41c6:b0:1eb:6cfe:7423 with SMTP id d9443c01a7336-1f4481794e1mr145169375ad.19.1716827095933; Mon, 27 May 2024 09:24:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716827095; cv=pass; d=google.com; s=arc-20160816; b=fpEmKTNswSdE12SHQkjetxVtpmFrKMSQx1Mp2Nd/da0ZJzNIVZzm3CwlQ2HsCfKamD ggTNININXPX9jFCYpwb+axA1YxLHRV4veyqaIN929BBssOIYaXz8goRLFY/AkyVMEqvl Z/QHGGR8XCMTdjN1RWqipopnEx6JWTV0vj7Qdn87amkrpxzatawYmB2oEwbThuMfXCWB sOG6rCsKYfwkXpYRAtSu3aLoIDM9X7ikt8f7oJKbkbBl6YCYavGw6JOAIJ5YbdwgkdeN G+BEPFx61oFF+6dDMu9XOyi07luRpe3CfsyfiaO7XdDfCt+bc9uC42AZ+5lOSeELIVU5 YmzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=QO6MO2tQLzhRdHV29R9isrkZPQ7J/tsyyT7lZWEe/ds=; fh=qk1DPIL/K7Db8Z4wEkSUE0OJuKQwesg6wYhLDBhfCBA=; b=jqdrtkRJl2eyaVZs6JRze1+Vp9A8kMXfnZIfNehqToHTFtoa8w2vbEy2uXXwo63t6f +dq0CazftaMrSfBd96JBCLv+6wrDygYTOQISritV/sGdpohhlk6c1MOSmQYR2qTtFbIp JzobxR6r0pnKmaBDAYfPQwkNue4/BfEGg5SAUMPCg/ni9fqtPLVVr2zG2XcXgFFKPpup hmSlatzkIa/cNxCgI8LtgzMzrB2g+nlTgCNULjKXiKF88Wh9YC10LhBtdUgX5gPTp5R0 UF/s1QtxV8T1h7vGlXv5v+XNhHaaQJmAyi56ZLe3m8uXLXJw4J44j500mtDbVXmUGEkK 1MbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-191198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f45dc060ebsi52829865ad.366.2024.05.27.09.24.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:24:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-191198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A92C22A663E for ; Mon, 27 May 2024 16:14:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8661E1607B2; Mon, 27 May 2024 16:04:13 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 1921C15FA61 for ; Mon, 27 May 2024 16:04:10 +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=1716825853; cv=none; b=ifxYbWxrsz0yT9c83CEkLcYOx65BtoWNBB8VnmXosmiLmYlpfVNqVb2DT6Ce2Fjw0/XVN6eL8Y5PWFEJ10unDrekTgykdO9yYB7ycL5oTBIrBxFcI8/Zm1d1fRsx8k9Y+0zza/rLaoWkEK8zzX9UHHpSGZjvsJw6fE57tTjOhII= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825853; c=relaxed/simple; bh=h54dWY/zDi3py//moP1826iPuQH0d1/QxOp7rIFQxz0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HUk79eNlT6GUjtYnXDF0sPr7k+FeGr4aSWch4umDoj+KKGoZGRdiEepNlFEC/bl2MiaWyU1zbZKKX7W34J2RJlXLxw1wpkX0Ke+L587JEbtVJolpzj/7gQOkQujuECpbJ1v2N9fHBDUAgASLHMZjSEX/pZ6ifXkQYeEpGtl/QuE= 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 663494 invoked by uid 1000); 27 May 2024 12:04:10 -0400 Date: Mon, 27 May 2024 12:04:10 -0400 From: Alan Stern To: Jonas Oberhauser Cc: paulmck@kernel.org, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, 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: [RFC][PATCH 3/4] tools/memory-model: Define effect of Mb tags on RMWs in tools/... Message-ID: <42f31a6a-2f99-46fa-9fac-c3ad5174399a@rowland.harvard.edu> References: <20240527152253.195956-1-jonas.oberhauser@huaweicloud.com> <20240527152253.195956-4-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: <20240527152253.195956-4-jonas.oberhauser@huaweicloud.com> On Mon, May 27, 2024 at 05:22:52PM +0200, Jonas Oberhauser wrote: > Herd7 transforms successful RMW with Mb tags by inserting smp_mb() fences > around them. We emulate this by considering imaginary po-edges before the > RMW read and before the RMW write, and extending the smp_mb() ordering > rule, which currently only applies to real po edges that would be found > around a really inserted smp_mb(), also to cases of the only imagined po > edges. > > Reported-by: Viktor Vafeiadis > Suggested-by: Alan Stern > Signed-off-by: Jonas Oberhauser > --- > tools/memory-model/linux-kernel.cat | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/tools/memory-model/linux-kernel.cat b/tools/memory-model/linux-kernel.cat > index adf3c4f41229..3a6e9677abe4 100644 > --- a/tools/memory-model/linux-kernel.cat > +++ b/tools/memory-model/linux-kernel.cat > @@ -34,6 +34,15 @@ 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. > + *) This file's style calls for multiline comments to start with "(*" on a line by themselves. > + ([M] ; po ; [Mb] ; (* po ; *) [R]) | > + ([W] ; (* po ; *) [Mb] ; po ; [M]) | Can't these be written as: ([M] ; po ; [Mb & R]) | ([Mb & W] ; po ; [M]) | ? I think this would be easier to understand, even though it doesn't correspond as directly to the comment. Alan > ([M] ; fencerel(Before-atomic) ; [RMW] ; po? ; [M]) | > ([M] ; po? ; [RMW] ; fencerel(After-atomic) ; [M]) | > ([M] ; po? ; [LKW] ; fencerel(After-spinlock) ; [M]) | > -- > 2.34.1 >