Re: [PATCH] mm: pgtable: protect lockless kernel page table walks with RCU

From: David CARLIER

Date: Fri Jun 12 2026 - 01:00:02 EST


sure thing. Thanks !

On Fri, 12 Jun 2026 at 05:52, Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:
>
> On Fri, Jun 12, 2026 at 05:38:27AM +0100, David Carlier wrote:
> > @@ -434,6 +434,14 @@ static void kernel_pgtable_work_func(struct work_struct *work)
> > spin_unlock(&kernel_pgtable_work.lock);
> >
> > iommu_sva_invalidate_kva_range(PAGE_OFFSET, TLB_FLUSH_ALL);
> > +
> > + /*
> > + * Lockless kernel page table walkers (ptdump, and any other user of
> > + * walk_kernel_page_table_range_lockless()) dereference these pages
> > + * under rcu_read_lock(). Wait for a grace period so no walker can
> > + * still be reading a page we are about to free.
> > + */
> > + synchronize_rcu();
> > list_for_each_entry_safe(pt, next, &page_list, pt_list)
> > __pagetable_free(pt);
>
> synchronize_rcu() is rather expensive. Can't you rcu-free the page
> tables instead? There's an rcu head in struct page.