Re: [PATCH mm-new] mm/mglru: clarify the generation placement in lru_gen_folio_seq()

From: Kairui Song

Date: Tue Oct 20 2026 - 04:25:22 EST


On Tue, Oct 20, 2026 at 2:28 PM Ridong Chen <ridong.chen@xxxxxxxxx> wrote:
> On 10/20/2026 1:43 PM, Barry Song wrote:
> > On Tue, Oct 20, 2026 at 10:36 AM Ridong Chen <ridong.chen@xxxxxxxxx> wrote:
> >>
> >> From: Ridong Chen <chenridong@xxxxxxxxxx>
> >>
> >> lru_gen_folio_seq() computes how many generations below max_seq a
> >> folio should be added to, but stores it in a variable named "gen".
> >> Elsewhere in MGLRU "gen" means an index into lrugen->folios[], i.e.
> >> seq % MAX_NR_GENS, so reusing the name for a relative offset is
> >> confusing.
> >>
> >> The comment table above the code also no longer matches it. It only
> >> covers the PG_active and the final branch, leaving out the reclaiming
> >> and "can't evict yet" cases, and it lists LRU_REFS_FLAGS as an input
> >> although lru_gen_folio_seq() never looks at it.
> >>
> >> Rename the local variable to "age", redraw the table so that each
> >> branch maps to the age and seq it produces, and note that the result
> >> is clamped to min_seq[type].
> >>
> >> No functional change.
> >>
> >> Assisted-by: LLM
> >> Signed-off-by: Ridong Chen <chenridong@xxxxxxxxxx>
> >> ---
> >
> > Hi Ridong,
> >
> > The cleanup might be right, but this part is changing rapidly
> > with Kairui's MGLRU-FG series. Maybe we should wait until
> > that series lands and then see if this cleanup is still needed?
> >
> Sure, I'm fine to wait. Looking at MGLRU-FG v4, though, only [4/17]
> touches this function, and it mostly adapts the workingset checks to
> LRU refs. The local is still called "gen" and the table still leaves
> out the reclaiming and "can't evict yet" branches, so the function
> stays just as confusing after the series.
>
> Or,Kairui, do you think this is worth cleaning up? If so, would you
> mind adding a patch to MGLRU-FG to clean it up, so it doesn't
> conflict with your changes?

Sure, I can rebase or add this patch in next FG series, BTW for the
comment part I left some review reply, I think we better keep that
part simpler as the if branches ain't too complex to follow, repeating
it again in the comment seems not helpful. How do you think?