Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp724994lqo; Wed, 8 May 2024 12:50:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV/M5B5YdlJZciYgmhFs2Uq6X44n60gXXOZanlFDQSfZIr52pBw4ZWwWJqfyesPMtdGdadh5J8upPfxnlF9unal6aNW+d38HTTA9c2ECg== X-Google-Smtp-Source: AGHT+IG7fjjP6I5PzUG7XWFTuu2DhDxQRMp+dMq0d2Hl5NJODHiJX5+2JR9Q7CT1+LgXIYDoxrG7 X-Received: by 2002:a05:6512:3ba6:b0:520:dc1c:3c5d with SMTP id 2adb3069b0e04-5217cc458a8mr2986201e87.42.1715197807405; Wed, 08 May 2024 12:50:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715197807; cv=pass; d=google.com; s=arc-20160816; b=0qZBYe8qt5e1i2T+L7Fmn83gyqJrGlCKAAdj8R7Hqyu47xtPylohnFVkOH40SumJ+x MbYrVgkPKPUqkooNAeD6X0p8Z0iSm+cOYmbDh9El2RCNhtd0FCYB5MPkIqzAxXwzDyHr 9iK41Dr9SjoPcmoYRNK5HXiFjdU2k8L1F+q+kVAqNo0AIYXy78CrI6A6hU/TENwy25w9 DfuNuoieZkWcfJG5qYsFFLTR/TbS1r89+EyRlGWlcXwqBdYFhgKDIrzh2LsivpUEnWeM ZsNnZrYwR/T0gHuolhx/Y/sSNhT9bCruNEYFmiZCDkPtrWhbURYFSAjCVTpoMzUMHHwF czSg== 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:feedback-id:dkim-signature; bh=KIRuwcchnty1CBuL+Q3afkKdUuWXmceqML8Qpq5pbYU=; fh=e07ll8pZGAFeKhgR4GMRIgxKq9GGuuaSWP+DqgMAZBs=; b=KUSr5n6LLI8PgGUxAFzSncXdMfoDb1iTJhfj6sGFU3iTXTzCPGoxqI1rWeoT1iFccr 9J4iniLTgHSo47/LwbjjQ12mOodr9yOvLyGly/RJ/6pG3STaR/2tVShaKQ2v8j++nUEx PcbNGl+Gpr/fTry3L825ivNt0Jp/VrXjLgfKZCNcs3uEWvmwKuJq01xtjqdckOwilEuG 9NZu1su60UnqQJOWUxkAFkdIoDpvKqgak3SMoT0WjT2b7VK5ePGSgMP6S00NYa9JS2Ot e3jT8Vl7AL31EYb4Vi0Vd5thLmRgJB+VWYnaQ7kfP6s864/RynpamYoF/6Jf+UcshL7W jHJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eIHesTbH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173779-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173779-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cs20-20020a170906dc9400b00a59b8daf310si5111519ejc.519.2024.05.08.12.50.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 12:50:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173779-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eIHesTbH; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-173779-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173779-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 229C11F2580F for ; Wed, 8 May 2024 19:50:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F231130AC0; Wed, 8 May 2024 19:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIHesTbH" Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D24944316A; Wed, 8 May 2024 19:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715197796; cv=none; b=FlJ7cqOBva2EejuZbzm4mmWDyqn8NNmwDWpw2iPjMHa1n7c3pgdsv9buwRDt6wikmqwdZ/84fpUOjQ1umkZtLziM1I+70yzfQMLt6WX57d9VWfof4o2ueOSrUJMYlMRk/HiPsv26+shoNBlC/tPxzzaxuG38o3LonS9O0/PjPQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715197796; c=relaxed/simple; bh=0xmgJhVJefdoBl8v4cz1CxG3Tb76dy/UQNKncMchWE4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Me7t6TNYQX/jpktADrRUQUqfsA9Shg7oZxlnZ+Apr0CFghZkEjL9VxJLJeE035fpzm+Mdw8HeGX5aHnPfvKXdQc7D76SmX8+xjTyvrbbyFL8VaRqx3OGfWOuQj9b2U5U8f4SHNNoSJLn9SBPT+376RSEPpYjth6/gRAsFH+0b20= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eIHesTbH; arc=none smtp.client-ip=209.85.128.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-61be4b986aaso1326977b3.3; Wed, 08 May 2024 12:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715197794; x=1715802594; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=KIRuwcchnty1CBuL+Q3afkKdUuWXmceqML8Qpq5pbYU=; b=eIHesTbHJVnoyTNAK5VGgI9kLUwW2/WvJ/Lo6dHyiVTGz++zcgymQFS/gF7vf96nDg LFOQJh2RI2QVY/J4GuuenSQp608pG02m4TirXqWk/EIrveRj4nCI2lldM8XAvKo2kNwu 3P3PqrFx5tD59e2FuP9KF9eMvqfi0R+orQ9D+M4vrUMdoi0M+7BUcDphiV3PuZk6KHOu HQRhKtRw4oyCI0AgicFEy7lrPMxkkS7ixxwhkab9tq7ATqxIu1dSYoIuPllia956D5g0 hV/ZFTx67hawTA/jSkoUxDKQNdrWcccWBT2hmxE5YEiPf3xjq/VHIu/fWiqgG1GQop2r MMaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715197794; x=1715802594; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KIRuwcchnty1CBuL+Q3afkKdUuWXmceqML8Qpq5pbYU=; b=A0uSR/f3Fwq5nR7Z00XFNvGBK3ra1sdP8azQkbRtSTYNuU20lVTlT49ZVbkA6vzCe9 h0ysTAWeE5E5a/wk8ZHUv922lcqW0t2gwR4x/MI737J8zw1Lsmc6Z2UmctV5iwWkOx1m yW4jFsroHlA+JkY4O16yxgaFMQdxwfgGrLpMNN2X3adwvsGgw+sY95fRaj9HyWsLecqt P9COH/edjbQwuC/zMZ9CVuM+srls+xPh/W5XOrNYTffbCT+O6UG6xyQg1rpxWBiz8a7R +krukvh8+lk5j2Welop/sAh0lZ+UMmxpUfJxr9MA3Y5P0+Z8H7OH63NYzQszK77ciuVu sk5g== X-Forwarded-Encrypted: i=1; AJvYcCWOJmWuk3QXpfjH/8Hp7mz7zxHsfz19sXApo9QJj1QBF4vTJ3t6pO5S/23fJEoMM+TOIKP1vzFCYtqR6IxCSJbp7ktML/e7vKYF9JYpRdlCVe8VldOwp8L15Eaip4aRRePIKgxRzmLn+w== X-Gm-Message-State: AOJu0YwjJSgMKPFulpf2PTaLtJcKahGgyDGv0cYyqQONDva0UMAIuD5B SzP6BdIxOMLEeiygFEwPur24NilFQl9HLw3RSOszupTzW1VKVT+w X-Received: by 2002:a0d:ccd4:0:b0:61b:748:55a1 with SMTP id 00721157ae682-62085a6a59dmr41813767b3.13.1715197793766; Wed, 08 May 2024 12:49:53 -0700 (PDT) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id hf23-20020a05622a609700b0043d1fc9b7d9sm5575791qtb.48.2024.05.08.12.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 12:49:53 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfauth.nyi.internal (Postfix) with ESMTP id B0C9D1200032; Wed, 8 May 2024 15:49:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 08 May 2024 15:49:52 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeftddgudegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhepffdtiefhieegtddvueeuffeiteevtdegjeeuhffhgfdugfefgefgfedt ieeghedvnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhht hhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquh hnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 May 2024 15:49:52 -0400 (EDT) Date: Wed, 8 May 2024 12:49:57 -0700 From: Boqun Feng To: Puranjay Mohan Cc: Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, puranjay12@gmail.com Subject: Re: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative Message-ID: References: <20240508143400.36256-1-puranjay@kernel.org> 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: <20240508143400.36256-1-puranjay@kernel.org> On Wed, May 08, 2024 at 02:34:00PM +0000, Puranjay Mohan wrote: > Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's > atomics operations. > > Use these in linux-kernel.def to implement atomic_and()/or()/xor() with > all their ordering variants. > > atomic_add_negative() is already available so add its acquire, release, > and relaxed ordering variants. > > [1] https://github.com/herd/herdtools7/pull/849 A newer version of herd is required for this feature, right? So please also do a change in tools/memory-model/README "REQUIREMENTS" session when the new version released. Needless to say, this patch looks good to me. Reviewed-by: Boqun Feng Regards, Boqun > > Signed-off-by: Puranjay Mohan > --- > tools/memory-model/linux-kernel.def | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/tools/memory-model/linux-kernel.def b/tools/memory-model/linux-kernel.def > index 88a39601f525..d1f11930ec51 100644 > --- a/tools/memory-model/linux-kernel.def > +++ b/tools/memory-model/linux-kernel.def > @@ -65,6 +65,9 @@ atomic_set_release(X,V) { smp_store_release(X,V); } > > atomic_add(V,X) { __atomic_op(X,+,V); } > atomic_sub(V,X) { __atomic_op(X,-,V); } > +atomic_and(V,X) { __atomic_op(X,&,V); } > +atomic_or(V,X) { __atomic_op(X,|,V); } > +atomic_xor(V,X) { __atomic_op(X,^,V); } > atomic_inc(X) { __atomic_op(X,+,1); } > atomic_dec(X) { __atomic_op(X,-,1); } > > @@ -77,6 +80,21 @@ atomic_fetch_add_relaxed(V,X) __atomic_fetch_op{once}(X,+,V) > atomic_fetch_add_acquire(V,X) __atomic_fetch_op{acquire}(X,+,V) > atomic_fetch_add_release(V,X) __atomic_fetch_op{release}(X,+,V) > > +atomic_fetch_and(V,X) __atomic_fetch_op{mb}(X,&,V) > +atomic_fetch_and_relaxed(V,X) __atomic_fetch_op{once}(X,&,V) > +atomic_fetch_and_acquire(V,X) __atomic_fetch_op{acquire}(X,&,V) > +atomic_fetch_and_release(V,X) __atomic_fetch_op{release}(X,&,V) > + > +atomic_fetch_or(V,X) __atomic_fetch_op{mb}(X,|,V) > +atomic_fetch_or_relaxed(V,X) __atomic_fetch_op{once}(X,|,V) > +atomic_fetch_or_acquire(V,X) __atomic_fetch_op{acquire}(X,|,V) > +atomic_fetch_or_release(V,X) __atomic_fetch_op{release}(X,|,V) > + > +atomic_fetch_xor(V,X) __atomic_fetch_op{mb}(X,^,V) > +atomic_fetch_xor_relaxed(V,X) __atomic_fetch_op{once}(X,^,V) > +atomic_fetch_xor_acquire(V,X) __atomic_fetch_op{acquire}(X,^,V) > +atomic_fetch_xor_release(V,X) __atomic_fetch_op{release}(X,^,V) > + > atomic_inc_return(X) __atomic_op_return{mb}(X,+,1) > atomic_inc_return_relaxed(X) __atomic_op_return{once}(X,+,1) > atomic_inc_return_acquire(X) __atomic_op_return{acquire}(X,+,1) > @@ -117,3 +135,6 @@ atomic_sub_and_test(V,X) __atomic_op_return{mb}(X,-,V) == 0 > atomic_dec_and_test(X) __atomic_op_return{mb}(X,-,1) == 0 > atomic_inc_and_test(X) __atomic_op_return{mb}(X,+,1) == 0 > atomic_add_negative(V,X) __atomic_op_return{mb}(X,+,V) < 0 > +atomic_add_negative_relaxed(V,X) __atomic_op_return{once}(X,+,V) < 0 > +atomic_add_negative_acquire(V,X) __atomic_op_return{acquire}(X,+,V) < 0 > +atomic_add_negative_release(V,X) __atomic_op_return{release}(X,+,V) < 0 > -- > 2.40.1 >