Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
@ 2026-04-04 12:20 Muchun Song
  2026-04-04 12:20 ` [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
  2026-06-26  8:21 ` [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() patchwork-bot+linux-riscv
  0 siblings, 2 replies; 5+ messages in thread
From: Muchun Song @ 2026-04-04 12:20 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: linux-mm, 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,
	Petr Tesarik, Vishal Moola (Oracle), Junhui Liu, Austin Kim,
	Chengkaitao, Matthew Wilcox (Oracle), Alex Shi, linux-arm-kernel,
	linux-kernel, loongarch, linux-riscv, sparclinux

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.

v1 -> v2:
- Fixed a tooling issue in v1 where duplicate/conflicting patches
  were incorrectly sent to the mailing list. No code changes compared
  to the intended v1.


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] 5+ messages in thread

* [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code
  2026-04-04 12:20 [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
@ 2026-04-04 12:20 ` Muchun Song
  2026-05-18 12:33   ` Will Deacon
  2026-06-26  8:21 ` [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() patchwork-bot+linux-riscv
  1 sibling, 1 reply; 5+ messages in thread
From: Muchun Song @ 2026-04-04 12:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: linux-mm, akpm, Muchun Song, Muchun Song, Ryan Roberts,
	David Hildenbrand, Kevin Brodsky, Dev Jain, Lorenzo Stoakes,
	Anshuman Khandual, Yang Shi, Chaitanya S Prakash,
	linux-arm-kernel, linux-kernel

The generic implementations now suffice; remove the arm64 copies.

Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 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 ec1c6971a561..b87053452641 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1745,20 +1745,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_sect(READ_ONCE(*pmdp));
-}
-
 int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
 		struct vmem_altmap *altmap)
 {
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code
  2026-04-04 12:20 ` [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
@ 2026-05-18 12:33   ` Will Deacon
  2026-05-19  6:15     ` Muchun Song
  0 siblings, 1 reply; 5+ messages in thread
From: Will Deacon @ 2026-05-18 12:33 UTC (permalink / raw)
  To: Muchun Song
  Cc: Catalin Marinas, linux-mm, akpm, Muchun Song, Ryan Roberts,
	David Hildenbrand, Kevin Brodsky, Dev Jain, Lorenzo Stoakes,
	Anshuman Khandual, Yang Shi, Chaitanya S Prakash,
	linux-arm-kernel, linux-kernel

On Sat, Apr 04, 2026 at 08:20:55PM +0800, Muchun Song wrote:
> The generic implementations now suffice; remove the arm64 copies.
> 
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  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 ec1c6971a561..b87053452641 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -1745,20 +1745,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_sect(READ_ONCE(*pmdp));
> -}

I think this is fine:

Acked-by: Will Deacon <will@kernel.org>

but note that, since c25c4aa3f79a ("arm64: mm: Add PTE_DIRTY back to
PAGE_KERNEL* to fix kexec/hibernation"), I think that using PAGE_KERNEL
(like the generic code does in the first patch of this series) means
that this change isn't a no-op -- it means that the huge entries will
now be marked as dirty. That's possibly a bug fix (?)

Will


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code
  2026-05-18 12:33   ` Will Deacon
@ 2026-05-19  6:15     ` Muchun Song
  0 siblings, 0 replies; 5+ messages in thread
From: Muchun Song @ 2026-05-19  6:15 UTC (permalink / raw)
  To: Will Deacon
  Cc: Muchun Song, Catalin Marinas, linux-mm, akpm, Ryan Roberts,
	David Hildenbrand, Kevin Brodsky, Dev Jain, Lorenzo Stoakes,
	Anshuman Khandual, Yang Shi, Chaitanya S Prakash,
	linux-arm-kernel, linux-kernel



> On May 18, 2026, at 20:33, Will Deacon <will@kernel.org> wrote:
> 
> On Sat, Apr 04, 2026 at 08:20:55PM +0800, Muchun Song wrote:
>> The generic implementations now suffice; remove the arm64 copies.
>> 
>> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
>> ---
>> 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 ec1c6971a561..b87053452641 100644
>> --- a/arch/arm64/mm/mmu.c
>> +++ b/arch/arm64/mm/mmu.c
>> @@ -1745,20 +1745,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_sect(READ_ONCE(*pmdp));
>> -}
> 
> I think this is fine:
> 
> Acked-by: Will Deacon <will@kernel.org>

Thanks.

> 
> but note that, since c25c4aa3f79a ("arm64: mm: Add PTE_DIRTY back to
> PAGE_KERNEL* to fix kexec/hibernation"), I think that using PAGE_KERNEL
> (like the generic code does in the first patch of this series) means
> that this change isn't a no-op -- it means that the huge entries will
> now be marked as dirty. That's possibly a bug fix (?)

I think you are right. We should mark kernel mapping as dirty.

Thanks,
Muchun

> 
> Will



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd()
  2026-04-04 12:20 [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
  2026-04-04 12:20 ` [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
@ 2026-06-26  8:21 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-06-26  8:21 UTC (permalink / raw)
  To: Muchun Song
  Cc: linux-riscv, catalin.marinas, will, chenhuacai, pjw, palmer, aou,
	davem, andreas, akpm, david, linux-mm, muchun.song, kernel, alex,
	ljs, Liam.Howlett, vbabka, rppt, surenb, mhocko, ryan.roberts,
	kevin.brodsky, dev.jain, anshuman.khandual, yang,
	chaitanyas.prakash, ptesarik, vishal.moola, junhui.liu,
	austin.kim, chengkaitao, willy, alexs, linux-arm-kernel,
	linux-kernel, loongarch, sparclinux

Hello:

This patch was applied to riscv/linux.git (fixes)
by Andrew Morton <akpm@linux-foundation.org>:

On Sat,  4 Apr 2026 20:20:53 +0800 you 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.
> 
> [...]

Here is the summary with links:
  - [v2,3/5] riscv/mm: drop vmemmap_pmd helpers and use generic code
    https://git.kernel.org/riscv/c/abff0ecf7602

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-26  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-04 12:20 [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() Muchun Song
2026-04-04 12:20 ` [PATCH v2 2/5] arm64/mm: drop vmemmap_pmd helpers and use generic code Muchun Song
2026-05-18 12:33   ` Will Deacon
2026-05-19  6:15     ` Muchun Song
2026-06-26  8:21 ` [PATCH v2 0/5] mm/sparse-vmemmap: provide generic vmemmap_set_pmd() and vmemmap_check_pmd() patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox