On 2/5/26 17:48, Matthew Wilcox wrote:
On Fri, Feb 06, 2026 at 12:30:56AM +0800, Lance Yang wrote:
On 2026/2/5 23:41, Dave Hansen wrote:
Yeah, but one aim of RCU is ensuring that readers see valid data but not
necessarily the most up to date data.
Are there cases where ongoing concurrent lockless page-table walks need
to see the writes and they can't tolerate seeing valid but slightly
stale data?
The issue is we're about to free the page table (e.g.
pmdp_collapse_flush()).
We have to ensure no walker is still doing a lockless page-table walk
when the page directories are freed, otherwise we get use-after-free.
But can't we RCU-free the page table? Why do we need to wait for the
RCU readers to finish?
For unsharing hugetlb PMD tables the problem is not the freeing but the
reuse of the PMD table for other purposes in the last remaining user.
It's complicated.
For page table freeing, we only do it if we fail to allocate memory --
if we cannot use RCU IIRC.
khugepaged, no idea.
--
Cheers,
David