notifier-error-inject.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. CPU notifier error injection module
  12. -----------------------------------
  13. This feature can be used to test the error handling of the CPU notifiers by
  14. injecting artificial errors to CPU notifier chain callbacks.
  15. If the notifier call chain should be failed with some events notified, write
  16. the error code to debugfs interface
  17. /sys/kernel/debug/notifier-error-inject/cpu/actions/<notifier event>/error
  18. Possible CPU notifier events to be failed are:
  19. * CPU_UP_PREPARE
  20. * CPU_UP_PREPARE_FROZEN
  21. * CPU_DOWN_PREPARE
  22. * CPU_DOWN_PREPARE_FROZEN
  23. Example1: Inject CPU offline error (-1 == -EPERM)
  24. # cd /sys/kernel/debug/notifier-error-inject/cpu
  25. # echo -1 > actions/CPU_DOWN_PREPARE/error
  26. # echo 0 > /sys/devices/system/cpu/cpu1/online
  27. bash: echo: write error: Operation not permitted
  28. Example2: inject CPU online error (-2 == -ENOENT)
  29. # echo -2 > actions/CPU_UP_PREPARE/error
  30. # echo 1 > /sys/devices/system/cpu/cpu1/online
  31. bash: echo: write error: No such file or directory
  32. PM notifier error injection module
  33. ----------------------------------
  34. This feature is controlled through debugfs interface
  35. /sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error
  36. Possible PM notifier events to be failed are:
  37. * PM_HIBERNATION_PREPARE
  38. * PM_SUSPEND_PREPARE
  39. * PM_RESTORE_PREPARE
  40. Example: Inject PM suspend error (-12 = -ENOMEM)
  41. # cd /sys/kernel/debug/notifier-error-inject/pm/
  42. # echo -12 > actions/PM_SUSPEND_PREPARE/error
  43. # echo mem > /sys/power/state
  44. bash: echo: write error: Cannot allocate memory
  45. Memory hotplug notifier error injection module
  46. ----------------------------------------------
  47. This feature is controlled through debugfs interface
  48. /sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error
  49. Possible memory notifier events to be failed are:
  50. * MEM_GOING_ONLINE
  51. * MEM_GOING_OFFLINE
  52. Example: Inject memory hotplug offline error (-12 == -ENOMEM)
  53. # cd /sys/kernel/debug/notifier-error-inject/memory
  54. # echo -12 > actions/MEM_GOING_OFFLINE/error
  55. # echo offline > /sys/devices/system/memory/memoryXXX/state
  56. bash: echo: write error: Cannot allocate memory
  57. powerpc pSeries reconfig notifier error injection module
  58. --------------------------------------------------------
  59. This feature is controlled through debugfs interface
  60. /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error
  61. Possible pSeries reconfig notifier events to be failed are:
  62. * PSERIES_RECONFIG_ADD
  63. * PSERIES_RECONFIG_REMOVE
  64. * PSERIES_DRCONF_MEM_ADD
  65. * PSERIES_DRCONF_MEM_REMOVE
  66. For more usage examples
  67. -----------------------
  68. There are tools/testing/selftests using the notifier error injection features
  69. for CPU and memory notifiers.
  70. * tools/testing/selftests/cpu-hotplug/on-off-test.sh
  71. * tools/testing/selftests/memory-hotplug/on-off-test.sh
  72. These scripts first do simple online and offline tests and then do fault
  73. injection tests if notifier error injection module is available.