Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp681896lqb; Wed, 29 May 2024 07:40:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6HYZqJ0T1IjYmOW+WZZ8ZwjWNF2xo1MXi2jVL1doU6kc4c4FR4404EsH1qQ3nVtcUpZcrkoml3oChZRSuFQvy8FujUtU7x2f5IBqd9A== X-Google-Smtp-Source: AGHT+IHpY+oE5cHgrP54vuOJO1Pdzoyljyr6mobbHlY2n0LA+8uxPA/1aU2N2jGge60WVXnZecwN X-Received: by 2002:a05:6359:2eb0:b0:186:40c3:e495 with SMTP id e5c5f4694b2df-197e546a8a4mr1136195355d.23.1716993631346; Wed, 29 May 2024 07:40:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716993631; cv=pass; d=google.com; s=arc-20160816; b=t+ltglPLcWlFiCHB8RFViNyzZGGZcrGhujo3pn/Z2WcD6DjZAdoM4m7L9pDi6JBn1t s45l7FjkOO61nty+I5ce0iKuHp3WJ4ugHhWo8hLY3dlVdjaPwbcDRKldm58RWoXMZbHr PFeHKlbKH3b/pf8gaGk+gOBYoXeLdZuselka5Ju4bOI8f8flHRPjJjoZULhKUGa/6rdL il00HAwEHtFNx2D/J7GVRclE9heFEQy+8Xx7OQCwQ981xGtoWbIyGkSfmkk6809hCMBI Csdbm2PXTnsj3zcNd0yF2iV49t+7a7vvy2QZ8d8CUPi9oiS5nSpQb8m+rKm3B7ikAWCl nnPw== 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=qT/BhQXpuFYn0DJLCCfAW17A1aprBObV+ouZRJK0Ae8=; fh=nH33adjnN/gsJTWUmN4ptcPPT/1qvO9FCMI9KyDNvBE=; b=pheJsLU2ipm0UuxDp9Z8hAn56Dr7EPXJJ6nus8BUNNRZln4EI/c0XW078dt3GKpU+n zN1OpYe/IZ2SoQQRFWQZYBx+Kw7q+L5Mq2Rld+v25oFXGH3y2bhZOktAm+7UfDynU4Kd X8B94SCn9+DY+BBtdvPaRJWKQU1V2JfcFqWeD0jarZAnYY9qHcOBeipSDhPxJ1AM6WlB q2u2HVc/c7V+oBt3aFzCuhOBMRjYvUMG4ryKEFAJVHKwSApuhhsaZvLcub7KinY0rK5+ eOjH4lYAza7BofqLDeUUttyjdS8GsFLdZlQ/mIPfdC8jvzUAIQR359WKnAcaNIGgRByD /S+g==; 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-194261-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194261-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6bbbf511f06si927396a12.535.2024.05.29.07.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194261-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-194261-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194261-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B75F5B24A9F for ; Wed, 29 May 2024 14:24:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD1B51581E9; Wed, 29 May 2024 14:24:29 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id C5351157E84 for ; Wed, 29 May 2024 14:24:27 +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=1716992669; cv=none; b=ZiXFsbe5XneaAyFm8Frt8+tGrbO9fsSebk7SdBCEhzVLPEys8EEDHcNcUzfrRbnBoHA6Gk5dNWU2IuPMi+k2dGGaqRbNY8xg3B1iNUfRoraDviTfIHDWuEOT97oyG86MKCXx827crl0FGwTVrOpedBF8EG+gEBod4+p5mCV84I8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716992669; c=relaxed/simple; bh=gehAJrBCj0tUPfdTW7IgQRwjU9msG11mfhKKvOrwlj4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=obAXXEjtu9OQspCe4Ym4UBLhwUYXTfolR6+/X4MJqSRtT6yd0y6EdHocHZrHnbHYDUWFAA43u+5MXR2FdmCW7VDi7TVJzHT2z5BjdXl9QUVlO6cZXRfnpZiWMIigfn8iTkeueebchf40TSeDmHgeqqkAFS5DOXe4ZAV5jwqxYvU= 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 724843 invoked by uid 1000); 29 May 2024 10:24:26 -0400 Date: Wed, 29 May 2024 10:24:26 -0400 From: Alan Stern To: Jonas Oberhauser Cc: Boqun Feng , Andrea Parri , Hernan Ponce de Leon , will@kernel.org, peterz@infradead.org, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, paulmck@kernel.org, akiyks@gmail.com, dlustig@nvidia.com, joel@joelfernandes.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH] tools/memory-model: Document herd7 (internal) representation Message-ID: <2e34674c-2443-4345-8bc7-8c950a47f621@rowland.harvard.edu> References: <20240524151356.236071-1-parri.andrea@gmail.com> <1a3c892c-903e-8fd3-24a6-2454c2a55302@huaweicloud.com> <41bc01fa-ce02-4005-a3c2-abfabe1c6927@huaweicloud.com> <7e2963a3-d471-4593-9170-7f59aa1ce038@huaweicloud.com> <8c6174c7-a26c-416e-b9b1-2aff2d43dea1@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: <8c6174c7-a26c-416e-b9b1-2aff2d43dea1@huaweicloud.com> On Wed, May 29, 2024 at 04:17:36PM +0200, Jonas Oberhauser wrote: > > > Am 5/29/2024 um 4:07 PM schrieb Alan Stern: > > On Wed, May 29, 2024 at 02:37:30PM +0200, Jonas Oberhauser wrote: > > > Given herd's other syntactic limitations, perhaps the best way would be to > > > introduce these macros as > > > > > > x = cmpxchg(...) { > > > __fence{mb-successful-rmw}; > > > x = __cmpxchg{once}(...); > > > __fence{mb-successful-rmw}; > > > } > > > > > > since I think x = M(...) is the only way we are allowed to use these macros > > > anyways. > > > > If we did this, how would the .cat file know to ignore the fence events > > when the cmpxchg() fails? It doesn't look like there's anything to > > connect the two of them. > > > > Adding the MB tag to the cmpxchg itself seems like the only way forward. > > > > Alan > > Something along these lines: > > Mb = Mb | Mb-successful-rmw & (domain((po\(po;po));rmw) | > range(rmw;(po\(po;po))) > > i.e., using the fact that these mb-successful-rmw fences must appear > directly next to a possibly failing rmw, and looking for successful rmw > directly around them. > > I suppose we have to distinguish between the before- and after- fences > though to make it work for cases like > > xchg_release(); > cmpxchg(); // fails > > > __xchg_release(...); // is an rmw > __fence{mb-successful-rmw}; // wrong takes mb semantics > x = __cmpxchg{once}(...); // fails > __fence{mb-successful-rmw}; > > > So that would leave us with > > x = cmpxchg(...) { > __fence{mb-before-successful-rmw}; > x = __cmpxchg{once}(...); > __fence{mb-after-successful-rmw}; > } > > and in .cat/.bell: > > Mb = Mb | Mb-before-successful-rmw & domain((po\(po;po));rmw) | > Mb-after-successful-rmw & range(rmw;(po\(po;po))) It's messy. Associating the fences directly with the RMW event(s) by adding the MB tags is much cleaner, IMO. Also, does the syntax you are proposing require changes to herd7? I'm not aware that it is currently able to parse that kind of definition. Alan