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