From 82134823a07b4f45096a287f790c169511859617 Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Wed, 26 Aug 2026 15:27:18 +0200 Subject: [PATCH 1/3] MAINTAINERS: add Alice Ryhl as co-maintainer for Rust [ALLOC] Add Alice as co-maintainer for the Rust alloc module to share maintenance responsibility. This is also a natural fit, as some of the alloc code overlaps with the mm subsystem. Acked-by: Gary Guo Acked-by: Alice Ryhl Acked-by: Liam R. Howlett (Oracle) Acked-by: Vlastimil Babka (SUSE) Acked-by: Lorenzo Stoakes (ARM) Link: https://patch.msgid.link/20260826132729.3281308-1-dakr@kernel.org Signed-off-by: Danilo Krummrich --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3a19da74d00c..1945b1001849 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -23973,6 +23973,7 @@ K: \b(?i:rust)\b RUST [ALLOC] M: Danilo Krummrich +M: Alice Ryhl R: Lorenzo Stoakes R: Vlastimil Babka R: Liam R. Howlett From d190aa209416f6d6d7bdaffffaaab2af5d3ccdec Mon Sep 17 00:00:00 2001 From: Andreas Hindborg Date: Fri, 5 Jun 2026 12:56:31 +0200 Subject: [PATCH 2/3] rust: alloc: allow different error types in `KBox::pin_slice` Previously, `KBox::pin_slice` required the initializer error type to match the return error type via `E: From`. This prevented using infallible initializers like `new_mutex!` inside `pin_slice`, because `Infallible` does not implement `From`. Introduce a separate type parameter `E2` for the initializer error type and require `E: From` and `E: From` instead. This allows the initializer to return a different error type that can be converted into the final error type, enabling use of infallible pin initializers in fallible allocation contexts. Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/.E2.9C.94.20Constructing.20Mutex.20from.20PinInit.3CT.2C.20Error.3E Co-developed-by: Benno Lossin Signed-off-by: Benno Lossin Signed-off-by: Andreas Hindborg Link: https://patch.msgid.link/20260605-pin-slice-init-v2-1-b197e84040ba@kernel.org Signed-off-by: Danilo Krummrich --- rust/kernel/alloc/kbox.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs index c63d6acdbb6f..2c929eb1c3d6 100644 --- a/rust/kernel/alloc/kbox.rs +++ b/rust/kernel/alloc/kbox.rs @@ -345,7 +345,7 @@ pub fn pin(x: T, flags: Flags) -> Result>, AllocError> /// } /// /// // Allocate a boxed slice of 10 `Example`s. - /// let s = KBox::pin_slice( + /// let s = KBox::pin_slice::<_, _, Error, _>( /// | _i | Example::new(), /// 10, /// GFP_KERNEL @@ -355,15 +355,16 @@ pub fn pin(x: T, flags: Flags) -> Result>, AllocError> /// assert_eq!(s[3].d.lock().a, 20); /// # Ok::<(), Error>(()) /// ``` - pub fn pin_slice( + pub fn pin_slice( mut init: Func, len: usize, flags: Flags, ) -> Result>, E> where Func: FnMut(usize) -> Item, - Item: PinInit, + Item: PinInit, E: From, + E: From, { let mut buffer = super::Vec::::with_capacity(len, flags)?; for i in 0..len { From 6e8339118040f24ebcc21db22c9c1b7398b7e39e Mon Sep 17 00:00:00 2001 From: Andreas Hindborg Date: Tue, 29 Sep 2026 17:18:24 +0200 Subject: [PATCH 3/3] rust: alloc: add `NumaNode::id()` accessor `NumaNode` wraps an `i32` but offers no way to read it back. Add a trivial `id()` getter so callers that need to pass the node id to a C binding can recover the underlying `c_int` without reaching into the private field. Reviewed-by: Alice Ryhl Reviewed-by: Gary Guo Signed-off-by: Andreas Hindborg Link: https://patch.msgid.link/20260929-numa-node-id-v2-1-fdd2c0a49412@kernel.org Signed-off-by: Danilo Krummrich --- rust/kernel/alloc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs index 21067bde6860..68d80f3fa6c8 100644 --- a/rust/kernel/alloc.rs +++ b/rust/kernel/alloc.rs @@ -130,6 +130,12 @@ pub fn new(node: i32) -> Result { } Ok(Self(node)) } + + /// Returns the raw NUMA node identifier as an `i32`. + #[inline] + pub fn id(&self) -> i32 { + self.0 + } } /// Specify necessary constant to pass the information to Allocator that the caller doesn't care