Re: [PATCH 12/33] cpuset: Provide lockdep check for cpuset lock held

From
Waiman Long <hidden>
Date
2026-01-12 01:43:33
Also in
cgroups, linux-arm-kernel, linux-block, linux-mm, linux-pci, lkml
Reply to
Frederic Weisbecker, 2026-01-01
On 1/1/26 5:13 PM, Frederic Weisbecker wrote:
quoted hunk ↗ jump to hunk
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>
---
  include/linux/cpuset.h | 2 ++
  kernel/cgroup/cpuset.c | 7 +++++++
  2 files changed, 9 insertions(+)
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index a98d3330385c..1c49ffd2ca9b 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -18,6 +18,8 @@
  #include <linux/mmu_context.h>
  #include <linux/jump_label.h>
  
+extern bool lockdep_is_cpuset_held(void);
+
  #ifdef CONFIG_CPUSETS
  
  /*
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 3afa72f8d579..5e2e3514c22e 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)
The cgroup/for-next tree already have a similar lockdep_assert_cpuset_lock_held() defined. So you can drop this patch if this series won't land in the next merge window.

Cheers,
Longman
Thread (59 messages) 59 messages, 9 authors, last reply 2026-02-23
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help