mm/damon/core: destroy targets when kdamond_fn() finish

When kdamond_fn() completes, the targets are kept.  Those are kept to let
callers do additional cleanups if they need.  There are no such additional
cleanups though.  DAMON sysfs interface deallocates those in
before_terminate() callback, to reduce unnecessary memory usage, for
[f]vaddr use case.  Just destroy the targets for every case in the core
layer.  This saves more memory and simplifies the logic.

Link: https://lkml.kernel.org/r/20250712195016.151108-13-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
SeongJae Park 2025-07-12 12:50:14 -07:00 committed by Andrew Morton
parent f59ae147ab
commit 3a69f16357

View file

@ -2657,6 +2657,7 @@ done:
running_exclusive_ctxs = false;
mutex_unlock(&damon_lock);
damon_destroy_targets(ctx);
return 0;
}