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

From: Breno Leitao

Date: Mon Apr 27 2026 - 10:43:54 EST


Hello David,

On Mon, Apr 27, 2026 at 03:23:33PM +0200, David Hildenbrand (Arm) wrote:
> On 4/27/26 15:21, Andrew Morton wrote:
> > On Mon, 27 Apr 2026 13:43:16 +0200 "David Hildenbrand (Arm)" <david@xxxxxxxxxx> wrote:
> >
> >> Let's replace the last user of page_mapped() by folio_mapped() so we
> >> can get rid of page_mapped().
> >>
> >> Replace the remaining occurrences of page_mapped() in rmap documentation
> >> by folio_mapped().
> >
> > This broke Breno's "mm/memory-failure: add panic option for
> > unrecoverable pages"
> > (https://lore.kernel.org/20260424-ecc_panic-v5-2-a35f4b50425c@xxxxxxxxxx),
> > which added a new page_mapped() call. I made the below adjustment to
> > Breno's patch:
> >
> > --- a/mm/memory-failure.c~mm-memory-failure-add-panic-option-for-unrecoverable-pages-fix
> > +++ a/mm/memory-failure.c
> > @@ -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?

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

Thanks,
--breno