Re: [PATCH v4 06/17] mm/mglru: move add/del LRU size accounting out of lru_gen_update_size()
From: Kairui Song
Date: Mon Nov 09 2026 - 04:41:14 EST
On Mon, Nov 9, 2026 at 4:48 AM Barry Song <baohua@xxxxxxxxxx> wrote:
>
> On Fri, Oct 16, 2026 at 2:15 AM Kairui Song via B4 Relay
> <devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
> >
> > From: Kairui Song <kasong@xxxxxxxxxxx>
> >
> > Pure code shuffle, no behavior change. lru_gen_update_size() now only
> > updates the per-generation counters plus the promotion move; the
> > addition and deletion active/inactive accounting move to
> > lru_gen_add_folio() and lru_gen_del_folio(), which know the generation
> > and can apply the active-window test directly.
> >
> > The unevictable case is untouched: unevictable folios never enter
> > lru_gen_add_folio() and keep being accounted by lruvec_add_folio() as
> > before.
> >
> > Tested-by: zhaozhengzhuo <zhaozhengzhuo@xxxxxxxxxxxxx>
> > Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> > ---
>
> The patch looks good to me.
>
> Meanwhile, I've been struggling with the names of
> __update_lru_size() and lru_gen_update_size() for a long
> time.
>
> Given that lru_gen_update_size() now only updates
> nr_pages:
> static inline void lru_gen_update_size(struct lruvec *lruvec, int type,
> struct folio *folio, int old_gen, int new_gen)
> {
> ...
>
> if (old_gen >= 0)
> atomic_long_sub(delta, &lrugen->nr_pages[old_gen][type][zone]);
> if (new_gen >= 0)
> atomic_long_add(delta, &lrugen->nr_pages[new_gen][type][zone]);
> }
>
> while __update_lru_size() only handles
> active/inactive accounting, could we rename them to make
> their roles clearer? For example:
>
> lru_gen_update_nr_pages()
> lru_gen_update_active_inactive_size()
Hmm but __update_lru_size is also used by CLRU, so it's not a
"lru_gen" specific helper. If we can merge CLRU/MGLRU, then maybe we
can rename them?