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

Danilo Krummrich
2025-02-05T19:13:08Z

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@gmail.com>
> ---
> 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@gmail.com
> ---
> rust/kernel/alloc/allocator_test.rs | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)

Acked-by: Danilo Krummrich <dakr@kernel.org>