Re: [PATCH v10 06/14] mm: multi-gen LRU: minimal implementation

From: Barry Song
Date: Fri Apr 15 2022 - 06:26:27 EST


On Fri, Apr 15, 2022 at 8:36 AM Yu Zhao <yuzhao@xxxxxxxxxx> wrote:
>
> On Thu, Apr 14, 2022 at 06:03:10PM +1200, Barry Song wrote:
> >
> > On Thu, Apr 7, 2022 at 3:16 PM Yu Zhao <yuzhao@xxxxxxxxxx> wrote:
> > >
> > > +
> > > +static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int swappiness,
> > > + int *type_scanned, struct list_head *list)
> > > +{
> > > + int i;
> > > + int type;
> > > + int scanned;
> > > + int tier = -1;
> > > + DEFINE_MIN_SEQ(lruvec);
> > > +
> > > + VM_BUG_ON(!seq_is_valid(lruvec));
> > > +
> > > + /*
> > > + * Try to make the obvious choice first. When anon and file are both
> > > + * available from the same generation, interpret swappiness 1 as file
> > > + * first and 200 as anon first.
> > > + */
> >
> > Has this changed the ABI of swapiness?
>
> No.
>
> > or it is only something
> > meaningful for the internal code?
>
> This is how swappiness is interpreted.
>
> > if so, can we rename it to
> > something else? otherwise, it is quite confusing.
>
> Feel free to suggest something.
>
> > it seems 1 is set internally as a magic number here:
> > +static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct
> > scan_control *sc)
> > +{
> > + ...
> > + else if (!cgroup_reclaim(sc) && get_swappiness(lruvec, sc))
> > + swappiness = 1;
> > + else
> > + swappiness = 0;
> > + }
> > obviously this swappiness is neither /proc/sys/vm/swappiness nor
> > /sys/fs/cgroup/memory/<group>/>memory.swappiness, right?
>
> Right.
>
> > > @@ -3928,6 +4726,11 @@ static void age_active_anon(struct pglist_data *pgdat,
> > > struct mem_cgroup *memcg;
> > > struct lruvec *lruvec;
> > >
> > > + if (lru_gen_enabled()) {
> > > + lru_gen_age_node(pgdat, sc);
> > > + return;
> > > + }
> >
> > is it really a good place for lru_gen_age_node() since the function
> > is named age_active_anon()
> > but here you are doing aging for both anon and file pages?
>
> Yes.
>
> > obviously
> > lru_gen_age_node() is not

> > doing "age active anon".
>
;> We can rename it if you have something in mind.

i wonder if we can directly do:

if (lru_gen_enabled())
lru_gen_age_node(pgdat, sc);
else
age_active_anon();

rather than:

/*
* Do some background aging of the anon list, to give
* pages a chance to be referenced before reclaiming. All
* pages are rotated regardless of classzone as this is
* about consistent aging.
*/
age_active_anon()
{
if (lru_gen_enabled())
return lru_gen_age_node(pgdat, sc);
}

the comment above makes no sense to lru_gen_age_node(pgdat, sc);

another way is that we can add a wrapper for them as below,
age_node()
{
if (lru_gen_enabled())
return lru_gen_age_node(pgdat, sc);
age_active_anon();
}

Thanks
Barry