From: Frederic Weisbecker Date: Tue, 27 May 2025 13:35:14 +0000 (+0200) Subject: cpuset: Provide lockdep check for cpuset lock held X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7e546354d9c534dc045ce0cf9ff05d81351a751;p=thirdparty%2Flinux.git cpuset: Provide lockdep check for cpuset lock held cpuset modifies partitions, including isolated, while holding the cpuset mutex. This means that holding the cpuset mutex is safe to synchronize against housekeeping cpumask changes. Provide a lockdep check to validate that. Signed-off-by: Frederic Weisbecker Cc: "Michal Koutný" Cc: Johannes Weiner Cc: Marco Crivellari Cc: Michal Hocko Cc: Peter Zijlstra Cc: Tejun Heo Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: Waiman Long Cc: cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index a98d3330385c2..1c49ffd2ca9b4 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -18,6 +18,8 @@ #include #include +extern bool lockdep_is_cpuset_held(void); + #ifdef CONFIG_CPUSETS /* diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 3afa72f8d579a..5e2e3514c22e9 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -283,6 +283,13 @@ void cpuset_full_unlock(void) cpus_read_unlock(); } +#ifdef CONFIG_LOCKDEP +bool lockdep_is_cpuset_held(void) +{ + return lockdep_is_held(&cpuset_mutex); +} +#endif + static DEFINE_SPINLOCK(callback_lock); void cpuset_callback_lock_irq(void)