Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp403031lqb; Tue, 4 Jun 2024 15:15:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDSHEhLl30NQB1S2m5NVH7Xz59SeXB+jlOHPCcWjpOS6EDsWkdFunpC7po/3QnF3Z2qtndJyDSR7DG2I+2sL5f8eokFkqqEaeep4n99A== X-Google-Smtp-Source: AGHT+IHqyXYMXqtoRPNvsdIyXvdB7RcarvRTq/mlMYxT6kU6tAVrSO0J30Uo2ssJRqtfXkU4Fgfa X-Received: by 2002:a05:6214:3d89:b0:6af:cd16:e4ed with SMTP id 6a1803df08f44-6b030a4a1bemr8263526d6.36.1717539313242; Tue, 04 Jun 2024 15:15:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717539313; cv=pass; d=google.com; s=arc-20160816; b=rU68NvHTrmmbFMi14AyfCwmXBwoSipK4qOrLh74EiJEDirS6U3T1UTpQdXVxABOM34 cJgzP9a8w8nBgcJIO8NRcTEr+V7+xesMNiVaZi94z88Hh3duHtXwpeqC264VAV4EbJln I+UXvm3cRn3FMfCo7Gi5fEMUFvw3D/oIOF3CqBkuB163M47rD7I3yX1g8DJ20573dM6f xVdbOMcfZFM7mYDxWF++r1nbe1Qd6iaQ1G2neyhIHiHVmTdG9KnofNTFYScJ0VJIDHvu OTX18ZMEsFMb92bld920wqzvlEtmmu8hyaOjchIh0PCprzf0H6Ak4RHzHdIBaVIMRcxi Z68w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AqFoLUmXjUEKs35099UYG8mYQvORHu1TzLr1G7URdAw=; fh=7HWEHsFKNKC0a1kVQt7Mzf3RfUZH3vlCtorAb+U8Iq0=; b=ilTm+rNwidINo/dRwvp2D1A2h1jck2U7gjqHv7mosFDN3ETuWvrMH4t/knDaJtC9xT rg6AygDKCQXnyNdoM8JFyqHBbqo+uSkwVO4h9BLPE5CUkes/3EyGMWdurb6CDbHlIAI9 eCWq1zIzWg8nmvekLLNaSyv/5nEaDP5XZwN7M0slcFEJ7/KhPRzKiWGmlw7mQLBFGjbL pjJw47R0SednOQAfVOkkfHrQN6aGtCbQmOFfjTWBR8cqWRQm8v4gvTDCQB34LiysXn1s +OTUcEXkcNLOE6sF34N5TJi5W8qX8GYL0w9c0mNFOVMgH0Q7DFZVRwMKq7F4L5G628Nn 5JvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gSVr668a; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201442-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201442-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4a732aa1si120303356d6.78.2024.06.04.15.15.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 15:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201442-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gSVr668a; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201442-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201442-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D8D7C1C23C68 for ; Tue, 4 Jun 2024 22:15:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2502414D428; Tue, 4 Jun 2024 22:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gSVr668a" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 44CA214D296; Tue, 4 Jun 2024 22:14:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717539262; cv=none; b=qvbHzOicifc4cwmlyQMhDwRXgpvOlC2tZh5kYow7/9PEMh4RhyvaFHp0l3gwkeIEHkQFds+O7xLIM6QmbrcVVOlDbD80OUM6TF4xvthLAZmvCDW4p5dvvvzARYnlhhFFW7rxlZlwbPnGM5YxLP/5/NvT+X8PCznyvOhtzwZCsMo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717539262; c=relaxed/simple; bh=21ND8h3aXwqP4GPXt1SePJHjRlQNFlNVkqExdK3K1F0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ORzUJBn9R4loSikNrXSotyKVktmr5+oroKNa4yVVc8/yOyqi/TJS5VDF/XbGCYqfGPlcFxUnq39YvX4RetoUObo1sij7wD3PPFDro2m0vCvR6sXyoY5wEQ5sUE6Mv7oTTaK4BX9oP4kqvMQlktkQkVeCFkj8NiBpgmBLc/ZDsok= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gSVr668a; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2A6EC4AF07; Tue, 4 Jun 2024 22:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717539261; bh=21ND8h3aXwqP4GPXt1SePJHjRlQNFlNVkqExdK3K1F0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gSVr668awxDRSjBZV5RFYun+pWRsVnW0dBdtDZipl1jI3FGx//mlNRdW5gBAhtxQe jZ2SZi0TV1CPBMnG9QoTIdrVBRWboQ7VsGQYXhod85XCxoHKoOBHnI8dYlzSrmojSJ 4bF/WHIiCbCv3t4HebkbUDA9+OqNa1ziXvD3kDtpvBLQrekOKLTFhKBLnU/Pgisytc OZ58tbLJoUMhg/5yWsJ9vfKdwz0XMWIeWugZetuKvRa/HSQMWyrz1fTc1Ksx23PtXG K7ofpHxf8/rZs6EwULzTdDWyzN4JFGcMpuudcp5w/Vkrm1KILCCGkbO45f6cK80Sku ZXlQpsTtIqD4w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 7D913CE3F0F; Tue, 4 Jun 2024 15:14:21 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@meta.com, mingo@kernel.org Cc: stern@rowland.harvard.edu, 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, Puranjay Mohan , "Paul E . McKenney" , Daniel Lustig , Joel Fernandes Subject: [PATCH memory-model 2/3] tools/memory-model: Add atomic_andnot() with its variants Date: Tue, 4 Jun 2024 15:14:18 -0700 Message-Id: <20240604221419.2370127-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Puranjay Mohan Pull-855[1] added the support of atomic_andnot() to the herd tool. Use this to add the implementation in the LKMM. All of the ordering variants are also added. Here is a small litmus-test that uses this operation: C andnot { atomic_t u = ATOMIC_INIT(7); } P0(atomic_t *u) { r0 = atomic_fetch_andnot(3, u); r1 = READ_ONCE(*u); } exists (0:r0=7 /\ 0:r1=4) Test andnot Allowed States 1 0:r0=7; 0:r1=4; Ok Witnesses Positive: 1 Negative: 0 Condition exists (0:r0=7 /\ 0:r1=4) Observation andnot Always 1 0 Time andnot 0.00 Hash=78f011a0b5a0c65fa1cf106fcd62c845 [1] https://github.com/herd/herdtools7/pull/855 Signed-off-by: Puranjay Mohan Acked-by: Andrea Parri Signed-off-by: Paul E. McKenney Cc: Alan Stern Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Nicholas Piggin Cc: David Howells Cc: Jade Alglave Cc: Luc Maranget Cc: Akira Yokosawa Cc: Daniel Lustig Cc: Joel Fernandes Cc: --- tools/memory-model/linux-kernel.def | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/memory-model/linux-kernel.def b/tools/memory-model/linux-kernel.def index d1f11930ec512..a12b96c547b7a 100644 --- a/tools/memory-model/linux-kernel.def +++ b/tools/memory-model/linux-kernel.def @@ -70,6 +70,7 @@ 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); } +atomic_andnot(V,X) { __atomic_op(X,&~,V); } atomic_add_return(V,X) __atomic_op_return{mb}(X,+,V) atomic_add_return_relaxed(V,X) __atomic_op_return{once}(X,+,V) @@ -138,3 +139,8 @@ 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 + +atomic_fetch_andnot(V,X) __atomic_fetch_op{mb}(X,&~,V) +atomic_fetch_andnot_acquire(V,X) __atomic_fetch_op{acquire}(X,&~,V) +atomic_fetch_andnot_release(V,X) __atomic_fetch_op{release}(X,&~,V) +atomic_fetch_andnot_relaxed(V,X) __atomic_fetch_op{once}(X,&~,V) -- 2.40.1