Commit 8e1c4961 authored by Akinobu Mita's avatar Akinobu Mita Committed by Andrew Morton
Browse files

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: da878780 ("mm/damon/sysfs: support online inputs update")
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 3ac4638a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;
				}
			}
		}
	}