Re: [PATCH] mm: change vma_alloc_folio_noprof() macro to inline function
From: Zi Yan
Date: Mon Feb 16 2026 - 11:59:04 EST
On 16 Feb 2026, at 7:17, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> In a few rare configurations with extra warnings eanbled, the new
s/eanbled/enabled
> drm_pagemap_migrate_populate_ram_pfn() calls vma_alloc_folio_noprof()
> but that does not use all the arguments, leading to a harmless warning:
>
> drivers/gpu/drm/drm_pagemap.c: In function 'drm_pagemap_migrate_populate_ram_pfn':
> drivers/gpu/drm/drm_pagemap.c:701:63: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter=]
> 701 | unsigned long addr)
> | ~~~~~~~~~~~~~~^~~~
>
But addr is used at line 739 or line 741:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/gpu/drm/drm_pagemap.c#n739
I wonder why compiler reported the error.
> Replace the macro with an inline function so the compiler can see
> how the argument would be used, but is still able to optimize out
> the assignments.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> include/linux/gfp.h | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 6ecf6dda93e0..23240208a91f 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -335,8 +335,11 @@ static inline struct folio *folio_alloc_mpol_noprof(gfp_t gfp, unsigned int orde
> {
> return folio_alloc_noprof(gfp, order);
> }
> -#define vma_alloc_folio_noprof(gfp, order, vma, addr) \
> - folio_alloc_noprof(gfp, order)
> +static inline struct folio *vma_alloc_folio_noprof(gfp_t gfp, int order,
> + struct vm_area_struct *vma, unsigned long addr)
> +{
> + return folio_alloc_noprof(gfp, order);
> +}
> #endif
>
> #define alloc_pages(...) alloc_hooks(alloc_pages_noprof(__VA_ARGS__))
> --
> 2.39.5
The changes look good to me.
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
--
Best Regards,
Yan, Zi