Re: [PATCH 07/49] mm/mm_init: use pageblock_migratetype_init_range() in deferred_free_pages()

Muchun Song
2026-04-14T03:00:51Z

> On Apr 14, 2026, at 02:54, David Hildenbrand (Arm) <david@kernel.org> wrote:
>
> On 4/5/26 14:51, Muchun Song wrote:
>> Simplify deferred_free_pages by replacing the duplicate loops for
>> initializing pageblock migratetype with a call to
>> pageblock_migratetype_init_range to simplify the code.
>
> "Simplify ... to simplify the code."
>
> Likely you can drop the last part.

OK. I'll rewrite the message.

>
>>
>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>> ---
>> mm/mm_init.c | 13 ++++---------
>> 1 file changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/mm/mm_init.c b/mm/mm_init.c
>> index 4936ca78966c..a92c5053f63d 100644
>> --- a/mm/mm_init.c
>> +++ b/mm/mm_init.c
>> @@ -1974,13 +1974,12 @@ static void __init deferred_free_pages(unsigned long pfn,
>> if (!nr_pages)
>> return;
>>
>> + pageblock_migratetype_init_range(pfn, nr_pages, MIGRATE_MOVABLE);
>
>
> pageblock_migratetype_init_range() will align the PFN up to the next
> pageblock.

IIUC, pageblock_align(pfn) is to **round up** PFN to the next multiple of
pageblock_nr_pages.

>
> Are we sure the range we are getting called with is always aligned to
> pageblocks, such that we won't miss to initialize the first pageblock?

That means if pageblock_aligned(pfn) == 1, then the result of
pageblock_align(pfn) is the pfn itself.

So there is no problem as you said.

Thanks,
Muchun.

>
> --
> Cheers,
>
> David