Re: [PATCH v7 12/19] mm/damon: convert to LRU refs based operations for MGLRU
From: jm5905938
Date: Thu Dec 03 2026 - 06:31:13 EST
Hi Kairui,
On Wed, 02 Dec 2026 04:18:52 +0800, Kairui Song wrote:
> Reset the count instead under MGLRU, with folio_clear_lru_refs(), which
> also clears PG_young.
LGTM, thanks.
Reviewed-by: Aveline Noir <jm5905938@xxxxxxxxx>
Thanks,
Aveline
On Wed, 02 Dec 2026 04:18:52 +0800, Kairui Song via B4 Relay
<devnull+kasong.tencent.com@xxxxxxxxxx> wrote:
> From: Kairui Song <kasong@xxxxxxxxxxx>
>
> damon_pa_pageout() cleared PG_referenced directly, which under MGLRU
> corrupts the folio's refs count. That flag is now
> bit 0 of the count (LRU_REFS_FLAGS).
>
> Reset the count instead under MGLRU, with folio_clear_lru_refs(), which
> also clears PG_young.
>
> Tested-by: Zhao Zhenzhuo <zhaozhengzhuo@xxxxxxxxxxxxx>
> Reviewed-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>
> Tested-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
> ---
> mm/damon/paddr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
> index b9d83e64a588..4104b8eb76f6 100644
> --- a/mm/damon/paddr.c
> +++ b/mm/damon/paddr.c
> @@ -290,8 +290,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r,
> else
> *sz_filter_passed += folio_size(folio) / addr_unit;
>
> - folio_clear_referenced(folio);
> - folio_test_clear_young(folio);
> + /* The region is cold, better drop the hotness info. */
> + folio_clear_lru_refs(folio);
> if (!folio_isolate_lru(folio))
> goto put_folio;
> if (folio_test_unevictable(folio))
>
> --
> 2.56.1