From: Baoquan He <baoquan.he@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: linux-mm@kvack.org, 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: Tue, 24 Nov 2026 15:21:08 +0800 [thread overview]
Message-ID: <awU65FQ4XGGdwMpG@bogon> (raw)
In-Reply-To: <sashiko-outbox-226848@kernel.org>
On 11/21/26 at 08:59am, sashiko-bot@kernel.org wrote:
> 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()
> --
>
...snip...
> > @@ -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)?
Agreed, and the counter is not worth keeping. MM_LEAF_YOUNG already
counts the leaves we care about: it is incremented after get_pfn_folio()
confirms the folio belongs to this lruvec. So v5 drops MM_LEAF_ASSOCIATED.
>
> 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-24 7:21 UTC|newest]
Thread overview: 9+ 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
2026-11-24 7:21 ` Baoquan He [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
2026-11-24 7:22 ` [PATCH 0/4] skip empty PUD subtrees during aging with a PUD-level Bloom 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=awU65FQ4XGGdwMpG@bogon \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox