diff options
Diffstat (limited to 'lib/cpu-notifier-error-inject.c')
| -rw-r--r-- | lib/cpu-notifier-error-inject.c | 46 |
1 files changed, 40 insertions, 6 deletions
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 | ||
