Re: [PATCH v1] mm/damon/stat: roll back context on damon_call() failure

From: SeongJae Park

Date: Fri May 29 2026 - 10:49:16 EST


Hello Yuho,


Thank you for sharing this patch!

On Thu, 28 May 2026 23:15:19 -0400 Yuho Choi <dbgh9129@xxxxxxxxx> wrote:

> damon_stat_start() allocates and starts damon_stat_context before
> registering the repeated damon_call() callback. If damon_call() fails,
> the function currently returns the error while leaving the context
> allocated and stored in the global pointer.
>
> The retry-time cleanup added for this path only runs if users try to
> enable DAMON_STAT again. If no retry happens, the failed start leaves
> the context allocated indefinitely.
>
> Roll back the failed start by stopping the kdamond before destroying
> the context and clearing the global pointer. damon_stop() waits for a
> live kdamond via kthread_stop_put(); if the worker has already completed
> teardown, there is no kdamond left to wait on and the context can be
> destroyed.

But, having one damon_ctx object in the memory is a real problem? Why?


Thanks,
SJ

[...]