2012-07-31 01:43:02 +04:00
Notifier error injection
========================
2012-11-08 16:57:35 +04:00
Notifier error injection provides the ability to inject artificial errors to
2012-07-31 01:43:02 +04:00
specified notifier chain callbacks. It is useful to test the error handling of
notifier call chain failures which is rarely executed. There are kernel
modules that can be used to test the following notifiers.
* PM notifier
* Memory hotplug notifier
* powerpc pSeries reconfig notifier
2015-11-28 15:45:28 +03:00
* Netdevice notifier
2012-07-31 01:43:02 +04:00
PM notifier error injection module
----------------------------------
This feature is controlled through debugfs interface
2019-06-12 20:52:44 +03:00
/sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error
2012-07-31 01:43:02 +04:00
Possible PM notifier events to be failed are:
* PM_HIBERNATION_PREPARE
* PM_SUSPEND_PREPARE
* PM_RESTORE_PREPARE
2019-06-12 20:52:44 +03:00
Example: Inject PM suspend error (-12 = -ENOMEM)::
2012-07-31 01:43:02 +04:00
# cd /sys/kernel/debug/notifier-error-inject/pm/
# echo -12 > actions/PM_SUSPEND_PREPARE/error
# echo mem > /sys/power/state
bash: echo: write error: Cannot allocate memory
Memory hotplug notifier error injection module
----------------------------------------------
This feature is controlled through debugfs interface
2019-06-12 20:52:44 +03:00
/sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error
2012-07-31 01:43:02 +04:00
Possible memory notifier events to be failed are:
* MEM_GOING_ONLINE
* MEM_GOING_OFFLINE
2019-06-12 20:52:44 +03:00
Example: Inject memory hotplug offline error (-12 == -ENOMEM)::
2012-07-31 01:43:02 +04:00
# cd /sys/kernel/debug/notifier-error-inject/memory
# echo -12 > actions/MEM_GOING_OFFLINE/error
# echo offline > /sys/devices/system/memory/memoryXXX/state
bash: echo: write error: Cannot allocate memory
powerpc pSeries reconfig notifier error injection module
--------------------------------------------------------
This feature is controlled through debugfs interface
2019-06-12 20:52:44 +03:00
/sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error
2012-07-31 01:43:02 +04:00
Possible pSeries reconfig notifier events to be failed are:
* PSERIES_RECONFIG_ADD
* PSERIES_RECONFIG_REMOVE
* PSERIES_DRCONF_MEM_ADD
* PSERIES_DRCONF_MEM_REMOVE
2015-11-28 15:45:28 +03:00
Netdevice notifier error injection module
----------------------------------------------
This feature is controlled through debugfs interface
2019-06-12 20:52:44 +03:00
/sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error
2015-11-28 15:45:28 +03:00
Netdevice notifier events which can be failed are:
* NETDEV_REGISTER
* NETDEV_CHANGEMTU
* NETDEV_CHANGENAME
* NETDEV_PRE_UP
* NETDEV_PRE_TYPE_CHANGE
* NETDEV_POST_INIT
* NETDEV_PRECHANGEMTU
* NETDEV_PRECHANGEUPPER
2015-12-03 14:12:04 +03:00
* NETDEV_CHANGEUPPER
2015-11-28 15:45:28 +03:00
2019-06-12 20:52:44 +03:00
Example: Inject netdevice mtu change error (-22 == -EINVAL)::
2015-11-28 15:45:28 +03:00
# cd /sys/kernel/debug/notifier-error-inject/netdev
# echo -22 > actions/NETDEV_CHANGEMTU/error
# ip link set eth0 mtu 1024
RTNETLINK answers: Invalid argument
2012-07-31 01:43:02 +04:00
For more usage examples
-----------------------
There are tools/testing/selftests using the notifier error injection features
for CPU and memory notifiers.
2022-09-30 09:35:27 +03:00
* tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
* tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
2012-07-31 01:43:02 +04:00
These scripts first do simple online and offline tests and then do fault
injection tests if notifier error injection module is available.