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/sysfs: use damon_kdamond_pid()

DAMON sysfs interface directly uses damon_ctx->kdamond field with manual
synchronization using damon_ctx->kdamond_lock, to get the pid of the
kdamond. Use a new dedicated function for the purpose, namely
damon_kdamond_pid(), since that doesn't require manual and error-prone
synchronization.

Avoid use of kdamond_lock outside of the core.

Link: https://lkml.kernel.org/r/20260115152047.68415-3-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
f54b51ce 4262c532

+3 -4
+3 -4
mm/damon/sysfs.c
··· 1819 1819 if (!ctx) 1820 1820 goto out; 1821 1821 1822 - mutex_lock(&ctx->kdamond_lock); 1823 - if (ctx->kdamond) 1824 - pid = ctx->kdamond->pid; 1825 - mutex_unlock(&ctx->kdamond_lock); 1822 + pid = damon_kdamond_pid(ctx); 1823 + if (pid < 0) 1824 + pid = -1; 1826 1825 out: 1827 1826 mutex_unlock(&damon_sysfs_lock); 1828 1827 return sysfs_emit(buf, "%d\n", pid);