v2 2026-08-25

清理 MGLRU folio 计数与标志使用 · v2

清理MGLRU的folio计数与gen/refs标志处理,移动max_seq读取并修复代folio数量泄漏。

原始补丁链接

子 Patch(6)

1/6
mm/memcontrol: make lru_zone_size atomic and simplify sanity check
From: Kairui Song kasong@tencent.com commit ca707239e8a7 (“mm: update_lru_size warn and reset bad lru_size”) introduced a sanity check to catch memcg counter underflow, which was more of a workarou
2/6
mm/mglru: introduce helpers for manipulating gen and refs flags
From: Kairui Song kasong@tencent.com Instead of doing bit ops on folio->flags.f, introduce helpers for adjusting a folio’s refs and generation info, making the code easier to debug and understand.
3/6
mm/migrate: copy all referenced state via folio_migrate_lru_refs
From: Kairui Song kasong@tencent.com folio_migrate_flags() copies PG_referenced separately from the MGLRU refs counter, which folio_migrate_refs() transfers. Yet under MGLRU, PG_referenced and the
4/6
mm/mglru: move max_seq read into walk_update_folio
From: Kairui Song kasong@tencent.com walk_pte_range(), walk_pmd_range_locked(), and lru_gen_look_around() each read lrugen->max_seq to compute the target generation used by walk_update_folio(), the
5/6
mm/mglru: use explicit tier range in read_ctrl_pos()
From: Kairui Song kasong@tencent.com read_ctrl_pos() encodes the tier range in a single “tier” parameter via “tier % MAX_NR_TIERS” as the start and “min(tier, MAX_NR_TIERS-1)” as the end. This is h
6/6
mm/mglru: fix potential generation folio number leak
From: Kairui Song kasong@tencent.com Each generation of MGLRU accounts anon and file folio numbers separately, and the page table walker updates each generation’s counters in batch once the walk is