From: Alice Ryhl <aliceryhl@google.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>,
ojeda@kernel.org, a.hindborg@kernel.org,
bjorn3_gh@protonmail.com, dakr@kernel.org, gary@garyguo.net,
lossin@kernel.org, rust-for-linux@vger.kernel.org,
tmgross@umich.edu, jens.korinth.tuta.io@kernel.org
Subject: Re: [PATCH v1 0/2] Add support for print exactly once
Date: Fri, 14 Nov 2025 09:48:46 +0000 [thread overview]
Message-ID: <aRb6_v9BSpC6pVT_@google.com> (raw)
In-Reply-To: <aRaDjpYMPJtOfxPM@tardis.local>
On Thu, Nov 13, 2025 at 05:19:10PM -0800, Boqun Feng wrote:
> On Fri, Nov 14, 2025 at 10:12:08AM +0900, FUJITA Tomonori wrote:
> > On Thu, 13 Nov 2025 16:57:18 -0800
> > Boqun Feng <boqun.feng@gmail.com> wrote:
> >
> > > On Fri, Nov 14, 2025 at 09:47:30AM +0900, FUJITA Tomonori wrote:
> > > [...]
> > >> >> Using u8 as atomic type instead of i32 would require a fair amount of
> > >> >> work, since at the moment only i32 and i64 are supported as atomic
> > >> >> types, right?
> > >> >
> > >> > Supporting u8 atomics in general is tricky, but I think *specifically*
> > >> > load/store should not be a problem.
> > >>
> > >> You meant using read_volatile/write_volatile? Since we only need
> > >> "Relaxed" order so something like the following?
> > >>
> > >> #[repr(transparent)]
> > >> struct AtomicU8(UnsafeCell<u8>);
> > >>
> > >
> > > Please don't. Please make it work with Atomic<T>, also store release and
> > > load acquire should be introduced as well.
> >
> > I wanted to confirm what kind of u8 load/store implementation Alice
> > has in mind, and whether it would be used only for OnceLite.
> >
> > Of course. If we add something like that to kernel/sync, I agree that
> > it should be implemented in that way. If not, I'm not sure.
> >
>
> Yeah, I'm afraid that you want to implement something only for OneLite,
> and that'll introduce fragments for maintaining.
>
> For Atomic<T>, supporting load/store/xchg/cmpxchg is definitely the
> plan, so appreciate if you could help while working on this pr_*_once().
>
> Alternatively, we can start with i32, and improve that later.
I read over this discussion. Perhaps it's best that we go with i32 with
xchg after all to avoid adding new atomic types for this feature.
Still needs a load, though.
/// Calls the provided function exactly once.
pub fn call_once<F>(&self, f: F) -> bool
where
F: FnOnce(),
{
let old = self.0.load(Relaxed);
if old == State::Complete {
return false;
}
let old = self.0.xchg(State::Complete, Relaxed);
if old == State::Complete {
return false;
}
f();
true
}
This ensures that we do not perform a write operation when we don't need
to.
Alice
next prev parent reply other threads:[~2025-11-14 9:48 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <nsSZZk6z9Ia7Gl5JS9LVNDRjc-9eFvtSWyLI4SSjsHNouDkDV-GmXnixMYlIpGHryPfhLr8Z2W_CkWd6D2frYQ==@protonmail.internalid>
2025-11-05 5:47 ` [PATCH v1 0/2] Add support for print exactly once FUJITA Tomonori
2025-11-05 5:47 ` [PATCH v1 1/2] rust: Add support for calling a function " FUJITA Tomonori
2025-11-05 9:21 ` Onur Özkan
2025-11-05 10:35 ` Alice Ryhl
2025-11-05 10:32 ` Alice Ryhl
2025-11-06 0:34 ` FUJITA Tomonori
2025-11-05 16:19 ` Boqun Feng
2025-11-06 0:10 ` FUJITA Tomonori
2025-11-06 14:46 ` Boqun Feng
2025-11-07 9:03 ` Alice Ryhl
2025-11-10 9:21 ` FUJITA Tomonori
2025-11-10 16:14 ` Boqun Feng
2025-11-10 16:37 ` Miguel Ojeda
2025-11-10 16:55 ` Boqun Feng
2025-11-11 21:42 ` Miguel Ojeda
2025-11-11 3:09 ` FUJITA Tomonori
2025-11-11 5:17 ` Boqun Feng
2025-11-11 9:12 ` Andreas Hindborg
2025-11-11 23:38 ` FUJITA Tomonori
2025-11-12 9:04 ` Andreas Hindborg
2025-11-15 13:37 ` FUJITA Tomonori
2025-11-11 21:43 ` FUJITA Tomonori
2025-11-12 1:30 ` Boqun Feng
2025-11-12 2:23 ` Boqun Feng
2025-11-12 9:10 ` Andreas Hindborg
2025-11-14 15:03 ` Boqun Feng
2025-11-12 13:17 ` FUJITA Tomonori
2025-11-05 5:47 ` [PATCH v1 2/2] rust: Add pr_*_once macros FUJITA Tomonori
2025-11-05 10:33 ` Alice Ryhl
2025-11-05 20:59 ` [PATCH v1 0/2] Add support for print exactly once Andreas Hindborg
2025-11-05 23:12 ` FUJITA Tomonori
2025-11-06 14:31 ` Boqun Feng
2025-11-10 12:16 ` Andreas Hindborg
2025-11-10 16:08 ` Boqun Feng
2025-11-11 9:02 ` Andreas Hindborg
2025-11-12 0:45 ` FUJITA Tomonori
2025-11-12 1:04 ` Boqun Feng
2025-11-12 1:18 ` FUJITA Tomonori
2025-11-12 1:35 ` Boqun Feng
2025-11-13 9:55 ` FUJITA Tomonori
2025-11-11 1:28 ` FUJITA Tomonori
2025-11-13 10:07 ` Alice Ryhl
2025-11-13 11:18 ` FUJITA Tomonori
2025-11-13 12:06 ` Alice Ryhl
2025-11-14 0:47 ` FUJITA Tomonori
2025-11-14 0:57 ` Boqun Feng
2025-11-14 1:12 ` FUJITA Tomonori
2025-11-14 1:19 ` Boqun Feng
2025-11-14 9:48 ` Alice Ryhl [this message]
2025-11-14 13:55 ` FUJITA Tomonori
2025-11-14 13:47 ` FUJITA Tomonori
2025-11-13 15:20 ` 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=aRb6_v9BSpC6pVT_@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=jens.korinth.tuta.io@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.