[RFC PATCH V3 04/17] mm/kscand: Add only hot pages to migration list

Raghavendra K T
2025-08-14T15:34:17Z

Previously all pages, accessed once are added.
Improve it by adding those that are accessed second time.

This logic is closer to current NUMAB implementation
of spotting hot pages.

Signed-off-by: Raghavendra K T <raghavendra.kt@amd.com>
---
mm/kscand.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/kscand.c b/mm/kscand.c
index 1d883d411664..7552ce32beea 100644
--- a/mm/kscand.c
+++ b/mm/kscand.c
@@ -196,6 +196,7 @@ static int hot_vma_idle_pte_entry(pte_t *pte,
struct kscand_migrate_info *info;
struct kscand_scanctrl *scanctrl = walk->private;
int srcnid;
+ bool prev_idle;

scanctrl->address = addr;
pte_t pteval = ptep_get(pte);
@@ -219,6 +220,7 @@ static int hot_vma_idle_pte_entry(pte_t *pte,
folio_put(folio);
return 0;
}
+ prev_idle = folio_test_idle(folio);
folio_set_idle(folio);
page_idle_clear_pte_refs(page, pte, walk);
srcnid = folio_nid(folio);
@@ -233,7 +235,7 @@ static int hot_vma_idle_pte_entry(pte_t *pte,
folio_put(folio);
return 0;
}
- if (!folio_test_idle(folio) &&
+ if (!folio_test_idle(folio) && !prev_idle &&
(folio_test_young(folio) || folio_test_referenced(folio))) {

/* XXX: Leaking memory. TBD: consume info */
--
2.34.1