* [PATCH v2] mm/damon/ops-common: factor out damon_putback_folio_list()
@ 2026-08-18 2:06 dayou5941
2026-08-18 2:11 ` sashiko-bot
2026-08-18 3:21 ` SJ Park
0 siblings, 2 replies; 3+ messages in thread
From: dayou5941 @ 2026-08-18 2:06 UTC (permalink / raw)
To: sj, akpm; +Cc: damon, linux-mm, linux-kernel, Li Youhong
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] mm/damon/ops-common: factor out damon_putback_folio_list()
2026-08-18 2:06 [PATCH v2] mm/damon/ops-common: factor out damon_putback_folio_list() dayou5941
@ 2026-08-18 2:11 ` sashiko-bot
2026-08-18 3:21 ` SJ Park
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-08-18 2:11 UTC (permalink / raw)
To: dayou5941; +Cc: damon
> 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>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818020650.2844354-1-dayou5941@163.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm/damon/ops-common: factor out damon_putback_folio_list()
2026-08-18 2:06 [PATCH v2] mm/damon/ops-common: factor out damon_putback_folio_list() dayou5941
2026-08-18 2:11 ` sashiko-bot
@ 2026-08-18 3:21 ` SJ Park
1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-08-18 3:21 UTC (permalink / raw)
To: dayou5941; +Cc: SJ Park, akpm, damon, linux-mm, linux-kernel, Li Youhong
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
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-18 3:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 2:06 [PATCH v2] mm/damon/ops-common: factor out damon_putback_folio_list() dayou5941
2026-08-18 2:11 ` sashiko-bot
2026-08-18 3:21 ` SJ 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.