Skip to content

rust: sync: add WaitQueue infrastructure

Danilo Krummrich linux-fsdevel lkml rust-for-linux 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest5 patches 12 repliesIn review
  2. v25 patches 2 repliesSuperseded
  3. v15 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- Use Delta<Jiffy> for timeouts and treat negative durations as zero.
- Add might_sleep() and caller tracking to the wait_event() methods.
- Gate the WaitQueue KUnit tests behind a dedicated Kconfig option.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5rust: task: add safe schedule_timeout() wrapperrust/kernel/task.rs+23 -06 replies
2/5rust: sync: add WaitQueue infrastructurerust/kernel/Kconfig.test rust/kernel/sync.rs rust/kernel/sync/wait.rs+567 -02 replies
3/5rust: sync: convert CondVar and PollCondVar to use WaitQueuerust/kernel/sync/condvar.rs rust/kernel/sync/poll.rs rust/kernel/sync/wait.rs+33 -771 reply
4/5rust: sync: condvar: use task::schedule_timeout()rust/kernel/sync/condvar.rs+20 -222 replies
5/5rust: sync: condvar: add non-exclusive freezable waitingrust/kernel/sync/condvar.rs rust/kernel/sync/wait.rs+27 -31 reply

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchMiguel OjedaAlice Ryhl
1/5A-b R-b
2/5R-b
3/5R-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/5] rust: sync: add WaitQueue infrastructure

Add a WaitQueue abstraction wrapping struct wait_queue_head, providing wait_event()-style methods that take a condition closure directly.

This is needed for a (subsequent) DRM patch series to wait for in-flight file close operations during driver unbind. The Tyr driver also needs it for "CSF firmware responses and other GPU-driven events" [1].

Convert CondVar (and PollCondVar) to use WaitQueue internally, removing duplicate code using WaitQueue as the base primitive and add wait_interruptible_freezable_nonexclusive() for subsequent binder usage.

This series is based on FUJITA Tomonori's CondVar timeout conversion [2].

Changes in v3:
- Use Delta<Jiffy> for timeouts and treat negative durations as zero.
- Add might_sleep() and caller tracking to the wait_event() methods.
- Gate the WaitQueue KUnit tests behind a dedicated Kconfig option.

Changes in v2:
- Drop the already merged workqueue patch.
- Make as_raw() public.
- Split error types and use bindings constants for direct C calls.
- Avoid condition rechecks after success.
- Check the condition before preparing a waiter.
- Add non-exclusive wait support, including a CondVar method for subsequent Binder conversion.
- Handle zero and expired timeouts before interruption; extend KUnit coverage.

[1] https://lore.kernel.org/dri-devel/[email protected]/
[2] https://lore.kernel.org/rust-for-linux/[email protected]/

Danilo Krummrich (5):
rust: task: add safe schedule_timeout() wrapper
rust: sync: add WaitQueue infrastructure
rust: sync: convert CondVar and PollCondVar to use WaitQueue
rust: sync: condvar: use task::schedule_timeout()
rust: sync: condvar: add non-exclusive freezable waiting

 rust/kernel/Kconfig.test    |  10 +
 rust/kernel/sync.rs         |   8 +
 rust/kernel/sync/condvar.rs | 154 +++++-----
 rust/kernel/sync/poll.rs    |  19 +-
 rust/kernel/sync/wait.rs    | 546 ++++++++++++++++++++++++++++++++++++
 rust/kernel/task.rs         |  23 ++
 6 files changed, 664 insertions(+), 96 deletions(-)
 create mode 100644 rust/kernel/sync/wait.rs

base-commit: 60fff02883397e17439c16f0e72b2f8c5f6eb791

Signature · 1 line
2.56.1