mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mm/damon: align MMU notifier range when clearing PMD young bit
@ 2026-10-22 14:26 Aveline Noir
  2026-10-23  0:20 ` SJ Park
  0 siblings, 1 reply; 2+ messages in thread
From: Aveline Noir @ 2026-10-22 14:26 UTC (permalink / raw)
  To: SJ Park, Andrew Morton; +Cc: Shubhang Kaushik, damon, linux-mm, linux-kernel

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@gentwo.org/
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
---
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-23  0:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 14:26 [PATCH] mm/damon: align MMU notifier range when clearing PMD young bit Aveline Noir
2026-10-23  0:20 ` SJ Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®