Re: [PATCH 2/2] smp/hotplug,lockdep: Annotate cpuhp_state

From: Mike Galbraith
Date: Tue Sep 05 2017 - 09:00:05 EST


Mm, wants a build bandaid for !CONFIG_LOCKDEP

kernel/cpu.c: In function â_cpu_downâ:
kernel/cpu.c:720:43: error: âcpuhp_state_down_keyâ undeclared (first use in this function)
lockdep_init_map(&cpuhp_state_lock_map, "cpuhp_state-down",
^
kernel/cpu.c:720:43: note: each undeclared identifier is reported only once for each function it appears in
kernel/cpu.c: In function â_cpu_upâ:
kernel/cpu.c:836:41: error: âcpuhp_state_up_keyâ undeclared (first use in this function)
lockdep_init_map(&cpuhp_state_lock_map, "cpuhp_state-up",
^
scripts/Makefile.build:311: recipe for target 'kernel/cpu.o' failed
make[1]: *** [kernel/cpu.o] Error 1
Makefile:1666: recipe for target 'kernel/cpu.o' failed
make: *** [kernel/cpu.o] Error 2

(mine below, fold or vaporize as you see fit)

---
kernel/cpu.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -545,7 +545,7 @@ void __init cpuhp_threads_init(void)
* Must be macro to ensure we have two different call sites.
*/
#ifdef CONFIG_LOCKDEP
-#define lockdep_reinit_st_done() \
+#define lockdep_reinit_st_done(up) \
do { \
int __cpu; \
for_each_possible_cpu(__cpu) { \
@@ -553,9 +553,17 @@ do { \
per_cpu_ptr(&cpuhp_state, __cpu); \
init_completion(&st->done); \
} \
+ if (up) \
+ lockdep_init_map(&cpuhp_state_lock_map, \
+ "cpuhp_state-up", \
+ &cpuhp_state_up_key, 0); \
+ else \
+ lockdep_init_map(&cpuhp_state_lock_map, \
+ "cpuhp_state-down", \
+ &cpuhp_state_down_key, 0); \
} while(0)
#else
-#define lockdep_reinit_st_done()
+#define lockdep_reinit_st_done(up)
#endif

#ifdef CONFIG_HOTPLUG_CPU
@@ -716,9 +724,7 @@ static int __ref _cpu_down(unsigned int

cpus_write_lock();

- lockdep_reinit_st_done();
- lockdep_init_map(&cpuhp_state_lock_map, "cpuhp_state-down",
- &cpuhp_state_down_key, 0);
+ lockdep_reinit_st_done(0);

cpuhp_tasks_frozen = tasks_frozen;

@@ -832,9 +838,7 @@ static int _cpu_up(unsigned int cpu, int

cpus_write_lock();

- lockdep_reinit_st_done();
- lockdep_init_map(&cpuhp_state_lock_map, "cpuhp_state-up",
- &cpuhp_state_up_key, 0);
+ lockdep_reinit_st_done(1);

if (!cpu_present(cpu)) {
ret = -EINVAL;