[PATCH 11/49] mm: defer sparse_init() until after zone initialization
Muchun Song
muchun.song at linux.dev
Wed Apr 29 13:02:42 AEST 2026
> On Apr 28, 2026, at 15:15, Mike Rapoport <rppt at kernel.org> wrote:
>
> On Sun, Apr 05, 2026 at 08:52:02PM +0800, Muchun Song wrote:
>> According to the comment of free_area_init(), its main goal is to
>> initialise all pg_data_t and zone data. However, sparse_init() and
>> memmap_init() are aimed at allocating vmemmap pages and initializing
>> struct page respectively, which differs from the goal of free_area_init().
>> Therefore, it is reasonable to move them out of free_area_init().
>>
>> Call sparse_init() after free_area_init() to guarantee that zone data
>> structures are available when sparse_init() executes. This change is a
>> prerequisite for integrating vmemmap initialization steps and allows
>> sparse_init() to safely access zone information if needed (e.g. HVO case).
>>
>> Also, move hugetlb reservation functions (hugetlb_cma_reserve() and
>> hugetlb_bootmem_alloc()) to be after free_area_init(). This allows
>> hugetlb reservation to access zone information to ensure that contiguous
>> pages are not allocated across zone boundaries, which simplifies the
>> hugetlb code. So this is a preparation for subsequent changes.
>>
>> Signed-off-by: Muchun Song <songmuchun at bytedance.com>
>> ---
>> mm/mm_init.c | 15 ++++++++-------
>> mm/sparse.c | 3 ---
>> 2 files changed, 8 insertions(+), 10 deletions(-)
>>
>> diff --git a/mm/sparse.c b/mm/sparse.c
>> index c7f91dc2e5b5..5fe0a7e66775 100644
>> --- a/mm/sparse.c
>> +++ b/mm/sparse.c
>> @@ -406,9 +406,6 @@ void __init sparse_init(void)
>> pnum_begin = first_present_section_nr();
>> nid_begin = sparse_early_nid(__nr_to_section(pnum_begin));
>>
>> - /* Setup pageblock_order for HUGETLB_PAGE_SIZE_VARIABLE */
>> - set_pageblock_order();
>> -
>
> This does not seem related to this patch. Otherwise
Right. I will move this to the following patch as you suggested.
>
> Reviewed-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
Thanks.
>
>> for_each_present_section_nr(pnum_begin + 1, pnum_end) {
>> int nid = sparse_early_nid(__nr_to_section(pnum_end));
>>
>> --
>> 2.20.1
>>
>
> --
> Sincerely yours,
> Mike.
More information about the Linuxppc-dev
mailing list