From: Baoquan He <baoquan.he@linux.dev>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, david@kernel.org, kasong@tencent.com,
ljs@kernel.org, baohua@kernel.org, qi.zheng@linux.dev,
shakeel.butt@linux.dev, axelrasmussen@google.com,
yuanchu@google.com, weixugc@google.com, baoquan.he@linux.dev,
baolin.wang@linux.alibaba.com, liam@infradead.org,
vbabka@kernel.org, rppt@kernel.org, mhocko@suse.com,
riel@surriel.com, harry@kernel.org, jannh@google.com,
lance.yang@linux.dev, hannes@cmpxchg.org,
Baoquan He <hebaoquan@kylinos.cn>
Subject: [PATCH v6 1/4] mm/mglru: add MM_WALK_EMPTY stats and tracepoint
Date: Fri, 27 Nov 2026 14:16:27 +0800 [thread overview]
Message-ID: <20261127061630.11290-2-baoquan.he@linux.dev> (raw)
In-Reply-To: <20261127061630.11290-1-baoquan.he@linux.dev>
From: Baoquan He <hebaoquan@kylinos.cn>
Add per-walk counters to measure empty aging walks, which traverse an mm's
page tables but find no young leaf for the current lruvec (node+memcg).
These are common on multi-NUMA node systems because lru_gen_use_mm() marks
an mm for all nodes at every context switch.
New counters (accumulated in mm_state->stats[]):
MM_WALK_TOTAL - page-table walks completed
MM_WALK_EMPTY - walks that found no young leaf for this lruvec
MM_LEAF_EMPTY_WALKS - leaf entries scanned during empty walks
A walk is empty when MM_LEAF_TOTAL > 0 and MM_LEAF_YOUNG == 0.
MM_LEAF_YOUNG already counts only the young leaves whose folio is in this
lruvec, which is the condition the PUD-level filter of the following
patches uses.
The new tracepoint mm_vmscan_lru_gen_walk() fires after each walk, and the
debugfs lru_gen output ("TYFAWEE") exposes the counters.
Signed-off-by: Baoquan He <hebaoquan@kylinos.cn>
---
include/linux/mmzone.h | 3 +++
mm/trace_vmscan.h | 28 ++++++++++++++++++++++++++++
mm/vmscan.c | 32 ++++++++++++++++++++++++++++----
3 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 14c58bbd1606..12cba15a02fa 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -631,6 +631,9 @@ enum {
MM_LEAF_YOUNG, /* young leaf entries */
MM_NONLEAF_FOUND, /* non-leaf entries found in Bloom filters */
MM_NONLEAF_ADDED, /* non-leaf entries added to Bloom filters */
+ MM_WALK_TOTAL, /* page-table walks completed */
+ MM_WALK_EMPTY, /* walks that found no young leaf for this lruvec */
+ MM_LEAF_EMPTY_WALKS, /* leaf entries scanned during empty walks */
NR_MM_STATS
};
diff --git a/mm/trace_vmscan.h b/mm/trace_vmscan.h
index 9dafdb5bd3ce..b0c2af65c1ea 100644
--- a/mm/trace_vmscan.h
+++ b/mm/trace_vmscan.h
@@ -508,6 +508,34 @@ TRACE_EVENT(mm_mglru_aging,
__print_array(__entry->nr_anon, MAX_NR_GENS, sizeof(unsigned long)),
__print_array(__entry->nr_file, MAX_NR_GENS, sizeof(unsigned long)))
);
+TRACE_EVENT(mm_vmscan_lru_gen_walk,
+
+ TP_PROTO(int nid, unsigned long seq, int leaf_total,
+ int leaf_young, bool empty),
+
+ TP_ARGS(nid, seq, leaf_total, leaf_young, empty),
+
+ TP_STRUCT__entry(
+ __field(int, nid)
+ __field(unsigned long, seq)
+ __field(int, leaf_total)
+ __field(int, leaf_young)
+ __field(bool, empty)
+ ),
+
+ TP_fast_assign(
+ __entry->nid = nid;
+ __entry->seq = seq;
+ __entry->leaf_total = leaf_total;
+ __entry->leaf_young = leaf_young;
+ __entry->empty = empty;
+ ),
+
+ TP_printk("nid=%d seq=%lu leaf_total=%d leaf_young=%d empty=%d",
+ __entry->nid, __entry->seq, __entry->leaf_total,
+ __entry->leaf_young, __entry->empty)
+);
+
#endif /* CONFIG_LRU_GEN */
TRACE_EVENT(mm_vmscan_write_folio,
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 81797b71228f..c755d4914d76 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -4375,8 +4375,32 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long seq,
do {
success = iterate_mm_list(walk, &mm);
- if (mm)
+ if (mm) {
+ bool empty = false;
+
walk_mm(mm, walk);
+ /*
+ * A walk that traversed page tables but found no young
+ * leaf for this lruvec (node+memcg) is pure waste: the
+ * PUD-level filter will skip it next generation.
+ * MM_LEAF_YOUNG only counts leaves whose folio belongs
+ * to this lruvec, so it is the condition the filter
+ * uses as well.
+ */
+ if (walk->mm_stats[MM_LEAF_TOTAL]) {
+ walk->mm_stats[MM_WALK_TOTAL]++;
+ if (walk->mm_stats[MM_LEAF_YOUNG] == 0) {
+ walk->mm_stats[MM_WALK_EMPTY]++;
+ walk->mm_stats[MM_LEAF_EMPTY_WALKS] +=
+ walk->mm_stats[MM_LEAF_TOTAL];
+ empty = true;
+ }
+ }
+ trace_mm_vmscan_lru_gen_walk(
+ lruvec_pgdat(lruvec)->node_id, walk->seq,
+ walk->mm_stats[MM_LEAF_TOTAL],
+ walk->mm_stats[MM_LEAF_YOUNG], empty);
+ }
} while (mm);
done:
if (success) {
@@ -6010,14 +6034,14 @@ static void lru_gen_seq_show_full(struct seq_file *m, struct lruvec *lruvec,
seq_puts(m, " ");
for (i = 0; i < NR_MM_STATS; i++) {
- const char *s = "xxxx";
+ const char *s = "xxxxxxxx";
unsigned long n = 0;
if (seq == max_seq && NR_HIST_GENS == 1) {
- s = "TYFA";
+ s = "TYFAWEE";
n = READ_ONCE(mm_state->stats[hist][i]);
} else if (seq != max_seq && NR_HIST_GENS > 1) {
- s = "tyfa";
+ s = "tyfawee";
n = READ_ONCE(mm_state->stats[hist][i]);
}
--
2.52.0
next prev parent reply other threads:[~2026-11-27 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 6:16 [PATCH v6 0/4] skip empty PUD subtrees during aging with a PUD-level Bloom filter Baoquan He
2026-11-27 6:16 ` Baoquan He [this message]
2026-11-27 6:16 ` [PATCH v6 2/4] mm/mglru: add PUD-level Bloom filter state and generic helpers Baoquan He
2026-11-27 6:16 ` [PATCH v6 3/4] mm/mglru: skip cold PUD subtrees during aging Baoquan He
2026-11-27 6:16 ` [PATCH v6 4/4] mm/mglru: count PUD subtrees skipped by the PUD-level filter Baoquan He
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127061630.11290-2-baoquan.he@linux.dev \
--to=baoquan.he@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=hebaoquan@kylinos.cn \
--cc=jannh@google.com \
--cc=kasong@tencent.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=qi.zheng@linux.dev \
--cc=riel@surriel.com \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.