> On Dec 2, 2026, at 21:35, Lance Yang <[email protected]> wrote:
>
>
> On Tue, Dec 01, 2026 at 07:56:45PM +0800, Muchun Song wrote:
>> Runtime page-table pages are expected to pass through matching
>> constructors and destructors. The generic sparse-vmemmap path instead
>> allocates intermediate tables with vmemmap_alloc_block(), leaving even
>> runtime tables constructor-free.
>>
>> This mixed lifecycle has already required NR_PAGETABLE teardown fixes on
>> x86-64, arm64, and RISC-V. Use the standard page-table allocators once
>> slab is available, while retaining memblock allocation for early tables.
>
> Nice cleanup!
>
>> Signed-off-by: Muchun Song <[email protected]>
>> ---
>> mm/sparse-vmemmap.c | 90 ++++++++++++++++++++++++++++++---------------
>> 1 file changed, 60 insertions(+), 30 deletions(-)
>>
>> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
>> index 51fa77982ca5..5224eb4d8cf0 100644
>> --- a/mm/sparse-vmemmap.c
>> +++ b/mm/sparse-vmemmap.c
>> @@ -150,17 +150,6 @@ int __meminit section_nr_vmemmap_pages(unsigned long
>> pfn, unsigned long nr_pages
>> return 0;
>> }
>>
>> -static void * __meminit vmemmap_alloc_block_zero(unsigned long size, int
>> node)
>> -{
>> - void *p = vmemmap_alloc_block(size, node);
>> -
>> - if (!p)
>> - return NULL;
>> - memset(p, 0, size);
>> -
>> - return p;
>> -}
>> -
>> #ifdef CONFIG_VMEMMAP_OPTIMIZATION
>> #define VMEMMAP_OPTIMIZATION_NR_ORDERS (MAX_FOLIO_ORDER -
>> VMEMMAP_OPTIMIZATION_MIN_ORDER + 1)
>>
>> @@ -317,15 +306,32 @@ static pte_t * __meminit vmemmap_pte_populate(pmd_t
>> *pmd, unsigned long addr, in
>> return pte;
>> }
>>
>> +static __ref void *vmemmap_pgtable_alloc(int node)
>> +{
>> + void *pgtable = memblock_alloc_try_nid_raw(PAGE_SIZE, PAGE_SIZE,
>> + __pa(MAX_DMA_ADDRESS),
>> +
>> MEMBLOCK_ALLOC_NOLEAKTRACE,
>> + node);
>> + if (!pgtable)
>> + panic("Failed to allocate page table for vmemmap\n");
>> + memset(pgtable, 0, PAGE_SIZE);
>
> Can we use memblock_alloc_try_nid() here? It already zeroes the page,
> so memset() can go :D
Yeah, good point.
>
> Nothing else jumped out at me, so, feel free to add:
>
> Reviewed-by: Lance Yang <[email protected]>
Thanks.