Re: [PATCH 2/2] mm: kvmalloc: align kvrealloc() with krealloc()

Christoph Hellwig
2024-07-18T03:19:32Z

> +extern void *kvrealloc_noprof(const void *p, size_t size, gfp_t flags) __realloc_size(2);

Please drop the extern while you're at it and move the __realloc_size
attribute to a separate line.

> +static gfp_t to_kmalloc_flags(gfp_t flags, size_t size)
> +{
> + if (size > PAGE_SIZE) {
> + flags |= __GFP_NOWARN;
> +
> + if (!(flags & __GFP_RETRY_MAYFAIL))
> + flags |= __GFP_NORETRY;
> +
> + /* nofail semantic is implemented by the vmalloc fallback */
> + flags &= ~__GFP_NOFAIL;
> + }
> +
> + return flags;

The name for this function sounds a bit odd. Maybe kmalloc_gfp_adjust
instead? Also the comment explaining these flags tweaks should move
from the caller to this function.