Skip to content

rust: sync: Introduce LazyInit

Lyude Paul dri-devel lkml rust-for-linux 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesIn review
  2. v12 patches 1 replySuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2rust: sync: lock: Add Lock::get_mut_pinned()rust/kernel/sync/lock.rs+11 -01 reply
2/2rust: sync: Introduce LazyInitrust/kernel/sync.rs rust/kernel/sync/lazy_init.rs+354 -02 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchAlice Ryhl
1/2R-b
2/2

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

Read the v2 thread

Cover letter [PATCH v2 0/2] rust: sync: Introduce LazyInit

While trying to write up some SGTable bindings for the GEM shmem helpers, I discovered that SetOnce is actually quite difficult to make use of in a number of situations.

For one: there is (upstream) currently no way to use it with fallible initializers. Even with some of the work being done to add support for this from Gary Guo and Alvin Sun:

https://lore.kernel.org/rust-for-linux/[email protected]/

We're still left with the issue that if two callers race on trying to call init(), there's no actual way for either of them to block until the thread they raced with is done initializing the contents of the container.

LazyInit is my proposed solution to this issue. It provides a container which protects the initialization of its contents, without protecting access to its contents (implying of course, that its contents have to provide their own thread synchronization).

Lyude Paul (2):
rust: sync: lock: Add Lock::get_mut_pinned()
rust: sync: Introduce LazyInit

 rust/kernel/sync.rs           |   2 +
 rust/kernel/sync/lazy_init.rs | 352 ++++++++++++++++++++++++++++++++++
 rust/kernel/sync/lock.rs      |  11 ++
 3 files changed, 365 insertions(+)
 create mode 100644 rust/kernel/sync/lazy_init.rs

base-commit: 0e42ec83d46ab8877d38d37493328ed7d1a24de8

Signature · 1 line
2.54.0