Re: [PATCH 3/3] mm: remove page_mapped()

From: Matthew Wilcox

Date: Mon Apr 27 2026 - 11:03:12 EST


On Mon, Apr 27, 2026 at 07:42:46AM -0700, Breno Leitao wrote:
> > > @@ -1353,7 +1353,7 @@ static bool panic_on_unrecoverable_mf(un
> > > cpu_relax();
> > > return page_count(p) == 0 &&
> > > !PageLRU(p) &&
> > > - !page_mapped(p) &&
> > > + !folio_mapped(page_folio(p)) &&
> > > !page_folio(p)->mapping &&
> >
> > If we have a folio, we should really lookup the folio once. Not 4 times.
>
> Why 4 times?

Because there are page_folio() calls hidden in PageLRU, page_mapped()
and page_count().

> > Breno's patch likely needs some love. :)
>
> Would something like the following give it all the love in the world?
>
> folio = page_folio(p);
> return page_count(p) == 0 &&
> !PageLRU(p) &&
> !folio_mapped(folio) &&
> !folio->mapping &&
> !is_free_buddy_page(p);

No. You need to immerse yourself more deeply in the folio transition
;-)