Re: [PATCH RFC v3 15/17] mm/khugepaged: check folio referenced state via LRU refs under MGLRU
From: Kairui Song
Date: Sat Oct 03 2026 - 23:30:54 EST
On Sun, Oct 4, 2026 at 6:11 AM Zi Yan <ziy@xxxxxxxxxx> wrote:
>
> On Sat Oct 3, 2026 at 8:55 AM EDT, Kairui Song via B4 Relay wrote:
> > From: Kairui Song <kasong@xxxxxxxxxxx>
> >
> > For MGLRU, PG_referenced is only the lowest bit of the folio LRU refs
> > count, so folios with a higher refs count no longer have the bit set.
> > folio_pte_referenced() testing the raw bit misses hot folios at
> > refs >= 2, under-counting the referenced folios of a candidate range
> > and aborting otherwise good collapses with SCAN_LACK_REFERENCED_PAGE.
> >
> > Test the refs count directly when MGLRU is enabled, mirroring the
> > smaps conversion. The classical LRU keeps the plain bit test.
>
> Why not reuse the smaps helper function? You can rename the helper to
> check_folio_referenced() for general use.
>
That's a very nice idea, will use that.
> --
> Best Regards,
> Yan, Zi
>