Re: [PATCH 7/7] mm/mglru: improve code readability and harden folio_inc_gen
From: Barry Song
Date: Wed Aug 19 2026 - 17:31:18 EST
On Tue, Aug 18, 2026 at 1:38 PM Kairui Song via B4 Relay
<devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
>
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> The helper should never be called for an off-list folio, and it always
> expects the folio to be in the oldest generation before doing any
I'm really not sure whether that's true. Could the folios have been
found to be young more than once during the last two or three (or more)
aging cycles?
> cmpxchg. Add a sanity check for the off-list case: if it is ever
> violated, bail out and keep the folio flags untouched to minimize the
> damage, instead of silently treating the folio as if it were in the
> oldest generation and promoting it updating the flags to an unexpected
> status.
My printk shows that a folio can be promoted two or three times.
If a folio is promoted too many times, is that the cold/hot inversion
you are trying to fix?
>
> Also rename the variables to clearly distinguish the folio's current
> gen from the oldest gen.
>
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> ---
Best Regards
Barry