[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200707075451.24606-1-sjpark@amazon.com>
Date: Tue, 7 Jul 2020 09:54:51 +0200
From: SeongJae Park <sjpark@...zon.com>
To: SeongJae Park <sjpark@...zon.com>
CC: <akpm@...ux-foundation.org>, SeongJae Park <sjpark@...zon.de>,
<Jonathan.Cameron@...wei.com>, <aarcange@...hat.com>,
<acme@...nel.org>, <alexander.shishkin@...ux.intel.com>,
<amit@...nel.org>, <benh@...nel.crashing.org>,
<brendan.d.gregg@...il.com>, <brendanhiggins@...gle.com>,
<cai@....pw>, <colin.king@...onical.com>, <corbet@....net>,
<dwmw@...zon.com>, <foersleo@...zon.de>, <irogers@...gle.com>,
<jolsa@...hat.com>, <kirill@...temov.name>, <mark.rutland@....com>,
<mgorman@...e.de>, <minchan@...nel.org>, <mingo@...hat.com>,
<namhyung@...nel.org>, <peterz@...radead.org>,
<rdunlap@...radead.org>, <riel@...riel.com>, <rientjes@...gle.com>,
<rostedt@...dmis.org>, <sblbir@...zon.com>, <shakeelb@...gle.com>,
<shuah@...nel.org>, <sj38.park@...il.com>, <snu@...zon.de>,
<vbabka@...e.cz>, <vdavydov.dev@...il.com>,
<yang.shi@...ux.alibaba.com>, <ying.huang@...el.com>,
<david@...hat.com>, <linux-damon@...zon.com>, <linux-mm@...ck.org>,
<linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v17 03/15] mm/damon: Implement region based sampling
On Mon, 6 Jul 2020 13:53:10 +0200 SeongJae Park <sjpark@...zon.com> wrote:
> From: SeongJae Park <sjpark@...zon.de>
>
> This commit implements DAMON's target address space independent high
> level logics for basic access check and region based sampling. This
> doesn't work alone, but needs the target address space specific low
> level pritimives implementation for the monitoring target address ranges
> construction and the access check, though. A reference implementation
> of those will be provided by a later commit. Nevertheless, users can
> implement and use their own versions for their specific use cases.
>
[...]
> +/**
> + * damon_start() - Starts monitoring with given context.
> + * @ctx: monitoring context
> + *
> + * Return: 0 on success, negative error code otherwise.
> + */
> +int damon_start(struct damon_ctx *ctx)
> +{
> + int err = -EBUSY;
> +
> + mutex_lock(&ctx->kdamond_lock);
> + if (!ctx->kdamond) {
> + err = 0;
> + ctx->kdamond_stop = false;
> + ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond");
Oops, this means 'kdamond_fn' could see the unset '->kdamond'. I will use
'kthread_create()' and 'wake_up_process()' in the next spin.
> + if (IS_ERR(ctx->kdamond))
> + err = PTR_ERR(ctx->kdamond);
> + }
> + mutex_unlock(&ctx->kdamond_lock);
> +
> + return err;
> +}
So, the change would be something like below:
--- a/mm/damon.c
+++ b/mm/damon.c
@@ -1464,9 +1464,11 @@ int damon_start(struct damon_ctx *ctx)
if (!ctx->kdamond) {
err = 0;
ctx->kdamond_stop = false;
- ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond");
+ ctx->kdamond = kthread_create(kdamond_fn, ctx, "kdamond");
if (IS_ERR(ctx->kdamond))
err = PTR_ERR(ctx->kdamond);
+ else
+ wake_up_process(ctx->kdamond);
}
mutex_unlock(&ctx->kdamond_lock);
Thanks,
SeongJae Park
Powered by blists - more mailing lists