Re: [PATCH v3 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
"David Hildenbrand (Arm)" <[email protected]> Mon, 1 Jun 2026 14:22:52 +0200
| Newsgroups | org.kernel.vger.sparclinux,dev.linux.lists.loongarch,org.infradead.lists.linux-arm-kernel,org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On 6/1/26 10:48, Muchun Song wrote: > The two weak functions are currently no-ops on every architecture, > forcing each platform that needs them to duplicate the same handful > of lines. Provide a generic implementation: > > - vmemmap_set_pmd() simply sets a huge PMD with PAGE_KERNEL protection. > > - vmemmap_check_pmd() verifies that the PMD is present and leaf, > then calls the existing vmemmap_verify() helper. > > Architectures that need special handling can continue to override the > weak symbols; everyone else gets the standard version for free. > > Signed-off-by: Muchun Song <[email protected]> > --- > v2->v3: > - Replace BUG_ON() with WARN_ON_ONCE() in vmemmap_set_pmd() > --- > mm/sparse-vmemmap.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c > index 112ccf9c71ca..99e2be39671b 100644 > --- a/mm/sparse-vmemmap.c > +++ b/mm/sparse-vmemmap.c > @@ -386,12 +386,17 @@ int __meminit vmemmap_populate_hvo(unsigned long addr, 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)); Not sure if a VM_WARN_ON_ONCE() would be appropriate. (then, we have to move the pmd_set_huge() out of the statement). Acked-by: David Hildenbrand (Arm) <[email protected]> -- Cheers, David