All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/damon/vaddr: avoid unnecessary migration between target nodes
@ 2025-08-03 13:00 Akinobu Mita
  2025-08-03 18:01 ` SeongJae Park
  0 siblings, 1 reply; 7+ messages in thread
From: Akinobu Mita @ 2025-08-03 13:00 UTC (permalink / raw)
  To: damon; +Cc: akinobu.mita, SeongJae Park, Bijan Tabatabai

This change avoids unnecessary migration by checking if the folio to which
the migration is applied is already located in one of the target nodes.

Cc: SeongJae Park <sj@kernel.org>
Cc: Bijan Tabatabai <bijantabatab@micron.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 mm/damon/vaddr.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index 87e825349bdf..d531763a3b2b 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -665,6 +665,7 @@ static bool damos_va_filter_out(struct damos *scheme, struct folio *folio,
 struct damos_va_migrate_private {
 	struct list_head *migration_lists;
 	struct damos *scheme;
+	nodemask_t dest_nodes;
 };
 
 /*
@@ -747,6 +748,8 @@ static int damos_va_migrate_pmd_entry(pmd_t *pmd, unsigned long addr,
 	if (!folio)
 		goto unlock;
 
+	if (node_isset(folio_nid(folio), priv->dest_nodes))
+		goto put_folio;
 	if (damos_va_filter_out(s, folio, walk->vma, addr, NULL, pmd))
 		goto put_folio;
 
@@ -781,6 +784,8 @@ static int damos_va_migrate_pte_entry(pte_t *pte, unsigned long addr,
 	if (!folio)
 		return 0;
 
+	if (node_isset(folio_nid(folio), priv->dest_nodes))
+		goto put_folio;
 	if (damos_va_filter_out(s, folio, walk->vma, addr, pte, NULL))
 		goto put_folio;
 
@@ -865,10 +870,13 @@ static unsigned long damos_va_migrate(struct damon_target *target,
 		sizeof(*priv.migration_lists), GFP_KERNEL);
 	if (!priv.migration_lists)
 		return 0;
+	priv.dest_nodes = NODE_MASK_NONE;
 
-	for (int i = 0; i < nr_dests; i++)
+	for (int i = 0; i < nr_dests; i++) {
 		INIT_LIST_HEAD(&priv.migration_lists[i]);
-
+		node_set(use_target_nid ? s->target_nid : dests->node_id_arr[i],
+				priv.dest_nodes);
+	}
 
 	mm = damon_get_mm(target);
 	if (!mm)
-- 
2.34.1


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

end of thread, other threads:[~2025-08-05 17:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-03 13:00 [PATCH] mm/damon/vaddr: avoid unnecessary migration between target nodes Akinobu Mita
2025-08-03 18:01 ` SeongJae Park
2025-08-04 12:46   ` Akinobu Mita
2025-08-04 15:19     ` Bijan Tabatabai
2025-08-04 16:43       ` SeongJae Park
2025-08-05 16:04         ` Akinobu Mita
2025-08-05 17:51           ` SeongJae Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.