Thread (59 messages) 59 messages, 8 authors, 5d ago

Re: [PATCH v4 11/12] mm: make userland page table freeing RCU-safe

From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Date: 2026-09-23 09:07:06
Also in: linux-alpha, linux-arch, linux-doc, linux-m68k, linux-mips, linux-mm, linux-riscv, linux-s390, linux-sh, linux-um, lkml, loongarch, sparclinux

On Wed, Sep 23, 2026 at 11:04:17AM +0200, David Hildenbrand (Arm) wrote:
On 9/22/26 17:35, Lorenzo Stoakes (ARM) wrote:

The patch subject confused me at first: that's not what the patch is doing, no?
Previous patches did that, and now you're just removing the leftovers?

Maybe I'm missing something that this patch does along the lines of teaching the
code to be RCU-safe.
It is the final piece that makes that the case, so I think it's OK to allow
oneself a nice subject line? No? :)

If people are confused they can read the commit message which goes into some
detail.
quoted
Now every architecture has been converted to support
CONFIG_MMU_GATHER_RCU_TABLE_FREE, this configuration option no longer makes
any sense to keep around.

Therefore remove it, and remove all the dead code that existed for
!CONFIG_MMU_GATHER_RCU_TABLE_FREE architectures previously.

Additionally, CONFIG_MMU_GATHER_TABLE_FREE is no longer necessary, as all
architectures instead use CONFIG_HAVE_ARCH_TLB_REMOVE_TABLE when a custom
__tlb_remove_table() is required, so remove this too.

A number of architectures only enabled CONFIG_MMU_GATHER_RCU_TABLE_FREE if
CONFIG_MMU was set, however the mmu_gather logic only actually does
something meaningful if CONFIG_MMU is set (mmu_gather.c is only compiled in
this case, for instance).

As a result, there's no need to gate any of this logic on CONFIG_MMU
explicitly.

CONFIG_PT_RECLAIM however does have a strict dependency on CONFIG_MMU, so
make this dependency explicit.

Additionally, correct comments to remove references to non-RCU page table
gathering and make it clear that this is not 'semi-RCU', nor has it been
since commit 1fb3d8c20bfa ("mm/mmu_gather: replace IPI with
synchronize_rcu() when batch allocation fails").

With this change in place the kernel policy is now that userspace page
tables are freed after an RCU grace period, and thus it is now safe to
unconditionally perform page table walks under RCU, safe in the knowledge
that page tables will not be freed underneath the walker.

This is all that is guaranteed, however, so naturally it is still incumbent
upon page table walkers to ensure that the page table entries are as
expected.

Acked-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

[...]
quoted
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1465,7 +1465,7 @@ config HAVE_ARCH_TLB_REMOVE_TABLE

 config PT_RECLAIM
 	def_bool y
-	depends on MMU_GATHER_RCU_TABLE_FREE && !HAVE_ARCH_TLB_REMOVE_TABLE
+	depends on MMU && !HAVE_ARCH_TLB_REMOVE_TABLE
 	help
 	  Try to reclaim empty user page table pages in paths other than munmap
 	  and exit_mmap path.
$ git grep PT_RECLAIM
mm/Kconfig:config PT_RECLAIM
mm/memory.c:    if (!IS_ENABLED(CONFIG_PT_RECLAIM))
mm/mmu_gather.c:#ifdef CONFIG_PT_RECLAIM
mm/mmu_gather.c:#endif /* CONFIG_PT_RECLAIM */

whereby all files are MMU-only.

Makes sense.


Very nice

Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Thanks.
--
Cheers,

David
--
Cheers, Lorenzo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help