162306a36Sopenharmony_ciNotifier error injection 262306a36Sopenharmony_ci======================== 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciNotifier error injection provides the ability to inject artificial errors to 562306a36Sopenharmony_cispecified notifier chain callbacks. It is useful to test the error handling of 662306a36Sopenharmony_cinotifier call chain failures which is rarely executed. There are kernel 762306a36Sopenharmony_cimodules that can be used to test the following notifiers. 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci * PM notifier 1062306a36Sopenharmony_ci * Memory hotplug notifier 1162306a36Sopenharmony_ci * powerpc pSeries reconfig notifier 1262306a36Sopenharmony_ci * Netdevice notifier 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciPM notifier error injection module 1562306a36Sopenharmony_ci---------------------------------- 1662306a36Sopenharmony_ciThis feature is controlled through debugfs interface 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciPossible PM notifier events to be failed are: 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci * PM_HIBERNATION_PREPARE 2362306a36Sopenharmony_ci * PM_SUSPEND_PREPARE 2462306a36Sopenharmony_ci * PM_RESTORE_PREPARE 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ciExample: Inject PM suspend error (-12 = -ENOMEM):: 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci # cd /sys/kernel/debug/notifier-error-inject/pm/ 2962306a36Sopenharmony_ci # echo -12 > actions/PM_SUSPEND_PREPARE/error 3062306a36Sopenharmony_ci # echo mem > /sys/power/state 3162306a36Sopenharmony_ci bash: echo: write error: Cannot allocate memory 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciMemory hotplug notifier error injection module 3462306a36Sopenharmony_ci---------------------------------------------- 3562306a36Sopenharmony_ciThis feature is controlled through debugfs interface 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciPossible memory notifier events to be failed are: 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci * MEM_GOING_ONLINE 4262306a36Sopenharmony_ci * MEM_GOING_OFFLINE 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciExample: Inject memory hotplug offline error (-12 == -ENOMEM):: 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci # cd /sys/kernel/debug/notifier-error-inject/memory 4762306a36Sopenharmony_ci # echo -12 > actions/MEM_GOING_OFFLINE/error 4862306a36Sopenharmony_ci # echo offline > /sys/devices/system/memory/memoryXXX/state 4962306a36Sopenharmony_ci bash: echo: write error: Cannot allocate memory 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cipowerpc pSeries reconfig notifier error injection module 5262306a36Sopenharmony_ci-------------------------------------------------------- 5362306a36Sopenharmony_ciThis feature is controlled through debugfs interface 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ciPossible pSeries reconfig notifier events to be failed are: 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci * PSERIES_RECONFIG_ADD 6062306a36Sopenharmony_ci * PSERIES_RECONFIG_REMOVE 6162306a36Sopenharmony_ci * PSERIES_DRCONF_MEM_ADD 6262306a36Sopenharmony_ci * PSERIES_DRCONF_MEM_REMOVE 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ciNetdevice notifier error injection module 6562306a36Sopenharmony_ci---------------------------------------------- 6662306a36Sopenharmony_ciThis feature is controlled through debugfs interface 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci /sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciNetdevice notifier events which can be failed are: 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci * NETDEV_REGISTER 7362306a36Sopenharmony_ci * NETDEV_CHANGEMTU 7462306a36Sopenharmony_ci * NETDEV_CHANGENAME 7562306a36Sopenharmony_ci * NETDEV_PRE_UP 7662306a36Sopenharmony_ci * NETDEV_PRE_TYPE_CHANGE 7762306a36Sopenharmony_ci * NETDEV_POST_INIT 7862306a36Sopenharmony_ci * NETDEV_PRECHANGEMTU 7962306a36Sopenharmony_ci * NETDEV_PRECHANGEUPPER 8062306a36Sopenharmony_ci * NETDEV_CHANGEUPPER 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ciExample: Inject netdevice mtu change error (-22 == -EINVAL):: 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci # cd /sys/kernel/debug/notifier-error-inject/netdev 8562306a36Sopenharmony_ci # echo -22 > actions/NETDEV_CHANGEMTU/error 8662306a36Sopenharmony_ci # ip link set eth0 mtu 1024 8762306a36Sopenharmony_ci RTNETLINK answers: Invalid argument 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ciFor more usage examples 9062306a36Sopenharmony_ci----------------------- 9162306a36Sopenharmony_ciThere are tools/testing/selftests using the notifier error injection features 9262306a36Sopenharmony_cifor CPU and memory notifiers. 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci * tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh 9562306a36Sopenharmony_ci * tools/testing/selftests/memory-hotplug/mem-on-off-test.sh 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciThese scripts first do simple online and offline tests and then do fault 9862306a36Sopenharmony_ciinjection tests if notifier error injection module is available. 99