freenode
Kernel & Low-Level

Linux unifies RCU-safe page table freeing across all architectures

A twelve-patch series from Lorenzo Stoakes finishes years of work so every architecture defers userspace page-table teardown until after an RCU grace period.

Lorenzo Stoakes has posted a patch series that makes userspace page-table freeing RCU-safe on every remaining Linux architecture and then deletes the CONFIG_MMU_GATHER_RCU_TABLE_FREE option entirely. The change means a page-table walker can now rely on RCU alone, without taking page-table locks, and still be certain the tables will not vanish underneath it.

Most architectures already deferred freeing until an RCU grace period had elapsed. A handful still freed tables immediately or only under SMP or LPAE constraints. Stoakes converted those hold-outs (including arc, microblaze, xtensa, sparc32, sh-X2, m68k variants, arm, riscv UP, and several two-level arches), fixed the last non-RCU deposit path used by transparent-huge-page collapse, and removed the now-redundant Kconfig switch and its associated dead code.

The practical result is lower lock contention, simpler lock ordering, and the ability to write fast lockless walkers that previously would have needed the PTE page-table lock. The series also eliminates architecture-specific special cases that had accumulated over years. Earlier groundwork by Hugh Dickins, Qi Zheng and Lance Yang made the final conversion possible; once every architecture behaved the same way, the configuration option itself could disappear.

Kernel documentation now states the new rule explicitly: page tables may be walked under RCU provided the mm stays alive, but any entry found must still be revalidated under the appropriate lock before it is acted upon, and writers continue to need the usual exclusion locks.