* [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
@ 2026-06-01 8:48 Muchun Song
2026-06-01 8:48 ` [PATCH v3 1/5] mm/sparse-vmemmap: provide " Muchun Song
` (4 more replies)
0 siblings, 5 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 8:48 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
The weak vmemmap_set_pmd() and vmemmap_check_pmd() hooks are
currently no-ops in the generic code, which leaves architectures that
need PMD-level handling to open-code the same logic locally.
This series provides generic implementations for both helpers in
mm/sparse-vmemmap.c. vmemmap_set_pmd() installs a huge PMD with
PAGE_KERNEL protection, and vmemmap_check_pmd() verifies a present
leaf PMD before reusing the existing vmemmap_verify() helper.
With those generic helpers in place, patches 2-5 remove the now
redundant arch-specific implementations from arm64, riscv, loongarch,
and sparc.
v2 -> v3:
- Replace BUG_ON() with WARN_ON_ONCE() in patch 1
- Add Will Deacon's Acked-by to patch 2
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(-)
base-commit: 7da7f07112610a520567421dd2ffcb51beaefbcc
--
2.54.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-06-01 8:48 [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
@ 2026-06-01 8:48 ` Muchun Song
2026-06-01 12:22 ` David Hildenbrand (Arm)
2026-06-02 4:41 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
` (3 subsequent siblings)
4 siblings, 2 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 8:48 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
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>
---
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));
}
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.54.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code
2026-06-01 8:48 [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
2026-06-01 8:48 ` [PATCH v3 1/5] mm/sparse-vmemmap: provide " Muchun Song
@ 2026-06-01 8:48 ` Muchun Song
2026-06-01 12:23 ` David Hildenbrand (Arm)
2026-06-02 4:42 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 3/5] riscv/mm: " Muchun Song
` (2 subsequent siblings)
4 siblings, 2 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 8:48 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
The generic implementations now suffice; remove the arm64 copies.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Will Deacon <will@kernel.org>
---
v2->v3:
- Collect Acked-by from Will Deacon
---
arch/arm64/mm/mmu.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 24388e5c727d..ea10b0ebecd7 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1776,20 +1776,6 @@ static void free_empty_tables(unsigned long addr, unsigned long end,
}
#endif
-void __meminit vmemmap_set_pmd(pmd_t *pmdp, void *p, int node,
- unsigned long addr, unsigned long next)
-{
- pmd_set_huge(pmdp, __pa(p), __pgprot(PROT_SECT_NORMAL));
-}
-
-int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
- unsigned long addr, unsigned long next)
-{
- vmemmap_verify((pte_t *)pmdp, node, addr, next);
-
- return pmd_leaf(READ_ONCE(*pmdp));
-}
-
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
struct vmem_altmap *altmap)
{
--
2.54.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 3/5] riscv/mm: drop vmemmap_pmd helpers and use generic code
2026-06-01 8:48 [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
2026-06-01 8:48 ` [PATCH v3 1/5] mm/sparse-vmemmap: provide " Muchun Song
2026-06-01 8:48 ` [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
@ 2026-06-01 8:48 ` Muchun Song
2026-06-01 12:23 ` David Hildenbrand (Arm)
2026-06-02 4:44 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper " Muchun Song
2026-06-01 8:48 ` [PATCH v3 5/5] sparc/mm: " Muchun Song
4 siblings, 2 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 8:48 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
The generic implementations now suffice; remove the riscv copies.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
arch/riscv/mm/init.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 885f1db4e9bf..5f680eb83e86 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1359,19 +1359,6 @@ void __init misc_mem_init(void)
}
#ifdef CONFIG_SPARSEMEM_VMEMMAP
-void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,
- unsigned long addr, unsigned long next)
-{
- pmd_set_huge(pmd, virt_to_phys(p), PAGE_KERNEL);
-}
-
-int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
- unsigned long addr, unsigned long next)
-{
- vmemmap_verify((pte_t *)pmdp, node, addr, next);
- return 1;
-}
-
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
struct vmem_altmap *altmap)
{
--
2.54.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 8:48 [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
` (2 preceding siblings ...)
2026-06-01 8:48 ` [PATCH v3 3/5] riscv/mm: " Muchun Song
@ 2026-06-01 8:48 ` Muchun Song
2026-06-01 12:24 ` David Hildenbrand (Arm)
2026-06-02 4:45 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 5/5] sparc/mm: " Muchun Song
4 siblings, 2 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 8:48 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
The generic implementations now suffice; remove the loongarch copies.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
arch/loongarch/mm/init.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c
index 687980b6e91f..3407030f3e7a 100644
--- a/arch/loongarch/mm/init.c
+++ b/arch/loongarch/mm/init.c
@@ -140,17 +140,6 @@ void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,
set_pmd_at(&init_mm, addr, pmd, entry);
}
-int __meminit vmemmap_check_pmd(pmd_t *pmd, int node,
- unsigned long addr, unsigned long next)
-{
- int huge = pmd_val(pmdp_get(pmd)) & _PAGE_HUGE;
-
- if (huge)
- vmemmap_verify((pte_t *)pmd, node, addr, next);
-
- return huge;
-}
-
int __meminit vmemmap_populate(unsigned long start, unsigned long end,
int node, struct vmem_altmap *altmap)
{
--
2.54.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v3 5/5] sparc/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 8:48 [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
` (3 preceding siblings ...)
2026-06-01 8:48 ` [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper " Muchun Song
@ 2026-06-01 8:48 ` Muchun Song
2026-06-01 12:25 ` David Hildenbrand (Arm)
2026-06-02 4:46 ` Oscar Salvador (SUSE)
4 siblings, 2 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 8:48 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
The generic implementations now suffice; remove the sparc copies.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
arch/sparc/mm/init_64.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 3b679b1d1d72..103db4683b16 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -2559,17 +2559,6 @@ void __meminit vmemmap_set_pmd(pmd_t *pmd, void *p, int node,
pmd_val(*pmd) = pte_base | __pa(p);
}
-int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
- unsigned long addr, unsigned long next)
-{
- int large = pmd_leaf(*pmdp);
-
- if (large)
- vmemmap_verify((pte_t *)pmdp, node, addr, next);
-
- return large;
-}
-
int __meminit vmemmap_populate(unsigned long vstart, unsigned long vend,
int node, struct vmem_altmap *altmap)
{
--
2.54.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-06-01 8:48 ` [PATCH v3 1/5] mm/sparse-vmemmap: provide " Muchun Song
@ 2026-06-01 12:22 ` David Hildenbrand (Arm)
2026-06-01 12:37 ` Muchun Song
2026-06-02 4:41 ` Oscar Salvador (SUSE)
1 sibling, 1 reply; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-01 12:22 UTC (permalink / raw)
To: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
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 <songmuchun@bytedance.com>
> ---
> 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) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code
2026-06-01 8:48 ` [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
@ 2026-06-01 12:23 ` David Hildenbrand (Arm)
2026-06-02 4:42 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-01 12:23 UTC (permalink / raw)
To: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
On 6/1/26 10:48, Muchun Song wrote:
> The generic implementations now suffice; remove the arm64 copies.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> Acked-by: Will Deacon <will@kernel.org>
> ---
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/5] riscv/mm: drop vmemmap_pmd helpers and use generic code
2026-06-01 8:48 ` [PATCH v3 3/5] riscv/mm: " Muchun Song
@ 2026-06-01 12:23 ` David Hildenbrand (Arm)
2026-06-02 4:44 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-01 12:23 UTC (permalink / raw)
To: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
On 6/1/26 10:48, Muchun Song wrote:
> The generic implementations now suffice; remove the riscv copies.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 8:48 ` [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper " Muchun Song
@ 2026-06-01 12:24 ` David Hildenbrand (Arm)
2026-06-01 12:26 ` Muchun Song
2026-06-02 4:45 ` Oscar Salvador (SUSE)
1 sibling, 1 reply; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-01 12:24 UTC (permalink / raw)
To: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
On 6/1/26 10:48, Muchun Song wrote:
> The generic implementations now suffice; remove the loongarch copies.
You are only removing a single function? So "copy"
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 5/5] sparc/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 8:48 ` [PATCH v3 5/5] sparc/mm: " Muchun Song
@ 2026-06-01 12:25 ` David Hildenbrand (Arm)
2026-06-02 4:46 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-01 12:25 UTC (permalink / raw)
To: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller
Cc: Muchun Song, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
On 6/1/26 10:48, Muchun Song wrote:
> The generic implementations now suffice; remove the sparc copies.
"copy"
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 12:24 ` David Hildenbrand (Arm)
@ 2026-06-01 12:26 ` Muchun Song
0 siblings, 0 replies; 19+ messages in thread
From: Muchun Song @ 2026-06-01 12:26 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
> On Jun 1, 2026, at 20:24, David Hildenbrand (Arm) <david@kernel.org> wrote:
>
> On 6/1/26 10:48, Muchun Song wrote:
>> The generic implementations now suffice; remove the loongarch copies.
>
> You are only removing a single function? So "copy"
Yes. I copied the commit message from other commit and forgot to update
accordingly.
>
>
> Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Thanks.
>
> --
> Cheers,
>
> David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-06-01 12:22 ` David Hildenbrand (Arm)
@ 2026-06-01 12:37 ` Muchun Song
2026-06-02 4:40 ` Oscar Salvador (SUSE)
0 siblings, 1 reply; 19+ messages in thread
From: Muchun Song @ 2026-06-01 12:37 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Muchun Song, Andrew Morton, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, linux-mm, linux-kernel, linux-arm-kernel,
linux-riscv, loongarch, sparclinux, Alexandre Ghiti, Albert Ou,
WANG Xuerui, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko
> On Jun 1, 2026, at 20:22, David Hildenbrand (Arm) <david@kernel.org> wrote:
>
> 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 <songmuchun@bytedance.com>
>> ---
>> 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).
I think it might be better to keep WARN_ON_ONCE here. This way, we can still
monitor for warnings in production while keeping the code simple.
>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Thanks.
>
>
> --
> Cheers,
>
> David
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-06-01 12:37 ` Muchun Song
@ 2026-06-02 4:40 ` Oscar Salvador (SUSE)
0 siblings, 0 replies; 19+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02 4:40 UTC (permalink / raw)
To: Muchun Song
Cc: David Hildenbrand (Arm), Muchun Song, Andrew Morton,
Catalin Marinas, Will Deacon, Palmer Dabbelt, Paul Walmsley,
Huacai Chen, Andreas Larsson, David S. Miller, linux-mm,
linux-kernel, linux-arm-kernel, linux-riscv, loongarch,
sparclinux, Alexandre Ghiti, Albert Ou, WANG Xuerui,
Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Mon, Jun 01, 2026 at 08:37:42PM +0800, Muchun Song wrote:
>
>
> > On Jun 1, 2026, at 20:22, David Hildenbrand (Arm) <david@kernel.org> wrote:
> >
> > 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 <songmuchun@bytedance.com>
> >> ---
> >> 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).
>
> I think it might be better to keep WARN_ON_ONCE here. This way, we can still
> monitor for warnings in production while keeping the code simple.
IIRC there was a discussion about this some time ago, given the fact that quite
some people out there tend to have 'panic_on_warn', but then again, if we fail to
set a PMD here it means something pretty nasty happened, so I am ok with that.
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
2026-06-01 8:48 ` [PATCH v3 1/5] mm/sparse-vmemmap: provide " Muchun Song
2026-06-01 12:22 ` David Hildenbrand (Arm)
@ 2026-06-02 4:41 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02 4:41 UTC (permalink / raw)
To: Muchun Song
Cc: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Mon, Jun 01, 2026 at 04:48:40PM +0800, 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 <songmuchun@bytedance.com>
Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code
2026-06-01 8:48 ` [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
2026-06-01 12:23 ` David Hildenbrand (Arm)
@ 2026-06-02 4:42 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02 4:42 UTC (permalink / raw)
To: Muchun Song
Cc: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Mon, Jun 01, 2026 at 04:48:41PM +0800, Muchun Song wrote:
> The generic implementations now suffice; remove the arm64 copies.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> Acked-by: Will Deacon <will@kernel.org>
Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
> ---
> v2->v3:
> - Collect Acked-by from Will Deacon
> ---
> arch/arm64/mm/mmu.c | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 24388e5c727d..ea10b0ebecd7 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1776,20 +1776,6 @@ static void free_empty_tables(unsigned long addr, unsigned long end,
> }
> #endif
>
> -void __meminit vmemmap_set_pmd(pmd_t *pmdp, void *p, int node,
> - unsigned long addr, unsigned long next)
> -{
> - pmd_set_huge(pmdp, __pa(p), __pgprot(PROT_SECT_NORMAL));
> -}
> -
> -int __meminit vmemmap_check_pmd(pmd_t *pmdp, int node,
> - unsigned long addr, unsigned long next)
> -{
> - vmemmap_verify((pte_t *)pmdp, node, addr, next);
> -
> - return pmd_leaf(READ_ONCE(*pmdp));
> -}
> -
> int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
> struct vmem_altmap *altmap)
> {
> --
> 2.54.0
>
>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/5] riscv/mm: drop vmemmap_pmd helpers and use generic code
2026-06-01 8:48 ` [PATCH v3 3/5] riscv/mm: " Muchun Song
2026-06-01 12:23 ` David Hildenbrand (Arm)
@ 2026-06-02 4:44 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02 4:44 UTC (permalink / raw)
To: Muchun Song
Cc: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Mon, Jun 01, 2026 at 04:48:42PM +0800, Muchun Song wrote:
> The generic implementations now suffice; remove the riscv copies.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 8:48 ` [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper " Muchun Song
2026-06-01 12:24 ` David Hildenbrand (Arm)
@ 2026-06-02 4:45 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02 4:45 UTC (permalink / raw)
To: Muchun Song
Cc: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Mon, Jun 01, 2026 at 04:48:43PM +0800, Muchun Song wrote:
> The generic implementations now suffice; remove the loongarch copies.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 5/5] sparc/mm: drop vmemmap_check_pmd helper and use generic code
2026-06-01 8:48 ` [PATCH v3 5/5] sparc/mm: " Muchun Song
2026-06-01 12:25 ` David Hildenbrand (Arm)
@ 2026-06-02 4:46 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 19+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-02 4:46 UTC (permalink / raw)
To: Muchun Song
Cc: Andrew Morton, David Hildenbrand, Catalin Marinas, Will Deacon,
Palmer Dabbelt, Paul Walmsley, Huacai Chen, Andreas Larsson,
David S. Miller, Muchun Song, linux-mm, linux-kernel,
linux-arm-kernel, linux-riscv, loongarch, sparclinux,
Alexandre Ghiti, Albert Ou, WANG Xuerui, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko
On Mon, Jun 01, 2026 at 04:48:44PM +0800, Muchun Song wrote:
> The generic implementations now suffice; remove the sparc copies.
>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2026-06-02 4:47 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-01 8:48 [PATCH v3 0/5] mm/sparse-vmemmap: Provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
2026-06-01 8:48 ` [PATCH v3 1/5] mm/sparse-vmemmap: provide " Muchun Song
2026-06-01 12:22 ` David Hildenbrand (Arm)
2026-06-01 12:37 ` Muchun Song
2026-06-02 4:40 ` Oscar Salvador (SUSE)
2026-06-02 4:41 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
2026-06-01 12:23 ` David Hildenbrand (Arm)
2026-06-02 4:42 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 3/5] riscv/mm: " Muchun Song
2026-06-01 12:23 ` David Hildenbrand (Arm)
2026-06-02 4:44 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 4/5] loongarch/mm: drop vmemmap_check_pmd helper " Muchun Song
2026-06-01 12:24 ` David Hildenbrand (Arm)
2026-06-01 12:26 ` Muchun Song
2026-06-02 4:45 ` Oscar Salvador (SUSE)
2026-06-01 8:48 ` [PATCH v3 5/5] sparc/mm: " Muchun Song
2026-06-01 12:25 ` David Hildenbrand (Arm)
2026-06-02 4:46 ` Oscar Salvador (SUSE)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox