[RFC PATCH 1/3] mm/damon: add damon_region->last_probe_hits
From: SeongJae Park
Date: Sun Jun 21 2026 - 17:42:55 EST
Add new damon_region filed, last_probe_hits. Maintain fully accumulated
probe_hits values from the last aggregation interval in the field.
Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
include/linux/damon.h | 2 +-
mm/damon/core.c | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index fc3d467dc2e34..f0dd45ca788f5 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -70,10 +70,10 @@ struct damon_region {
unsigned int nr_accesses;
unsigned char probe_hits[DAMON_MAX_PROBES];
struct list_head list;
-
unsigned int age;
/* private: Internal value for age calculation. */
unsigned int last_nr_accesses;
+ unsigned char last_probe_hits[DAMON_MAX_PROBES];
};
/**
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 4f7954b383d18..e84f2f1b07cc6 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -304,8 +304,10 @@ struct damon_region *damon_new_region(unsigned long start, unsigned long end)
region->ar.start = start;
region->ar.end = end;
region->nr_accesses = 0;
- for (i = 0; i < DAMON_MAX_PROBES; i++)
+ for (i = 0; i < DAMON_MAX_PROBES; i++) {
region->probe_hits[i] = 0;
+ region->last_probe_hits[i] = 0;
+ }
INIT_LIST_HEAD(®ion->list);
region->age = 0;
@@ -2024,8 +2026,10 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
damon_nr_regions(t), nr_probes);
r->last_nr_accesses = r->nr_accesses;
r->nr_accesses = 0;
- for (i = 0; i < DAMON_MAX_PROBES; i++)
+ for (i = 0; i < DAMON_MAX_PROBES; i++) {
+ r->last_probe_hits[i] = r->probe_hits[i];
r->probe_hits[i] = 0;
+ }
}
ti++;
}
@@ -3216,6 +3220,8 @@ static void damon_split_region_at(struct damon_target *t,
new->nr_accesses = r->nr_accesses;
/* todo: do this for only installed probes */
memcpy(new->probe_hits, r->probe_hits, sizeof(r->probe_hits));
+ memcpy(new->last_probe_hits, r->last_probe_hits,
+ sizeof(r->last_probe_hits));
damon_insert_region(new, r, damon_next_region(r), t);
}
--
2.47.3