Re: [PATCH v3 3/5] rust: sync: convert CondVar and PollCondVar to use WaitQueue
From: Gary Guo
Date: Wed Nov 18 2026 - 05:49:58 EST
On Tue Nov 17, 2026 at 12:14 AM GMT, Danilo Krummrich wrote:
> CondVar currently wraps a raw wait_queue_head directly. Now that
> WaitQueue provides the same primitive, convert CondVar to use it
> instead. This removes duplicate init, pinning, Send/Sync, and wake-up
> code from CondVar.
>
> Keep the wait logic in CondVar since it needs to release and reacquire a
> lock guard around the sleep, which WaitQueue's condition-based
> wait_event() methods do not handle. Use wait_once_exclusive() to perform
> a single prepare_to_wait_exclusive / finish_wait cycle with a
> caller-provided schedule function to implement the lock-aware sleep.
>
> Adapt PollCondVar accordingly.
>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> rust/kernel/sync/condvar.rs | 89 +++++++++++--------------------------
> rust/kernel/sync/poll.rs | 19 ++++----
> rust/kernel/sync/wait.rs | 2 -
> 3 files changed, 33 insertions(+), 77 deletions(-)