* [PATCH 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
@ 2026-04-04 7:17 Muchun Song
2026-04-04 7:17 ` [PATCH 1/5] " Muchun Song
2026-04-04 7:35 ` [PATCH 0/5] " Muchun Song
0 siblings, 2 replies; 3+ messages in thread
From: Muchun Song @ 2026-04-04 7:17 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Huacai Chen, Paul Walmsley,
Palmer Dabbelt, Albert Ou, David S. Miller, Andreas Larsson,
Andrew Morton, David Hildenbrand
Cc: Muchun Song, Muchun Song, WANG Xuerui, Alexandre Ghiti,
Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Ryan Roberts, Kevin Brodsky,
Dev Jain, Anshuman Khandual, Yang Shi, Chaitanya S Prakash,
Yuquan Wang, Petr Tesarik, Austin Kim, Vishal Moola (Oracle),
Junhui Liu, Matthew Wilcox (Oracle), Alex Shi, Chengkaitao,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
sparclinux, linux-mm
The two weak functions vmemmap_set_pmd() and vmemmap_check_pmd() 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.
This series drops the custom implementations in arm64, riscv, loongarch,
and sparc, replacing them with the generic implementation introduced
in the first patch.
Muchun Song (5):
mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and
vmemmap_check_pmd()
arm64/mm: drop vmemmap_pmd helpers and use generic code
riscv/mm: drop vmemmap_pmd helpers and use generic code
loongarch/mm: drop vmemmap_check_pmd helper and use generic code
sparc/mm: drop vmemmap_check_pmd helper and use generic code
arch/arm64/mm/mmu.c | 14 --------------
arch/loongarch/mm/init.c | 11 -----------
arch/riscv/mm/init.c | 13 -------------
arch/sparc/mm/init_64.c | 11 -----------
mm/sparse-vmemmap.c | 7 ++++++-
5 files changed, 6 insertions(+), 50 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-04-04 7:17 [PATCH 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
@ 2026-04-04 7:17 ` Muchun Song
2026-04-04 7:35 ` [PATCH 0/5] " Muchun Song
1 sibling, 0 replies; 3+ messages in thread
From: Muchun Song @ 2026-04-04 7:17 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Muchun Song, Muchun Song, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
linux-mm, linux-kernel
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 <songmuchun@bytedance.com>
---
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 6eadb9d116e4..1eb990610d50 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -391,12 +391,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)
{
+ BUG_ON(!pmd_set_huge(pmd, virt_to_phys(p), PAGE_KERNEL));
}
int __weak __meminit vmemmap_check_pmd(pmd_t *pmd, int node,
unsigned long addr, unsigned long next)
{
- return 0;
+ if (!pmd_leaf(pmdp_get(pmd)))
+ return 0;
+ vmemmap_verify((pte_t *)pmd, node, addr, next);
+
+ return 1;
}
int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end,
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-04-04 7:17 [PATCH 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
2026-04-04 7:17 ` [PATCH 1/5] " Muchun Song
@ 2026-04-04 7:35 ` Muchun Song
1 sibling, 0 replies; 3+ messages in thread
From: Muchun Song @ 2026-04-04 7:35 UTC (permalink / raw)
To: Muchun Song
Cc: Catalin Marinas, Will Deacon, Huacai Chen, Paul Walmsley,
Palmer Dabbelt, Albert Ou, David S. Miller, Andreas Larsson,
Andrew Morton, David Hildenbrand, WANG Xuerui, Alexandre Ghiti,
Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Ryan Roberts, Kevin Brodsky,
Dev Jain, Anshuman Khandual, Yang Shi, Chaitanya S Prakash,
Yuquan Wang, Petr Tesarik, Austin Kim, Vishal Moola (Oracle),
Junhui Liu, Matthew Wilcox (Oracle), Alex Shi, Chengkaitao,
linux-arm-kernel, linux-kernel, loongarch, linux-riscv,
sparclinux, linux-mm
> On Apr 4, 2026, at 15:17, Muchun Song <songmuchun@bytedance.com> wrote:
>
> The two weak functions vmemmap_set_pmd() and vmemmap_check_pmd() 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.
>
> This series drops the custom implementations in arm64, riscv, loongarch,
> and sparc, replacing them with the generic implementation introduced
> in the first patch.
>
> Muchun Song (5):
> mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and
> vmemmap_check_pmd()
> arm64/mm: drop vmemmap_pmd helpers and use generic code
> riscv/mm: drop vmemmap_pmd helpers and use generic code
> loongarch/mm: drop vmemmap_check_pmd helper and use generic code
> sparc/mm: drop vmemmap_check_pmd helper and use generic code
Hi all,
Please accept my sincere apologies for the mailing list noise.
Due to an error in my local scripts (failing to clean up the patch
output directory before regenerating the series with an updated commit
range), multiple duplicate and conflicting patches were accidentally
sent to the list simultaneously (10 patches in total instead of the
intended 5).
Sorry again for the inconvenience.
Thanks,
Muchun
>
> arch/arm64/mm/mmu.c | 14 --------------
> arch/loongarch/mm/init.c | 11 -----------
> arch/riscv/mm/init.c | 13 -------------
> arch/sparc/mm/init_64.c | 11 -----------
> mm/sparse-vmemmap.c | 7 ++++++-
> 5 files changed, 6 insertions(+), 50 deletions(-)
>
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-04 7:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-04 7:17 [PATCH 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
2026-04-04 7:17 ` [PATCH 1/5] " Muchun Song
2026-04-04 7:35 ` [PATCH 0/5] " Muchun Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox