diff mbox series

[v4,04/12] mm: enable MMU_GATHER_RCU_TABLE_FREE for MMU arm

Message ID 20260922-rcu-pagetable-freeing-v4-4-fe1ad1f1e303@kernel.org
State New
Headers show
Series mm: make userland page table freeing RCU-safe | expand

Commit Message

Lorenzo Stoakes (ARM) Sept. 22, 2026, 3:35 p.m. UTC
Commit a0ad5496b2b3 ("arm: mm: enable HAVE_RCU_TABLE_FREE logic") enabled
CONFIG_MMU_GATHER_RCU_TABLE_FREE (then named HAVE_RCU_TABLE_FREE) for SMP
arm architectures with LPAE enabled.

Regardless of whether CONFIG_ARM_LPAE is enabled or not, the same page
table freeing functions __pte_free_tlb() and __pmd_free_tlb() are used.

Non-LPAE PMD page tables are folded into the PGD and freed by
pgd_free() (PGD freeing is not part of mmu_gather page table freeing in any
case), so this is a noop in this case.

Since commit 358d1c39c82a ("arm: convert various functions to use ptdescs")
both LPAE and non-LPAE PTE page table freeing uses tlb_remove_ptdesc().

Thus all page table freeing is performed under RCU with
CONFIG_MMU_GATHER_RCU_TABLE_FREE enabled for LPAE and non-LPAE and thus it
need not be gated on LPAE.

A UP arm system can set CONFIG_PREEMPT_RCU, so a future pure RCU page
table walker requires MMU_GATHER_RCU_TABLE_FREE to be enabled on UP as
well, even if concurrent GUP fast is not possible there.

Therefore, it is both safe and desirable to set
CONFIG_MMU_GATHER_RCU_TABLE_FREE for all MMU arm architectures (nommu does
not perform mmu_gather operations).

This forms part of an overall effort to switch every architecture to this
mode.

Acked-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
 arch/arm/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lance Yang Sept. 23, 2026, 8:05 a.m. UTC | #1
On Tue, Sep 22, 2026 at 04:35:35PM +0100, Lorenzo Stoakes (ARM) wrote:
>Commit a0ad5496b2b3 ("arm: mm: enable HAVE_RCU_TABLE_FREE logic") enabled
>CONFIG_MMU_GATHER_RCU_TABLE_FREE (then named HAVE_RCU_TABLE_FREE) for SMP
>arm architectures with LPAE enabled.
>
>Regardless of whether CONFIG_ARM_LPAE is enabled or not, the same page
>table freeing functions __pte_free_tlb() and __pmd_free_tlb() are used.
>
>Non-LPAE PMD page tables are folded into the PGD and freed by
>pgd_free() (PGD freeing is not part of mmu_gather page table freeing in any
>case), so this is a noop in this case.
>
>Since commit 358d1c39c82a ("arm: convert various functions to use ptdescs")
>both LPAE and non-LPAE PTE page table freeing uses tlb_remove_ptdesc().
>
>Thus all page table freeing is performed under RCU with
>CONFIG_MMU_GATHER_RCU_TABLE_FREE enabled for LPAE and non-LPAE and thus it
>need not be gated on LPAE.
>
>A UP arm system can set CONFIG_PREEMPT_RCU, so a future pure RCU page
>table walker requires MMU_GATHER_RCU_TABLE_FREE to be enabled on UP as
>well, even if concurrent GUP fast is not possible there.
>
>Therefore, it is both safe and desirable to set
>CONFIG_MMU_GATHER_RCU_TABLE_FREE for all MMU arm architectures (nommu does
>not perform mmu_gather operations).
>
>This forms part of an overall effort to switch every architecture to this
>mode.
>
>Acked-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
>Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
>---

Tested under heavy page-table teardown load on qemu-system-arm,
with and without ARM_LPAE. No issues seen :D

Tested-by: Lance Yang <lance.yang@linux.dev>

Also, feel free to add:

Acked-by: Lance Yang <lance.yang@linux.dev>


> arch/arm/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>index 408aa58a2a5b..72b9afc6ae10 100644
>--- a/arch/arm/Kconfig
>+++ b/arch/arm/Kconfig
>@@ -134,7 +134,7 @@ config ARM
> 	select HAVE_PERF_REGS
> 	select HAVE_PERF_USER_STACK_DUMP
> 	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
>-	select MMU_GATHER_RCU_TABLE_FREE if SMP && ARM_LPAE
>+	select MMU_GATHER_RCU_TABLE_FREE if MMU
> 	select HAVE_REGS_AND_STACK_ACCESS_API
> 	select HAVE_RSEQ
> 	select HAVE_RUST if CPU_LITTLE_ENDIAN && CPU_32v7 && !KASAN
>
>-- 
>2.55.0
>
>
Lorenzo Stoakes (ARM) Sept. 23, 2026, 8:15 a.m. UTC | #2
On Wed, Sep 23, 2026 at 04:05:23PM +0800, Lance Yang wrote:
>
> On Tue, Sep 22, 2026 at 04:35:35PM +0100, Lorenzo Stoakes (ARM) wrote:
> >Commit a0ad5496b2b3 ("arm: mm: enable HAVE_RCU_TABLE_FREE logic") enabled
> >CONFIG_MMU_GATHER_RCU_TABLE_FREE (then named HAVE_RCU_TABLE_FREE) for SMP
> >arm architectures with LPAE enabled.
> >
> >Regardless of whether CONFIG_ARM_LPAE is enabled or not, the same page
> >table freeing functions __pte_free_tlb() and __pmd_free_tlb() are used.
> >
> >Non-LPAE PMD page tables are folded into the PGD and freed by
> >pgd_free() (PGD freeing is not part of mmu_gather page table freeing in any
> >case), so this is a noop in this case.
> >
> >Since commit 358d1c39c82a ("arm: convert various functions to use ptdescs")
> >both LPAE and non-LPAE PTE page table freeing uses tlb_remove_ptdesc().
> >
> >Thus all page table freeing is performed under RCU with
> >CONFIG_MMU_GATHER_RCU_TABLE_FREE enabled for LPAE and non-LPAE and thus it
> >need not be gated on LPAE.
> >
> >A UP arm system can set CONFIG_PREEMPT_RCU, so a future pure RCU page
> >table walker requires MMU_GATHER_RCU_TABLE_FREE to be enabled on UP as
> >well, even if concurrent GUP fast is not possible there.
> >
> >Therefore, it is both safe and desirable to set
> >CONFIG_MMU_GATHER_RCU_TABLE_FREE for all MMU arm architectures (nommu does
> >not perform mmu_gather operations).
> >
> >This forms part of an overall effort to switch every architecture to this
> >mode.
> >
> >Acked-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> >Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> >---
>
> Tested under heavy page-table teardown load on qemu-system-arm,
> with and without ARM_LPAE. No issues seen :D
>
> Tested-by: Lance Yang <lance.yang@linux.dev>
>
> Also, feel free to add:
>
> Acked-by: Lance Yang <lance.yang@linux.dev>

Thanks, much appreciated! :)

>
>
> > arch/arm/Kconfig | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> >index 408aa58a2a5b..72b9afc6ae10 100644
> >--- a/arch/arm/Kconfig
> >+++ b/arch/arm/Kconfig
> >@@ -134,7 +134,7 @@ config ARM
> > 	select HAVE_PERF_REGS
> > 	select HAVE_PERF_USER_STACK_DUMP
> > 	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
> >-	select MMU_GATHER_RCU_TABLE_FREE if SMP && ARM_LPAE
> >+	select MMU_GATHER_RCU_TABLE_FREE if MMU
> > 	select HAVE_REGS_AND_STACK_ACCESS_API
> > 	select HAVE_RSEQ
> > 	select HAVE_RUST if CPU_LITTLE_ENDIAN && CPU_32v7 && !KASAN
> >
> >--
> >2.55.0
> >
> >

--
Cheers, Lorenzo
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 408aa58a2a5b..72b9afc6ae10 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -134,7 +134,7 @@  config ARM
 	select HAVE_PERF_REGS
 	select HAVE_PERF_USER_STACK_DUMP
 	select HAVE_POSIX_CPU_TIMERS_TASK_WORK
-	select MMU_GATHER_RCU_TABLE_FREE if SMP && ARM_LPAE
+	select MMU_GATHER_RCU_TABLE_FREE if MMU
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_RSEQ
 	select HAVE_RUST if CPU_LITTLE_ENDIAN && CPU_32v7 && !KASAN