[RFC PATCH 05/10] mm/damon/paddr: support addr_unit for MIGRATE_{HOT,COLD}

SeongJae Park
2025-04-16T04:26:02Z

Add support of addr_unit for DAMOS_MIGRATE_HOT and DAMOS_MIGRATE_COLD
action handling from the DAMOS operation implementation for the physical
address space.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/paddr.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index fc1c720e8cb5..20955eefcdbf 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -518,15 +518,17 @@ static unsigned long damon_pa_migrate_pages(struct list_head *folio_list,
return nr_migrated;
}

-static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s,
+static unsigned long damon_pa_migrate(struct damon_region *r,
+ unsigned long addr_unit, struct damos *s,
unsigned long *sz_filter_passed)
{
- unsigned long addr, applied;
+ phys_addr_t addr;
+ unsigned long applied;
LIST_HEAD(folio_list);
struct folio *folio;

- addr = r->ar.start;
- while (addr < r->ar.end) {
+ addr = damon_pa_phys_addr(r->ar.start, addr_unit);
+ while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
folio = damon_get_folio(PHYS_PFN(addr));
if (damon_pa_invalid_damos_folio(folio, s)) {
addr += PAGE_SIZE;
@@ -691,7 +693,7 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx,
sz_filter_passed);
case DAMOS_MIGRATE_HOT:
case DAMOS_MIGRATE_COLD:
- return damon_pa_migrate(r, scheme, sz_filter_passed);
+ return damon_pa_migrate(r, aunit, scheme, sz_filter_passed);
#ifdef CONFIG_ACMA
case DAMOS_ALLOC:
return damon_pa_alloc_or_free(r, scheme, true);
--
2.39.5