All of lore.kernel.org
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: Muchun Song <muchun.song@linux.dev>,
	Muchun Song <songmuchun@bytedance.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Rapoport <rppt@kernel.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	David Hildenbrand <david@kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Ritesh Harjani <ritesh.list@gmail.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
	Pavithra Prakash <pavrampu@linux.ibm.com>,
	Lance Yang <lance.yang@linux.dev>, Qi Zheng <qi.zheng@linux.dev>,
	linux-mm@kvack.org, Chris Down <chris@chrisdown.name>
Subject: Re: [PATCH v2 5/7] powerpc/mm: remove radix-specific vmemmap PMD overrides
Date: Sat, 5 Dec 2026 12:50:37 +0800	[thread overview]
Message-ID: <5A9EE026-3EF6-4013-B77A-F5D53E705D5F@linux.dev> (raw)
In-Reply-To: <sashiko-outbox-251034@kernel.org>



> On Dec 5, 2026, at 12:01, sashiko-bot@kernel.org wrote:
> 
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] powerpc/mm: generic vmemmap_set_pmd() triggers DEBUG_VIRTUAL
>  WARN_ON
> --
> 
> commit a9504cd665757ddc46e5e09b6e4346110cc1bfe2
> Author: Muchun Song <muchun.song@linux.dev>
> 
> powerpc/mm: remove radix-specific vmemmap PMD overrides
> 
> This commit removes the PowerPC radix-specific vmemmap_check_pmd() and
> vmemmap_set_pmd() overrides in favor of the generic helpers in
> mm/sparse-vmemmap.c, and drops the per-PTE ptesync in
> radix__vmemmap_pte_populate().
> 
>> diff --git a/arch/powerpc/mm/book3s64/radix_pgtable.c b/arch/powerpc/mm/book3s64/radix_pgtable.c
>> index 63f369d296b47..f8217de00bff3 100644
>> --- a/arch/powerpc/mm/book3s64/radix_pgtable.c
>> +++ b/arch/powerpc/mm/book3s64/radix_pgtable.c
>> @@ -978,31 +978,6 @@ int __meminit radix__vmemmap_create_mapping(unsigned long start,
> [ ... ]
>> -void __meminit vmemmap_set_pmd(pmd_t *pmdp, void *p, int node,
>> -			       unsigned long addr, unsigned long next)
>> -{
>> -	pte_t entry;
>> -	pte_t *ptep = pmdp_ptep(pmdp);
>> -
>> -	VM_BUG_ON(!IS_ALIGNED(addr, PMD_SIZE));
>> -	entry = pfn_pte(__pa(p) >> PAGE_SHIFT, PAGE_KERNEL);
>> -	set_pte_at(&init_mm, addr, ptep, entry);
>> -	asm volatile("ptesync": : :"memory");
>> -
>> -	vmemmap_verify(ptep, node, addr, next);
>> -}
> 
> [Severity: Medium]
> Can removing the PowerPC vmemmap_set_pmd() override trigger a
> CONFIG_DEBUG_VIRTUAL warning on every PMD vmemmap mapping during boot?

You're right. The bellow diff will fix this issue without affecting other
architectures.

diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 2dc0b3533c3e..eaaebb9746b5 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -434,7 +434,7 @@ int __meminit vmemmap_populate_basepages(unsigned long start, unsigned long end,
 void __weak __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,
                                      unsigned long addr, unsigned long next)
 {
-       WARN_ON_ONCE(!pmd_set_huge(pmd, virt_to_phys(p), PAGE_KERNEL));
+       WARN_ON_ONCE(!pmd_set_huge(pmd, __pa(p), PAGE_KERNEL));
 }

 int __weak __meminit vmemmap_check_pmd(pmd_t *pmd, int node,

> 
> The removed override converted p with __pa(p), whereas the generic
> vmemmap_set_pmd() in mm/sparse-vmemmap.c calls virt_to_phys(p).  On
> PowerPC, virt_to_phys() runs WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) &&
> !virt_addr_valid(address)), and virt_addr_valid() requires pfn_valid().
> 
> During early boot in sparse_init() -> sparse_metadata_init_nid(),
> __populate_section_memmap() populates vmemmap before
> sparse_init_one_section() sets SECTION_HAS_MEM_MAP, so pfn_valid()
> returns 0 for p.
> 
> With CONFIG_DEBUG_VIRTUAL enabled, this fires an unthrottled WARN_ON on
> every PMD vmemmap mapping and panics on boot when panic_on_warn is set.
> Using __pa(p) in the generic vmemmap_set_pmd(), matching
> vmemmap_pte_populate(), would avoid this regression.
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20261205032627.4745-1-songmuchun@bytedance.com?part=5



  reply	other threads:[~2026-12-05  4:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  3:26 [PATCH v2 0/7] mm: Generalize HVO vmemmap population Muchun Song
2026-12-05  3:26 ` [PATCH v2 1/7] mm/sparse-vmemmap: use page-table constructors for runtime tables Muchun Song
2026-12-05  3:26 ` [PATCH v2 2/7] mm/sparse-vmemmap: align page-table helpers with core MM Muchun Song
2026-12-05  3:26 ` [PATCH v2 3/7] mm/sparse-vmemmap: introduce vmemmap_optimizable_pte_populate Muchun Song
2026-12-05  3:26 ` [PATCH v2 4/7] mm/sparse-vmemmap: support PMD mappings spanning sections Muchun Song
2026-12-05  4:01   ` sashiko-bot
2026-12-05  4:47     ` Muchun Song
2026-12-05  3:26 ` [PATCH v2 5/7] powerpc/mm: remove radix-specific vmemmap PMD overrides Muchun Song
2026-12-05  4:01   ` sashiko-bot
2026-12-05  4:50     ` Muchun Song [this message]
2026-12-05  5:02   ` [PATCH] fixup! " Muchun Song
2026-12-05  3:26 ` [PATCH v2 6/7] powerpc/mm: fix uninitialized ZONE_DEVICE struct pages with PMDs Muchun Song
2026-12-05  3:26 ` [PATCH v2 7/7] powerpc/mm: reuse generic HVO vmemmap population 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=5A9EE026-3EF6-4013-B77A-F5D53E705D5F@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=chris@chrisdown.name \
    --cc=david@kernel.org \
    --cc=lance.yang@linux.dev \
    --cc=linux-mm@kvack.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=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.