mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mm/damon/core: do parameter testing commit on damon_start()
damon_start() and damon_commit_ctx() are two main DAMON core API functions for setting whole DAMON parameters. While damon_commit_ctx() does holistic parameters testing, damon_start() just believes the caller validated the whole thing. Embed the holistic parameter check that is already in damon_commit_ctx() into damon_start(). After this change, the callers can safely call damon_start() without validating the parameters. Link: https://lore.kernel.org/20260705155600.96555-3-sj@kernel.org Signed-off-by: SJ Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
b90408ef11
commit
b1471afe4d
|
|
@ -1865,6 +1865,8 @@ static int __damon_start(struct damon_ctx *ctx)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* damon_start() - Starts the monitorings for a given group of contexts.
|
* damon_start() - Starts the monitorings for a given group of contexts.
|
||||||
* @ctxs: an array of the pointers for contexts to start monitoring
|
* @ctxs: an array of the pointers for contexts to start monitoring
|
||||||
|
|
@ -1886,8 +1888,16 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
for (i = 0; i < nr_ctxs; i++) {
|
for (i = 0; i < nr_ctxs; i++) {
|
||||||
if (!is_power_of_2(ctxs[i]->min_region_sz))
|
struct damon_ctx *test_ctx;
|
||||||
return -EINVAL;
|
|
||||||
|
test_ctx = damon_new_ctx();
|
||||||
|
if (!test_ctx)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
err = __damon_commit_ctx(test_ctx, ctxs[i]);
|
||||||
|
damon_destroy_ctx(test_ctx);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_lock(&damon_lock);
|
mutex_lock(&damon_lock);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user