Blame view
lib/cpu-notifier-error-inject.c
1.95 KB
c9d221f86
|
1 |
#include <linux/kernel.h> |
c9d221f86
|
2 |
#include <linux/module.h> |
f5a9f52e2
|
3 |
#include <linux/cpu.h> |
c9d221f86
|
4 |
|
f5a9f52e2
|
5 |
#include "notifier-error-inject.h" |
c9d221f86
|
6 |
|
f5a9f52e2
|
7 |
static int priority; |
c9d221f86
|
8 9 |
module_param(priority, int, 0); MODULE_PARM_DESC(priority, "specify cpu notifier priority"); |
8c58898b3
|
10 11 12 13 |
#define UP_PREPARE 0 #define UP_PREPARE_FROZEN 0 #define DOWN_PREPARE 0 #define DOWN_PREPARE_FROZEN 0 |
f5a9f52e2
|
14 15 |
static struct notifier_err_inject cpu_notifier_err_inject = { .actions = { |
8c58898b3
|
16 17 18 19 |
{ NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE) }, { NOTIFIER_ERR_INJECT_ACTION(UP_PREPARE_FROZEN) }, { NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE) }, { NOTIFIER_ERR_INJECT_ACTION(DOWN_PREPARE_FROZEN) }, |
f5a9f52e2
|
20 |
{} |
c9d221f86
|
21 |
} |
c9d221f86
|
22 |
}; |
8c58898b3
|
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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 ", 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]); } |
f5a9f52e2
|
49 |
static struct dentry *dir; |
c9d221f86
|
50 51 |
static int err_inject_init(void) { |
f5a9f52e2
|
52 53 54 55 56 57 |
int err; dir = notifier_err_inject_init("cpu", notifier_err_inject_dir, &cpu_notifier_err_inject, priority); if (IS_ERR(dir)) return PTR_ERR(dir); |
8c58898b3
|
58 59 60 61 |
err = cpuhp_setup_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE, "cpu-err-notif:prepare", notf_err_inj_up_prepare, notf_err_inj_dead); |
f5a9f52e2
|
62 63 |
if (err) debugfs_remove_recursive(dir); |
c9d221f86
|
64 |
|
f5a9f52e2
|
65 |
return err; |
c9d221f86
|
66 67 68 69 |
} static void err_inject_exit(void) { |
8c58898b3
|
70 |
cpuhp_remove_state_nocalls(CPUHP_NOTF_ERR_INJ_PREPARE); |
f5a9f52e2
|
71 |
debugfs_remove_recursive(dir); |
c9d221f86
|
72 73 74 75 76 77 78 79 |
} module_init(err_inject_init); module_exit(err_inject_exit); MODULE_DESCRIPTION("CPU notifier error injection module"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>"); |