Re: [RFC PATCH v2 01/18] mm: free PG_rcu_free folios only after an RCU grace period

From: Kiryl Shutsemau

Date: Thu Nov 12 2026 - 07:29:56 EST


On Wed, Nov 11, 2026 at 11:03:38AM +0100, David Hildenbrand (Arm) wrote:
> So I might be completely off, but what I imagine is that the memdescs will get
> RCU-freed (these are not pages), and once they are then getting freed, they will
> probably take the physical page with them.
>
> And freeing memdescs through RCU will likely be memdesc specific.
>
> I really don't know, Willy might know more about these plans.

Right: once the folio is allocated separately, the lockless read
dereferences it too, so it has to wait for the grace period along with
its pages. The per-CPU batching and the waits in the allocator later
in the series do not depend on where the check sits.

Until then the folio is the struct page, and __free_pages_prepare() is
the one place every page cache folio passes, so v3 keeps the check
there. That function already takes page_folio() for the mlock and anon
checks, so making page_folio() fail for non-folios has to handle it
anyway.

Willy, is there a plan for how a folio memdesc gets freed after a grace
period?

The rest of v3 for this patch: CONFIG_FOLIO_RCU_FREE with help text for
what it adds, and FOLIO_SPLIT_FLAGS as a #define in a preparatory patch,
on top of Zi's PG_waiters fix.

I will not post v3 for a while: mm has enough traffic right now.
Unless you say I should.

--
Kiryl Shutsemau / Kirill A. Shutemov