Skip to content

Commit

Permalink
mm/damon/core: finish kdamond as soon as any callback returns an error
Browse files Browse the repository at this point in the history
When 'after_sampling()' or 'after_aggregation()' DAMON callbacks return an
error, kdamond continues the remaining loop once.  It makes no much sense
to run the remaining part while something wrong already happened.  The
context might be corrupted or having invalid data.  This commit therefore
makes kdamond skips the remaining works and immediately finish in the
cases.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: SeongJae Park <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sjp38 authored and akpm00 committed May 13, 2022
1 parent 6e74d2b commit abacd63
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mm/damon/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,10 @@ static int kdamond_fn(void *data)
if (ctx->ops.prepare_access_checks)
ctx->ops.prepare_access_checks(ctx);
if (ctx->callback.after_sampling &&
ctx->callback.after_sampling(ctx))
ctx->callback.after_sampling(ctx)) {
done = true;
continue;
}

kdamond_usleep(ctx->sample_interval);

Expand All @@ -1102,8 +1104,10 @@ static int kdamond_fn(void *data)
max_nr_accesses / 10,
sz_limit);
if (ctx->callback.after_aggregation &&
ctx->callback.after_aggregation(ctx))
ctx->callback.after_aggregation(ctx)) {
done = true;
continue;
}
kdamond_apply_schemes(ctx);
kdamond_reset_aggregated(ctx);
kdamond_split_regions(ctx);
Expand Down

0 comments on commit abacd63

Please sign in to comment.