Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp548905lqo; Wed, 8 May 2024 07:48:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXiMeEx9sKJ6VVFZXix6+4zRYvrhprEOmK07YtrWX3vVSziHZqtYEvyy381rm09pF3wz5f9L0VwSOxpayDvXNJNwFE3LvYIPxqLvBXvaw== X-Google-Smtp-Source: AGHT+IHG/SgKjyCjVTXGMtBybXeQjmRQsnYgBXktXd7w0myYJpwsJ+rFbeEhC1p2BNjrZhZExqVN X-Received: by 2002:a05:6358:70b:b0:186:27ce:639c with SMTP id e5c5f4694b2df-192d2d28b11mr363095155d.18.1715179690582; Wed, 08 May 2024 07:48:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715179690; cv=pass; d=google.com; s=arc-20160816; b=0O0Jve8hfBme7/5jjFlELmmHdaSfB6l4JHHoc72IvJ27JqhRes9y0FOeaB6cSmfZNW n55p6C0bA8s4FRcQQ2/aDCrnzjTuyYjRuNdvrdF8tESOoy//pB4QauKEtO6rRVxkTdZS z/C+MUm8hrnzPv6jHieF3hKo10cau/Kzdt3UCMOa0oyc6bP27f+GXcc8u4wJ/yhkPuHv AavNPmP2cM2K2mKlUogAseJRhbOjmBkdxrjGGn9hC96Sn0NmdndeUCpO93RTxslJyu4x QHPC+E4IFkUxlfBHfi79qPVWmhJiVyFXjjtCFoUndgBh/qWzAgSuJHayURL0F1JrnRgC ubUA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=TwvHwyc8cN+2zCR+dnjzu8bzKwPQmeKThdmMuEz7PTA=; fh=MaZkM021qbfAX3aLJulL8oJ9TBXZh2SjH2oVXl7lSWc=; b=x7ocWROykp5IBUzRfkPBJXTDsLUPJvJO9NoIVcxrM5r/GDenLYe7RakpfqAYpJJFf6 aeWHzzafJWno8r0KDdBx1mQkPnUGDCZthu2TOsQcD/6BUswBmCgbupbFTi89st4zcADZ Lji1x4tv7L0Blz2yEdNQ0CO5MTIZ5aWOK7dZPiODx2g73r1UTMB2nMVs/++X8ivPNyOY ILsK2PavF+U5dp9rOnD5KMIdiR/DfhSzIi22HLcvDBNbqcoCaL3ylPqBieMY7reX8hVk o8h+IaMfRNyBtYjkjNXrUohoPQ8oUW176HIokGlTisV+JFKD5UyPx9b4yHwGRpThWOUO 8UNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sb49OlRC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-173409-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173409-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m7-20020a632607000000b005f9099588d9si886119pgm.717.2024.05.08.07.48.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 07:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173409-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sb49OlRC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-173409-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173409-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 406B9B23C25 for ; Wed, 8 May 2024 14:35:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A9D8127B53; Wed, 8 May 2024 14:34:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sb49OlRC" 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 5050186630; Wed, 8 May 2024 14:34:37 +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=1715178878; cv=none; b=j9LWj7Z3H5AlQHVwE2gaEeFyJDPxwL0nc4P8anPxHcNb7BZLkaQK7s3VY9euKZUfOmxcDwxjpjqprVZ/v6TY8Ns6ybLQsloa9iWu+AWQwAxYoBok4Ikl3jpxFzyPu0COJMtAf2Bc03h/Tphg2963DDQTbym/8inUCTL0H+HN6F4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715178878; c=relaxed/simple; bh=LkpImf7Xtegq1U9a+QMyUfSZIIkF8bJjQH28HZhVga0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=pdRCfcv5oTyl47h97jD2+zBB//BWUfyGxzN/JHMRA63zqMzmsd8XXJgp2YOos9gxQPswB5P68PIAr4l16JldOGvZH1fG7pfMjB/Mh/pDzWR7Gxnu+Mg4EKwyAO7detugQjJuMnELoA52vA0vqg+EekQqZepF/prwpffV4LZQ8r8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sb49OlRC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84C1CC32783; Wed, 8 May 2024 14:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715178877; bh=LkpImf7Xtegq1U9a+QMyUfSZIIkF8bJjQH28HZhVga0=; h=From:To:Cc:Subject:Date:From; b=Sb49OlRC1SeN2Z3yjggk5qbbS+bA9/SmtwkeG/4KATklP+CJdtZ2EXsJCcgoPI19L u00EsvbrMumHLyBDeGfjvZMtz5Xlg44JC9XWF4fVhkhcfrAawWN9/dNRayNeU7A8OT IboYGxypuslUkGCdY7BipEsqI0msBln/hKwRHdcFa4Tx65YBxL69IfAmf/9aAdL4SR stdL30hqMNFSAWipoYsCjisjsHFhc0VipbCbJfw3mKqTPdYnu0R38pxOTljGKceX3t glP/6q93MgUdFh3SxLtg6Hfa2J2yVvx3E2/bW0omYLgFQk3agx1Qf4+XKmMyv4xZLp qBNgO1v+I/6oA== From: Puranjay Mohan To: Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , 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 Cc: puranjay12@gmail.com Subject: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative Date: Wed, 8 May 2024 14:34:00 +0000 Message-Id: <20240508143400.36256-1-puranjay@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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