Re: [PATCH v2 10/22] mm: introduce freetype_t

From: Brendan Jackman

Date: Mon May 11 2026 - 12:56:39 EST


On Mon May 11, 2026 at 3:34 PM UTC, Vlastimil Babka (SUSE) wrote:
>> +/**
>> + * __get_pfnblock_freetype - Return the freetype of a pageblock, optionally
>> + * ignoring the fact that it's currently isolated.
>> + * @page: The page within the block of interest
>> + * @pfn: The target page frame number
>> + * @ignore_iso: If isolated, return the migratetype that the block had before
>> + * isolation.
>> + */
>> +__always_inline freetype_t
>
> 'static' too?

Yup thanks

>
>> +__get_pfnblock_freetype(const struct page *page, unsigned long pfn,
>> + bool ignore_iso)
>> +{
>> + int mt = get_pfnblock_migratetype(page, pfn);
>> +
>> + return migrate_to_freetype(mt, 0);
>> +}
>> +
>> +/**
>> + * get_pfnblock_migratetype - Return the freetype of a pageblock
>> + * @page: The page within the block of interest
>> + * @pfn: The target page frame number
>> + *
>> + * Return: The freetype of the pageblock
>> + */
>> +__always_inline freetype_t
>
> And this is declared in a header so the __always_inline is not really
> applicable?

> (seems we should fix up get_pfnblock_migratetype too)

Um, I think it probably still forces inlining in calls within the same
translation unit?

Anyway I am pretty meh about this, I suspect humans and compilers are
equally bad at making this decision, I was just trying to be consistent
with the code it's replacing.

>> + /*
>> + * Fallback to different migratetypes, but currently always with
>> + * the same freetype flags.
>> + */
>> + freetype_t fallback_ft = freetype_with_migrate(freetype, fallback_mt);
>>
>> - if (!free_area_empty(area, fallback_mt)) {
>> - if (mt_out)
>> - *mt_out = fallback_mt;
>> + if (freetype_idx(fallback_ft) < 0)
>> + continue;
>
> How can this happen? Is it preparatory?

Oops, yeah looks like I need to clean up how this happens in the
history and clarify the commit messages.

In a later patch I add an optimisation where we avoid having freelists
for freetypes that never arise in practice. And in those cases
freetype_idx() returns -1.