fault-injection/cpu: Convert to hotplug state machine
Install the callbacks via the state machine. This is just a temporary vehicle to keep the interface working for now, It'll be replaced by the sysfs interface which allows to step through the hotplug state machine step by step. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Akinobu Mita <akinobu.mita@gmail.com> Cc: rt@linutronix.de Link: http://lkml.kernel.org/r/20160906170457.32393-15-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
30e92153b4
commit
8c58898b3e
|
@ -43,6 +43,7 @@ enum cpuhp_state {
|
||||||
CPUHP_ARM_SHMOBILE_SCU_PREPARE,
|
CPUHP_ARM_SHMOBILE_SCU_PREPARE,
|
||||||
CPUHP_SH_SH3X_PREPARE,
|
CPUHP_SH_SH3X_PREPARE,
|
||||||
CPUHP_TIMERS_DEAD,
|
CPUHP_TIMERS_DEAD,
|
||||||
|
CPUHP_NOTF_ERR_INJ_PREPARE,
|
||||||
CPUHP_BRINGUP_CPU,
|
CPUHP_BRINGUP_CPU,
|
||||||
CPUHP_AP_IDLE_DEAD,
|
CPUHP_AP_IDLE_DEAD,
|
||||||
CPUHP_AP_OFFLINE,
|
CPUHP_AP_OFFLINE,
|
||||||
|
|
|
@ -8,16 +8,47 @@ static int priority;
|
||||||
module_param(priority, int, 0);
|
module_param(priority, int, 0);
|
||||||
MODULE_PARM_DESC(priority, "specify cpu notifier priority");
|
MODULE_PARM_DESC(priority, "specify cpu notifier priority");
|
||||||
|
|
||||||
|
#define UP_PREPARE 0
|
||||||
|
#define UP_PREPARE_FROZEN 0
|
||||||
|
#define DOWN_PREPARE 0
|
||||||
|
#define DOWN_PREPARE_FROZEN 0
|
||||||
|
|
||||||
static struct notifier_err_inject cpu_notifier_err_inject = {
|
static struct notifier_err_inject cpu_notifier_err_inject = {
|
||||||
.actions = {
|
.actions = {
|
||||||
{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) },
|
{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) },
|
||||||
{ NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) },
|
{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) },
|
||||||
{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) },
|
{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) },
|
||||||
{ NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) },
|
{ NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) },
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int notf_err_handle(struct notifier_err_inject_action *action)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = action->error;
|
||||||
|
if (ret)
|
||||||
|
pr_info("Injecting error (%d) to %s\n", ret, action->name);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int notf_err_inj_up_prepare(unsigned int cpu)
|
||||||
|
{
|
||||||
|
if (!cpuhp_tasks_frozen)
|
||||||
|
return notf_err_handle(&cpu_notifier_err_inject.actions[0]);
|
||||||
|
else
|
||||||
|
return notf_err_handle(&cpu_notifier_err_inject.actions[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int notf_err_inj_dead(unsigned int cpu)
|
||||||
|
{
|
||||||
|
if (!cpuhp_tasks_frozen)
|
||||||
|
return notf_err_handle(&cpu_notifier_err_inject.actions[2]);
|
||||||
|
else
|
||||||
|
return notf_err_handle(&cpu_notifier_err_inject.actions[3]);
|
||||||
|
}
|
||||||
|
|
||||||
static struct dentry *dir;
|
static struct dentry *dir;
|
||||||
|
|
||||||
static int err_inject_init(void)
|
static int err_inject_init(void)
|
||||||
|
@ -29,7 +60,10 @@ static int err_inject_init(void)
|
||||||
if (IS_ERR(dir))
|
if (IS_ERR(dir))
|
||||||
return PTR_ERR(dir);
|
return PTR_ERR(dir);
|
||||||
|
|
||||||
err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb);
|
err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE,
|
||||||
|
"cpu-err-notif:prepare",
|
||||||
|
notf_err_inj_up_prepare,
|
||||||
|
notf_err_inj_dead);
|
||||||
if (err)
|
if (err)
|
||||||
debugfs_remove_recursive(dir);
|
debugfs_remove_recursive(dir);
|
||||||
|
|
||||||
|
@ -38,7 +72,7 @@ static int err_inject_init(void)
|
||||||
|
|
||||||
static void err_inject_exit(void)
|
static void err_inject_exit(void)
|
||||||
{
|
{
|
||||||
unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb);
|
cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE);
|
||||||
debugfs_remove_recursive(dir);
|
debugfs_remove_recursive(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue