Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp575670lqp; Wed, 22 May 2024 12:48:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWF/C2dCsVAgc6s0JUgPmXfKMvbUtxgrqndoyBd8sHnlRQGsjJ0LQe+glOAHKioHig0biPVjU8uBnyyXEKpcKZpKkuV4nBcYNf/vB56Q== X-Google-Smtp-Source: AGHT+IF3nHyETHRWXf1QohLojUg0gGLADp+RPgWy1md+1jZDJgZAm/Ct49umkzv90q0mV8Fh/WHB X-Received: by 2002:a05:6a00:228b:b0:6f4:4b84:7c17 with SMTP id d2e1a72fcca58-6f7727bd846mr341441b3a.13.1716407333435; Wed, 22 May 2024 12:48:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716407333; cv=pass; d=google.com; s=arc-20160816; b=RAmSXgDeyRcHC9Fcy2g7QA/e288wCvUz3RkC2TjASpApEXj78U0EUi3TUKV0lh8B/K ulnjSdN3JTS+cGznNtottNkPZy6JQkM9emExgTyHt2ckaYm+eO8bW9PNSxsPT41rxFec jZuedybjQJ0CuJXR44HBr3vdLQqMpc9ZBw+/1bu9syvERHkhAeEqlhgvE9RgzWi2MG00 jfGbRmdsukwMK+5TEFdYFs+s7xzQWaPiI8teXMFRyZBFob8nrOBOprFVcdyt/jqTJG9i X9YZ9vHhO3eG5M5EHfyoLstbl4B2GfGTnlcqO1z+pvP8dxVH5QFA4VtO6j3Jva+c4xaC BoFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=OGvnyGtxc037oqCAR/b/qazhk+OfS4PLYG6JdzVN8Pc=; fh=t8n9LVsasfWsOGKz0BlDAA8Kh54clqUUyCwy8eS5dz4=; b=vYvH8dLSr/F3Oki001KPoZEzN7iOh9JXY7a6BahHwJzSDfj93ZU9VY6WA3jLN4MppG C1nPLDvhjmHY0i5nqTwb07Hb8qXOOYoI6/QbuGrHankaDO13dfuiN2iXFgwKtU6tlQ5j ln2PJH5JrHvlZ8+mA61hBKCFvsv4lvp4PzCRX0sm8fPxhgJ5fiwgbwquYpuswjPAEx9W otOSq6u7G5ZAtPo6BTinKSNglCJXltcyn3059o6pUBaJfvg6k6QSbOzlcZDLeKV6KBKn X7ypPim658siJjhLsgIyb0KbI/R1KcHbAPcv6TNNbcujprp2z0f6HyKaT276MpFx8aFV Kd9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-186683-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186683-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b41a4esi6171729b3a.312.2024.05.22.12.48.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 12:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186683-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-186683-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186683-linux.lists.archive=gmail.com@vger.kernel.org" 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 11364283141 for ; Wed, 22 May 2024 19:48:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1219146A71; Wed, 22 May 2024 19:48:46 +0000 (UTC) Received: from frasgout13.his.huawei.com (frasgout13.his.huawei.com [14.137.139.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31ACEA3F; Wed, 22 May 2024 19:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716407326; cv=none; b=MzhnDi2ha54S1asBfIn3y7swdYVnhVsrX+JQU+A7ytWiIlkX1ze1ncwmp6E45TnltykUTqefc6I584NTtxWDJrPj7SuSPcGkR8TozBKFB+n+/8Drd5y+5gHrpkGSoggsYBqEmgUH+MOSMkslGCoa8Id5yZhNvBQBkbqiHIpn4Tk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716407326; c=relaxed/simple; bh=HdAT56sJXNa4TBXRL+PSM8UK/YONNo0f7tIuiu+4yYs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IFQLGWOwH2VBqLcqW0q0PBKRFeDj0pEJpA3RhNR8K8hgwlz5MS+Zek1h3kU5CZ2ieus21M3GawkM3hFyldQZuXfS7u2ZDEUVtwYmOtz0ZE4tztf+20R7/ARS9RrXMXFDFsXdQSz/0VbLzFMSj6e7I6IRPF3qYpSCwpwfSq48GYw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4Vl1d65fL0z9v7Hl; Thu, 23 May 2024 03:31:22 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.27]) by mail.maildlp.com (Postfix) with ESMTP id 24B10140489; Thu, 23 May 2024 03:48:34 +0800 (CST) Received: from [10.48.210.253] (unknown [10.48.210.253]) by APP2 (Coremail) with SMTP id GxC2BwDHASYHTE5mbkOzCA--.18061S2; Wed, 22 May 2024 20:48:33 +0100 (CET) Message-ID: <22b9837b-16c2-5413-3cd7-4d3a47252a6a@huaweicloud.com> Date: Wed, 22 May 2024 21:48:18 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: LKMM: Making RMW barriers explicit Content-Language: en-US To: Alan Stern , Andrea Parri Cc: Jonas Oberhauser , "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 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> From: Hernan Ponce de Leon In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID:GxC2BwDHASYHTE5mbkOzCA--.18061S2 X-Coremail-Antispam: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qos00pfhgvzhhrqqx5xdzvxpfor3voofrz/ On 5/22/2024 8:20 PM, Alan Stern wrote: > 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. I can give my motivation as a tool developer. It would be much simpler if one could find all the information to support lkmm in tools/memory-model/ (in the form of the model + some comments or a .txt to cover those things we cannot move out of the tool implementation), rather than having to dive into herd7 code. Hernan > > Alan