Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/damon/vaddr: put pid in cleanup_target()

Implement cleanup_target() callback for [f]vaddr, which calls put_pid()
for each target that will be destroyed. Also remove redundant put_pid()
calls in core, sysfs and sample modules, which were required to be done
redundantly due to the lack of such self cleanup in vaddr.

Link: https://lkml.kernel.org/r/20250712195016.151108-11-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
ff01aba6 7114bc5e

+8 -14
-2
mm/damon/core.c
··· 1139 1139 } else { 1140 1140 struct damos *s; 1141 1141 1142 - if (damon_target_has_pid(dst)) 1143 - put_pid(dst_target->pid); 1144 1142 damon_destroy_target(dst_target, dst); 1145 1143 damon_for_each_scheme(s, dst) { 1146 1144 if (s->quota.charge_target_from == dst_target) {
+2 -8
mm/damon/sysfs.c
··· 1298 1298 static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) 1299 1299 { 1300 1300 struct damon_target *t, *next; 1301 - bool has_pid = damon_target_has_pid(ctx); 1302 1301 1303 - damon_for_each_target_safe(t, next, ctx) { 1304 - if (has_pid) 1305 - put_pid(t->pid); 1302 + damon_for_each_target_safe(t, next, ctx) 1306 1303 damon_destroy_target(t, ctx); 1307 - } 1308 1304 } 1309 1305 1310 1306 static int damon_sysfs_set_regions(struct damon_target *t, ··· 1383 1387 if (!damon_target_has_pid(ctx)) 1384 1388 return; 1385 1389 1386 - damon_for_each_target_safe(t, next, ctx) { 1387 - put_pid(t->pid); 1390 + damon_for_each_target_safe(t, next, ctx) 1388 1391 damon_destroy_target(t, ctx); 1389 - } 1390 1392 } 1391 1393 1392 1394 /*
+6
mm/damon/vaddr.c
··· 805 805 return false; 806 806 } 807 807 808 + static void damon_va_cleanup_target(struct damon_target *t) 809 + { 810 + put_pid(t->pid); 811 + } 812 + 808 813 #ifndef CONFIG_ADVISE_SYSCALLS 809 814 static unsigned long damos_madvise(struct damon_target *target, 810 815 struct damon_region *r, int behavior) ··· 951 946 .prepare_access_checks = damon_va_prepare_access_checks, 952 947 .check_accesses = damon_va_check_accesses, 953 948 .target_valid = damon_va_target_valid, 949 + .cleanup_target = damon_va_cleanup_target, 954 950 .cleanup = NULL, 955 951 .apply_scheme = damon_va_apply_scheme, 956 952 .get_scheme_score = damon_va_scheme_score,
-2
samples/damon/prcl.c
··· 120 120 damon_stop(&ctx, 1); 121 121 damon_destroy_ctx(ctx); 122 122 } 123 - if (target_pidp) 124 - put_pid(target_pidp); 125 123 } 126 124 127 125 static bool init_called;
-2
samples/damon/wsse.c
··· 100 100 damon_stop(&ctx, 1); 101 101 damon_destroy_ctx(ctx); 102 102 } 103 - if (target_pidp) 104 - put_pid(target_pidp); 105 103 } 106 104 107 105 static bool init_called;