Re: [PATCH v11 7/8] rust: Add read_poll_timeout functions

Danilo Krummrich
2025-07-28T14:30:18Z

On Mon Jul 28, 2025 at 4:13 PM CEST, Daniel Almeida wrote:
> Tyr needs read_poll_timeout_atomic() too, but I never really understood
> if that's not achievable by setting sleep_delta==0, which skips the
> call to fsleep().

read_poll_timeout_atomic() uses udelay() instead of fsleep(), where the latter
may sleep.

In [1] I explicitly asked for not having the

if sleep_delta != 0 {
might_sleep();
}

conditional.

It hides bugs and callers should be explicit about what they want. Either they
want something that actually may sleep or they want something that can be used
from atomic context.

Even better, in Rust we can use Klint to validate correct usage at compile time
with this separation.

[1] https://lore.kernel.org/lkml/DBNPR4KQZXY5.279JBMO315A12@kernel.org/