Merge tag 'rproc-v5.3' of git://github.com/andersson/remoteproc
[sfrench/cifs-2.6.git] / Documentation / fault-injection / notifier-error-inject.rst
1 Notifier error injection
2 ========================
3
4 Notifier error injection provides the ability to inject artificial errors to
5 specified notifier chain callbacks. It is useful to test the error handling of
6 notifier call chain failures which is rarely executed.  There are kernel
7 modules that can be used to test the following notifiers.
8
9  * PM notifier
10  * Memory hotplug notifier
11  * powerpc pSeries reconfig notifier
12  * Netdevice notifier
13
14 PM notifier error injection module
15 ----------------------------------
16 This feature is controlled through debugfs interface
17
18   /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error
19
20 Possible PM notifier events to be failed are:
21
22  * PM_HIBERNATION_PREPARE
23  * PM_SUSPEND_PREPARE
24  * PM_RESTORE_PREPARE
25
26 Example: Inject PM suspend error (-12 = -ENOMEM)::
27
28         # cd /sys/kernel/debug/notifier-error-inject/pm/
29         # echo -12 > actions/PM_SUSPEND_PREPARE/error
30         # echo mem > /sys/power/state
31         bash: echo: write error: Cannot allocate memory
32
33 Memory hotplug notifier error injection module
34 ----------------------------------------------
35 This feature is controlled through debugfs interface
36
37   /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error
38
39 Possible memory notifier events to be failed are:
40
41  * MEM_GOING_ONLINE
42  * MEM_GOING_OFFLINE
43
44 Example: Inject memory hotplug offline error (-12 == -ENOMEM)::
45
46         # cd /sys/kernel/debug/notifier-error-inject/memory
47         # echo -12 > actions/MEM_GOING_OFFLINE/error
48         # echo offline > /sys/devices/system/memory/memoryXXX/state
49         bash: echo: write error: Cannot allocate memory
50
51 powerpc pSeries reconfig notifier error injection module
52 --------------------------------------------------------
53 This feature is controlled through debugfs interface
54
55   /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error
56
57 Possible pSeries reconfig notifier events to be failed are:
58
59  * PSERIES_RECONFIG_ADD
60  * PSERIES_RECONFIG_REMOVE
61  * PSERIES_DRCONF_MEM_ADD
62  * PSERIES_DRCONF_MEM_REMOVE
63
64 Netdevice notifier error injection module
65 ----------------------------------------------
66 This feature is controlled through debugfs interface
67
68   /sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error
69
70 Netdevice notifier events which can be failed are:
71
72  * NETDEV_REGISTER
73  * NETDEV_CHANGEMTU
74  * NETDEV_CHANGENAME
75  * NETDEV_PRE_UP
76  * NETDEV_PRE_TYPE_CHANGE
77  * NETDEV_POST_INIT
78  * NETDEV_PRECHANGEMTU
79  * NETDEV_PRECHANGEUPPER
80  * NETDEV_CHANGEUPPER
81
82 Example: Inject netdevice mtu change error (-22 == -EINVAL)::
83
84         # cd /sys/kernel/debug/notifier-error-inject/netdev
85         # echo -22 > actions/NETDEV_CHANGEMTU/error
86         # ip link set eth0 mtu 1024
87         RTNETLINK answers: Invalid argument
88
89 For more usage examples
90 -----------------------
91 There are tools/testing/selftests using the notifier error injection features
92 for CPU and memory notifiers.
93
94  * tools/testing/selftests/cpu-hotplug/on-off-test.sh
95  * tools/testing/selftests/memory-hotplug/on-off-test.sh
96
97 These scripts first do simple online and offline tests and then do fault
98 injection tests if notifier error injection module is available.