From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 DCF9333290A for ; Sun, 11 Jan 2026 12:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132959; cv=none; b=UjxnABQ7XmK0Ab/qNDREKwQ6JUmTC7aXwsDiWUYEQnvjULPMFiOmHBINq/U7ktxsNWQsLJxMCj0ILBOISHJL1qgnwreIjxQxxstbW+EqAk1YmkI1TADy20rL/MIF7ECYYOm1oMWkVOklz1jd+KUnYavgG+lGy4FD/6vEyLQc/ik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768132959; c=relaxed/simple; bh=pBgDlAOsGrzI3Re6SaL//+qFBEUcrGUHfG4Pbeg88CQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdtsbhhygkneMzs7KYD+EyeFH3qXqsWiUHAFUQeZ+PL0NT41Y1X6u48zw8OqvJUgcSULHW4h/vkOqePpj12rrPYX7xp4xb8LowG0N1IRomI6bm2GD1y3Ws8farVCUG7GEC4tdVg0Qv0zfkQbt57c5NdEqx5tAxgvQP/S+kR/xbM= 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=LHfvdv68; arc=none smtp.client-ip=209.85.160.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LHfvdv68" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-4ee158187aaso60611181cf.0 for ; Sun, 11 Jan 2026 04:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768132951; x=1768737751; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:from:to:cc:subject :date:message-id:reply-to; bh=B/bejPLe7xYmbBbJHynANAMI1H7QA7zM0cLAIcFauC0=; b=LHfvdv68e8fLErpSIK0nNAEfa8WK1bSsQSrnEr82Opf87mtQ8cIaN9EoclR0qkJJTk n/qgU/eFkspTFujnBty0upyzDm3RMYu5yhk4s5i3ZhCk/ysxfOft8w/0LUAkxPOrSCj6 5NRdZZTQa2KqH2bYgVPNeCOGVnxl2eXRpwFhVr2R30dUZLAjtpFHeFvJNaPHnypDMZeH LA8xZCSO5JTlHsWxBvq06bLotvOs8nWkkRc7x9Q3ld0tML973HprWWhvjmvO98KoONZo vtl3ZqoTWFG1qPEI3LvkrvZR3C6PURBpyH4Yw5I9FcNkC25ffqxDKYKGS5ocOwMpc2xt ghqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768132951; x=1768737751; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B/bejPLe7xYmbBbJHynANAMI1H7QA7zM0cLAIcFauC0=; b=PWTjZr6VOhBmiVbeJrz1gaFuI5ASGxCXmbrDP5HfdUSGTu8runRTDCtWHrs/qsT22K zttlbJTf1o0EtPooBlXRV7AVTu/8Xy+n1Dcs8Vw1DPQxfOXfWiXQh1gbr0sgP0KFM9jo q6zKd6ClEghrr9L1jI9mVEiQprhBDsmi6mgnOnWCaFzshvupTW7k1i7Kp8qkN1PKyaJu P9zA5ItTux0ozFGHk14yAqmOUMO71/PzJ2C78yhMWaXtue4EzwpMtB460qLQvJ+/DBPr NUXeyuMrFK/T7ryhvKMEBO54lp2raxY/qyz57ipJR8MypbkfxFIDmxoJwKdHWdKGIL8i k89w== X-Forwarded-Encrypted: i=1; AJvYcCUTyBiah70imuDuzKG6i00c4qTZqRuQwn10T5Tg7nhUBEqcnvk52cSUBkMIT2QMCy4Ho1P82XIkdo4XNB4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/fk3rof4xzsdesKt3u/ExS2nMVrP8iQrUYASoKZPOjLnhcSh8 x6RjhSPjwkyLSPaefcVX72FFZE5QE8pLzBvf4YkAcYN99S+s8v6ZCwaB X-Gm-Gg: AY/fxX6LNJwcKdoQV2CBCx/u04cmOk/5tbYpcGm1glpe/HpvknAQG6UDo8+/TGL48zf LoYjqd2uMBrCAculBnF3BeDV7wLpLkDlAJgbT1dqqii+lkDhPZruJ9sM/nnjDFmbdMqdyb2e5Oj j/d5hNyPqH59Hs53sXag/KJCeNFu0hHa6k9ZGspGcvedpwqRF4I1B9bzJ2ut9h2SmGZ5ArpJBFx eOGwryr++uvOWt7mBgyqTqgZT/ySrsXmGb+YJMdoKjvqX9bhINI1t2fJFyn0zqDkmg/eh9aPxWC 4aDwUAW1PBFdPHqS8KNF9qtJJOBs/sLhJm8r99UK8KjdizHdorirWwpoRzWIzLitn0CMOINglOf brDmS5Qlz5M4LmaKVj9kz6hvqHjotntrcwvRZUJrShnCTDkVF1j69g9h6djeT1vS6Sa4ixpbH5Y Ysrrlq2bxzKBpT9eTEVpP6i/mlBeA9MjYmJ9QHlw7ZBrEm4AMlka/qvf8tlOt3httCZDCr7ROGk oqpJ3wuenSVY94= X-Google-Smtp-Source: AGHT+IFSOjFyCEwBHEJwDCrU5rW5lKDRaDYjzQ8c/6PyMz3dbdKv0kF1iGi2tchWyu44RKkeSzRHtw== X-Received: by 2002:ac8:6f05:0:b0:4ee:17eb:ece0 with SMTP id d75a77b69052e-4ffb4913cbcmr187856071cf.9.1768132950842; Sun, 11 Jan 2026 04:02:30 -0800 (PST) Received: from fauth-a2-smtp.messagingengine.com (fauth-a2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4ffa926a9d9sm106445811cf.25.2026.01.11.04.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jan 2026 04:02:30 -0800 (PST) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfauth.phl.internal (Postfix) with ESMTP id D271BF40068; Sun, 11 Jan 2026 07:02:29 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Sun, 11 Jan 2026 07:02:29 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduudeghedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpedvveekvddtffelffelfedvudefffeuheejgeeivedufffgledvgeduveffueeh leenucffohhmrghinhepmhhsghhiugdrlhhinhhknecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgv rhhsohhnrghlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfh gvnhhgpeepghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvpdhnsggprhgtphhtthho peduhedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphgvthgvrhiisehinhhfrh gruggvrggurdhorhhgpdhrtghpthhtohepmhhinhhgoheskhgvrhhnvghlrdhorhhgpdhr tghpthhtoheprhhushhtqdhfohhrqdhlihhnuhigsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtohepfihilhhlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehmrg hrkhdrrhhuthhlrghnugesrghrmhdrtghomhdprhgtphhtthhopehtghhlgieslhhinhhu thhrohhnihigrdguvgdprhgtphhtthhopehojhgvuggrsehkvghrnhgvlhdrohhrghdprh gtphhtthhopehgrghrhiesghgrrhihghhuohdrnhgvth X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 11 Jan 2026 07:02:29 -0500 (EST) From: Boqun Feng To: "Peter Zijlstra" , "Ingo Molnar" Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, "Will Deacon" , "Mark Rutland" , "Thomas Gleixner" , "Miguel Ojeda" , "Gary Guo" , "Alice Ryhl" , "Andreas Hindborg" , "Benno Lossin" , "Danilo Krummrich" , FUJITA Tomonori , Boqun Feng Subject: [PATCH 07/36] rust: helpers: Add i8/i16 atomic xchg helpers Date: Sun, 11 Jan 2026 20:01:40 +0800 Message-ID: <20260111120209.6133-5-boqun.feng@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260111120209.6133-1-boqun.feng@gmail.com> References: <20260111115808.5702-1-boqun.feng@gmail.com> <20260111120209.6133-1-boqun.feng@gmail.com> 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: FUJITA Tomonori Add i8/i16 atomic xchg helpers that call xchg() macro implementing atomic xchg using architecture-specific instructions. [boqun: Use xchg() instead of raw_xchg()] Reviewed-by: Alice Ryhl Signed-off-by: FUJITA Tomonori Reviewed-by: Gary Guo Signed-off-by: Boqun Feng Link: https://patch.msgid.link/20251223062140.938325-2-fujita.tomonori@gmail.com --- rust/helpers/atomic_ext.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rust/helpers/atomic_ext.c b/rust/helpers/atomic_ext.c index 02e05b4246ae..3136255a84c6 100644 --- a/rust/helpers/atomic_ext.c +++ b/rust/helpers/atomic_ext.c @@ -2,6 +2,7 @@ #include #include +#include __rust_helper s8 rust_helper_atomic_i8_read(s8 *ptr) { @@ -42,3 +43,20 @@ __rust_helper void rust_helper_atomic_i16_set_release(s16 *ptr, s16 val) { smp_store_release(ptr, val); } + +/* + * xchg helpers depend on ARCH_SUPPORTS_ATOMIC_RMW and on the + * architecture provding xchg() support for i8 and i16. + * + * The architectures that currently support Rust (x86_64, armv7, + * arm64, riscv, and loongarch) satisfy these requirements. + */ +__rust_helper s8 rust_helper_atomic_i8_xchg(s8 *ptr, s8 new) +{ + return xchg(ptr, new); +} + +__rust_helper s16 rust_helper_atomic_i16_xchg(s16 *ptr, s16 new) +{ + return xchg(ptr, new); +} -- 2.51.0