From: Akinobu Mita Date: Sat, 17 May 2025 14:18:52 +0000 (+0900) Subject: mm/damon/core: avoid destroyed target reference from DAMOS quota X-Git-Tag: v6.16-rc1~73^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e1c4961f44be6172553c062d8f425a4a4357afa;p=thirdparty%2Flinux.git mm/damon/core: avoid destroyed target reference from DAMOS quota When the number of the monitoring targets in running contexts is reduced, there may be DAMOS quotas referencing the targets that will be destroyed. Applying the scheme action for such DAMOS scheme will be skipped forever looking for the starting part of the region for the destroyed monitoring target. To fix this issue, when the monitoring target is destroyed, reset the starting part for all DAMOS quotas that reference the target. Link: https://lkml.kernel.org/r/20250517141852.142802-1-akinobu.mita@gmail.com Fixes: da87878010e5 ("mm/damon/sysfs: support online inputs update") Signed-off-by: Akinobu Mita Reviewed-by: SeongJae Park Signed-off-by: Andrew Morton --- diff --git a/mm/damon/core.c b/mm/damon/core.c index 0bb71e2ab7131..b217e0120e09e 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1093,9 +1093,17 @@ static int damon_commit_targets( if (err) return err; } else { + struct damos *s; + if (damon_target_has_pid(dst)) put_pid(dst_target->pid); damon_destroy_target(dst_target); + damon_for_each_scheme(s, dst) { + if (s->quota.charge_target_from == dst_target) { + s->quota.charge_target_from = NULL; + s->quota.charge_addr_from = 0; + } + } } }