Re: [PATCH 1/2] mm: Move default_gfp() into gfp_types.h
From: Vlastimil Babka (SUSE)
Date: Tue Sep 15 2026 - 02:57:43 EST
On 9/15/26 00:32, Kees Cook wrote:
> Using default_gfp() only depends on the GFP_KERNEL value. Move
> default_gfp() into gfp_types.h so that future use in devres.h doesn't
> require pulling in all of gfp.h.
>
> Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
Incidentally I was thinking if default_gfp(...) usage should be extended
also for the legacy kmalloc() API. Because it's going to still have users,
buffers are needed for many things that are not objects (structs). Mike is
converting many unnecessary page allocator usages to kmalloc(PAGE_SIZE, ...)
often with GFP_KERNEL, so that would be neater too...
> ---
> Cc: Lorenzo Stoakes <ljs@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: David Hildenbrand <david@xxxxxxxxxx>
> Cc: "Liam R. Howlett" <liam@xxxxxxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxxxxx>
> Cc: Mike Rapoport <rppt@xxxxxxxxxx>
> Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxx>
> Cc: Brendan Jackman <brendan.jackman@xxxxxxxxx>
> Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
> Cc: Zi Yan <ziy@xxxxxxxxxx>
> Cc: <linux-mm@xxxxxxxxx>
> ---
> include/linux/gfp.h | 4 ----
> include/linux/gfp_types.h | 4 ++++
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index 872bc53f32ec..b62e2fd53cb4 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -13,10 +13,6 @@
> struct vm_area_struct;
> struct mempolicy;
>
> -/* Helper macro to avoid gfp flags if they are the default one */
> -#define __default_gfp(a,b,...) b
> -#define default_gfp(...) __default_gfp(,##__VA_ARGS__,GFP_KERNEL)
> -
> static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
> {
> return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
> diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h
> index 190191411009..b1cd143f3c42 100644
> --- a/include/linux/gfp_types.h
> +++ b/include/linux/gfp_types.h
> @@ -382,4 +382,8 @@ enum {
> __GFP_NOMEMALLOC | __GFP_NOWARN) & ~__GFP_RECLAIM)
> #define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM)
>
> +/* Helper macro to avoid gfp flags if they are the default one */
> +#define __default_gfp(a,b,...) b
> +#define default_gfp(...) __default_gfp(,##__VA_ARGS__,GFP_KERNEL)
> +
> #endif /* __LINUX_GFP_TYPES_H */