linux/rust/kernel/alloc
Danilo Krummrich fde578c862 rust: alloc: replace aligned_size() with Kmalloc::aligned_layout()
aligned_size() dates back to when Rust did support kmalloc() only, but
is now used in ReallocFunc::call() and hence for all allocators.

However, the additional padding applied by aligned_size() is only
required by the kmalloc() allocator backend.

Hence, replace aligned_size() with Kmalloc::aligned_layout() and use it
for the affected allocators, i.e. kmalloc() and kvmalloc(), only.

While at it, make Kmalloc::aligned_layout() public, such that Rust
abstractions, which have to call subsystem specific kmalloc() based
allocation primitives directly, can make use of it.

Fixes: 8a799831fc ("rust: alloc: implement `ReallocFunc`")
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250731154919.4132-2-dakr@kernel.org
[ Remove `const` from Kmalloc::aligned_layout(). - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-08-11 23:20:53 +02:00
..
kvec rust: alloc: add Vec::insert_within_capacity 2025-05-07 18:40:45 +02:00
allocator.rs rust: alloc: replace aligned_size() with Kmalloc::aligned_layout() 2025-08-11 23:20:53 +02:00
allocator_test.rs rust: enable clippy::ptr_as_ptr lint 2025-06-22 23:08:42 +02:00
kbox.rs Alloc & DMA changes for v6.17 2025-07-15 23:42:55 +02:00
kvec.rs Alloc & DMA changes for v6.17 2025-07-15 23:42:55 +02:00
layout.rs rust: alloc: add doctest for ArrayLayout::new() 2025-01-13 23:45:30 +01:00