]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cpuset: Provide lockdep check for cpuset lock held
authorFrederic Weisbecker <frederic@kernel.org>
Tue, 27 May 2025 13:35:14 +0000 (15:35 +0200)
committerFrederic Weisbecker <frederic@kernel.org>
Tue, 3 Feb 2026 14:23:33 +0000 (15:23 +0100)
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 <frederic@kernel.org>
Cc: "Michal Koutný" <mkoutny@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Marco Crivellari <marco.crivellari@suse.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Waiman Long <longman@redhat.com>
Cc: cgroups@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
include/linux/cpuset.h
kernel/cgroup/cpuset.c

index a98d3330385c2954fa02b472893a6c3fd68bbab3..1c49ffd2ca9b46cbf80113108a05e8775dfeb508 100644 (file)
@@ -18,6 +18,8 @@
 #include <linux/mmu_context.h>
 #include <linux/jump_label.h>
 
+extern bool lockdep_is_cpuset_held(void);
+
 #ifdef CONFIG_CPUSETS
 
 /*
index 3afa72f8d579ac1130d8985f7926ce025913ecf0..5e2e3514c22e958053a9cbb45afdbed09e27e7d1 100644 (file)
@@ -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)