Re: [PATCH v2] rust: alloc: satisfy `aligned_alloc` requirements

From: Danilo Krummrich
Date: Wed Feb 05 2025 - 14:14:27 EST


On Sun, Feb 02, 2025 at 06:27:16AM -0500, Tamir Duberstein wrote:
> The implementation added in commit dd09538fb409 ("rust: alloc: implement
> `Cmalloc` in module allocator_test") did not honor the documented
> requirements of `aligned_alloc`. These requirements may not be enforced
> on all systems, but they are on macOS. Ensure that alignment is at least
> `sizeof(void *)` and round size up to the nearest multiple of that
> value.
>
> Fixes: dd09538fb409 ("rust: alloc: implement `Cmalloc` in module allocator_test")
>
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
> ---
> Changes in v2:
> - Shorten some variable names. (Danilo Krummrich)
> - Replace shadowing alignment variable with a second call to
> Layout::align. (Danilo Krummrich)
> - Link to v1: https://lore.kernel.org/r/20250201-aligned-alloc-v1-1-c99a73f3cbd4@xxxxxxxxx
> ---
> rust/kernel/alloc/allocator_test.rs | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)

Acked-by: Danilo Krummrich <dakr@xxxxxxxxxx>