public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 0/2] rust: sync: Introduce LazyInit
@ 2026-05-26 20:41 Lyude Paul
  2026-05-26 20:41 ` [PATCH 1/2] rust: sync: lock: Add Lock::get_mut_pinned() Lyude Paul
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lyude Paul @ 2026-05-26 20:41 UTC (permalink / raw)
  To: dri-devel, rust-for-linux, nouveau
  Cc: Gary Guo, Ingo Molnar, Miguel Ojeda, Alice Ryhl, linux-kernel,
	Tamir Duberstein, Boqun Feng, Peter Zijlstra, Shankari Anand,
	Viresh Kumar, Benno Lossin, Will Deacon, Lyude Paul

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/20260326-b4-tyr-debugfs-v1-1-074badd18716@linux.dev/

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 | 354 ++++++++++++++++++++++++++++++++++
 rust/kernel/sync/lock.rs      |  11 ++
 3 files changed, 367 insertions(+)
 create mode 100644 rust/kernel/sync/lazy_init.rs

-- 
2.54.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-27  4:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 20:41 [PATCH 0/2] rust: sync: Introduce LazyInit Lyude Paul
2026-05-26 20:41 ` [PATCH 1/2] rust: sync: lock: Add Lock::get_mut_pinned() Lyude Paul
2026-05-27  4:07   ` Claude review: " Claude Code Review Bot
2026-05-26 20:41 ` [PATCH 2/2] rust: sync: Introduce LazyInit Lyude Paul
2026-05-27  4:07   ` Claude review: " Claude Code Review Bot
2026-05-27  4:07 ` Claude Code Review Bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox