[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aV2yBUW7W_dytCUG@tardis-2.local>
Date: Wed, 7 Jan 2026 09:08:21 +0800
From: Boqun Feng <boqun.feng@...il.com>
To: John Hubbard <jhubbard@...dia.com>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Gary Guo <gary@...yguo.net>,
Andreas Hindborg <a.hindborg@...nel.org>,
FUJITA Tomonori <fujita.tomonori@...il.com>, lyude@...hat.com,
will@...nel.org, peterz@...radead.org, richard.henderson@...aro.org,
mattst88@...il.com, linmag7@...il.com, catalin.marinas@....com,
ojeda@...nel.org, bjorn3_gh@...tonmail.com, lossin@...nel.org,
tmgross@...ch.edu, dakr@...nel.org, mark.rutland@....com,
frederic@...nel.org, tglx@...utronix.de, anna-maria@...utronix.de,
jstultz@...gle.com, sboyd@...nel.org, viro@...iv.linux.org.uk,
brauner@...nel.org, jack@...e.cz, linux-kernel@...r.kernel.org,
linux-alpha@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
rust-for-linux@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 4/5] rust: hrtimer: use READ_ONCE instead of read_volatile
On Tue, Jan 06, 2026 at 04:47:35PM -0800, John Hubbard wrote:
> On 1/6/26 10:43 AM, Alice Ryhl wrote:
> > On Tue, Jan 06, 2026 at 03:23:00PM +0000, Gary Guo wrote:
> >> On Tue, 06 Jan 2026 13:37:34 +0100
> >> Andreas Hindborg <a.hindborg@...nel.org> wrote:
> >>
> >>> "FUJITA Tomonori" <fujita.tomonori@...il.com> writes:
> >>>>
> >>>> Sorry, of course this should be:
> >>>>
> >>>> +__rust_helper ktime_t rust_helper_hrtimer_get_expires(const struct hrtimer *timer)
> >>>> +{
> >>>> + return hrtimer_get_expires(timer);
> >>>> +}
> >>>>
> >>>
> >>> This is a potentially racy read. As far as I recall, we determined that
> >>> using read_once is the proper way to handle the situation.
> >>>
> >>> I do not think it makes a difference that the read is done by C code.
> >>
> >> If that's the case I think the C code should be fixed by inserting the
> >> READ_ONCE?
> >
> > I maintain my position that if this is what you recommend C code does,
> > it's confusing to not make the same recommendation for Rust abstractions
> > to the same thing.
> >
> > After all, nothing is stopping you from calling atomic_read() in C too.
> >
>
> Hi Alice and everyone!
>
> I'm having trouble fully understanding the latest reply, so maybe what
> I'm saying is actually what you just said.
>
> Anyway, we should use READ_ONCE in both the C and Rust code. Relying
> on the compiler for that is no longer OK. We shouldn't be shy about
> fixing the C side (not that I think you have been, so far!).
>
Agreed on most of it, except that we should be more explicit in Rust,
by using atomic_load[1] instead of READ_ONCE().
[1]: https://lore.kernel.org/rust-for-linux/aV0FxCRzXFrNLZik@tardis-2.local/
Regards,
Boqun
> thanks,
> --
> John Hubbard
>
Powered by blists - more mailing lists