diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-05-24 04:15:15 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-05-26 04:10:35 -0400 |
commit | 9805c6733349ea3ccd22cf75b8ebaabb5290e310 (patch) | |
tree | 62f380b6dbed4bc0eb2cf5e8f4c64b6f59bea3a5 | |
parent | 71def423fe3da0d40ad3427a4cd5f9edc53bff67 (diff) |
cpu/hotplug: Add __cpuhp_state_add_instance_cpuslocked()
Add cpuslocked() variants for the multi instance registration so this can
be called from a cpus_read_lock() protected region.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170524081547.321782217@linutronix.de
-rw-r--r-- | include/linux/cpuhotplug.h | 9 | ||||
-rw-r--r-- | kernel/cpu.c | 18 |
2 files changed, 24 insertions, 3 deletions
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 4fac564dde70..df3d2719a796 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h | |||
@@ -240,6 +240,8 @@ static inline int cpuhp_setup_state_multi(enum cpuhp_state state, | |||
240 | 240 | ||
241 | int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, | 241 | int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, |
242 | bool invoke); | 242 | bool invoke); |
243 | int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state, | ||
244 | struct hlist_node *node, bool invoke); | ||
243 | 245 | ||
244 | /** | 246 | /** |
245 | * cpuhp_state_add_instance - Add an instance for a state and invoke startup | 247 | * cpuhp_state_add_instance - Add an instance for a state and invoke startup |
@@ -272,6 +274,13 @@ static inline int cpuhp_state_add_instance_nocalls(enum cpuhp_state state, | |||
272 | return __cpuhp_state_add_instance(state, node, false); | 274 | return __cpuhp_state_add_instance(state, node, false); |
273 | } | 275 | } |
274 | 276 | ||
277 | static inline int | ||
278 | cpuhp_state_add_instance_nocalls_cpuslocked(enum cpuhp_state state, | ||
279 | struct hlist_node *node) | ||
280 | { | ||
281 | return __cpuhp_state_add_instance_cpuslocked(state, node, false); | ||
282 | } | ||
283 | |||
275 | void __cpuhp_remove_state(enum cpuhp_state state, bool invoke); | 284 | void __cpuhp_remove_state(enum cpuhp_state state, bool invoke); |
276 | void __cpuhp_remove_state_cpuslocked(enum cpuhp_state state, bool invoke); | 285 | void __cpuhp_remove_state_cpuslocked(enum cpuhp_state state, bool invoke); |
277 | 286 | ||
diff --git a/kernel/cpu.c b/kernel/cpu.c index dc27c5a28153..e4389ac55b65 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -1413,18 +1413,20 @@ static void cpuhp_rollback_install(int failedcpu, enum cpuhp_state state, | |||
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, | 1416 | int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state, |
1417 | bool invoke) | 1417 | struct hlist_node *node, |
1418 | bool invoke) | ||
1418 | { | 1419 | { |
1419 | struct cpuhp_step *sp; | 1420 | struct cpuhp_step *sp; |
1420 | int cpu; | 1421 | int cpu; |
1421 | int ret; | 1422 | int ret; |
1422 | 1423 | ||
1424 | lockdep_assert_cpus_held(); | ||
1425 | |||
1423 | sp = cpuhp_get_step(state); | 1426 | sp = cpuhp_get_step(state); |
1424 | if (sp->multi_instance == false) | 1427 | if (sp->multi_instance == false) |
1425 | return -EINVAL; | 1428 | return -EINVAL; |
1426 | 1429 | ||
1427 | cpus_read_lock(); | ||
1428 | mutex_lock(&cpuhp_state_mutex); | 1430 | mutex_lock(&cpuhp_state_mutex); |
1429 | 1431 | ||
1430 | if (!invoke || !sp->startup.multi) | 1432 | if (!invoke || !sp->startup.multi) |
@@ -1453,6 +1455,16 @@ add_node: | |||
1453 | hlist_add_head(node, &sp->list); | 1455 | hlist_add_head(node, &sp->list); |
1454 | unlock: | 1456 | unlock: |
1455 | mutex_unlock(&cpuhp_state_mutex); | 1457 | mutex_unlock(&cpuhp_state_mutex); |
1458 | return ret; | ||
1459 | } | ||
1460 | |||
1461 | int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, | ||
1462 | bool invoke) | ||
1463 | { | ||
1464 | int ret; | ||
1465 | |||
1466 | cpus_read_lock(); | ||
1467 | ret = __cpuhp_state_add_instance_cpuslocked(state, node, invoke); | ||
1456 | cpus_read_unlock(); | 1468 | cpus_read_unlock(); |
1457 | return ret; | 1469 | return ret; |
1458 | } | 1470 | } |