Re: [RFC PATCH] mm/damon: reset thread status parameters upon kdamond termination

SeongJae Park
2026-03-31T05:02:36Z

On Tue, 31 Mar 2026 00:43:47 +0800 Liew Rui Yan <aethernet65535@gmail.com> wrote:

> Problem
> =======
> kdamond does not actively modify the module's
> (DAMON_LRU_SORT/DAMON_RECLAIM) 'enabled' and 'kdamond_pid' after
> exiting. After an unexpected termination, user will still see 'enabled'
> as 'Y' and 'kdamond_pid' as a value other than -1. Furthermore, user
> cannot restart the unexpectedly terminated kdamond by executing 'echo
> Y/N > enabled' again.

Nice catch!

I guess this can easily reproducible? Sharing detailed reproduction steps
would be nice.

>
> Solution
> ========
> Introduce a 'thread_status' structure to link the internal kdamond
> state with module parameters ('enabled' and 'kdamond_pid').
>
> Specifically:
> 1. Extend 'struct damon_ctx' to include pointers to the module's
> parameters.
> 2. Initialize these pointers in damon_lru_sort_apply_parameters()
> and damon_reclaim_apply_parameters() to point the respective
> module variables.
> 3. Implement damon_update_thread_status() to reset 'enabled' to
> false and 'kdamond_pid' to -1 when the kdamond thread finishes.

This feels too much extension of core API for a problem that can more simply be
fixed. Can't we detect the unexpected termination of kdamond from the modules
and update the paramter values accordingly?

If we cannot due to a limitation of the DAMON core API, I'd like to extend the
API for letting the caller detects the unexpected termination.

Because this is an RFC and I already have question for the high level
direction, I will skip code level review.

Thanks,
SJ …