notifier-error-inject.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. Notifier error injection
  2. ========================
  3. Notifier error injection provides the ability to inject artificial errors to
  4. specified notifier chain callbacks. It is useful to test the error handling of
  5. notifier call chain failures which is rarely executed. There are kernel
  6. modules that can be used to test the following notifiers.
  7. * CPU notifier
  8. * PM notifier
  9. * Memory hotplug notifier
  10. * powerpc pSeries reconfig notifier
  11. * Netdevice notifier
  12. CPU notifier error injection module
  13. -----------------------------------
  14. This feature can be used to test the error handling of the CPU notifiers by
  15. injecting artificial errors to CPU notifier chain callbacks.
  16. If the notifier call chain should be failed with some events notified, write
  17. the error code to debugfs interface
  18. /sys/kernel/debug/notifier-error-inject/cpu/actions/<notifier event>/error
  19. Possible CPU notifier events to be failed are:
  20. * CPU_UP_PREPARE
  21. * CPU_UP_PREPARE_FROZEN
  22. * CPU_DOWN_PREPARE
  23. * CPU_DOWN_PREPARE_FROZEN
  24. Example1: Inject CPU offline error (-1 == -EPERM)
  25. # cd /sys/kernel/debug/notifier-error-inject/cpu
  26. # echo -1 > actions/CPU_DOWN_PREPARE/error
  27. # echo 0 > /sys/devices/system/cpu/cpu1/online
  28. bash: echo: write error: Operation not permitted
  29. Example2: inject CPU online error (-2 == -ENOENT)
  30. # echo -2 > actions/CPU_UP_PREPARE/error
  31. # echo 1 > /sys/devices/system/cpu/cpu1/online
  32. bash: echo: write error: No such file or directory
  33. PM notifier error injection module
  34. ----------------------------------
  35. This feature is controlled through debugfs interface
  36. /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error
  37. Possible PM notifier events to be failed are:
  38. * PM_HIBERNATION_PREPARE
  39. * PM_SUSPEND_PREPARE
  40. * PM_RESTORE_PREPARE
  41. Example: Inject PM suspend error (-12 = -ENOMEM)
  42. # cd /sys/kernel/debug/notifier-error-inject/pm/
  43. # echo -12 > actions/PM_SUSPEND_PREPARE/error
  44. # echo mem > /sys/power/state
  45. bash: echo: write error: Cannot allocate memory
  46. Memory hotplug notifier error injection module
  47. ----------------------------------------------
  48. This feature is controlled through debugfs interface
  49. /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error
  50. Possible memory notifier events to be failed are:
  51. * MEM_GOING_ONLINE
  52. * MEM_GOING_OFFLINE
  53. Example: Inject memory hotplug offline error (-12 == -ENOMEM)
  54. # cd /sys/kernel/debug/notifier-error-inject/memory
  55. # echo -12 > actions/MEM_GOING_OFFLINE/error
  56. # echo offline > /sys/devices/system/memory/memoryXXX/state
  57. bash: echo: write error: Cannot allocate memory
  58. powerpc pSeries reconfig notifier error injection module
  59. --------------------------------------------------------
  60. This feature is controlled through debugfs interface
  61. /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error
  62. Possible pSeries reconfig notifier events to be failed are:
  63. * PSERIES_RECONFIG_ADD
  64. * PSERIES_RECONFIG_REMOVE
  65. * PSERIES_DRCONF_MEM_ADD
  66. * PSERIES_DRCONF_MEM_REMOVE
  67. Netdevice notifier error injection module
  68. ----------------------------------------------
  69. This feature is controlled through debugfs interface
  70. /sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error
  71. Netdevice notifier events which can be failed are:
  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
  80. * NETDEV_CHANGEUPPER
  81. Example: Inject netdevice mtu change error (-22 == -EINVAL)
  82. # cd /sys/kernel/debug/notifier-error-inject/netdev
  83. # echo -22 > actions/NETDEV_CHANGEMTU/error
  84. # ip link set eth0 mtu 1024
  85. RTNETLINK answers: Invalid argument
  86. For more usage examples
  87. -----------------------
  88. There are tools/testing/selftests using the notifier error injection features
  89. for CPU and memory notifiers.
  90. * tools/testing/selftests/cpu-hotplug/on-off-test.sh
  91. * tools/testing/selftests/memory-hotplug/on-off-test.sh
  92. These scripts first do simple online and offline tests and then do fault
  93. injection tests if notifier error injection module is available.