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

Matthew Wilcox
2026-04-27T14:59:29Z

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
;-)