From: sashiko-bot@kernel.org
To: "Krishna Iyer" <kiyer@crusoe.ai>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 3/6] mm/damon/paddr: support hugetlb folios in access monitoring
Date: Sun, 30 Aug 2026 05:29:35 +0000 [thread overview]
Message-ID: <20260830052936.44F301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830051407.50008-4-kiyer@crusoe.ai>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Non-atomic huge PTE modification in damon_hugetlb_mkold() causes a TOCTOU race with hardware page table walkers, silently dropping dirty bits.
- [High] Incorrect physical address advancement when starting from a tail page of a large folio.
--
commit fa7cc985c2891991281afce141ed40264af354fe
Author: Krishna Iyer <kiyer@crusoe.ai>
mm/damon/paddr: support hugetlb folios in access monitoring
DAMON's physical address space monitoring is blind to hugetlb-backed
memory. Every access check starts at damon_get_folio(), which rejects
folios that are not on the LRU lists. This commit adds
damon_get_folio_incl_hugetlb() to additionally accept hugetlb folios.
[ ... ]
> diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
> index 62004206ca310..ece101d346844 100644
> --- a/mm/damon/ops-common.c
> +++ b/mm/damon/ops-common.c
[ ... ]
[Severity: Critical]
This is a pre-existing issue, but does this non-atomic huge PTE modification
drop hardware dirty bits?
In damon_hugetlb_mkold() in mm/damon/ops-common.c:
pte_t entry = huge_ptep_get(mm, addr, pte);
struct folio *folio = pfn_folio(pte_pfn(entry));
unsigned long psize = huge_page_size(hstate_vma(vma));
folio_get(folio);
if (pte_young(entry)) {
referenced = true;
entry = pte_mkold(entry);
set_huge_pte_at(mm, addr, pte, entry, psize);
}
If a hardware page table walker sets the dirty bit concurrently between the
read and the write, does the non-atomic writeback via set_huge_pte_at()
silently overwrite and clear the dirty bit?
[Severity: High]
This isn't a bug introduced by this patch, but does this physical address
advancement skip memory pages?
In damon_pa_pageout() in mm/damon/paddr.c:
addr = damon_pa_phys_addr(r->ar.start, addr_unit);
while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
folio = damon_get_folio(PHYS_PFN(addr));
...
put_folio:
addr += folio_size(folio);
folio_put(folio);
}
If the region's start address is not naturally aligned to the folio boundary
and lands on a tail page of a large folio, does adding the full folio size
overshoot the start of the next folio?
The same pattern appears in damon_pa_stat() where it also over-accounts the
filter size:
if (damos_pa_filter_out(s, folio))
goto put_folio;
else
*sz_filter_passed += folio_size(folio) / addr_unit;
...
put_folio:
addr += folio_size(folio);
folio_put(folio);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260830051407.50008-1-kiyer@crusoe.ai?part=3
next prev parent reply other threads:[~2026-08-30 5:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 5:14 [PATCH 0/6] mm/damon: support access monitoring of hugetlb-backed memory Krishna Iyer
2026-08-30 5:14 ` [PATCH 1/6] mm/damon: move damon_hugetlb_mkold() from vaddr to ops-common Krishna Iyer
2026-08-30 5:26 ` sashiko-bot
2026-08-30 16:33 ` SJ Park
2026-08-30 5:14 ` [PATCH 2/6] mm/damon/ops-common: handle hugetlb folios in folio mkold/young rmap walkers Krishna Iyer
2026-08-30 5:28 ` sashiko-bot
2026-08-30 16:13 ` SJ Park
2026-08-30 18:10 ` SJ Park
2026-08-30 16:48 ` SJ Park
2026-08-30 5:14 ` [PATCH 3/6] mm/damon/paddr: support hugetlb folios in access monitoring Krishna Iyer
2026-08-30 5:29 ` sashiko-bot [this message]
2026-08-30 16:15 ` SJ Park
2026-08-30 17:12 ` SJ Park
2026-08-30 5:14 ` [PATCH 4/6] mm/damon: support flush-assisted access bit clearing for monitoring Krishna Iyer
2026-08-30 5:23 ` sashiko-bot
2026-08-30 5:14 ` [PATCH 5/6] mm/damon/sysfs: support aging_flush Krishna Iyer
2026-08-30 5:22 ` sashiko-bot
2026-08-30 5:14 ` [PATCH 6/6] mm/damon/stat: " Krishna Iyer
2026-08-30 5:18 ` sashiko-bot
2026-08-30 18:04 ` [PATCH 0/6] mm/damon: support access monitoring of hugetlb-backed memory SJ Park
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=20260830052936.44F301F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=kiyer@crusoe.ai \
--cc=sashiko-reviews@lists.linux.dev \
/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