Re: [RFC PATCH v2 4/5] mm: mglru: run aging when pages are severely imbalanced across gens

From: Barry Song

Date: Tue Jul 28 2026 - 07:23:23 EST


On Tue, Jul 28, 2026 at 11:46 AM Zicheng Wang <wangzicheng@xxxxxxxxx> wrote:
>
> Hi Barry, lyugaofei,
>
> The cover letter results look good.
>
> This change looks like it resolves the cross-type skew from 798c0330c2ca
> [1] (if I understand correctly).

Hi Zicheng,

I guess it somehow moves MGLRU back toward its original design
of maintaining some balance across generations.

>
> But:
>
> removed (798c0330c2ca): old * 4 < total
> 4/5: old * 4 < young
>
> Can a single type also skew, and does changing total to young have any
> downside?

The original code is a bit odd, as it compares a single young
generation and a single old generation against the total,
rather than comparing all young generations with all old
generations.
if (seq == max_seq)
young += size;
else if (seq + MIN_NR_GENS == max_seq)
old += size;

Also, for the swappiness bias, we care more about the preferred
type than the other type. So comparing a single type, rather
than the sum of both types, makes more sense.

>
> Nit: the old form derived the constant from (MIN_NR_GENS + 2).

By comparing all young generations against all old
generations, we no longer depend on the exact value of
MIN_NR_GENS. The idea is to emulate inactive_is_low().

>
> [1] https://lore.kernel.org/all/20241231043538.4075764-4-yuzhao@xxxxxxxxxx/
>

Thanks
Barry