2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

mm/damon/stat: use damon_call() repeat mode instead of damon_callback

DAMON_STAT uses damon_callback for periodically reading DAMON internal
data.  Use its alternative, damon_call() repeat mode.

Link: https://lkml.kernel.org/r/20250712195016.151108-4-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
SeongJae Park 2025-07-12 12:50:05 -07:00 committed by Andrew Morton
parent 43df7676e5
commit 405f61996d

View File

@ -122,8 +122,9 @@ static void damon_stat_set_idletime_percentiles(struct damon_ctx *c)
kfree(sorted_regions);
}
static int damon_stat_after_aggregation(struct damon_ctx *c)
static int damon_stat_damon_call_fn(void *data)
{
struct damon_ctx *c = data;
static unsigned long last_refresh_jiffies;
/* avoid unnecessarily frequent stat update */
@ -182,19 +183,29 @@ static struct damon_ctx *damon_stat_build_ctx(void)
damon_add_target(ctx, target);
if (damon_set_region_biggest_system_ram_default(target, &start, &end))
goto free_out;
ctx->callback.after_aggregation = damon_stat_after_aggregation;
return ctx;
free_out:
damon_destroy_ctx(ctx);
return NULL;
}
static struct damon_call_control call_control = {
.fn = damon_stat_damon_call_fn,
.repeat = true,
};
static int damon_stat_start(void)
{
int err;
damon_stat_context = damon_stat_build_ctx();
if (!damon_stat_context)
return -ENOMEM;
return damon_start(&damon_stat_context, 1, true);
err = damon_start(&damon_stat_context, 1, true);
if (err)
return err;
call_control.data = damon_stat_context;
return damon_call(damon_stat_context, &call_control);
}
static void damon_stat_stop(void)