blob: 1668b6e48d3a229b3e896433b9cc7ec0f26bcd9d [file] [log] [blame]
Akinobu Mita8d438282012-07-30 14:43:02 -07001Notifier error injection
2========================
3
Masanari Iida4e79162a2012-11-08 21:57:35 +09004Notifier error injection provides the ability to inject artificial errors to
Akinobu Mita8d438282012-07-30 14:43:02 -07005specified notifier chain callbacks. It is useful to test the error handling of
6notifier call chain failures which is rarely executed. There are kernel
7modules that can be used to test the following notifiers.
8
Akinobu Mita8d438282012-07-30 14:43:02 -07009 * PM notifier
10 * Memory hotplug notifier
11 * powerpc pSeries reconfig notifier
Nikolay Aleksandrov02fff962015-11-28 13:45:28 +010012 * Netdevice notifier
Akinobu Mita8d438282012-07-30 14:43:02 -070013
Akinobu Mita8d438282012-07-30 14:43:02 -070014PM notifier error injection module
15----------------------------------
16This feature is controlled through debugfs interface
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030017
18 /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error
Akinobu Mita8d438282012-07-30 14:43:02 -070019
20Possible PM notifier events to be failed are:
21
22 * PM_HIBERNATION_PREPARE
23 * PM_SUSPEND_PREPARE
24 * PM_RESTORE_PREPARE
25
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030026Example: Inject PM suspend error (-12 = -ENOMEM)::
Akinobu Mita8d438282012-07-30 14:43:02 -070027
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
33Memory hotplug notifier error injection module
34----------------------------------------------
35This feature is controlled through debugfs interface
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030036
37 /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error
Akinobu Mita8d438282012-07-30 14:43:02 -070038
39Possible memory notifier events to be failed are:
40
41 * MEM_GOING_ONLINE
42 * MEM_GOING_OFFLINE
43
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030044Example: Inject memory hotplug offline error (-12 == -ENOMEM)::
Akinobu Mita8d438282012-07-30 14:43:02 -070045
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
51powerpc pSeries reconfig notifier error injection module
52--------------------------------------------------------
53This feature is controlled through debugfs interface
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030054
55 /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error
Akinobu Mita8d438282012-07-30 14:43:02 -070056
57Possible 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
Nikolay Aleksandrov02fff962015-11-28 13:45:28 +010064Netdevice notifier error injection module
65----------------------------------------------
66This feature is controlled through debugfs interface
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030067
68 /sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error
Nikolay Aleksandrov02fff962015-11-28 13:45:28 +010069
70Netdevice 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
Ido Schimmelc39d0452015-12-03 12:12:04 +010080 * NETDEV_CHANGEUPPER
Nikolay Aleksandrov02fff962015-11-28 13:45:28 +010081
Mauro Carvalho Chehab10ffebb2019-06-12 14:52:44 -030082Example: Inject netdevice mtu change error (-22 == -EINVAL)::
Nikolay Aleksandrov02fff962015-11-28 13:45:28 +010083
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
Akinobu Mita8d438282012-07-30 14:43:02 -070089For more usage examples
90-----------------------
91There are tools/testing/selftests using the notifier error injection features
92for 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
97These scripts first do simple online and offline tests and then do fault
98injection tests if notifier error injection module is available.