[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aJ2dwkHX0i7bFobg@google.com>
Date: Thu, 14 Aug 2025 08:26:42 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: a.hindborg@...nel.org, alex.gaynor@...il.com, ojeda@...nel.org,
anna-maria@...utronix.de, bjorn3_gh@...tonmail.com, boqun.feng@...il.com,
dakr@...nel.org, frederic@...nel.org, gary@...yguo.net, jstultz@...gle.com,
linux-kernel@...r.kernel.org, lossin@...nel.org, lyude@...hat.com,
rust-for-linux@...r.kernel.org, sboyd@...nel.org, tglx@...utronix.de,
tmgross@...ch.edu, acourbot@...dia.com, daniel.almeida@...labora.com,
me@...enk.dev
Subject: Re: [PATCH v1 2/2] rust: Add read_poll_timeout functions
On Thu, Aug 14, 2025 at 03:11:47PM +0900, FUJITA Tomonori wrote:
> On Mon, 11 Aug 2025 09:50:59 +0000
> Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> > On Mon, Aug 11, 2025 at 01:10:38PM +0900, FUJITA Tomonori wrote:
> >> Add read_poll_timeout functions which poll periodically until a
> >> condition is met or a timeout is reached.
> >>
> >> The C's read_poll_timeout (include/linux/iopoll.h) is a complicated
> >> macro and a simple wrapper for Rust doesn't work. So this implements
> >> the same functionality in Rust.
> >>
> >> The C version uses usleep_range() while the Rust version uses
> >> fsleep(), which uses the best sleep method so it works with spans that
> >> usleep_range() doesn't work nicely with.
> >>
> >> The sleep_before_read argument isn't supported since there is no user
> >> for now. It's rarely used in the C version.
> >>
> >> read_poll_timeout() can only be used in a nonatomic context. This
> >> requirement is not checked by these abstractions, but it is intended
> >> that klint [1] or a similar tool will be used to check it in the
> >> future.
> >
> > I would drop this paragraph. You have a call to might_sleep() now.
>
> Do you mean that, since it’s obvious might_sleep() can only be used in
> a non-atomic context, the above statement is redundant and can be
> dropped?
I mean, klint is nice as it's a compile-time check rather than a
runtime check. But might_sleep() still counts as having the
abstractions check it in my book. So you shouldn't say that you are not
checking it, when you are checking it.
Alice
Powered by blists - more mailing lists