public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: boqun.feng@gmail.com, aliceryhl@google.com, arve@android.com,
	brauner@kernel.org, cmllamas@google.com,
	gregkh@linuxfoundation.org, ojeda@kernel.org, tkjos@android.com,
	a.hindborg@kernel.org, bjorn3_gh@protonmail.com, dakr@kernel.org,
	lossin@kernel.org, tmgross@umich.edu,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v1 1/3] rust: revocable: Switch to kernel::sync atomic primitives
Date: Thu, 1 Jan 2026 04:34:54 +0000	[thread overview]
Message-ID: <20260101043454.69dee1c8.gary@garyguo.net> (raw)
In-Reply-To: <20251231.183502.304307662571984456.fujita.tomonori@gmail.com>

On Wed, 31 Dec 2025 18:35:02 +0900 (JST)
FUJITA Tomonori <fujita.tomonori@gmail.com> wrote:

> On Wed, 31 Dec 2025 07:29:17 +0800
> Boqun Feng <boqun.feng@gmail.com> wrote:
> 
> >>  /// An object that can become inaccessible at runtime.
> >> @@ -65,7 +73,7 @@
> >>  /// ```
> >>  #[pin_data(PinnedDrop)]
> >>  pub struct Revocable<T> {
> >> -    is_available: AtomicBool,
> >> +    is_available: Atomic<bool>,
> >>      #[pin]
> >>      data: Opaque<T>,  
> > 
> > I actually think we should use Atomic<i32> instead of Atomic<bool> here,
> > because in most of the cases `T` is a aligned to at least 4-bytes (e.g.
> > Devres uses a Revocable<IoMem>) And in that case, using Atomic<bool>
> > doesn't save extra memory but makes the xchg() operation slower on
> > architectures that don't support byte-wise RmW instructions (e.g.
> > riscv).  
> 
> I agree. Recent RISC-V support byte-wise swap instructions so this may
> not appliy to them. Among the architectures currently supporting Rust,
> perhaps only loongarch could have this issue.

The narrower atomic instructions are extensions and not part of the base
ISA. RISC-V arch use alternative mechanisms for this, but using the
mechanism has an overhead, let alone the hardwares that do not have the
extensions.

Best,
Gary

  parent reply	other threads:[~2026-01-01  4:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-30  9:37 [PATCH v1 0/3] rust: Switch to kernel::sync atomic primitives FUJITA Tomonori
2025-12-30  9:37 ` [PATCH v1 1/3] rust: revocable: " FUJITA Tomonori
2025-12-30 23:29   ` Boqun Feng
2025-12-31  9:35     ` FUJITA Tomonori
2025-12-31 23:41       ` Boqun Feng
2026-01-01  4:34       ` Gary Guo [this message]
2025-12-31 10:12     ` Alice Ryhl
2025-12-31 10:33       ` FUJITA Tomonori
2025-12-31 10:54   ` Alice Ryhl
2025-12-30  9:37 ` [PATCH v1 2/3] rust: list: " FUJITA Tomonori
2025-12-31 10:53   ` Alice Ryhl
2025-12-30  9:37 ` [PATCH v1 3/3] rust_binder: " FUJITA Tomonori
2025-12-31 10:52   ` Alice Ryhl
2026-01-05 13:34 ` [PATCH v1 0/3] rust: " Boqun Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260101043454.69dee1c8.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=dakr@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tkjos@android.com \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox