Re: [PATCH v2 0/2] Take ARCH_KMALLOC_MINALIGN into account for build-time XArray check

From: Danilo Krummrich
Date: Fri Aug 15 2025 - 15:15:43 EST


On Mon Aug 11, 2025 at 2:31 PM CEST, Alice Ryhl wrote:
> Alice Ryhl (2):
> rust: alloc: specify the minimum alignment of each allocator

[ Add helper for ARCH_KMALLOC_MINALIGN; remove cast to usize. - Danilo ]

> rust: alloc: take the allocator into account for FOREIGN_ALIGN

Applied to alloc-next, thanks!

--

@Andrew: Just a heads-up, this has a minor conflict with your tree, which
should also show up in linux-next soon.

diff --cc rust/kernel/alloc.rs
index b39c279236f5,907301334d8c..000000000000
--- a/rust/kernel/alloc.rs
+++ b/rust/kernel/alloc.rs
@@@ -164,7 -137,15 +164,15 @@@ impl NumaNode
/// - Implementers must ensure that all trait functions abide by the guarantees documented in the
/// `# Guarantees` sections.
pub unsafe trait Allocator {
+ /// The minimum alignment satisfied by all allocations from this allocator.
+ ///
+ /// # Guarantees
+ ///
+ /// Any pointer allocated by this allocator is guaranteed to be aligned to `MIN_ALIGN` even if
+ /// the requested layout has a smaller alignment.
+ const MIN_ALIGN: usize;
+
- /// Allocate memory based on `layout` and `flags`.
+ /// Allocate memory based on `layout`, `flags` and `nid`.
///
/// On success, returns a buffer represented as `NonNull<[u8]>` that satisfies the layout
/// constraints (i.e. minimum size and alignment as specified by `layout`).