From: sashiko-bot@kernel.org
To: "Baoquan He" <baoquan.he@linux.dev>, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, david@kernel.org, kasong@tencent.com,
baohua@kernel.org, qi.zheng@linux.dev, shakeel.butt@linux.dev,
axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
baolin.wang@linux.alibaba.com,
"Baoquan He" <hebaoquan@kylinos.cn>
Subject: Re: [PATCH 1/4] mm/mglru: add MM_WALK_EMPTY stats and tracepoint
Date: Sat, 21 Nov 2026 08:59:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-226848@kernel.org> (raw)
In-Reply-To: <20261120085806.781225-2-baoquan.he@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/mglru: inconsistent MM_LEAF_ASSOCIATED accounting across
mm_has_notifiers()
--
commit 4f0dadfe0435dfb7f058c5e9c459aef67be5dff2
Author: Baoquan He <hebaoquan@kylinos.cn>
mm/mglru: add MM_WALK_EMPTY stats and tracepoint
This commit adds MGLRU aging statistics (MM_LEAF_ASSOCIATED,
MM_WALK_TOTAL, MM_WALK_EMPTY, and MM_LEAF_EMPTY_WALKS) and the
mm_vmscan_lru_gen_walk tracepoint to track page-table walks that find no
matching folios in the target lruvec.
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 6a2ad0cff7951..902f4877fd0cb 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -579,6 +579,10 @@ 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_LEAF_ASSOCIATED, /* young leaf entries whose folio is in this lruvec */
> + MM_WALK_TOTAL, /* page-table walks completed */
> + MM_WALK_EMPTY, /* walks that found nothing young for this lruvec */
> + MM_LEAF_EMPTY_WALKS, /* leaf entries scanned during empty walks */
> NR_MM_STATS
> };
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index bc7579d47f9b4..36e0946bf2cc4 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3584,6 +3584,8 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end,
> if (!folio)
> continue;
>
> + walk->mm_stats[MM_LEAF_ASSOCIATED]++;
> +
> if (folio_test_large(folio)) {
> const unsigned int max_nr = (end - addr) >> PAGE_SHIFT;
>
> @@ -3591,6 +3593,7 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end,
> max_nr, FPB_MERGE_YOUNG_DIRTY);
> total += nr - 1;
> walk->mm_stats[MM_LEAF_TOTAL] += nr - 1;
> + walk->mm_stats[MM_LEAF_ASSOCIATED] += nr - 1;
> }
>
> if (!test_and_clear_young_ptes_notify(args->vma, addr, cur_pte, nr))
> @@ -3682,6 +3685,8 @@ static void walk_pmd_range_locked(pud_t *pud, unsigned long addr, struct vm_area
> if (!folio)
> goto next;
>
> + walk->mm_stats[MM_LEAF_ASSOCIATED]++;
> +
> if (!pmdp_test_and_clear_young_notify(vma, addr, pmd + i))
> goto next;
>
[Severity: Medium]
Does MM_LEAF_ASSOCIATED count all leaf entries belonging to the target
lruvec (as described in the commit message), or only young leaf entries
in the target lruvec (as described in the header comments)?
In walk_pte_range() and walk_pmd_range_locked(), get_pte_pfn() and
get_pmd_pfn() filter out non-young entries before get_pfn_folio() is
reached whenever !mm_has_notifiers(vma->vm_mm):
mm/vmscan.c:get_pte_pfn() {
...
if (!pte_young(pte) && !mm_has_notifiers(vma->vm_mm))
return -1;
...
}
When !mm_has_notifiers(vma->vm_mm), every entry that reaches
get_pfn_folio(pfn, memcg, pgdat) is already young, so MM_LEAF_ASSOCIATED
is identical to MM_LEAF_YOUNG (which also only counts young entries after
get_pfn_folio() verifies the folio belongs to this lruvec), and an mm
with old folios in the lruvec is still counted as MM_WALK_EMPTY.
Conversely, when mm_has_notifiers(vma->vm_mm) is true (such as KVM
guests), get_pte_pfn() and get_pmd_pfn() let non-young entries through so
secondary MMU notifiers can be checked by
test_and_clear_young_ptes_notify() and pmdp_test_and_clear_young_notify().
Because MM_LEAF_ASSOCIATED is incremented before those notify calls, it
counts both old and young entries when mm_has_notifiers(vma->vm_mm) is
true, giving MM_LEAF_ASSOCIATED and MM_WALK_EMPTY different meanings
depending on whether the mm has MMU notifiers registered.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120085806.781225-1-baoquan.he@linux.dev?part=1
next prev parent reply other threads:[~2026-11-21 8:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 8:58 [PATCH 0/4] skip empty PUD subtrees during aging with a PUD-level Bloom filter Baoquan He
2026-11-20 8:58 ` [PATCH 1/4] mm/mglru: add MM_WALK_EMPTY stats and tracepoint Baoquan He
2026-11-21 8:59 ` sashiko-bot [this message]
2026-11-20 8:58 ` [PATCH 2/4] mm/mglru: add PUD-level Bloom filter state and generic helpers Baoquan He
2026-11-20 8:58 ` [PATCH 3/4] mm/mglru: skip cold PUD subtrees during aging Baoquan He
2026-11-21 8:59 ` sashiko-bot
2026-11-20 8:58 ` [PATCH 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=sashiko-outbox-226848@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=david@kernel.org \
--cc=hebaoquan@kylinos.cn \
--cc=kasong@tencent.com \
--cc=linux-mm@kvack.org \
--cc=qi.zheng@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shakeel.butt@linux.dev \
--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.