Re: [PATCH 08/17] mm/sparse: mark memory sections present earlier
From: Muchun Song
Date: Thu Jul 16 2026 - 03:20:59 EST
> On Jul 15, 2026, at 13:08, Mike Rapoport <rppt@xxxxxxxxxx> wrote:
>
>> Upcoming HugeTLB bootmem changes need sparsemem section metadata before
>> the HugeTLB bootmem allocation path runs. The memblock ranges are marked
>> present from sparse_init(), which is called too late for that setup.
>>
>> Move the code that marks memblock ranges present into
>> mm_core_init_early(), before free_area_init() and the HugeTLB bootmem
>> setup. Rename the helper to sparse_memblock_present() to make the new
>> caller describe the sparsemem-specific initialization step.
>>
>> This is a preparatory change.
>>
>> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
>>
>> diff --git a/mm/internal.h b/mm/internal.h
>> index 8ec8b447d75e..11844b40f47a 100644
>> --- a/mm/internal.h
>> +++ b/mm/internal.h
>> @@ -960,6 +960,7 @@ void memmap_init_range(unsigned long, int, unsigned long, unsigned long,
>> * mm/sparse.c
>> */
>> #ifdef CONFIG_SPARSEMEM
>> +void sparse_memblock_present(void);
>> void sparse_init(void);
>> int sparse_index_init(unsigned long section_nr, int nid);
>>
>> @@ -997,6 +998,7 @@ static inline void __section_mark_present(struct mem_section *ms,
>> int section_nr_vmemmap_pages(unsigned long pfn, unsigned long nr_pages,
>> struct vmem_altmap *altmap, struct dev_pagemap *pgmap);
>> #else
>> +static inline void sparse_memblocks_present(void) {}
>
> Sashiko found that this fail comilation with SPARSEMEM=n.
>
> https://sashiko.dev/#/patchset/20260702093821.2740183-1-songmuchun%40bytedance.com?part=8
Thanks for the heads-up. I've noticed that as well, and
I'll have it fixed in the next version.
>
> Please build test your changes with FLATMEM and with
> SPARSEMEM_VMEMMAP=n.
No problem.
Muchun
Thanks.
>
> --
> Sincerely yours,
> Mike.