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