Re: [PATCH] mm/damon: support freeze kdamond

From: SeongJae Park

Date: Wed Apr 08 2026 - 10:12:19 EST


Hello Lin,


Thank you for sharing this patch.

On Wed, 8 Apr 2026 16:06:52 +0800 Lin Ruifeng <linruifeng4@xxxxxxxxxx> wrote:

> During suspend and resume, the data monitored by kdamond is
> no longer meaningful. Meanwhile, since kdamond may involve
> I/O operations, it is necessary to freeze it.

I'm not used to PM freezer, and maybe because of that, I'm not fully
understanding the motivation of this patch. Could you please elaborate the
existing problem and how this patch is fixing or improving it?


Thanks,
SJ

>
> Signed-off-by: Lin Ruifeng <linruifeng4@xxxxxxxxxx>
> ---
> mm/damon/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 3e1890d64d06..5cd1f0aed66b 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -16,6 +16,7 @@
> #include <linux/slab.h>
> #include <linux/string.h>
> #include <linux/string_choices.h>
> +#include <linux/freezer.h>
>
> #define CREATE_TRACE_POINTS
> #include <trace/events/damon.h>
> @@ -2753,6 +2754,7 @@ static int kdamond_fn(void *data)
>
> complete(&ctx->kdamond_started);
> kdamond_init_ctx(ctx);
> + set_freezable();
>
> if (ctx->ops.init)
> ctx->ops.init(ctx);
> @@ -2774,6 +2776,8 @@ static int kdamond_fn(void *data)
> unsigned long next_ops_update_sis = ctx->next_ops_update_sis;
> unsigned long sample_interval = ctx->attrs.sample_interval;
>
> + try_to_freeze();
> +
> if (kdamond_wait_activation(ctx))
> break;
>
> --
> 2.43.0