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: hide kdamond and kdamond_lock of damon_ctx

There is no DAMON API caller that directly access 'kdamond' and
'kdamond_lock' fields of 'struct damon_ctx'. Keeping those exposed could
only encourage creative but error-prone usages. Hide them from DAMON API
callers by marking those as private fields.

Link: https://lkml.kernel.org/r/20260115152047.68415-6-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
6fe0e6d5 33402229

+14 -15
+14 -15
include/linux/damon.h
··· 759 759 * of the monitoring. 760 760 * 761 761 * @attrs: Monitoring attributes for accuracy/overhead control. 762 - * @kdamond: Kernel thread who does the monitoring. 763 - * @kdamond_lock: Mutex for the synchronizations with @kdamond. 764 762 * 765 - * For each monitoring context, one kernel thread for the monitoring is 766 - * created. The pointer to the thread is stored in @kdamond. 763 + * For each monitoring context, one kernel thread for the monitoring, namely 764 + * kdamond, is created. The pid of kdamond can be retrieved using 765 + * damon_kdamond_pid(). 767 766 * 768 - * Once started, the monitoring thread runs until explicitly required to be 769 - * terminated or every monitoring target is invalid. The validity of the 770 - * targets is checked via the &damon_operations.target_valid of @ops. The 771 - * termination can also be explicitly requested by calling damon_stop(). 772 - * The thread sets @kdamond to NULL when it terminates. Therefore, users can 773 - * know whether the monitoring is ongoing or terminated by reading @kdamond. 774 - * Reads and writes to @kdamond from outside of the monitoring thread must 775 - * be protected by @kdamond_lock. 767 + * Once started, kdamond runs until explicitly required to be terminated or 768 + * every monitoring target is invalid. The validity of the targets is checked 769 + * via the &damon_operations.target_valid of @ops. The termination can also be 770 + * explicitly requested by calling damon_stop(). To know if a kdamond is 771 + * running, damon_is_running() can be used. 776 772 * 777 - * Note that the monitoring thread protects only @kdamond via @kdamond_lock. 778 - * Accesses to other fields must be protected by themselves. 773 + * While the kdamond is running, all accesses to &struct damon_ctx from a 774 + * thread other than the kdamond should be made using safe DAMON APIs, 775 + * including damon_call() and damos_walk(). 779 776 * 780 777 * @ops: Set of monitoring operations for given use cases. 781 778 * @addr_unit: Scale factor for core to ops address conversion. ··· 813 816 struct damos_walk_control *walk_control; 814 817 struct mutex walk_control_lock; 815 818 816 - /* public: */ 819 + /* Working thread of the given DAMON context */ 817 820 struct task_struct *kdamond; 821 + /* Protects @kdamond field access */ 818 822 struct mutex kdamond_lock; 819 823 824 + /* public: */ 820 825 struct damon_operations ops; 821 826 unsigned long addr_unit; 822 827 unsigned long min_sz_region;