mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] cpu: CPU hotplug lock updates
@ 2026-06-04  3:38 Reinette Chatre
  2026-06-04  3:38 ` [PATCH 1/2] MAINTAINERS: Add include/linux/cpuhplock.h to CPU HOTPLUG area Reinette Chatre
  2026-06-04  3:38 ` [PATCH 2/2] cpu: Add lockdep_is_cpus_held()/lockdep_is_cpus_write_held() stubs for !CONFIG_HOTPLUG_CPU Reinette Chatre
  0 siblings, 2 replies; 3+ messages in thread
From: Reinette Chatre @ 2026-06-04  3:38 UTC (permalink / raw)
  To: tglx, peterz, bp, frederic, tony.luck; +Cc: reinette.chatre, linux-kernel

resctrl would like to use lockdep_is_cpus_held() as the lockdep
expression provided to list_for_each_entry_rcu() but Sashiko pointed out
that lockdep_is_cpus_held() is undefined when CONFIG_HOTPLUG_CPU is unset.

Patch 2 adds stubs for lockdep_is_cpus_held() and lockdep_is_cpus_write_held().

Patch 1 supports this work by adding include/linux/cpuhplock.h to the
MAINTAINERS CPU HOTPLUG area to help ensure patches touching it are routed
correctly.

Applies against tip/master.

Reinette Chatre (2):
  MAINTAINERS: Add include/linux/cpuhplock.h to CPU HOTPLUG area
  cpu: Add lockdep_is_cpus_held()/lockdep_is_cpus_write_held() stubs for
    !CONFIG_HOTPLUG_CPU

 MAINTAINERS               | 1 +
 include/linux/cpuhplock.h | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] MAINTAINERS: Add include/linux/cpuhplock.h to CPU HOTPLUG area
  2026-06-04  3:38 [PATCH 0/2] cpu: CPU hotplug lock updates Reinette Chatre
@ 2026-06-04  3:38 ` Reinette Chatre
  2026-06-04  3:38 ` [PATCH 2/2] cpu: Add lockdep_is_cpus_held()/lockdep_is_cpus_write_held() stubs for !CONFIG_HOTPLUG_CPU Reinette Chatre
  1 sibling, 0 replies; 3+ messages in thread
From: Reinette Chatre @ 2026-06-04  3:38 UTC (permalink / raw)
  To: tglx, peterz, bp, frederic, tony.luck; +Cc: reinette.chatre, linux-kernel

The move of CPU hotplug function declarations to include/linux/cpuhplock.h
did not update the CPU HOTPLUG section of MAINTAINERS. Update it now.

Fixes: 195fb517ee25 ("cpu: Move CPU hotplug function declarations into their own header")
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index e4833d334edc..42de7dd62b46 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6675,6 +6675,7 @@ P:	Documentation/process/maintainer-tip.rst
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git smp/core
 F:	include/linux/cpu.h
 F:	include/linux/cpuhotplug.h
+F:	include/linux/cpuhplock.h
 F:	include/linux/smpboot.h
 F:	kernel/cpu.c
 F:	kernel/smpboot.*
-- 
2.50.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] cpu: Add lockdep_is_cpus_held()/lockdep_is_cpus_write_held() stubs for !CONFIG_HOTPLUG_CPU
  2026-06-04  3:38 [PATCH 0/2] cpu: CPU hotplug lock updates Reinette Chatre
  2026-06-04  3:38 ` [PATCH 1/2] MAINTAINERS: Add include/linux/cpuhplock.h to CPU HOTPLUG area Reinette Chatre
@ 2026-06-04  3:38 ` Reinette Chatre
  1 sibling, 0 replies; 3+ messages in thread
From: Reinette Chatre @ 2026-06-04  3:38 UTC (permalink / raw)
  To: tglx, peterz, bp, frederic, tony.luck; +Cc: reinette.chatre, linux-kernel

lockdep_is_cpus_held() and lockdep_is_cpus_write_held() are undefined when
!CONFIG_HOTPLUG_CPU. This is ok because their few callers protect the calls
with a "if (IS_ENABLED(CONFIG_HOTPLUG_CPU) ..." check.

It is error prone to require callers to protect lockdep_is_cpus_held()
and lockdep_is_cpus_write_held() with an IS_ENABLED(CONFIG_HOTPLUG_CPU)
check while the custom for equivalent functions, for example the more
prevalent lockdep_is_held(), is to not require similar protection.
It is also inconsistent with CPU hotplug lockdep code self since related
call lockdep_assert_cpus_held() does not require protection.

Create stubs for lockdep_is_cpus_held() and lockdep_is_cpus_write_held()
that returns 1 (LOCK_STATE_UNKNOWN/LOCK_STATE_HELD) when !CONFIG_HOTPLUG_CPU.
This makes the CPU hotplug lockdep checks consistent while following
existing lockdep custom. Drop the "extern" from the function declaration
as part of the move to match kernel coding style.

Keep the IS_ENABLED(CONFIG_HOTPLUG_CPU) checks in existing users since
removing them would change the logic of these expressions.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/cover.1780456704.git.reinette.chatre%40intel.com?part=1
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
While this was reported by Sashiko this is not a bugfix since all callers
use the "IS_ENABLED(CONFIG_HOTPLUG_CPU)" protection. The Sashiko report
was triggered by a review of code that adds more lockdep_is_cpus_held()
calls but omitted the "IS_ENABLED(CONFIG_HOTPLUG_CPU)" protection.
---
 include/linux/cpuhplock.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/cpuhplock.h b/include/linux/cpuhplock.h
index 286b3ab92e15..42f6a095ba5b 100644
--- a/include/linux/cpuhplock.h
+++ b/include/linux/cpuhplock.h
@@ -12,9 +12,6 @@
 
 struct device;
 
-extern int lockdep_is_cpus_held(void);
-extern int lockdep_is_cpus_write_held(void);
-
 #ifdef CONFIG_HOTPLUG_CPU
 void cpus_write_lock(void);
 void cpus_write_unlock(void);
@@ -22,6 +19,8 @@ void cpus_read_lock(void);
 void cpus_read_unlock(void);
 int  cpus_read_trylock(void);
 void lockdep_assert_cpus_held(void);
+int lockdep_is_cpus_held(void);
+int lockdep_is_cpus_write_held(void);
 void cpu_hotplug_disable_offlining(void);
 void cpu_hotplug_disable(void);
 void cpu_hotplug_enable(void);
@@ -38,6 +37,8 @@ static inline void cpus_read_lock(void) { }
 static inline void cpus_read_unlock(void) { }
 static inline int  cpus_read_trylock(void) { return true; }
 static inline void lockdep_assert_cpus_held(void) { }
+static inline int lockdep_is_cpus_held(void) { return 1; }
+static inline int lockdep_is_cpus_write_held(void) { return 1; }
 static inline void cpu_hotplug_disable_offlining(void) { }
 static inline void cpu_hotplug_disable(void) { }
 static inline void cpu_hotplug_enable(void) { }
-- 
2.50.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-04  3:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-04  3:38 [PATCH 0/2] cpu: CPU hotplug lock updates Reinette Chatre
2026-06-04  3:38 ` [PATCH 1/2] MAINTAINERS: Add include/linux/cpuhplock.h to CPU HOTPLUG area Reinette Chatre
2026-06-04  3:38 ` [PATCH 2/2] cpu: Add lockdep_is_cpus_held()/lockdep_is_cpus_write_held() stubs for !CONFIG_HOTPLUG_CPU Reinette Chatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome