All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] rust: sync: lock: allow fallible initializers in Lock::new
@ 2026-11-14 20:06 Ivan Tverdokhleb
  2026-11-14 20:07 ` [PATCH 1/2] " Ivan Tverdokhleb
  2026-11-14 20:07 ` [PATCH 2/2] rust: gpu: buddy: store the allocator inside the Mutex Ivan Tverdokhleb
  0 siblings, 2 replies; 3+ messages in thread
From: Ivan Tverdokhleb @ 2026-11-14 20:06 UTC (permalink / raw)
  To: rust-for-linux
  Cc: Matthew Auld, Arun Pravin, Joel Fernandes, Danilo Krummrich,
	Alice Ryhl, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Trevor Gross, Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, Peter Zijlstra, Ingo Molnar, Will Deacon,
	Waiman Long, Lyude Paul, dri-devel, linux-kernel

GpuBuddyInner keeps the C gpu_buddy structure next to a separate
Mutex<()> and has a TODO to move the structure inside the mutex once
Mutex::new() accepts a fallible initializer.

Patch 1 makes Lock::new() generic over the error type of the initializer
for the protected data, so a fallible initializer such as
Opaque::try_ffi_init() can be wrapped in a Mutex or SpinLock.

Patch 2 uses it to put the gpu_buddy allocator directly inside the Mutex
in GPU buddy, so that the allocator can only be reached through the lock
guard, and resolves the TODO.

Tested by building the rust/kernel crate (x86_64 defconfig with
CONFIG_RUST=y and CONFIG_GPU_BUDDY=y, built with LLVM=1). Not tested at
runtime.

Ivan Tverdokhleb (2):
  rust: sync: lock: allow fallible initializers in Lock::new
  rust: gpu: buddy: store the allocator inside the Mutex

 rust/kernel/gpu/buddy.rs | 38 +++++++++++++++-----------------------
 rust/kernel/sync/lock.rs |  8 ++++----
 2 files changed, 19 insertions(+), 27 deletions(-)

-- 
2.56.1


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

end of thread, other threads:[~2026-11-14 20:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-14 20:06 [PATCH 0/2] rust: sync: lock: allow fallible initializers in Lock::new Ivan Tverdokhleb
2026-11-14 20:07 ` [PATCH 1/2] " Ivan Tverdokhleb
2026-11-14 20:07 ` [PATCH 2/2] rust: gpu: buddy: store the allocator inside the Mutex Ivan Tverdokhleb

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.