Re: [PATCH v4 3/4] rust: sync: add `CondVar::wait_timeout`

From: Benno Lossin
Date: Wed Jan 10 2024 - 05:01:49 EST


On 08.01.24 15:49, Alice Ryhl wrote:
> Sleep on a condition variable with a timeout.
>
> This is used by Rust Binder for process freezing. There, we want to
> sleep until the freeze operation completes, but we want to be able to
> abort the process freezing if it doesn't complete within some timeout.
>
> Note that it is not enough to avoid jiffies by introducing a variant of
> `CondVar::wait_timeout` that takes the timeout in msecs because we need
> to be able to restart the sleep with the remaining sleep duration if it
> is interrupted, and if the API takes msecs rather than jiffies, then
> that would require a conversion roundtrip jiffies->msecs->jiffies that
> is best avoided.
>
> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@xxxxxxxxx>
> Reviewed-by: Tiago Lam <tiagolam@xxxxxxxxx>
> Reviewed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> ---
> rust/kernel/sync/condvar.rs | 60 ++++++++++++++++++++++++++++++++++++++++-----
> rust/kernel/sync/lock.rs | 4 +--
> rust/kernel/task.rs | 5 +++-
> 3 files changed, 60 insertions(+), 9 deletions(-)

Reviewed-by: Benno Lossin <benno.lossin@xxxxxxxxx>

--
Cheers,
Benno