Skip to content

Commit ddd6d8e

Browse files
Yu Zhaoakpm00
authored andcommitted
mm: multi-gen LRU: remove MM_LEAF_OLD and MM_NONLEAF_TOTAL stats
Patch series "mm: multi-gen LRU: Have secondary MMUs participate in MM_WALK". Today, the MM_WALK capability causes MGLRU to clear the young bit from PMDs and PTEs during the page table walk before eviction, but MGLRU does not call the clear_young() MMU notifier in this case. By not calling this notifier, the MM walk takes less time/CPU, but it causes pages that are accessed mostly through KVM / secondary MMUs to appear younger than they should be. We do call the clear_young() notifier today, but only when attempting to evict the page, so we end up clearing young/accessed information less frequently for secondary MMUs than for mm PTEs, and therefore they appear younger and are less likely to be evicted. Therefore, memory that is *not* being accessed mostly by KVM will be evicted *more* frequently, worsening performance. ChromeOS observed a tab-open latency regression when enabling MGLRU with a setup that involved running a VM: Tab-open latency histogram (ms) Version p50 mean p95 p99 max base 1315 1198 2347 3454 10319 mglru 2559 1311 7399 12060 43758 fix 1119 926 2470 4211 6947 This series replaces the final non-selftest patchs from this series[1], which introduced a similar change (and a new MMU notifier) with KVM optimizations. I'll send a separate series (to Sean and Paolo) for the KVM optimizations. This series also makes proactive reclaim with MGLRU possible for KVM memory. I have verified that this functions correctly with the selftest from [1], but given that that test is a KVM selftest, I'll send it with the rest of the KVM optimizations later. Andrew, let me know if you'd like to take the test now anyway. [1]: https://lore.kernel.org/linux-mm/20240926013506.860253-18-jthoughton@google.com/ This patch (of 2): The removed stats, MM_LEAF_OLD and MM_NONLEAF_TOTAL, are not very helpful and become more complicated to properly compute when adding test/clear_young() notifiers in MGLRU's mm walk. Link: https://lkml.kernel.org/r/20241019012940.3656292-1-jthoughton@google.com Link: https://lkml.kernel.org/r/20241019012940.3656292-2-jthoughton@google.com Fixes: bd74fda ("mm: multi-gen LRU: support page table walks") Signed-off-by: Yu Zhao <yuzhao@google.com> Signed-off-by: James Houghton <jthoughton@google.com> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: David Matlack <dmatlack@google.com> Cc: David Rientjes <rientjes@google.com> Cc: David Stevens <stevensd@google.com> Cc: Oliver Upton <oliver.upton@linux.dev> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Wei Xu <weixugc@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent d4148ae commit ddd6d8e

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

include/linux/mmzone.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,7 @@ struct lru_gen_folio {
458458

459459
enum {
460460
MM_LEAF_TOTAL, /* total leaf entries */
461-
MM_LEAF_OLD, /* old leaf entries */
462461
MM_LEAF_YOUNG, /* young leaf entries */
463-
MM_NONLEAF_TOTAL, /* total non-leaf entries */
464462
MM_NONLEAF_FOUND, /* non-leaf entries found in Bloom filters */
465463
MM_NONLEAF_ADDED, /* non-leaf entries added to Bloom filters */
466464
NR_MM_STATS

mm/vmscan.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,7 +3399,6 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end,
33993399
continue;
34003400

34013401
if (!pte_young(ptent)) {
3402-
walk->mm_stats[MM_LEAF_OLD]++;
34033402
continue;
34043403
}
34053404

@@ -3552,7 +3551,6 @@ static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end,
35523551
walk->mm_stats[MM_LEAF_TOTAL]++;
35533552

35543553
if (!pmd_young(val)) {
3555-
walk->mm_stats[MM_LEAF_OLD]++;
35563554
continue;
35573555
}
35583556

@@ -3564,8 +3562,6 @@ static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end,
35643562
continue;
35653563
}
35663564

3567-
walk->mm_stats[MM_NONLEAF_TOTAL]++;
3568-
35693565
if (!walk->force_scan && should_clear_pmd_young()) {
35703566
if (!pmd_young(val))
35713567
continue;
@@ -5254,11 +5250,11 @@ static void lru_gen_seq_show_full(struct seq_file *m, struct lruvec *lruvec,
52545250
for (tier = 0; tier < MAX_NR_TIERS; tier++) {
52555251
seq_printf(m, " %10d", tier);
52565252
for (type = 0; type < ANON_AND_FILE; type++) {
5257-
const char *s = " ";
5253+
const char *s = "xxx";
52585254
unsigned long n[3] = {};
52595255

52605256
if (seq == max_seq) {
5261-
s = "RT ";
5257+
s = "RTx";
52625258
n[0] = READ_ONCE(lrugen->avg_refaulted[type][tier]);
52635259
n[1] = READ_ONCE(lrugen->avg_total[type][tier]);
52645260
} else if (seq == min_seq[type] || NR_HIST_GENS > 1) {
@@ -5280,14 +5276,14 @@ static void lru_gen_seq_show_full(struct seq_file *m, struct lruvec *lruvec,
52805276

52815277
seq_puts(m, " ");
52825278
for (i = 0; i < NR_MM_STATS; i++) {
5283-
const char *s = " ";
5279+
const char *s = "xxxx";
52845280
unsigned long n = 0;
52855281

52865282
if (seq == max_seq && NR_HIST_GENS == 1) {
5287-
s = "LOYNFA";
5283+
s = "TYFA";
52885284
n = READ_ONCE(mm_state->stats[hist][i]);
52895285
} else if (seq != max_seq && NR_HIST_GENS > 1) {
5290-
s = "loynfa";
5286+
s = "tyfa";
52915287
n = READ_ONCE(mm_state->stats[hist][i]);
52925288
}
52935289

0 commit comments

Comments
 (0)