Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: Lance Yang <lance.yang@linux.dev>
Cc: Muchun Song <muchun.song@linux.dev>,
	Muchun Song <songmuchun@bytedance.com>,
	akpm@linux-foundation.org, Mike Rapoport <rppt@kernel.org>,
	maddy@linux.ibm.com, David Hildenbrand <david@kernel.org>,
	mpe@ellerman.id.au, ritesh.list@gmail.com,
	aneesh.kumar@linux.ibm.com, pavrampu@linux.ibm.com,
	Qi Zheng <qi.zheng@linux.dev>,
	linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/7] mm/sparse-vmemmap: use page-table constructors for runtime tables
Date: Thu, 3 Dec 2026 10:04:50 +0800	[thread overview]
Message-ID: <2E3B3B9D-7906-4395-920E-136C3AFBADCF@linux.dev> (raw)
In-Reply-To: <20261202133502.78002-1-lance.yang@linux.dev>



> On Dec 2, 2026, at 21:35, Lance Yang <lance.yang@linux.dev> 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 <songmuchun@bytedance.com>
>> ---
>> 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 <lance.yang@linux.dev>

Thanks.



  reply	other threads:[~2026-12-03  2:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 11:56 [PATCH 0/7] mm: Generalize HVO vmemmap population Muchun Song
2026-12-01 11:56 ` [PATCH 1/7] mm/sparse-vmemmap: use page-table constructors for runtime tables Muchun Song
2026-12-02 13:35   ` Lance Yang
2026-12-03  2:04     ` Muchun Song [this message]
2026-12-01 11:56 ` [PATCH 2/7] mm/sparse-vmemmap: align page-table helpers with core MM Muchun Song
2026-12-02 13:55   ` Lance Yang
2026-12-01 11:56 ` [PATCH 3/7] mm/sparse-vmemmap: introduce vmemmap_optimizable_pte_populate Muchun Song
2026-12-02 22:56   ` Chris Down
2026-12-03  1:58     ` Muchun Song
2026-12-01 11:56 ` [PATCH 4/7] mm/sparse-vmemmap: support PMD mappings spanning sections Muchun Song
2026-12-01 11:56 ` [PATCH 5/7] powerpc/mm: fix uninitialized ZONE_DEVICE struct pages with PMDs Muchun Song
2026-12-01 11:56 ` [PATCH 6/7] powerpc/mm: remove radix-specific vmemmap PMD overrides Muchun Song
2026-12-01 11:56 ` [PATCH 7/7] powerpc/mm: reuse generic HVO vmemmap population Muchun Song
2026-12-02 22:56 ` [PATCH 0/7] mm: Generalize " Chris Down
2026-12-03  2:07   ` Muchun Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2E3B3B9D-7906-4395-920E-136C3AFBADCF@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=david@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=pavrampu@linux.ibm.com \
    --cc=qi.zheng@linux.dev \
    --cc=ritesh.list@gmail.com \
    --cc=rppt@kernel.org \
    --cc=songmuchun@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox