summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/damon.h3
-rw-r--r--mm/damon/core.c13
2 files changed, 13 insertions, 3 deletions
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 3813373a9200..1d8a1515e75a 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -330,6 +330,8 @@ struct damos_watermarks {
* @sz_ops_filter_passed:
* Total bytes that passed ops layer-handled DAMOS filters.
* @qt_exceeds: Total number of times the quota of the scheme has exceeded.
+ * @nr_snapshots:
+ * Total number of DAMON snapshots that the scheme has tried.
*
* "Tried an action to a region" in this context means the DAMOS core logic
* determined the region as eligible to apply the action. The access pattern
@@ -355,6 +357,7 @@ struct damos_stat {
unsigned long sz_applied;
unsigned long sz_ops_filter_passed;
unsigned long qt_exceeds;
+ unsigned long nr_snapshots;
};
/**
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 2379a07c2f87..9d5be7e9b8e0 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -157,6 +157,12 @@ void damon_destroy_region(struct damon_region *r, struct damon_target *t)
damon_free_region(r);
}
+static bool damon_is_last_region(struct damon_region *r,
+ struct damon_target *t)
+{
+ return list_is_last(&r->list, &t->regions_list);
+}
+
/*
* Check whether a region is intersecting an address range
*
@@ -1978,10 +1984,11 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
if (damos_skip_charged_region(t, &r, s, c->min_sz_region))
continue;
- if (!damos_valid_target(c, t, r, s))
- continue;
+ if (damos_valid_target(c, t, r, s))
+ damos_apply_scheme(c, t, r, s);
- damos_apply_scheme(c, t, r, s);
+ if (damon_is_last_region(r, t))
+ s->stat.nr_snapshots++;
}
}