summaryrefslogtreecommitdiff
path: root/mm/damon
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2023-12-21 01:47:18 +0300
committerAndrew Morton <akpm@linux-foundation.org>2023-12-21 01:47:18 +0300
commita721aeac8bc2cade37e68ea195f28d2ed28c1130 (patch)
tree34da931ad1d0d715c4fde89d19af67780e40a6aa /mm/damon
parentd9d9bd979cced7d4a51b65224b1d7f396c8b4eea (diff)
parent1803d0c5ee1a3bbee23db2336e21add067824f02 (diff)
downloadlinux-a721aeac8bc2cade37e68ea195f28d2ed28c1130.tar.xz
sync mm-stable with mm-hotfixes-stable to pick up depended-upon changes
Diffstat (limited to 'mm/damon')
-rw-r--r--mm/damon/core.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/mm/damon/core.c b/mm/damon/core.c
index f91715a58dc7..2c0cc65d041e 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -445,6 +445,8 @@ struct damon_ctx *damon_new_ctx(void)
if (!ctx)
return NULL;
+ init_completion(&ctx->kdamond_started);
+
ctx->attrs.sample_interval = 5 * 1000;
ctx->attrs.aggr_interval = 100 * 1000;
ctx->attrs.ops_update_interval = 60 * 1000 * 1000;
@@ -668,11 +670,14 @@ static int __damon_start(struct damon_ctx *ctx)
mutex_lock(&ctx->kdamond_lock);
if (!ctx->kdamond) {
err = 0;
+ reinit_completion(&ctx->kdamond_started);
ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond.%d",
nr_running_ctxs);
if (IS_ERR(ctx->kdamond)) {
err = PTR_ERR(ctx->kdamond);
ctx->kdamond = NULL;
+ } else {
+ wait_for_completion(&ctx->kdamond_started);
}
}
mutex_unlock(&ctx->kdamond_lock);
@@ -1483,6 +1488,7 @@ static int kdamond_fn(void *data)
pr_debug("kdamond (%d) starts\n", current->pid);
+ complete(&ctx->kdamond_started);
kdamond_init_intervals_sis(ctx);
if (ctx->ops.init)