Re: [PATCH v6 4/4] rust: support large alignments in allocations
From: Danilo Krummrich
Date: Fri Jun 27 2025 - 14:37:35 EST
On Fri, Jun 27, 2025 at 08:16:50PM +0200, Vitaly Wool wrote:
> Add support for large (> PAGE_SIZE) alignments in Rust allocators.
> All the preparations on the C side are already done, we just need
> to add bindings for <alloc>_node_align() functions and start
> using those.
>
> Signed-off-by: Vitaly Wool <vitaly.wool@xxxxxxxxxxx>
> ---
> rust/helpers/slab.c | 14 ++++++++++++++
> rust/helpers/vmalloc.c | 7 +++++++
> rust/kernel/alloc/allocator.rs | 34 +++++++++++-----------------------
> 3 files changed, 32 insertions(+), 23 deletions(-)
>
> diff --git a/rust/helpers/slab.c b/rust/helpers/slab.c
> index 5abd552ccbd4..c4bb451bcf4e 100644
> --- a/rust/helpers/slab.c
> +++ b/rust/helpers/slab.c
> @@ -25,3 +25,17 @@ rust_helper_kvrealloc_node(const void *p, size_t size, gfp_t flags, int node)
> {
> return kvrealloc_node(p, size, flags, node);
> }
> +
> +void * __must_check __realloc_size(2)
> +rust_helper_krealloc_node_align(const void *objp, size_t new_size, unsigned long align,
> + gfp_t flags, int node)
> +{
> + return krealloc_node_align(objp, new_size, align, flags, node);
> +}
> +
> +void * __must_check __realloc_size(2)
> +rust_helper_kvrealloc_node_align(const void *p, size_t size, unsigned long align,
> + gfp_t flags, int node)
> +{
> + return kvrealloc_node_align(p, size, align, flags, node);
> +}
> diff --git a/rust/helpers/vmalloc.c b/rust/helpers/vmalloc.c
> index e6c796c65ee1..09aee472340f 100644
> --- a/rust/helpers/vmalloc.c
> +++ b/rust/helpers/vmalloc.c
> @@ -13,3 +13,10 @@ rust_helper_vrealloc_node(const void *p, size_t size, gfp_t flags, int node)
> {
> return vrealloc_node(p, size, flags, node);
> }
> +
> +void * __must_check __realloc_size(2)
> +rust_helper_vrealloc_node_align(const void *p, size_t size, unsigned long align,
> + gfp_t flags, int node)
> +{
> + return vrealloc_node_align(p, size, align, flags, node);
> +}
Here and in the previous patch, please remove unused helper functions when you
replace their usage with new ones.
Thanks,
Danilo