Re: [PATCH v3 2/6] mm/mglru: introduce helpers for manipulating gen and refs flags
From: Kairui Song
Date: Tue Aug 25 2026 - 14:21:15 EST
Sashiko reports (TLDR: false positive, please ignore)
commit 381ba2d1b94989f14f9427e1427b761444230107
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, replacing direct bit operations on folio->flags.f. No functional
changes are intended, splitting some combined atomic operations into two.
> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> index 621c8653d8f7e..edfaf26618120 100644
> --- a/include/linux/mm_inline.h
> +++ b/include/linux/mm_inline.h
[ ... ]
> @@ -270,7 +331,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 is a pre-existing issue, but since this line is being modified, does
it miss clearing the tier bits (LRU_REFS_FLAGS) when updating the MGLRU
generation?
When a folio moves to a new generation, its tier bits should be cleared so
tracking starts fresh. Failing to clear them can leave stale access counts
that inflate the folio's tier, which might distort eviction logic and cause
thrashing under memory pressure.
Since this path is executed by memory pressure or page faults triggering
MGLRU page additions, should LRU_REFS_FLAGS be included in the cleared
mask here?
===
Not really, MGLRU somehow currently keep PG_workingset once set, also
PG_referenced is a bit special. In fact, the usage isn't very clearly
defined, which I think we can sanitize with MGLRU-FG later, but not
now.