mm/damon: use alloc_migrate_target() for DAMOS_MIGRATE_{HOT,COLD}
Subsystems (5)
SeongJae Park
maintainercover mm/damon: use alloc_migrate_target() for DAMOS_MIGRATE_{HOT,COLD}
DAMOS_MIGRATE_{HOT,COLD} implementation resembles that for demotion, and hence the behavior is also similar to that. But, since those are not only for demotion but general migrations, it would be better to match with that for move_pages() system call. Make the implementation and the behavior more similar to move_pages() by not setting migration fallback nodes, and using alloc_migration_target() instead of alloc_migrate_folio().
alloc_migrate_folio() was renamed from alloc_demote_folio() and been non-static function, to let DAMOS_MIGRATE_{HOT,COLD} call it. As alloc_migration_target() is called instead, the renaming and de-static changes are no more required but could only make future code readers be confused. Revert the changes, too.
Changes from RFC
(https://lore.kernel.org/[email protected])
- Rebase to latest mm-new
- Slightly wordsmith cv and commit messages
SeongJae Park (3):
mm/damon/paddr: use alloc_migartion_target() with no migration
fallback nodemask
Revert "mm: rename alloc_demote_folio to alloc_migrate_folio" Revert "mm: make alloc_demote_folio externally invokable for
migration"
mm/damon/paddr.c | 4 +--- mm/internal.h | 1 - mm/vmscan.c | 5 +++-- 3 files changed, 4 insertions(+), 6 deletions(-)
base-commit: b29ac9653c1fae75d3444b6a03521c74adb6d4cc
Signature · 1 line
2.39.5
SeongJae Park
maintainerPATCH 1/3 mm/damon/paddr: use alloc_migartion_target() with no migration fallback nodemask
DAMOS_MIGRATE_{HOT,COLD} implementation resembles that for demote_folio_list(). Because those are not only for demotion but general folio migrations, it makes more sense to behave similarly to move_pages() system call. Make the behavior more similar to move_pages(), by using alloc_migration_target() instead of alloc_migrate_folio(), without fallback nodemask.
--- mm/damon/paddr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
mm/damon/paddr.c +1 -3
@@ -386,7 +386,6 @@ static unsigned int __damon_pa_migrate_folio_list( int target_nid) {unsigned int nr_succeeded =0 ; -nodemask_t allowed_mask =NODE_MASK_NONE ;struct migration_target_control mtc = {/* * Allocate from 'node', or fail quickly and quietly.
@@ -396,7 +395,6 @@ static unsigned int __damon_pa_migrate_folio_list( .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | __GFP_NOWARN | __GFP_NOMEMALLOC | GFP_NOWAIT, .nid = target_nid, - .nmask = &allowed_mask };if (pgdat->node_id == target_nid || target_nid ==NUMA_NO_NODE )
@@ -406,7 +404,7 @@ static unsigned int __damon_pa_migrate_folio_list(return 0 ;/* Migration ignores all cpuset and mempolicy settings */ -migrate_pages (migrate_folios, alloc_migrate_folio,NULL , +migrate_pages (migrate_folios, alloc_migration_target,NULL , (unsigned long )&mtc,MIGRATE_ASYNC ,MR_DAMON , &nr_succeeded);
Signature · 1 line
2.39.5
SeongJae Park
maintainerPATCH 2/3 Revert "mm: rename alloc_demote_folio to alloc_migrate_folio"
In reply to SeongJae ParkThis reverts commit 8f75267d22bdf8e3baf70f2fa7092d8c2f58da71.
Commit 8f75267d22bd ("mm: rename alloc_demote_folio to alloc_migrate_folio") was to reflect the fact the function is called for not only demotion, but also general migrations from DAMOS_MIGRATE_{HOT,COLD}. The previous commit made the DAMOS actions to not use alloc_migrate_folio(), though. So, demote_folio_list() is the only caller of alloc_migrate_folio(), and the name could now be rather confusing. Revert the renaming commit.
--- mm/internal.h | 2 +- mm/vmscan.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
mm/internal.h +1 -1
@@ -1227,7 +1227,7 @@ extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long, unsigned long, unsigned long);extern void set_pageblock_order (void ); -struct folio *alloc_migrate_folio (struct folio *src,unsigned long private); +struct folio *alloc_demote_folio (struct folio *src,unsigned long private);unsigned long reclaim_pages (struct list_head *folio_list);unsigned int reclaim_clean_pages_from_list (struct zone *zone,struct list_head *folio_list);
mm/vmscan.c +2 -2
@@ -1006,7 +1006,7 @@ static void folio_check_dirty_writeback(struct folio *folio, mapping->a_ops->is_dirty_writeback (folio, dirty, writeback); } -struct folio *alloc_migrate_folio (struct folio *src,unsigned long private) +struct folio *alloc_demote_folio (struct folio *src,unsigned long private) {struct folio *dst;nodemask_t *allowed_mask;
@@ -1069,7 +1069,7 @@ static unsigned int demote_folio_list(struct list_head *demote_folios,node_get_allowed_targets (pgdat, &allowed_mask);/* Demotion ignores all cpuset and mempolicy settings */ -migrate_pages (demote_folios, alloc_migrate_folio,NULL , +migrate_pages (demote_folios, alloc_demote_folio,NULL , (unsigned long )&mtc,MIGRATE_ASYNC ,MR_DEMOTION , &nr_succeeded);
Signature · 1 line
2.39.5
SeongJae Park
maintainerPATCH 3/3 Revert "mm: make alloc_demote_folio externally invokable for migration"
In reply to SeongJae ParkThis reverts commit a00ce85af2a1be494d3b0c9457e8e81cdcce2a89.
Commit a00ce85af2a1 ("mm: make alloc_demote_folio externally invokable for migration") was made to let DAMOS_MIGRATE_{HOT,COLD} call the function. But a previous commit made DAMOS_MIGRATE_{HOT,COLD} call alloc_migration_target() instead. Hence there are no more callers of the function outside of vmscan.c. Revert the commit to make the function static again.
--- mm/internal.h | 1 - mm/vmscan.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
mm/internal.h +0 -1
@@ -1227,7 +1227,6 @@ extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long, unsigned long, unsigned long);extern void set_pageblock_order (void ); -struct folio *alloc_demote_folio (struct folio *src,unsigned long private);unsigned long reclaim_pages (struct list_head *folio_list);unsigned int reclaim_clean_pages_from_list (struct zone *zone,struct list_head *folio_list);
mm/vmscan.c +2 -1
@@ -1006,7 +1006,8 @@ static void folio_check_dirty_writeback(struct folio *folio, mapping->a_ops->is_dirty_writeback (folio, dirty, writeback); } -struct folio *alloc_demote_folio (struct folio *src,unsigned long private) +static struct folio *alloc_demote_folio (struct folio *src, +unsigned long private) {struct folio *dst;nodemask_t *allowed_mask;
Signature · 1 line
2.39.5
Quoted 8 lines · On Mon, 16 Jun 2025 10:23:43 -0700 SeongJae Park <[email protected]> wrote:
DAMOS_MIGRATE_{HOT,COLD} implementation resembles that for demotion, and hence the behavior is also similar to that. But, since those are not only for demotion but general migrations, it would be better to match with that for
move_pages()system call. Make the implementation and the behavior more similar tomove_pages()by not setting migration fallback nodes, and usingalloc_migration_target()instead ofalloc_migrate_folio().
Quoted 5 lines
alloc_migrate_folio()was renamed fromalloc_demote_folio()and been non-static function, to let DAMOS_MIGRATE_{HOT,COLD} call it. Asalloc_migration_target()is called instead, the renaming and de-static changes are no more required but could only make future code readers be confused. Revert the changes, too.
Hi SJ,
I hope you are doing well!
These changes all look good to me. And I agree that changing the behavior to mimic migration as opposed to demotion might be helpful in making opportunities for others to use DAMOS as a means to perform other related works (like [1]), without having to use a "demotion" mechanism for simply moving pages around.
I do have one question: I'm curious what kinds of changes callers can expect. Would I be correct in understanding that this is mostly a semantic change (aside from no longer having a fallback nodemask)? Just want to make sure I have a correct understanding of your intent was.
In the meantime, feel free to add the following to the series:
Have a great day!
Joshua
[1] https://lore.kernel.org/all/[email protected]/
Sent using hkml (https://github.com/sjp38/hackermail)
SeongJae Park
maintainerHi Joshua,
Quoted 10 lines · On Mon, 16 Jun 2025 14:31:58 -0700 Joshua Hahn <[email protected]> wrote:
Quoted 8 lines · On Mon, 16 Jun 2025 10:23:43 -0700 SeongJae Park <[email protected]> wrote:
DAMOS_MIGRATE_{HOT,COLD} implementation resembles that for demotion, and hence the behavior is also similar to that. But, since those are not only for demotion but general migrations, it would be better to match with that for
move_pages()system call. Make the implementation and the behavior more similar tomove_pages()by not setting migration fallback nodes, and usingalloc_migration_target()instead ofalloc_migrate_folio().
Quoted 8 lines
Quoted 5 lines
alloc_migrate_folio()was renamed fromalloc_demote_folio()and been non-static function, to let DAMOS_MIGRATE_{HOT,COLD} call it. Asalloc_migration_target()is called instead, the renaming and de-static changes are no more required but could only make future code readers be confused. Revert the changes, too.Hi SJ,
I hope you are doing well!
Thank you, you too! :)
Quoted 11 lines
These changes all look good to me. And I agree that changing the behavior to mimic migration as opposed to demotion might be helpful in making opportunities for others to use DAMOS as a means to perform other related works (like [1]), without having to use a "demotion" mechanism for simply moving pages around.
I do have one question: I'm curious what kinds of changes callers can expect. Would I be correct in understanding that this is mostly a semantic change (aside from no longer having a fallback nodemask)? Just want to make sure I have a correct understanding of your intent was.
You're correct. This is not changing any DAMON interface, so DAMON API callers and DAMON ABI users would not need to make any change from their side.
Quoted 3 lines
In the meantime, feel free to add the following to the series:
Reviewed-by Joshua Hahn <[email protected]>
Thank you! :)
Quoted 2 lines
Have a great day!
You too!
Thanks,
SJ
[...]