From 9b25d4111e913b74a1756601449484c44fc58842 Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Wed, 13 May 2026 21:09:15 +0200 Subject: rust: alloc: cleanup imports and use "kernel vertical" style Change all imports in the alloc module to use the "kernel vertical" import style [1]. While at it, drop unnecessary imports covered by prelude::*. Link: https://docs.kernel.org/rust/coding-guidelines.html#imports [1] Reviewed-by: Eliot Courtney Link: https://patch.msgid.link/20260513190946.619810-1-dakr@kernel.org Signed-off-by: Danilo Krummrich --- rust/kernel/alloc/allocator.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'rust/kernel/alloc/allocator.rs') diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs index 63bfb91b3671..af20332d59f7 100644 --- a/rust/kernel/alloc/allocator.rs +++ b/rust/kernel/alloc/allocator.rs @@ -8,14 +8,25 @@ //! //! Reference: -use super::Flags; -use core::alloc::Layout; -use core::ptr; -use core::ptr::NonNull; - -use crate::alloc::{AllocError, Allocator, NumaNode}; -use crate::bindings; -use crate::page; +use super::{ + AllocError, + Allocator, + Flags, + NumaNode, // +}; + +use crate::{ + bindings, + page, // +}; + +use core::{ + alloc::Layout, + ptr::{ + self, + NonNull, // + }, // +}; const ARCH_KMALLOC_MINALIGN: usize = bindings::ARCH_KMALLOC_MINALIGN; -- cgit v1.2.3 From ec51531fb8efda9b75316111c040dd756f815b0c Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Wed, 13 May 2026 21:09:16 +0200 Subject: rust: alloc: cleanup doctest imports to "kernel vertical" style Change all imports in the alloc module's doctests to use the "kernel vertical" import style [1]. While at it, drop imports that are automatically included in doctests. Link: https://docs.kernel.org/rust/coding-guidelines.html#imports [1] Reviewed-by: Eliot Courtney Link: https://patch.msgid.link/20260513190946.619810-2-dakr@kernel.org Signed-off-by: Danilo Krummrich --- rust/kernel/alloc/allocator.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'rust/kernel/alloc/allocator.rs') diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs index af20332d59f7..562e41925ada 100644 --- a/rust/kernel/alloc/allocator.rs +++ b/rust/kernel/alloc/allocator.rs @@ -174,8 +174,11 @@ impl Vmalloc { /// # Examples /// /// ``` - /// # use core::ptr::{NonNull, from_mut}; - /// # use kernel::{page, prelude::*}; + /// # use core::ptr::{ + /// # from_mut, + /// # NonNull, // + /// # }; + /// # use kernel::page; /// use kernel::alloc::allocator::Vmalloc; /// /// let mut vbox = VBox::<[u8; page::PAGE_SIZE]>::new_uninit(GFP_KERNEL)?; -- cgit v1.2.3 From e74b7a3f5aee02c7df33c79991fd867ce421051b Mon Sep 17 00:00:00 2001 From: Yury Norov Date: Thu, 16 Apr 2026 23:15:28 -0400 Subject: rust: tests: add Kconfig for KUnit test There are 6 individual Rust KUnit test suites (plus the doctests one). All the tests are compiled unconditionally now, which adds ~200 kB to the kernel image for me on x86_64. As Rust matures, this bloating will inevitably grow. Add Kconfig.test which includes a RUST_KUNIT_TESTS menu, and all individual tests under it. As usual, new tests are all enabled if KUNIT_ALL_TESTS=y. Suggested-by: Alice Ryhl Signed-off-by: Yury Norov Reviewed-by: David Gow Acked-by: Gary Guo Link: https://patch.msgid.link/20260417031531.315281-3-ynorov@nvidia.com [ Fixed capitalization. Used singular for "API" for consistency. Reworded to clarify these are suites and that there exists the doctests one (which is the biggest at the moment by far). - Miguel ] Signed-off-by: Miguel Ojeda --- rust/kernel/alloc/allocator.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'rust/kernel/alloc/allocator.rs') diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs index 562e41925ada..cd4203f27aed 100644 --- a/rust/kernel/alloc/allocator.rs +++ b/rust/kernel/alloc/allocator.rs @@ -265,6 +265,7 @@ unsafe impl Allocator for KVmalloc { } } +#[cfg(CONFIG_RUST_ALLOCATOR_KUNIT_TEST)] #[macros::kunit_tests(rust_allocator)] mod tests { use super::*; -- cgit v1.2.3