Re: [PATCH 7/7] mm/mglru: improve code readability and harden folio_inc_gen

Barry Song <[email protected]>
Newsgroups org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <CAGsJ_4zNZLOs_w1XazV471d66BVaNq9bVj5=2ZjT2u_NX=XmAg@mail.gmail.com>
On Tue, Aug 18, 2026 at 1:38 PM Kairui Song via B4 Relay
<[email protected]> wrote:
>
> From: Kairui Song <[email protected]>
>
> 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 <[email protected]>
> ---

Best Regards
Barry
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.