[PATCH] mm/damon: align MMU notifier range when clearing PMD young bit
From: Aveline Noir
Date: Thu Oct 22 2026 - 11:06:58 EST
damon_pmdp_mkold() clears the young bit of a PMD but notifies
[addr, addr + HPAGE_PMD_SIZE), where addr can be an unaligned sampling
address. This can miss part of the sampled huge page and age secondary
mappings in the next one.
Align addr to HPAGE_PMD_MASK so both operations cover the same huge page.
Fixes: 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces")
Link: https://lore.kernel.org/r/20261021-damon-align-pte-young-notifier-v1-1-d0365ac45b66@xxxxxxxxxx/
Signed-off-by: Aveline Noir <jm5905938@xxxxxxxxx>
---
Tested both aligned and unaligned addresses on 2 MiB THPs in an x86-64 KVM
guest with a recording MMU notifier; all ranges matched the sampled PMD.
DAMON KUnit: 37 passed; selftests: 13 passed, 2 skipped.
mm/damon/ops-common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 8fc61d0..3b7519b 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -83,6 +83,8 @@ void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr
bool young = false;
unsigned long pfn;
+ addr &= HPAGE_PMD_MASK;
+
if (likely(pmd_present(pmdval)))
pfn = pmd_pfn(pmdval);
else
--
2.56.0