Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp402986lqb; Tue, 4 Jun 2024 15:15:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3NRzZIZalECuIme7LZ+eyTpu1/eEyhlZmBVDP7c5vkp5x+oHUr++LiQFrM+9/sm62gv00hjjyu6dP5Q+TjTb8Au9wJGQqKeoHqtO8Eg== X-Google-Smtp-Source: AGHT+IFCnkqzpqZWspkT7df3JJFbmVbO8HPHSNebzs0sKGUhkxfpBzU3kE4iMQpfrGHGt4kG9lmo X-Received: by 2002:a05:6a20:9144:b0:1b1:fc7b:bc9e with SMTP id adf61e73a8af0-1b2b6b054f2mr1086380637.0.1717539308846; Tue, 04 Jun 2024 15:15:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717539308; cv=pass; d=google.com; s=arc-20160816; b=oxVVPO6v0I8SwC2fgOUSqGsLg5Kfw+umyhBXvntam6uMTeMJFVUBOCTF5ZlZ0Y/mgs F6lNz2azVADkLHf8P8trrsyD8vXMAcMNFvILgYxHUMsu5dmx6AtawXuKaeDiG8/AiFMf AyN5mvvZ5Bo3Q33EjWe3n++K1tM4NSvmEy4nFlZtxel2oHqZNLMWs7fdWT328lYVhPCC PzIyar2KoShUq/GHXtcT1PpNgmkzX/TwiA9jB9keyBKuVl97yc6J5bnPxk0bXmDyKU/p OFAnE0J7M7N/7X1ObhCRJReCctYpgMJSkMhfVcjOcKtlJ1e8A0eTwm3OKQjRxvbabMRr 3smA== 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=WocHp6QVShIS8SbCCZM/boqeJlE8VM3fu+kLrW7nZwA=; fh=7HWEHsFKNKC0a1kVQt7Mzf3RfUZH3vlCtorAb+U8Iq0=; b=kfXNtvi1JSLAASTQ1+MLE1Gt974C7Sn3Thk3uP/85w2nA7uAaIiorFV29wuTLKOHsC 084nPI4y5kG2gKzyK4AtXs28nxrrq1uZ0gr/Z36BiJN0aWN5sBYKgCrN7QTvUZkbwxpL K43iOXJsffieInBEWbnBPTtTdGb3NFRgc/UX123atCHzmgPNXRJxSYter72L6ZAk3eyb tpYtWUqplDYt7p6AkbBZ1zp32YGPBDhJu7aFK9c6HB001/b0HeP6aCy6TwfoNi7T/yW5 lJDbnRJsEGabssW/JhQDT70iPJTwWlLYtIEdsUur0GlYb8T+HbvVJK/Ivm3ZcbYvt3FU Iw/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LrgyCsOk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201441-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2806efc55si24960a91.171.2024.06.04.15.15.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 15:15:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201441-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LrgyCsOk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201441-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201441-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 80206284FCF for ; Tue, 4 Jun 2024 22:15:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE22314D2B9; Tue, 4 Jun 2024 22:14:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LrgyCsOk" 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 F12C01422C2; Tue, 4 Jun 2024 22:14:21 +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=Wl3SIoqTfHQ6BTVlolrvU9JYEuS1sGImvyA4XhPzfCSp4s5jkLILJxMTM86rmpd9/AVxDPzliLbbxLJks1PbC2mNfDkCCyOo7YeAyyXVzt4Tt+4JkY+WreZH0zxTiyQL0TVSp5dkERGHvhwFhrMG03gt5shE2/2ynSvsfl/+eik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717539262; c=relaxed/simple; bh=01pGRoOVLm7FmVgPZ/DAaMBZsWrBo+heyMml9ojdBqE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ltbzUVxqLDFw/R1PAtb9sbtarUpHHzuPQ4ceXY0ISpJFoJXX9qdVlLTHNs5NDUehxoih066su47S0JVl4YdxzRK0GIrGOyW2TjU//a2fRZ0Td5ws2b8Ee7ogSNgpY4TD74alnLQfvvEQIm7PcHsUTDZVUCA4yNXLczWeXP/U02k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LrgyCsOk; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C29C9C3277B; 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=01pGRoOVLm7FmVgPZ/DAaMBZsWrBo+heyMml9ojdBqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LrgyCsOkoKsbedWkJFmOXWZtCJ3EfgoRKRhDX/gCdhr3WQTecd9lSDlwg9pi2qEk0 cx/O+yxGhahNjUAwemYo/ABJd7i4qnnLIlLEZZ7gJcfT8IjVwyDK7hDT8gCMug/5Js EQd20I+D1cDEXW/Qpqb3eaVFsyVP89uZTJb4DPZ5GzEUYqcaFrHjbOX5YqHmpZY3+s 9Uecvnu5CN8XdRRdkLR4xDNwlAHygBA9ustXUF7tX1DhFV6uWfYt7uzcWEHv5lHCMa KnOJbX/drAbFI3upAqHoRgoiuc6lPeic9YU5Dq06dONJkgqK2laJ2glNZt7h+HecMq 66MVDXyG90z1Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 78F41CE3ED6; 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 1/3] tools/memory-model: Add atomic_and()/or()/xor() and add_negative Date: Tue, 4 Jun 2024 15:14:17 -0700 Message-Id: <20240604221419.2370127-1-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-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 Acked-by: Andrea Parri Reviewed-by: Boqun Feng Signed-off-by: Paul E. McKenney Cc: Alan Stern Cc: Will Deacon Cc: Peter Zijlstra 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/memory-model/linux-kernel.def b/tools/memory-model/linux-kernel.def index 88a39601f5256..d1f11930ec512 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