]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rust: alloc: replace aligned_size() with Kmalloc::aligned_layout()
authorDanilo Krummrich <dakr@kernel.org>
Thu, 31 Jul 2025 15:48:06 +0000 (17:48 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Mon, 11 Aug 2025 21:20:53 +0000 (23:20 +0200)
commitfde578c86281f27b182680c7642836a0dbbd0be7
treefdb8f1eb9f3588818a552756369cff6e2d09f861
parentf87d597e8393f7038de046ed7f13bb176a4ead55
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: 8a799831fc63 ("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>
rust/kernel/alloc/allocator.rs