Re: [PATCH v2] mm/damon/core: Optimize kdamod.%d thread creation code

From: SeongJae Park
Date: Tue Oct 19 2021 - 06:03:43 EST


Hello Xin,

On Sun, 17 Oct 2021 00:59:14 +0800 Xin Hao <xhao@xxxxxxxxxxxxxxxxx> wrote:

> When the ctx->adaptive_targets list is empty,
> i did some test on monitor_on interface like this.
>
> echo on > /sys/kernel/debug/damon/monitor_on
> [ 851.988307] damon: kdamond (5390) starts
>
> Though the ctx->adaptive_targets list is empty, but the
> kthread_run still be called, and the kdamond.x thread still
> be created, this is meaningless.

Good finding, thank you!

>
> So there adds a judgment. only if the ctx->adaptive_targets
> list is not empty, and ctx->kdamond pointer is NULL, then call
> the __damon_start function.

I think we cannot believe user-space users, but kernel-space API users. How
about adding the check in 'dbgfs_monitor_on_write()' rather than
'__damon_start()'?

Also, apparently this patch is based on latest 'damon/next' branch of my tree.
Could you please rebase this on latest -mm tree?


Thanks,
SJ

[...]