From: sashiko-bot@kernel.org
To: "Kefeng Wang" <wangkefeng.wang@huawei.com>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH] mm/damon/vaddr: attempt per-vma lock during page table walk
Date: Tue, 12 May 2026 05:26:28 +0000 [thread overview]
Message-ID: <20260512052628.83798C2BCC7@smtp.kernel.org> (raw)
In-Reply-To: <20260511132546.1973270-1-wangkefeng.wang@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Inconsistent VMA Filtering (VM_PFNMAP) in damon_va_walk_page_range()
--
commit b5bde92b4c2b28a90660c48f50de91cd04010328
Author: Kefeng Wang <wangkefeng.wang@huawei.com>
mm/damon/vaddr: attempt per-vma lock during page table walk
This commit introduces damon_va_walk_page_range() to optimize DAMON's
virtual address page table walks. It attempts to acquire a per-VMA lock
and proceeds with walk_page_range_vma() if the range is contained within
a single VMA, falling back to the mmap_read_lock and walk_page_range()
otherwise.
> diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
> index 1b0ebe3b6951e..eed2ae132a589 100644
> --- a/mm/damon/vaddr.c
> +++ b/mm/damon/vaddr.c
> @@ -237,6 +237,32 @@ static void damon_va_update(struct damon_ctx *ctx)
> }
> }
>
> +static void damon_va_walk_page_range(struct mm_struct *mm, unsigned long start,
> + unsigned long end, struct mm_walk_ops *ops, void *private)
> +{
> + struct vm_area_struct *vma;
> +
> + vma = lock_vma_under_rcu(mm, start);
> + if (!vma)
> + goto lock_mmap;
> +
> + if (end > vma->vm_end) {
> + vma_end_read(vma);
> + goto lock_mmap;
> + }
> +
> + ops->walk_lock = PGWALK_VMA_RDLOCK_VERIFY;
> + walk_page_range_vma(vma, start, end, ops, private);
> + vma_end_read(vma);
> + return;
> +
> +lock_mmap:
> + mmap_read_lock(mm);
> + ops->walk_lock = PGWALK_RDLOCK;
> + walk_page_range(mm, start, end, ops, private);
> + mmap_read_unlock(mm);
> +}
Does this code handle VMAs with the VM_PFNMAP flag inconsistently?
In the fallback path using walk_page_range(), the page walker calls
walk_page_test(), which skips VM_PFNMAP VMAs by default since the DAMON
operations structures do not provide a test_walk callback.
However, the fast path uses walk_page_range_vma(), which bypasses
walk_page_test() entirely and directly walks the page range.
This means that if a queried address range is fully contained within a single
VM_PFNMAP VMA, the page tables will be walked via the fast path. But if the
same VMA is part of a larger range, the mmap lock fallback is triggered and
the VMA is properly skipped.
Can this lead to DAMON improperly modifying PTEs on raw PFN device mappings,
such as clearing the young bit in damon_mkold_pmd_entry(), when taking the
fast path?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511132546.1973270-1-wangkefeng.wang@huawei.com?part=1
prev parent reply other threads:[~2026-05-12 5:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 13:25 [PATCH] mm/damon/vaddr: attempt per-vma lock during page table walk Kefeng Wang
2026-05-12 1:31 ` SeongJae Park
2026-05-12 13:59 ` Kefeng Wang
2026-05-12 14:08 ` SeongJae Park
2026-05-12 5:26 ` sashiko-bot [this message]
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=20260512052628.83798C2BCC7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko@lists.linux.dev \
--cc=wangkefeng.wang@huawei.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