Skip to content

Commit 60e52e7

Browse files
sjp38torvalds
authored andcommitted
mm/damon/reclaim: provide reclamation statistics
This implements new DAMON_RECLAIM parameters for statistics reporting. Those can be used for understanding how DAMON_RECLAIM is working, and for tuning the other parameters. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6268eac commit 60e52e7

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

mm/damon/reclaim.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,36 @@ module_param(monitor_region_end, ulong, 0600);
185185
static int kdamond_pid __read_mostly = -1;
186186
module_param(kdamond_pid, int, 0400);
187187

188+
/*
189+
* Number of memory regions that tried to be reclaimed.
190+
*/
191+
static unsigned long nr_reclaim_tried_regions __read_mostly;
192+
module_param(nr_reclaim_tried_regions, ulong, 0400);
193+
194+
/*
195+
* Total bytes of memory regions that tried to be reclaimed.
196+
*/
197+
static unsigned long bytes_reclaim_tried_regions __read_mostly;
198+
module_param(bytes_reclaim_tried_regions, ulong, 0400);
199+
200+
/*
201+
* Number of memory regions that successfully be reclaimed.
202+
*/
203+
static unsigned long nr_reclaimed_regions __read_mostly;
204+
module_param(nr_reclaimed_regions, ulong, 0400);
205+
206+
/*
207+
* Total bytes of memory regions that successfully be reclaimed.
208+
*/
209+
static unsigned long bytes_reclaimed_regions __read_mostly;
210+
module_param(bytes_reclaimed_regions, ulong, 0400);
211+
212+
/*
213+
* Number of times that the time/space quota limits have exceeded
214+
*/
215+
static unsigned long nr_quota_exceeds __read_mostly;
216+
module_param(nr_quota_exceeds, ulong, 0400);
217+
188218
static struct damon_ctx *ctx;
189219
static struct damon_target *target;
190220

@@ -333,13 +363,29 @@ static void damon_reclaim_timer_fn(struct work_struct *work)
333363
}
334364
static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn);
335365

366+
static int damon_reclaim_after_aggregation(struct damon_ctx *c)
367+
{
368+
struct damos *s;
369+
370+
/* update the stats parameter */
371+
damon_for_each_scheme(s, c) {
372+
nr_reclaim_tried_regions = s->stat.nr_tried;
373+
bytes_reclaim_tried_regions = s->stat.sz_tried;
374+
nr_reclaimed_regions = s->stat.nr_applied;
375+
bytes_reclaimed_regions = s->stat.sz_applied;
376+
nr_quota_exceeds = s->stat.qt_exceeds;
377+
}
378+
return 0;
379+
}
380+
336381
static int __init damon_reclaim_init(void)
337382
{
338383
ctx = damon_new_ctx();
339384
if (!ctx)
340385
return -ENOMEM;
341386

342387
damon_pa_set_primitives(ctx);
388+
ctx->callback.after_aggregation = damon_reclaim_after_aggregation;
343389

344390
/* 4242 means nothing but fun */
345391
target = damon_new_target(4242);

0 commit comments

Comments
 (0)