| From: Thomas Gleixner <tglx@linutronix.de> |
| Date: Wed, 24 May 2017 10:15:15 +0200 |
| Subject: [PATCH 04/32] 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 |
| --- |
| include/linux/cpuhotplug.h | 9 +++++++++ |
| kernel/cpu.c | 18 +++++++++++++++--- |
| 2 files changed, 24 insertions(+), 3 deletions(-) |
| |
| --- a/include/linux/cpuhotplug.h |
| +++ b/include/linux/cpuhotplug.h |
| @@ -238,6 +238,8 @@ static inline int cpuhp_setup_state_mult |
| |
| int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, |
| bool invoke); |
| +int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state, |
| + struct hlist_node *node, bool invoke); |
| |
| /** |
| * cpuhp_state_add_instance - Add an instance for a state and invoke startup |
| @@ -270,6 +272,13 @@ static inline int cpuhp_state_add_instan |
| return __cpuhp_state_add_instance(state, node, false); |
| } |
| |
| +static inline int |
| +cpuhp_state_add_instance_nocalls_cpuslocked(enum cpuhp_state state, |
| + struct hlist_node *node) |
| +{ |
| + return __cpuhp_state_add_instance_cpuslocked(state, node, false); |
| +} |
| + |
| void __cpuhp_remove_state(enum cpuhp_state state, bool invoke); |
| void __cpuhp_remove_state_cpuslocked(enum cpuhp_state state, bool invoke); |
| |
| --- a/kernel/cpu.c |
| +++ b/kernel/cpu.c |
| @@ -1412,18 +1412,20 @@ static void cpuhp_rollback_install(int f |
| } |
| } |
| |
| -int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, |
| - bool invoke) |
| +int __cpuhp_state_add_instance_cpuslocked(enum cpuhp_state state, |
| + struct hlist_node *node, |
| + bool invoke) |
| { |
| struct cpuhp_step *sp; |
| int cpu; |
| int ret; |
| |
| + lockdep_assert_cpus_held(); |
| + |
| sp = cpuhp_get_step(state); |
| if (sp->multi_instance == false) |
| return -EINVAL; |
| |
| - cpus_read_lock(); |
| mutex_lock(&cpuhp_state_mutex); |
| |
| if (!invoke || !sp->startup.multi) |
| @@ -1452,6 +1454,16 @@ int __cpuhp_state_add_instance(enum cpuh |
| hlist_add_head(node, &sp->list); |
| unlock: |
| mutex_unlock(&cpuhp_state_mutex); |
| + return ret; |
| +} |
| + |
| +int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node, |
| + bool invoke) |
| +{ |
| + int ret; |
| + |
| + cpus_read_lock(); |
| + ret = __cpuhp_state_add_instance_cpuslocked(state, node, invoke); |
| cpus_read_unlock(); |
| return ret; |
| } |