Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp530385lqp; Wed, 22 May 2024 11:21:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXBKsSr4/+tmjAPfRkBvL7L93brC6kux4Mfv+ir08/Sp//Yjs80HNV+PgaQ57jd/rldm0gTH/rkaL/+vGOc4fbF7K3sbnJ21sxH9mZMg== X-Google-Smtp-Source: AGHT+IHxBai00Olrbq9Res4Y2aRg3yU39wW/1rq/+YVFPT901fDlQeY/f9wx+LYzoFV9JQBjH6rr X-Received: by 2002:a05:6a21:800f:b0:1af:abce:986d with SMTP id adf61e73a8af0-1b1f8a80683mr2615812637.61.1716402067170; Wed, 22 May 2024 11:21:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716402067; cv=pass; d=google.com; s=arc-20160816; b=NwIYhtpjKnI8vVEfWfBrJLa4UcxZ6rWLM8/K/wXfnvtpyjYZCCXy2iFnszVpj5geXt fqo5MaF3AwBpRtqEL6IRtL7EUKAe8L+nCDP3pEWQwVANCS7jnuaucAgsXgigMWPbrZLW iUrYqOs+C1VHkZStV86vwMvFlNzP8f07hFAsXAMFQaWDWAzLXIV5FCAiiTPL3QXnh7lN 3cK2d/pr0oyi1J6M7KNp0pbqzunx4+dwA6bM/Qc2dfOSy+K25ioGXi8jzni8xfMTx9xS 9FzgqIQk0qtSGU+ZvuChCMFdAPSKp/4jMycmlQjckctubvmI+5b/4xUItZ8jikZ56bj6 Tctw== 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=EBcNDXKEfEXIUCPRZ47kQ2eSu4c1rbV2m9x0wlHXPz0=; fh=3iVX+YjkZcnkGMmiZUsOwt/VWeJ1SF1vvOO6oZbxJy0=; b=XR7rZy/+AeFoiPCMGI/bAlFZWjDfkgBXvfiTeFCjAkcosDnwR8LL3ajHzfzWXGuSjA vPlZE6n/CqoOk7D2vlyvyCx5E8D77HbBGTXVeEcIiqdZaKqZgX1qoOK/2ZnR5H/GtK0b 1LkEMksDQKw6JWWb8w+5Ap179KhGemLV5NNtE2xvOSmqCk5y8Z6QQzVdaeiC7SbwLCeo zMTRJRtAOcjiSJtfC7V2Z+ZO658D5iE5d8eZwLI/5V8xhtOJiGFutS2nl9QS2NiqnAN5 7uh7PiQnuSzORPGJZUA8s4MgA++ADFSGwaZvanyqKtQWQTRNPHqbOqPI1m9KkNebJj6B meyw==; 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-186608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186608-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 41be03b00d2f7-6576d27743bsi13798896a12.737.2024.05.22.11.21.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 11:21:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186608-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-186608-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186608-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 CCDCD28215E for ; Wed, 22 May 2024 18:20:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C928D145B13; Wed, 22 May 2024 18:20:51 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 86C201BF40 for ; Wed, 22 May 2024 18:20:49 +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=1716402051; cv=none; b=pt51zA3NEfYs/Xr8cuhk+a5CHB4n71PSYHkKJC47FRNVsjplOCMpkeQoAyZ4bjOoqrRtLlbw13Vkkg0jzAjnC2lAb9qWelpc+jrxDOMOfHkLdR59bG1Im7BNcAJaPTqpb5MByu7Yk4sbTle38Ko4kdcDck9zHClCo36zCiq1rBk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716402051; c=relaxed/simple; bh=uxu8FI2vtIphGSI3l0Rvcfu2ul4LYPisCRq5cmLblag=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=akJuHr1d6RCNSLaI1cLTsSXmU499D0YpSYNiEOOf9/zENswYTEgFaOxPTu0uqf6d5XDLqNcplEBFw5aNua37c3VMSo8Cu3m1cZJEIKBkj8yHm8VsCkwulD4INnM4wBl3mRgMjEyDq8wEG4MRD4rxRTr/GhhXL0G9r18Bk4YjnOM= 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 508150 invoked by uid 1000); 22 May 2024 14:20:42 -0400 Date: Wed, 22 May 2024 14:20:42 -0400 From: Alan Stern To: Andrea Parri Cc: Jonas Oberhauser , Hernan Ponce de Leon , "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@meta.com, boqun.feng@gmail.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, Joel Fernandes Subject: Re: LKMM: Making RMW barriers explicit Message-ID: References: <72c804c8-2511-4349-a823-bc1de8bb729e@rowland.harvard.edu> <2f20e7cf-7c67-4ad3-8a0c-3c1d01257ae4@rowland.harvard.edu> <0c309dd3-f8c1-4945-b8f1-154b2a775216@huaweicloud.com> <4286e5b2-5954-4c77-a815-c1c2735d9509@rowland.harvard.edu> <58042cf3-e515-4e5f-ab48-1d0d6123c9e9@huaweicloud.com> <6174fd09-b287-49ae-b117-c3a36ef3800a@rowland.harvard.edu> 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 Wed, May 22, 2024 at 06:54:25PM +0200, Andrea Parri wrote: > Alan, all, > > ("randomly" picking a recent post in the thread, after having observed > this discussion for a while...) > > > It would be better if there was a way to tell herd7 not to add the 'mb > > tag to failed instructions in the first place. This approach is > > brittle; see below. > > AFAIU, changing the herd representation to generate mb-accesses in place > of certain mb-fences... I believe herd7 already generates mb accesses (not fences) for certain RMW operations. But then it does some post-processing on them, and that post-processing is what we are thinking of changing. > > If you do want to use this approach, it should be simplified. All you > > need is: > > > > [M] ; po ; [RMW_MB] > > > > [RMW_MB] ; po ; [M] > > > > This is because events tagged with RMW_MB always are memory accesses, > > and accesses that aren't part of the RMW are already covered by the > > fencerel(Mb) thing above. > > ... and updating the .cat file to the effects of something like > > -let mb = ([M] ; fencerel(Mb) ; [M]) | > +let mb = (([M] ; po? ; [Mb] ; po? ; [M]) \ id) | > > ... can hardly be called "making RMW barriers explicit". (So much so > that the first commit in PR #865 was titled "Remove explicit barriers > from RMWs". :-)) There is another point, something we didn't spell out explicitly in the email discussion. Namely, in linux-kernel.def there is a long list of instructions along with corresponding herd7 implementation instructions, and those instructions explicitly contain either {once}, {acquire}, {release}, or {mb} tags. So to a large extent, these barriers already are explicit in the memory model. Not in the .cat file, but in the .def file. What is not so explicit is how the {mb} tag works. Its operation isn't as simple as the operation of the {acquire} and {release} tags; those just modify the R or W access in the RMW pair as you would expect. Instead, an {mb} tag says to insert strong memory barriers before the R access and after the W access. This is more or less what the post-processing mentioned earlier does, and Jonas and Hernan want to move this out of herd7 and into the memory model. > Overall, this discussion rather seems to confirm the close link between > tools/memory-model/ and herdtools7. (After all, to what extent could > any putative RMW_MB be considered "explicit" without _knowing the under- > lying representation of the RMW operations...) My understanding is that > this discussion was at least in part motivated by a desire to experiment > and familiarize with the current herd representation (that does indeed > require some getting-used-to...); this suggests, as some of you already > mentioned, to add some comments or a .txt in tools/memory-model/ in order > to document such representation and ameliorate that experience. OTOH, I > must admit, I'm unable to see here sufficient motivation(tm) for changing > the current representation (and model): not the how, but the why... Well, it's not a big change. And in my opinion, if something can be moved out of herd7's innards and into the memory model files, then doing so is generally a good idea. However, I do agree that there will still be a close link between tools/memory-model/ and herdtools7. This may be unavoidable, at least to some extent, but any way to reduce it is worth considering. Alan