Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 1 | Notifier error injection |
| 2 | ======================== |
| 3 | |
Masanari Iida | 4e79162a | 2012-11-08 21:57:35 +0900 | [diff] [blame] | 4 | Notifier error injection provides the ability to inject artificial errors to |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 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 | |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 9 | * PM notifier |
| 10 | * Memory hotplug notifier |
| 11 | * powerpc pSeries reconfig notifier |
Nikolay Aleksandrov | 02fff96 | 2015-11-28 13:45:28 +0100 | [diff] [blame] | 12 | * Netdevice notifier |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 13 | |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 14 | PM notifier error injection module |
| 15 | ---------------------------------- |
| 16 | This feature is controlled through debugfs interface |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 17 | |
| 18 | /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 19 | |
| 20 | Possible PM notifier events to be failed are: |
| 21 | |
| 22 | * PM_HIBERNATION_PREPARE |
| 23 | * PM_SUSPEND_PREPARE |
| 24 | * PM_RESTORE_PREPARE |
| 25 | |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 26 | Example: Inject PM suspend error (-12 = -ENOMEM):: |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 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 |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 36 | |
| 37 | /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 38 | |
| 39 | Possible memory notifier events to be failed are: |
| 40 | |
| 41 | * MEM_GOING_ONLINE |
| 42 | * MEM_GOING_OFFLINE |
| 43 | |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 44 | Example: Inject memory hotplug offline error (-12 == -ENOMEM):: |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 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 |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 54 | |
| 55 | /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 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 | |
Nikolay Aleksandrov | 02fff96 | 2015-11-28 13:45:28 +0100 | [diff] [blame] | 64 | Netdevice notifier error injection module |
| 65 | ---------------------------------------------- |
| 66 | This feature is controlled through debugfs interface |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 67 | |
| 68 | /sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error |
Nikolay Aleksandrov | 02fff96 | 2015-11-28 13:45:28 +0100 | [diff] [blame] | 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 |
Ido Schimmel | c39d045 | 2015-12-03 12:12:04 +0100 | [diff] [blame] | 80 | * NETDEV_CHANGEUPPER |
Nikolay Aleksandrov | 02fff96 | 2015-11-28 13:45:28 +0100 | [diff] [blame] | 81 | |
Mauro Carvalho Chehab | 10ffebb | 2019-06-12 14:52:44 -0300 | [diff] [blame] | 82 | Example: Inject netdevice mtu change error (-22 == -EINVAL):: |
Nikolay Aleksandrov | 02fff96 | 2015-11-28 13:45:28 +0100 | [diff] [blame] | 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 | |
Akinobu Mita | 8d43828 | 2012-07-30 14:43:02 -0700 | [diff] [blame] | 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. |