mm/damon/ops-common.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
From: Li Youhong <liyouhong@kylinos.cn>
The putback loop is duplicated in damon_migrate_folio_list() and on the
invalid-nid path of damon_migrate_pages(). Factor it into a small helper
for readability. No functional change.
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
---
v2:
- Restore the removed "struct folio *folio" local variable to fix build error.
- Use get_maintainer.pl to include linux-mm@kvack.org, linux-kernel@vger.kernel.org and relevant DAMON maintainers.
v1: https://lore.kernel.org/all/20260817063458.351063-1-dayou5941@163.com/
---
mm/damon/ops-common.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c
index 0bcad6b1e5b9..ae101689612b 100644
--- a/mm/damon/ops-common.c
+++ b/mm/damon/ops-common.c
@@ -329,6 +329,19 @@ static unsigned int __damon_migrate_folio_list(
return nr_succeeded;
}
+static void damon_putback_folio_list(struct list_head *folio_list)
+{
+ struct folio *folio;
+
+ while (!list_empty(folio_list)) {
+ folio = lru_to_folio(folio_list);
+ list_del(&folio->lru);
+ node_stat_sub_folio(folio, NR_ISOLATED_ANON +
+ folio_is_file_lru(folio));
+ folio_putback_lru(folio);
+ }
+}
+
static unsigned int damon_migrate_folio_list(struct list_head *folio_list,
struct pglist_data *pgdat,
int target_nid)
@@ -372,13 +385,7 @@ static unsigned int damon_migrate_folio_list(struct list_head *folio_list,
list_splice(&ret_folios, folio_list);
- while (!list_empty(folio_list)) {
- folio = lru_to_folio(folio_list);
- list_del(&folio->lru);
- node_stat_sub_folio(folio, NR_ISOLATED_ANON +
- folio_is_file_lru(folio));
- folio_putback_lru(folio);
- }
+ damon_putback_folio_list(folio_list);
return nr_migrated;
}
@@ -395,14 +402,7 @@ unsigned long damon_migrate_pages(struct list_head *folio_list, int target_nid)
if (target_nid < 0 || target_nid >= MAX_NUMNODES ||
!node_state(target_nid, N_MEMORY)) {
- while (!list_empty(folio_list)) {
- struct folio *folio = lru_to_folio(folio_list);
-
- list_del(&folio->lru);
- node_stat_sub_folio(folio, NR_ISOLATED_ANON +
- folio_is_file_lru(folio));
- folio_putback_lru(folio);
- }
+ damon_putback_folio_list(folio_list);
return nr_migrated;
}
--
2.25.1
On Tue, 18 Aug 2026 10:06:50 +0800 dayou5941@163.com wrote: > From: Li Youhong <liyouhong@kylinos.cn> > > The putback loop is duplicated in damon_migrate_folio_list() and on the > invalid-nid path of damon_migrate_pages(). Factor it into a small helper > for readability. No functional change. Thank you for this nice cleanup. > > Signed-off-by: Li Youhong <liyouhong@kylinos.cn> Reviewed-by: SJ Park <sj@kernel.org> This patch is applied to damon/next [1] tree. If this patch is not added to mm.git in short term, I will ask mm.git maintainer (Andrew Morton) to pick this. So, no action from your side is needed for now. Note that we are in the middle of the merge window. Andrew might not pick this until the end of the merge window. I will make the action only after the merge window is closed. If it seems I also forgot doing that or you cannot wait for my action, please feel free to directly ask that to Andrew. [1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees Thanks, SJ [...]
© 2016 - 2026 Red Hat, Inc.