Re: [PATCH v5 04/26] rust: alloc: implement `Allocator` for `Kmalloc`
From: Alice Ryhl
Date: Wed Aug 14 2024 - 03:51:57 EST
On Mon, Aug 12, 2024 at 8:24 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> Implement `Allocator` for `Kmalloc`, the kernel's default allocator,
> typically used for objects smaller than page size.
>
> All memory allocations made with `Kmalloc` end up in `krealloc()`.
>
> It serves as allocator for the subsequently introduced types `KBox` and
> `KVec`.
>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> ---
> rust/helpers.c | 3 +-
> rust/kernel/alloc.rs | 2 +-
> rust/kernel/alloc/allocator.rs | 63 +++++++++++++++++++++++++++++++++-
> 3 files changed, 64 insertions(+), 4 deletions(-)
>
> diff --git a/rust/helpers.c b/rust/helpers.c
> index 92d3c03ae1bd..9f7275493365 100644
> --- a/rust/helpers.c
> +++ b/rust/helpers.c
> @@ -193,8 +193,7 @@ void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
> }
> EXPORT_SYMBOL_GPL(rust_helper_init_work_with_key);
>
> -void * __must_check __realloc_size(2)
> -rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags)
> +void *rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags)
> {
> return krealloc(objp, new_size, flags);
> }
Why are the various annotations on this helper being removed? This
deserves an explanation in the commit message.
Alice