Re: [PATCH v6 1/2] rust: allocator: add KUnit tests for alignment guarantees
From: Alice Ryhl
Date: Wed Jul 30 2025 - 04:02:12 EST
On Wed, Jul 30, 2025 at 11:35:21AM +0800, Hui Zhu wrote:
> From: Hui Zhu <zhuhui@xxxxxxxxxx>
>
> Add a test module to verify memory alignment guarantees for Rust kernel
> allocators.
> The tests cover `Kmalloc`, `Vmalloc` and `KVmalloc` allocators
> with both standard and large page-aligned allocations.
>
> Key features of the tests:
> 1. Creates alignment-constrained types:
> - 128-byte aligned `Blob`
> - 8192-byte (4-page) aligned `LargeAlignBlob`
> 2. Validates allocators using `TestAlign` helper which:
> - Checks address alignment masks
> - Supports uninitialized allocations
> 3. Tests all three allocators with both alignment requirements:
> - Kmalloc with 128B and 8192B
> - Vmalloc with 128B and 8192B
> - KVmalloc with 128B and 8192B
>
> Co-developed-by: Geliang Tang <geliang@xxxxxxxxxx>
> Signed-off-by: Geliang Tang <geliang@xxxxxxxxxx>
> Signed-off-by: Hui Zhu <zhuhui@xxxxxxxxxx>
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>