Commit cf392d10 authored by Thomas Gleixner's avatar Thomas Gleixner

cpu/hotplug: Add multi instance support

This patch adds the ability for a given state to have multiple
instances. Until now all states have a single instance and the startup /
teardown callback use global variables.
A few drivers need to perform a the same callbacks on multiple
"instances". Currently we have three drivers in tree which all have a
global list which they iterate over. With multi instance they support
don't need their private list and the functionality has been moved into
core code. Plus we hold the hotplug lock in core so no cpus comes/goes
while instances are registered and we do rollback in error case :)
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/1471024183-12666-3-git-send-email-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent a724632c
...@@ -99,7 +99,7 @@ enum cpuhp_state { ...@@ -99,7 +99,7 @@ enum cpuhp_state {
int __cpuhp_setup_state(enum cpuhp_state state, const char *name, bool invoke, int __cpuhp_setup_state(enum cpuhp_state state, const char *name, bool invoke,
int (*startup)(unsigned int cpu), int (*startup)(unsigned int cpu),
int (*teardown)(unsigned int cpu)); int (*teardown)(unsigned int cpu), bool multi_instance);
/** /**
* cpuhp_setup_state - Setup hotplug state callbacks with calling the callbacks * cpuhp_setup_state - Setup hotplug state callbacks with calling the callbacks
...@@ -116,7 +116,7 @@ static inline int cpuhp_setup_state(enum cpuhp_state state, ...@@ -116,7 +116,7 @@ static inline int cpuhp_setup_state(enum cpuhp_state state,
int (*startup)(unsigned int cpu), int (*startup)(unsigned int cpu),
int (*teardown)(unsigned int cpu)) int (*teardown)(unsigned int cpu))
{ {
return __cpuhp_setup_state(state, name, true, startup, teardown); return __cpuhp_setup_state(state, name, true, startup, teardown, false);
} }
/** /**
...@@ -135,7 +135,66 @@ static inline int cpuhp_setup_state_nocalls(enum cpuhp_state state, ...@@ -135,7 +135,66 @@ static inline int cpuhp_setup_state_nocalls(enum cpuhp_state state,
int (*startup)(unsigned int cpu), int (*startup)(unsigned int cpu),
int (*teardown)(unsigned int cpu)) int (*teardown)(unsigned int cpu))
{ {
return __cpuhp_setup_state(state, name, false, startup, teardown); return __cpuhp_setup_state(state, name, false, startup, teardown,
false);
}
/**
* cpuhp_setup_state_multi - Add callbacks for multi state
* @state: The state for which the calls are installed
* @name: Name of the callback.
* @startup: startup callback function
* @teardown: teardown callback function
*
* Sets the internal multi_instance flag and prepares a state to work as a multi
* instance callback. No callbacks are invoked at this point. The callbacks are
* invoked once an instance for this state are registered via
* @cpuhp_state_add_instance or @cpuhp_state_add_instance_nocalls.
*/
static inline int cpuhp_setup_state_multi(enum cpuhp_state state,
const char *name,
int (*startup)(unsigned int cpu,
struct hlist_node *node),
int (*teardown)(unsigned int cpu,
struct hlist_node *node))
{
return __cpuhp_setup_state(state, name, false,
(void *) startup,
(void *) teardown, true);
}
int __cpuhp_state_add_instance(enum cpuhp_state state, struct hlist_node *node,
bool invoke);
/**
* cpuhp_state_add_instance - Add an instance for a state and invoke startup
* callback.
* @state: The state for which the instance is installed
* @node: The node for this individual state.
*
* Installs the instance for the @state and invokes the startup callback on
* the present cpus which have already reached the @state. The @state must have
* been earlier marked as multi-instance by @cpuhp_setup_state_multi.
*/
static inline int cpuhp_state_add_instance(enum cpuhp_state state,
struct hlist_node *node)
{
return __cpuhp_state_add_instance(state, node, true);
}
/**
* cpuhp_state_add_instance_nocalls - Add an instance for a state without
* invoking the startup callback.
* @state: The state for which the instance is installed
* @node: The node for this individual state.
*
* Installs the instance for the @state The @state must have been earlier
* marked as multi-instance by @cpuhp_setup_state_multi.
*/
static inline int cpuhp_state_add_instance_nocalls(enum cpuhp_state state,
struct hlist_node *node)
{
return __cpuhp_state_add_instance(state, node, false);
} }
void __cpuhp_remove_state(enum cpuhp_state state, bool invoke); void __cpuhp_remove_state(enum cpuhp_state state, bool invoke);
...@@ -162,6 +221,51 @@ static inline void cpuhp_remove_state_nocalls(enum cpuhp_state state) ...@@ -162,6 +221,51 @@ static inline void cpuhp_remove_state_nocalls(enum cpuhp_state state)
__cpuhp_remove_state(state, false); __cpuhp_remove_state(state, false);
} }
/**
* cpuhp_remove_multi_state - Remove hotplug multi state callback
* @state: The state for which the calls are removed
*
* Removes the callback functions from a multi state. This is the reverse of
* cpuhp_setup_state_multi(). All instances should have been removed before
* invoking this function.
*/
static inline void cpuhp_remove_multi_state(enum cpuhp_state state)
{
__cpuhp_remove_state(state, false);
}
int __cpuhp_state_remove_instance(enum cpuhp_state state,
struct hlist_node *node, bool invoke);
/**
* cpuhp_state_remove_instance - Remove hotplug instance from state and invoke
* the teardown callback
* @state: The state from which the instance is removed
* @node: The node for this individual state.
*
* Removes the instance and invokes the teardown callback on the present cpus
* which have already reached the @state.
*/
static inline int cpuhp_state_remove_instance(enum cpuhp_state state,
struct hlist_node *node)
{
return __cpuhp_state_remove_instance(state, node, true);
}
/**
* cpuhp_state_remove_instance_nocalls - Remove hotplug instance from state
* without invoking the reatdown callback
* @state: The state from which the instance is removed
* @node: The node for this individual state.
*
* Removes the instance without invoking the teardown callback.
*/
static inline int cpuhp_state_remove_instance_nocalls(enum cpuhp_state state,
struct hlist_node *node)
{
return __cpuhp_state_remove_instance(state, node, false);
}
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
void cpuhp_online_idle(enum cpuhp_state state); void cpuhp_online_idle(enum cpuhp_state state);
#else #else
......
...@@ -33,6 +33,34 @@ TRACE_EVENT(cpuhp_enter, ...@@ -33,6 +33,34 @@ TRACE_EVENT(cpuhp_enter,
__entry->cpu, __entry->target, __entry->idx, __entry->fun) __entry->cpu, __entry->target, __entry->idx, __entry->fun)
); );
TRACE_EVENT(cpuhp_multi_enter,
TP_PROTO(unsigned int cpu,
int target,
int idx,
int (*fun)(unsigned int, struct hlist_node *),
struct hlist_node *node),
TP_ARGS(cpu, target, idx, fun, node),
TP_STRUCT__entry(
__field( unsigned int, cpu )
__field( int, target )
__field( int, idx )
__field( void *, fun )
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->target = target;
__entry->idx = idx;
__entry->fun = fun;
),
TP_printk("cpu: %04u target: %3d step: %3d (%pf)",
__entry->cpu, __entry->target, __entry->idx, __entry->fun)
);
TRACE_EVENT(cpuhp_exit, TRACE_EVENT(cpuhp_exit,
TP_PROTO(unsigned int cpu, TP_PROTO(unsigned int cpu,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment