Re: [PATCH v2 14/22] mm: encode freetype flags in pageblock flags
From: Vlastimil Babka (SUSE)
Date: Mon May 11 2026 - 14:29:18 EST
On 3/20/26 19:23, Brendan Jackman wrote:
> In preparation for implementing allocation from FREETYPE_UNMAPPED lists.
>
> Since it works nicely with the existing allocator logic, and also offers
> a simple way to amortize TLB flushing costs, __GFP_UNMAPPED will be
> implemented by changing mappings at pageblock granularity. Therefore,
> encode the mapping state in the pageblock flags.
>
> Also add the necessary logic to record this from a freetype, and
> reconstruct a freetype from the pageblock flags.
>
> Signed-off-by: Brendan Jackman <jackmanb@xxxxxxxxxx>
Acked-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
nit:
> @@ -434,9 +431,20 @@ __always_inline freetype_t
> __get_pfnblock_freetype(const struct page *page, unsigned long pfn,
> bool ignore_iso)
> {
> - int mt = get_pfnblock_migratetype(page, pfn);
> + unsigned long mask = PAGEBLOCK_FREETYPE_MASK;
> + enum migratetype migratetype;
> + unsigned int ft_flags;
> + unsigned long flags;
>
> - return migrate_to_freetype(mt, 0);
> + flags = __get_pfnblock_flags_mask(page, pfn, mask);
> + ft_flags = (flags & PAGEBLOCK_FREETYPE_FLAGS_MASK) >> PB_freetype_flags;
> +
> + migratetype = flags & PAGEBLOCK_MIGRATETYPE_MASK;
> +#ifdef CONFIG_MEMORY_ISOLATION
> + if (!ignore_iso && flags & BIT(PB_migrate_isolate))
(flags & BIT(PB_migrate_isolate)) ?
> + migratetype = MIGRATE_ISOLATE;
> +#endif
> + return migrate_to_freetype(migratetype, ft_flags);
> }
>
> /**
> @@ -570,6 +578,15 @@ static void set_pageblock_migratetype(struct page *page,
> PAGEBLOCK_MIGRATETYPE_MASK | PAGEBLOCK_ISO_MASK);
> }
>
> +static inline void set_pageblock_freetype_flags(struct page *page,
> + unsigned int ft_flags)
> +{
> + unsigned int flags = ft_flags << PB_freetype_flags;
> +
> + __set_pfnblock_flags_mask(page, page_to_pfn(page), flags,
> + PAGEBLOCK_FREETYPE_FLAGS_MASK);
> +}
> +
> void __meminit init_pageblock_migratetype(struct page *page,
> enum migratetype migratetype,
> bool isolate)
> @@ -593,7 +610,7 @@ void __meminit init_pageblock_migratetype(struct page *page,
> flags |= BIT(PB_migrate_isolate);
> #endif
> __set_pfnblock_flags_mask(page, page_to_pfn(page), flags,
> - PAGEBLOCK_MIGRATETYPE_MASK | PAGEBLOCK_ISO_MASK);
> + PAGEBLOCK_FREETYPE_MASK);
> }
>
> #ifdef CONFIG_DEBUG_VM
>