Re: [PATCH] mm: Introduce free_folio_and_swap_cache() to replace free_page_and_swap_cache()

From: Matthew Wilcox
Date: Thu Apr 10 2025 - 14:52:08 EST


On Thu, Apr 10, 2025 at 08:36:34PM +0200, David Hildenbrand wrote:
> > but would we be better off just passing in the folio which contains the
> > page and always flush all pages in the folio?
>
> The delay_rmap needs the precise pages, so we cannot easily switch to folio
> + nr_refs.
>
> Once the per-page mapcounts are gone for good, we might no longer need
> page+nr_pages but folio+nr_refs would work.

Ah, I see. And we'll always need to support 'nr_pages' because we might
have COWed a page in the middle of a large folio and so there's no rule
we can possibly invent that allows us to infer how many pages of the
folio are mapped. We'd have to go and actually walk the page table
in the rmap code, and that sounds like a terrible idea.