rust: sync: Introduce LazyInit
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 3 repliesIn review
- v12 patches 1 replySuperseded
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | rust: sync: lock: Add Lock::get_mut_pinned()rust/ | +11 | 1 reply | |
| 2/2 | rust: sync: Introduce LazyInitrust/ rust/ | +354 | 2 replies |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Alice Ryhl |
|---|---|
| 1/2 | R-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
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