All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-stable] mm-mglru-fix-young-counter-undercount-for-large-folios.patch removed from -mm tree
@ 2026-08-25  1:55 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-08-25  1:55 UTC (permalink / raw)
  To: mm-commits, yuanchu, weixugc, shakeel.butt, mhocko, ljs, kasong,
	hannes, david, baolin.wang, baohua, axelrasmussen, zhuhui, akpm


The quilt patch titled
     Subject: mm/mglru: fix young counter undercount for large folios
has been removed from the -mm tree.  Its filename was
     mm-mglru-fix-young-counter-undercount-for-large-folios.patch

This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Hui Zhu <zhuhui@kylinos.cn>
Subject: mm/mglru: fix young counter undercount for large folios
Date: Wed, 12 Aug 2026 14:59:33 +0800

lru_gen_look_around() feeds its local 'young' counter into
suitable_to_scan(), which decides whether the current PMD is added to
the bloom filter and checked again on the next aging round.

The folio triggering the look-around is processed at function entry:
test_and_clear_young_ptes_notify() clears the accessed bits of the nr PTEs
it maps, and the function bails out if none of them is young.  The loop
that follows therefore never recounts this folio, since its accessed bits
are already cleared.  Every other young folio the loop finds is accounted
as a batch (young += nr), where nr is the number of consecutive PTEs it
maps.  The triggering folio, however, still contributes a fixed young = 1
regardless of its size -- a leftover from before PTE batching.  A large
triggering folio is thus accounted inconsistently with the rest of the
window.

Initialize young to nr so the triggering folio is accounted the same way
as any other young folio batch in the loop.

Note this is a deliberate overestimate, not a measured value.  The
test-and-clear helper only reports whether any of the nr PTEs is young,
not how many were accessed, so the true number of accessed PTEs in a large
folio is unknown and can be smaller than nr.  Counting the full batch is
intentional: the mm core tracks accessed/dirty state per folio, not per
page, so a per-page count is neither obtainable nor meaningful.  The only
consumer is suitable_to_scan(), and the bloom filter it feeds tolerates
error.  Overestimating is also the safe direction: at worst a PMD that saw
little access is rescanned, whereas underestimating could skip rescanning
a PMD whose folios are still hot and reclaim them incorrectly.  (nr here
is the PTE batch size, not necessarily folio_nr_pages().)

Link: https://lore.kernel.org/20260813061019.49806-1-hui.zhu@linux.dev
Link: https://lore.kernel.org/20260812065933.103627-1-hui.zhu@linux.dev
Fixes: 56e5b60b2114 ("mm: support batched checking of the young flag for MGLRU")
Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Barry Song <baohua@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/vmscan.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/vmscan.c~mm-mglru-fix-young-counter-undercount-for-large-folios
+++ a/mm/vmscan.c
@@ -4261,7 +4261,7 @@ bool lru_gen_look_around(struct page_vma
 	unsigned long end;
 	struct lru_gen_mm_walk *walk;
 	struct folio *last = NULL;
-	int young = 1;
+	int young = nr;
 	pte_t *pte = pvmw->pte;
 	unsigned long addr = pvmw->address;
 	struct vm_area_struct *vma = pvmw->vma;
_

Patches currently in -mm which might be from zhuhui@kylinos.cn are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-25  1:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  1:55 [merged mm-stable] mm-mglru-fix-young-counter-undercount-for-large-folios.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.