[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250221.202010.155344232451640447.fujita.tomonori@gmail.com>
Date: Fri, 21 Feb 2025 20:20:10 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: me@...enk.dev
Cc: fujita.tomonori@...il.com, linux-kernel@...r.kernel.org,
daniel.almeida@...labora.com, rust-for-linux@...r.kernel.org,
netdev@...r.kernel.org, andrew@...n.ch, hkallweit1@...il.com,
tmgross@...ch.edu, ojeda@...nel.org, alex.gaynor@...il.com,
gary@...yguo.net, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
a.hindborg@...sung.com, aliceryhl@...gle.com, anna-maria@...utronix.de,
frederic@...nel.org, tglx@...utronix.de, arnd@...db.de,
jstultz@...gle.com, sboyd@...nel.org, mingo@...hat.com,
peterz@...radead.org, juri.lelli@...hat.com, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, vschneid@...hat.com, tgunders@...hat.com,
david.laight.linux@...il.com
Subject: Re: [PATCH v11 7/8] rust: Add read_poll_timeout functions
On Thu, 20 Feb 2025 16:04:50 +0100
Fiona Behrens <me@...enk.dev> 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.
>>
>> Link: https://rust-for-linux.com/klint [1]
>> Tested-by: Daniel Almeida <daniel.almeida@...labora.com>
>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@...il.com>
>
> Reviewed-by: Fiona Behrens <me@...enk.dev>
Thanks!
>> +#[track_caller]
>> +pub fn read_poll_timeout<Op, Cond, T>(
>> + mut op: Op,
>> + mut cond: Cond,
>> + sleep_delta: Delta,
>> + timeout_delta: Option<Delta>,
>
> Fun idea I just had, though not sure it is of actuall use (probably not).
> Instead of `Option<Delta> we could use `impl Into<Option<Delta>>`,
> that enables to use both, so not having to write Some if we have a value.
Either is fine by me. I couldn't find any functions under the
rust/kernel that use impl Into<Option<T>> as an argument. Any
rules regarding this?
Powered by blists - more mailing lists