Skip to content

Commit

Permalink
cpu/hotplug: Add __cpuhp_state_add_instance_cpuslocked()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Paul E. McKenney <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Sebastian Siewior <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
  • Loading branch information
KAGA-KOKO committed May 26, 2017
1 parent 71def42 commit 9805c67
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
9 changes: 9 additions & 0 deletions include/linux/cpuhotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ static inline int cpuhp_setup_state_multi(enum cpuhp_state state,

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
Expand Down Expand Up @@ -272,6 +274,13 @@ static inline int cpuhp_state_add_instance_nocalls(enum cpuhp_state state,
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);

Expand Down
18 changes: 15 additions & 3 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1413,18 +1413,20 @@ static void cpuhp_rollback_install(int failedcpu, enum cpuhp_state state,
}
}

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)
Expand Down Expand Up @@ -1453,6 +1455,16 @@ int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node,
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;
}
Expand Down

0 comments on commit 9805c67

Please sign in to comment.