From nobody Tue Sep 29 13:20:15 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 10C1D385D98; Fri, 7 Aug 2026 16:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786118743; cv=none; b=cTY8/bpGDE7cUkRg/nZKUrETz4iuylDyOoCbKRJ/rxEtAHWjULBF2BjzVNFsY7khuXbj7awC5+W1gloIT7JzGjDwoM9wassFgtpwGbw+tz4JU5CLZ6TmeHF/ezT7kL5bZhiwyU+F87EBlSAvp33bSg7CKRHuUxe2AXrfuOhoi50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786118743; c=relaxed/simple; bh=E4GE7zjsMl8MRSs0wx0JszOqpIkaJsxEeekau1quRp4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=EjWOMdT+ZXnVRZ5tGJfD4RPEilk/o14Y8x83y5aZjIo0Z6yJ47oaie6hu85Nb2AkczBydyRJEJTJo/9wM8LQW1yC7xAiDSNodHued7Yig0qP6s0ErMhzDqvvpWht5WZi0yLrOEDsQN1ILPalLpqPnyE4qEGDmgorYVtdqLQwg9U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=eTMSeeSx; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5XUfm6Mq; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eTMSeeSx"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5XUfm6Mq" Date: Fri, 07 Aug 2026 16:05:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786118740; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DeMwu7gpk5tFxtpxcPDpADxNyrOcmNmrDM0OoZI8U6s=; b=eTMSeeSxRU1EqNPUzKt5bZHHUvwAq4LIAzZ9KMT1WTSYybtNOS+B8Bcpgr+FZkJs6VxXi/ xzUG43iJF56QFIcROIXywXjXn+kbjwdtS4KT/0vCN0KsaM2H36TfxaCOXD64Kgxj5OqWpL HNe1LdoXg70KhtqHEhkxxKEljdV5gatq+o8Z9oqIWf/olrfbJbrHptRw/NDFsAtT/eqihW rL12o6ff+N+bjPex6Dche7lj56dZ2yK2tfNS9PGkHyvKXLAu63iopKzJ2OYHy8PhfJlQOU L1/a8EPFHBpmYjOpRPGF4gqKtFPA4BJq5A8KWAzZO6eyCpd6X18t9SQzxiflRw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786118740; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DeMwu7gpk5tFxtpxcPDpADxNyrOcmNmrDM0OoZI8U6s=; b=5XUfm6Mq07SwM3yC68/hVTNLW9FRR3mDuRnBtQA3dQXso0tGTjASII4BCOilbvff0wOuBQ Cdsk0gzHOYwVheBw== From: "tip-bot2 for Gary Guo" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] rust: revocable: Use LKMM atomics instead of Rust atomics Cc: Gary Guo , Alice Ryhl , FUJITA Tomonori , Boqun Feng , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260716145536.3681630-1-gary@kernel.org> References: <20260716145536.3681630-1-gary@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178611873850.708.17390058037206284906.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: 3f90c16d413b2f68407f1c5bb112a1b16ea35dc4 Gitweb: https://git.kernel.org/tip/3f90c16d413b2f68407f1c5bb112a1b16= ea35dc4 Author: Gary Guo AuthorDate: Thu, 16 Jul 2026 15:55:35 +01:00 Committer: Boqun Feng CommitterDate: Tue, 04 Aug 2026 05:52:54 -07:00 rust: revocable: Use LKMM atomics instead of Rust atomics Kernel code should use LKMM atomics. The existing code is `AtomicBool` with the need to use `xchg`, so convert it to `AtomicFlag`. Signed-off-by: Gary Guo Reviewed-by: Alice Ryhl Reviewed-by: FUJITA Tomonori Signed-off-by: Boqun Feng Link: https://patch.msgid.link/20260716145536.3681630-1-gary@kernel.org --- rust/kernel/revocable.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs index f539603..0e55e2a 100644 --- a/rust/kernel/revocable.rs +++ b/rust/kernel/revocable.rs @@ -9,14 +9,19 @@ use pin_init::Wrapper; =20 use crate::{ prelude::*, - sync::rcu, + sync::{ + atomic::{ + AtomicFlag, + Relaxed, // + }, + rcu, // + }, types::Opaque, // }; use core::{ marker::PhantomData, ops::Deref, - ptr::drop_in_place, - sync::atomic::{AtomicBool, Ordering}, + ptr::drop_in_place, // }; =20 /// An object that can become inaccessible at runtime. @@ -69,7 +74,7 @@ use core::{ /// ``` #[pin_data(PinnedDrop)] pub struct Revocable { - is_available: AtomicBool, + is_available: AtomicFlag, #[pin] data: Opaque, } @@ -88,7 +93,7 @@ impl Revocable { /// Creates a new revocable instance of the given data. pub fn new(data: impl PinInit) -> impl PinInit { try_pin_init!(Self { - is_available: AtomicBool::new(true), + is_available: AtomicFlag::new(true), data <- Opaque::pin_init(data), }? E) } @@ -102,7 +107,7 @@ impl Revocable { /// because another CPU may be waiting to complete the revocation of t= his object. pub fn try_access(&self) -> Option> { let guard =3D rcu::read_lock(); - if self.is_available.load(Ordering::Relaxed) { + if self.is_available.load(Relaxed) { // Since `self.is_available` is true, data is initialised and = has to remain valid // because the RCU read side lock prevents it from being dropp= ed. Some(RevocableGuard::new(self.data.get(), guard)) @@ -120,7 +125,7 @@ impl Revocable { /// allowed to sleep because another CPU may be waiting to complete th= e revocation of this /// object. pub fn try_access_with_guard<'a>(&'a self, _guard: &'a rcu::Guard) -> = Option<&'a T> { - if self.is_available.load(Ordering::Relaxed) { + if self.is_available.load(Relaxed) { // SAFETY: Since `self.is_available` is true, data is initiali= sed and has to remain // valid because the RCU read side lock prevents it from being= dropped. Some(unsafe { &*self.data.get() }) @@ -161,7 +166,7 @@ impl Revocable { /// /// Callers must ensure that there are no more concurrent users of the= revocable object. unsafe fn revoke_internal(&self) -> bool { - let revoke =3D self.is_available.swap(false, Ordering::Relaxed); + let revoke =3D self.is_available.xchg(false, Relaxed); =20 if revoke { if SYNC {