All of lore.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, ojeda@kernel.org, a.hindborg@kernel.org,
	aliceryhl@google.com, bjorn3_gh@protonmail.com, dakr@kernel.org,
	lossin@kernel.org, tmgross@umich.edu, acourbot@nvidia.com,
	rust-for-linux@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH v1 0/2] Add atomic bool support
Date: Wed, 31 Dec 2025 15:34:31 +0000	[thread overview]
Message-ID: <20251231153431.4a48816c.gary@garyguo.net> (raw)
In-Reply-To: <20251230045028.1773445-1-fujita.tomonori@gmail.com>

On Tue, 30 Dec 2025 13:50:26 +0900
FUJITA Tomonori <fujita.tomonori@gmail.com> wrote:

> This adds `bool` support to the Rust LKMM atomics.
> 
> Rust specifies that `bool` has size 1 and alignment 1 [1], so it can
> be represented using an `i8` backing type.
> 
> Since `bool` only permits the bit patterns 0x00 and 0x01, the first
> patch also documents an additional safety preconditions for unsafe
> `Atomic::<T>::from_ptr`.
> 
> `from_ptr()` exists to operate on C-side storage so I don't think it
> makes sense for bool. We could restrict from_ptr() via a marker trait.

The C-side does have `bool` type, too (`_Bool` has been there since C99 and
we have typedef'd it to `bool`). User might still want to perform relaxed
load/store on these C-side bool storage.

I think it's fine to leave out this line too (given Boqun also points out
that the additional safety precondition is not needed for `from_ptr).

Best,
Gary

> 
> [1] https://doc.rust-lang.org/reference/types/boolean.html
> 
> 
> FUJITA Tomonori (2):
>   rust: sync: atomic: Add atomic bool support via i8 representation
>   rust: sync: atomic: Add atomic bool tests
> 
>  rust/kernel/sync/atomic.rs           |  1 +
>  rust/kernel/sync/atomic/internal.rs  |  8 ++++++++
>  rust/kernel/sync/atomic/predefine.rs | 27 +++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+)
> 
> base-commit: 13ade169e801a423bc1a5a5c3c6ac680a144a608


  parent reply	other threads:[~2025-12-31 15:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-30  4:50 [PATCH v1 0/2] Add atomic bool support FUJITA Tomonori
2025-12-30  4:50 ` [PATCH v1 1/2] rust: sync: atomic: Add atomic bool support via i8 representation FUJITA Tomonori
2025-12-30 22:45   ` Boqun Feng
2025-12-31 12:21     ` FUJITA Tomonori
2025-12-30  4:50 ` [PATCH v1 2/2] rust: sync: atomic: Add atomic bool tests FUJITA Tomonori
2025-12-31 15:34 ` Gary Guo [this message]
2026-01-01  3:27   ` [PATCH v1 0/2] Add atomic bool support FUJITA Tomonori

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=20251231153431.4a48816c.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.