lkml.org 
[lkml]   [2020]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH v17 03/15] mm/damon: Implement region based sampling
Date
On Mon, 6 Jul 2020 13:53:10 +0200 SeongJae Park <sjpark@amazon.com> wrote:

> From: SeongJae Park <sjpark@amazon.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

\
 
 \ /
  Last update: 2020-07-07 09:56    [W:0.121 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site