diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2016-09-06 13:04:50 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-19 15:44:31 -0400 |
commit | 8c58898b3ecb213ad7c52aa0c7c9d3201e559be1 (patch) | |
tree | 3375fa766e1dc1b0b383569229171ee34b8a9b7e | |
parent | 30e92153b4e6f1cd01e30c34d9ef6f0986f96b0e (diff) |
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>
-rw-r--r-- | include/linux/cpuhotplug.h | 1 | ||||
-rw-r--r-- | lib/cpu-notifier-error-inject.c | 46 |
2 files changed, 41 insertions, 6 deletions
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 7706987c7827..bb6231d13d3a 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h | |||
@@ -43,6 +43,7 @@ enum cpuhp_state { | |||
43 | CPUHP_ARM_SHMOBILE_SCU_PREPARE, | 43 | CPUHP_ARM_SHMOBILE_SCU_PREPARE, |
44 | CPUHP_SH_SH3X_PREPARE, | 44 | CPUHP_SH_SH3X_PREPARE, |
45 | CPUHP_TIMERS_DEAD, | 45 | CPUHP_TIMERS_DEAD, |
46 | CPUHP_NOTF_ERR_INJ_PREPARE, | ||
46 | CPUHP_BRINGUP_CPU, | 47 | CPUHP_BRINGUP_CPU, |
47 | CPUHP_AP_IDLE_DEAD, | 48 | CPUHP_AP_IDLE_DEAD, |
48 | CPUHP_AP_OFFLINE, | 49 | CPUHP_AP_OFFLINE, |
diff --git a/lib/cpu-notifier-error-inject.c b/lib/cpu-notifier-error-inject.c index 707ca24f7b18..0e2c9a1e958a 100644 --- a/lib/cpu-notifier-error-inject.c +++ b/lib/cpu-notifier-error-inject.c | |||
@@ -8,16 +8,47 @@ static int priority; | |||
8 | module_param(priority, int, 0); | 8 | module_param(priority, int, 0); |
9 | MODULE_PARM_DESC(priority, "specify cpu notifier priority"); | 9 | MODULE_PARM_DESC(priority, "specify cpu notifier priority"); |
10 | 10 | ||
11 | #define UP_PREPARE 0 | ||
12 | #define UP_PREPARE_FROZEN 0 | ||
13 | #define DOWN_PREPARE 0 | ||
14 | #define DOWN_PREPARE_FROZEN 0 | ||
15 | |||
11 | static struct notifier_err_inject cpu_notifier_err_inject = { | 16 | static struct notifier_err_inject cpu_notifier_err_inject = { |
12 | .actions = { | 17 | .actions = { |
13 | { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE) }, | 18 | { NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) }, |
14 | { NOTIFIER_ERR_INJECT_ACTION(CPU_UP_PREPARE_FROZEN) }, | 19 | { NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) }, |
15 | { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE) }, | 20 | { NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) }, |
16 | { NOTIFIER_ERR_INJECT_ACTION(CPU_DOWN_PREPARE_FROZEN) }, | 21 | { NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) }, |
17 | {} | 22 | {} |
18 | } | 23 | } |
19 | }; | 24 | }; |
20 | 25 | ||
26 | static int notf_err_handle(struct notifier_err_inject_action *action) | ||
27 | { | ||
28 | int ret; | ||
29 | |||
30 | ret = action->error; | ||
31 | if (ret) | ||
32 | pr_info("Injecting error (%d) to %s\n", ret, action->name); | ||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | static int notf_err_inj_up_prepare(unsigned int cpu) | ||
37 | { | ||
38 | if (!cpuhp_tasks_frozen) | ||
39 | return notf_err_handle(&cpu_notifier_err_inject.actions[0]); | ||
40 | else | ||
41 | return notf_err_handle(&cpu_notifier_err_inject.actions[1]); | ||
42 | } | ||
43 | |||
44 | static int notf_err_inj_dead(unsigned int cpu) | ||
45 | { | ||
46 | if (!cpuhp_tasks_frozen) | ||
47 | return notf_err_handle(&cpu_notifier_err_inject.actions[2]); | ||
48 | else | ||
49 | return notf_err_handle(&cpu_notifier_err_inject.actions[3]); | ||
50 | } | ||
51 | |||
21 | static struct dentry *dir; | 52 | static struct dentry *dir; |
22 | 53 | ||
23 | static int err_inject_init(void) | 54 | static int err_inject_init(void) |
@@ -29,7 +60,10 @@ static int err_inject_init(void) | |||
29 | if (IS_ERR(dir)) | 60 | if (IS_ERR(dir)) |
30 | return PTR_ERR(dir); | 61 | return PTR_ERR(dir); |
31 | 62 | ||
32 | err = register_hotcpu_notifier(&cpu_notifier_err_inject.nb); | 63 | err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE, |
64 | "cpu-err-notif:prepare", | ||
65 | notf_err_inj_up_prepare, | ||
66 | notf_err_inj_dead); | ||
33 | if (err) | 67 | if (err) |
34 | debugfs_remove_recursive(dir); | 68 | debugfs_remove_recursive(dir); |
35 | 69 | ||
@@ -38,7 +72,7 @@ static int err_inject_init(void) | |||
38 | 72 | ||
39 | static void err_inject_exit(void) | 73 | static void err_inject_exit(void) |
40 | { | 74 | { |
41 | unregister_hotcpu_notifier(&cpu_notifier_err_inject.nb); | 75 | cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE); |
42 | debugfs_remove_recursive(dir); | 76 | debugfs_remove_recursive(dir); |
43 | } | 77 | } |
44 | 78 | ||