Re: [PATCH v6 2/6] mm/mglru: introduce helpers for manipulating gen and refs flags

From: Kairui Song

Date: Sat Sep 05 2026 - 13:32:12 EST


Sashiko reports (please ignore, false positive):

commit b3b2fc9d5285717c3d36754aee77477780b76245
Author: Kairui Song <kasong@xxxxxxxxxxx>

mm/mglru: introduce helpers for manipulating gen and refs flags

This commit introduces helpers for adjusting a folio's refs and generation
info instead of performing bit operations directly on folio flags. It
splits some combined atomic operations into two without intended functional
changes.

> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> --- a/include/linux/mm_inline.h
> +++ b/include/linux/mm_inline.h
[ ... ]
> @@ -270,7 +339,7 @@ static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio,
> gen = lru_gen_from_seq(seq);
> flags = (gen + 1UL) << LRU_GEN_PGOFF;
> /* see the comment on MIN_NR_GENS about PG_active */
> - set_mask_bits(&folio->flags.f, LRU_GEN_MASK | BIT(PG_active), flags);
> + set_mask_bits(folio_flags(folio, 0), LRU_GEN_MASK | BIT(PG_active), flags);

This isn't a bug introduced by this patch, but does lru_gen_add_folio()
fail to clear LRU_REFS_FLAGS when updating the LRU generation mask here?

When an isolated folio is added back to the LRU using lru_gen_add_folio(),
its generation is updated but the stale LRU_REFS_FLAGS are retained.
Stale tier bits can inflate access counts and severely distort eviction
decisions, defeating the purpose of the multi-gen LRU tier tracking.

===

As it said, it's not a bug introduced by this patch, and I don't think
it is an existing bug either, lru_gen_add_folio isn't suppose to clear
the refs flags, or we might under counted refs or workingset.