notifier error injection
Subsystems (4)
cover notifier error injection
This provides kernel modules that can be used to test the error handling of notifier call chain failures by injecting artifical errors to the following notifier chain callbacks.
* CPU notifier
* PM notifier
* memory hotplug notifier
* powerpc pSeries reconfig notifier
Example: Inject CPU offline error (-1 == -EPERM)
# cd /sys/kernel/debug/notifier-error-inject/cpu # echo -1 > actions/CPU_DOWN_PREPARE/error # echo 0 > /sys/devices/system/cpu/cpu1/online bash: echo: write error: Operation not permitted
This also adds cpu and memory hotplug tests to tools/testing/selftests These tests first do simple online and offline test and then do fault injection tests if notifier error injection module is available.
Changelog:
* v5 (change only testing scripts)
- make testing scripts a part of tools/testing/selftests
- do simple on/offline tests even if no notifier error injection support
* v4 (It is about 11 months since v3)
- prefix all APIs with notifier_err_inject_*
- rearrange debugfs interface
(e.g. $DEBUGFS/cpu-notifier-error-inject/CPU_DOWN_PREPARE -->
$DEBUGFS/notifier-error-inject/cpu/actions/CPU_DOWN_PREPARE/error)
- update modules to follow new interface
- add -r option for memory-notifier.sh to specify percent of offlining memory blocks
* v3
- rewrite to be kernel modules instead of initializing at late_initcall()s (it makes the diffstat look different but most code remains unchanged)
- export err_inject_notifier_block_{init,cleanup} for modules
- export pSeries_reconfig_notifier_{,un}register symbols for a module
- notifier priority can be specified as a module parameter
- add testing scripts in tools/testing/fault-injection
* v2
- "PM: Improve error code of pm_notifier_call_chain()" is now in -next
- "debugfs: add debugfs_create_int" is dropped
- put a comment in err_inject_notifier_block_init()
- only allow valid errno to be injected (-MAX_ERRNO <= errno <= 0)
- improve Kconfig help text
- make CONFIG_PM_NOTIFIER_ERROR_INJECTION visible even if PM_DEBUG is disabled
- make CONFIG_PM_NOTIFIER_ERROR_INJECTION default if PM_DEBUG is enabled
Akinobu Mita (6):
fault-injection: notifier error injection
cpu: rewrite cpu-notifier-error-inject module
PM: PM notifier error injection module
memory: memory notifier error injection module
powerpc: pSeries reconfig notifier error injection module
fault-injection: add selftests for cpu and memory hotplug
lib/Kconfig.debug | 91 +++++++- lib/Makefile | 5 + lib/cpu-notifier-error-inject.c | 63 +++--- lib/memory-notifier-error-inject.c | 48 ++++ lib/notifier-error-inject.c | 112 ++++++++++ lib/notifier-error-inject.h | 24 ++ lib/pSeries-reconfig-notifier-error-inject.c | 51 +++++ lib/pm-notifier-error-inject.c | 49 +++++ tools/testing/selftests/Makefile | 2 +- tools/testing/selftests/cpu-hotplug/Makefile | 6 + tools/testing/selftests/cpu-hotplug/on-off-test.sh | 221 +++++++++++++++++++ tools/testing/selftests/memory-hotplug/Makefile | 6 + .../selftests/memory-hotplug/on-off-test.sh | 230 ++++++++++++++++++++ 13 files changed, 867 insertions(+), 41 deletions(-) create mode 100644 lib/memory-notifier-error-inject.c create mode 100644 lib/notifier-error-inject.c create mode 100644 lib/notifier-error-inject.h create mode 100644 lib/pSeries-reconfig-notifier-error-inject.c create mode 100644 lib/pm-notifier-error-inject.c create mode 100644 tools/testing/selftests/cpu-hotplug/Makefile create mode 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh create mode 100644 tools/testing/selftests/memory-hotplug/Makefile create mode 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh
Signature · 1 line
1.7.10.4
PATCH 1/6 fault-injection: notifier error injection
The notifier error injection provides the ability to inject artifical errors to specified notifier chain callbacks. It is useful to test the error handling of notifier call chain failures.
This adds common basic functions to define which type of events can be fail and to initialize the debugfs interface to control what error code should be returned and which event should be failed.
---
No changes since v4
lib/Kconfig.debug | 11 +++++ lib/Makefile | 1 + lib/notifier-error-inject.c | 112 +++++++++++++++++++++++++++++++++++++++++++ lib/notifier-error-inject.h | 24 ++++++++++ 4 files changed, 148 insertions(+) create mode 100644 lib/notifier-error-inject.c create mode 100644 lib/notifier-error-inject.h
lib/Kconfig.debug +11 -0
@@ -1084,6 +1084,17 @@ config LKDTM Documentation on how to use the module can be found in Documentation/fault-injection/provoke-crashes.txt +config NOTIFIER_ERROR_INJECTION + tristate "Notifier error injection" + depends on DEBUG_KERNEL + select DEBUG_FS + help + This option provides the ability to inject artifical errors to + specified notifier chain callbacks. It is useful to test the error + handling of notifier call chain failures. + + Say N if unsure. + config CPU_NOTIFIER_ERROR_INJECT tristate "CPU notifier error injection module" depends on HOTPLUG_CPU && DEBUG_KERNEL
lib/Makefile +1 -0
@@ -90,6 +90,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o obj-$(CONFIG_SWIOTLB) += swiotlb.o obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o +obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o lib-$(CONFIG_GENERIC_BUG) += bug.o
lib/notifier-error-inject.c new file +112 -0
112 lines not on this page · raw message
lib/notifier-error-inject.h new file +24 -0
@@ -0,0 +1,24 @@ +#include <linux/atomic.h> +#include <linux/debugfs.h> +#include <linux/notifier.h> + +struct notifier_err_inject_action { +unsigned long val; +int error; +const char *name; +}; + +#define NOTIFIER_ERR_INJECT_ACTION (action) \ + .name = #action, .val = (action), + +struct notifier_err_inject { +struct notifier_block nb; +struct notifier_err_inject_action actions[]; +/* The last slot must be terminated with zero sentinel */ +}; + +extern struct dentry *notifier_err_inject_dir; + +extern struct dentry *notifier_err_inject_init (const char *name, +struct dentry *parent,struct notifier_err_inject *err_inject, +int priority);
Signature · 7 lines
1.7.10.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/6 PM: PM notifier error injection module
In reply to Akinobu MitaThis provides the ability to inject artifical errors to PM notifier chain callbacks. It is controlled through debugfs interface under /sys/kernel/debug/notifier-error-inject/pm
Each of the files in "error" directory represents an event which can be failed and contains the error code. If the notifier call chain should be failed with some events notified, write the error code to the files.
If the notifier call chain should be failed with some events notified, write the error code to "actions/<notifier event>/error".
Example: Inject PM suspend error (-12 = -ENOMEM)
# cd /sys/kernel/debug/notifier-error-inject/pm # echo -12 > actions/PM_SUSPEND_PREPARE/error # echo mem > /sys/power/state bash: echo: write error: Cannot allocate memory
---
No changes since v4
lib/Kconfig.debug | 24 ++++++++++++++++++++ lib/Makefile | 1 + lib/pm-notifier-error-inject.c | 49 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 lib/pm-notifier-error-inject.c
lib/Kconfig.debug +24 -0
@@ -1119,6 +1119,30 @@ config CPU_NOTIFIER_ERROR_INJECT If unsure, say N. +config PM_NOTIFIER_ERROR_INJECT + tristate "PM notifier error injection module" + depends on PM && NOTIFIER_ERROR_INJECTION + default m if PM_DEBUG + help + This option provides the ability to inject artifical errors to + PM notifier chain callbacks. It is controlled through debugfs + interface /sys/kernel/debug/notifier-error-inject/pm + + If the notifier call chain should be failed with some events + notified, write the error code to "actions/<notifier event>/error". + + Example: Inject PM suspend error (-12 = -ENOMEM) + + # cd /sys/kernel/debug/notifier-error-inject/pm/ + # echo -12 > actions/PM_SUSPEND_PREPARE/error + # echo mem > /sys/power/state + bash: echo: write error: Cannot allocate memory + + To compile this code as a module, choose M here: the module will + be called pm-notifier-error-inject. + + If unsure, say N. + config FAULT_INJECTION bool "Fault-injection framework" depends on DEBUG_KERNEL
lib/Makefile +1 -0
@@ -92,6 +92,7 @@ obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o +obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o lib-$(CONFIG_GENERIC_BUG) += bug.o
lib/pm-notifier-error-inject.c new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 6/6 fault-injection: add selftests for cpu and memory hotplug
In reply to Akinobu MitaThis adds two selftests
* tools/testing/selftests/cpu-hotplug/on-off-test.sh is testing script for CPU hotplug
1. Online all hot-pluggable CPUs
2. Offline all hot-pluggable CPUs
3. Online all hot-pluggable CPUs again
4. Exit if cpu-notifier-error-inject.ko is not available
5. Offline all hot-pluggable CPUs in preparation for testing
6. Test CPU hot-add error handling by injecting notifier errors
7. Online all hot-pluggable CPUs in preparation for testing
8. Test CPU hot-remove error handling by injecting notifier errors
* tools/testing/selftests/memory-hotplug/on-off-test.sh is doing the similar thing for memory hotplug.
1. Online all hot-pluggable memory
2. Offline 10% of hot-pluggable memory
3. Online all hot-pluggable memory again
4. Exit if memory-notifier-error-inject.ko is not available
5. Offline 10% of hot-pluggable memory in preparation for testing
6. Test memory hot-add error handling by injecting notifier errors
7. Online all hot-pluggable memory in preparation for testing
8. Test memory hot-remove error handling by injecting notifier errors
---
* v5
- make testing scripts a part of tools/testing/selftests
- do simple on/offline tests even if no notifier error injection support
tools/testing/selftests/Makefile | 2 +- tools/testing/selftests/cpu-hotplug/Makefile | 6 + tools/testing/selftests/cpu-hotplug/on-off-test.sh | 221 +++++++++++++++++++ tools/testing/selftests/memory-hotplug/Makefile | 6 + .../selftests/memory-hotplug/on-off-test.sh | 230 ++++++++++++++++++++ 5 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/cpu-hotplug/Makefile create mode 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh create mode 100644 tools/testing/selftests/memory-hotplug/Makefile create mode 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh
tools/testing/selftests/Makefile +1 -1
@@ -1,4 +1,4 @@ -TARGETS = breakpoints kcmp mqueue vm +TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug all: for TARGET in $(TARGETS); do \
tools/testing/selftests/cpu-hotplug/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +all: + +run_tests: + ./on-off-test.sh + +clean:
tools/testing/selftests/cpu-hotplug/on-off-test.sh new file +221 -0
221 lines not on this page · raw message
tools/testing/selftests/memory-hotplug/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +all: + +run_tests: + ./on-off-test.sh + +clean:
tools/testing/selftests/memory-hotplug/on-off-test.sh new file +230 -0
230 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/6 memory: memory notifier error injection module
In reply to Akinobu MitaThis provides the ability to inject artifical errors to memory hotplug notifier chain callbacks. It is controlled through debugfs interface under /sys/kernel/debug/notifier-error-inject/memory
If the notifier call chain should be failed with some events notified, write the error code to "actions/<notifier event>/error".
Example: Inject memory hotplug offline error (-12 == -ENOMEM)
# cd /sys/kernel/debug/notifier-error-inject/memory # echo -12 > actions/MEM_GOING_OFFLINE/error # echo offline > /sys/devices/system/memory/memoryXXX/state bash: echo: write error: Cannot allocate memory
---
No changes since v4
lib/Kconfig.debug | 23 +++++++++++++++++ lib/Makefile | 1 + lib/memory-notifier-error-inject.c | 48 ++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 lib/memory-notifier-error-inject.c
lib/Kconfig.debug +23 -0
@@ -1143,6 +1143,29 @@ config PM_NOTIFIER_ERROR_INJECT If unsure, say N. +config MEMORY_NOTIFIER_ERROR_INJECT + tristate "Memory hotplug notifier error injection module" + depends on MEMORY_HOTPLUG_SPARSE && NOTIFIER_ERROR_INJECTION + help + This option provides the ability to inject artifical errors to + memory hotplug notifier chain callbacks. It is controlled through + debugfs interface under /sys/kernel/debug/notifier-error-inject/memory + + If the notifier call chain should be failed with some events + notified, write the error code to "actions/<notifier event>/error". + + Example: Inject memory hotplug offline error (-12 == -ENOMEM) + + # cd /sys/kernel/debug/notifier-error-inject/memory + # echo -12 > actions/MEM_GOING_OFFLINE/error + # echo offline > /sys/devices/system/memory/memoryXXX/state + bash: echo: write error: Cannot allocate memory + + To compile this code as a module, choose M here: the module will + be called memory-notifier-error-inject. + + If unsure, say N. + config FAULT_INJECTION bool "Fault-injection framework" depends on DEBUG_KERNEL
lib/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o +obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o lib-$(CONFIG_GENERIC_BUG) += bug.o
lib/memory-notifier-error-inject.c new file +48 -0
48 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/6 cpu: rewrite cpu-notifier-error-inject module
In reply to Akinobu MitaRewrite existing cpu-notifier-error-inject module to use debugfs based new framework.
This change removes cpu_up_prepare_error and cpu_down_prepare_error module parameters which were used to specify error code to be injected. We could keep these module parameters for backward compatibility by module_param_cb but it seems overkill for this module.
This provides the ability to inject artifical errors to CPU notifier chain callbacks. It is controlled through debugfs interface under /sys/kernel/debug/notifier-error-inject/cpu
If the notifier call chain should be failed with some events notified, write the error code to "actions/<notifier event>/error".
Example1: inject CPU offline error (-1 == -EPERM)
# cd /sys/kernel/debug/notifier-error-inject/cpu # echo -1 > actions/CPU_DOWN_PREPARE/error # echo 0 > /sys/devices/system/cpu/cpu1/online bash: echo: write error: Operation not permitted
Example2: inject CPU online error (-2 == -ENOENT)
# cd /sys/kernel/debug/notifier-error-inject/cpu # echo -2 > actions/CPU_UP_PREPARE/error # echo 1 > /sys/devices/system/cpu/cpu1/online bash: echo: write error: No such file or directory
---
No changes since v4
lib/Kconfig.debug | 16 ++++++++-- lib/cpu-notifier-error-inject.c | 63 ++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 40 deletions(-)
lib/Kconfig.debug +14 -2
@@ -1097,10 +1097,22 @@ config NOTIFIER_ERROR_INJECTION config CPU_NOTIFIER_ERROR_INJECT tristate "CPU notifier error injection module" - depends on HOTPLUG_CPU && DEBUG_KERNEL + depends on HOTPLUG_CPU && NOTIFIER_ERROR_INJECTION help This option provides a kernel module that can be used to test - the error handling of the cpu notifiers + the error handling of the cpu notifiers by injecting artifical + errors to CPU notifier chain callbacks. It is controlled through + debugfs interface under /sys/kernel/debug/notifier-error-inject/cpu + + If the notifier call chain should be failed with some events + notified, write the error code to "actions/<notifier event>/error". + + Example: Inject CPU offline error (-1 == -EPERM) + + # cd /sys/kernel/debug/notifier-error-inject/cpu + # echo -1 > actions/CPU_DOWN_PREPARE/error + # echo 0 > /sys/devices/system/cpu/cpu1/online + bash: echo: write error: Operation not permitted To compile this code as a module, choose M here: the module will be called cpu-notifier-error-inject.
lib/cpu-notifier-error-inject.c +25 -38
83 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH 5/6 powerpc: pSeries reconfig notifier error injection module
In reply to Akinobu MitaThis provides the ability to inject artifical errors to pSeries reconfig notifier chain callbacks. It is controlled through debugfs interface under /sys/kernel/debug/notifier-error-inject/pSeries-reconfig
If the notifier call chain should be failed with some events notified, write the error code to "actions/<notifier event>/error".
---
No changes since v4
lib/Kconfig.debug | 17 +++++++++ lib/Makefile | 2 + lib/pSeries-reconfig-notifier-error-inject.c | 51 ++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 lib/pSeries-reconfig-notifier-error-inject.c
lib/Kconfig.debug +17 -0
@@ -1166,6 +1166,23 @@ config MEMORY_NOTIFIER_ERROR_INJECT If unsure, say N. +config PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT + tristate "pSeries reconfig notifier error injection module" + depends on PPC_PSERIES && NOTIFIER_ERROR_INJECTION + help + This option provides the ability to inject artifical errors to + pSeries reconfig notifier chain callbacks. It is controlled + through debugfs interface under + /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/ + + If the notifier call chain should be failed with some events + notified, write the error code to "actions/<notifier event>/error". + + To compile this code as a module, choose M here: the module will + be called memory-notifier-error-inject. + + If unsure, say N. + config FAULT_INJECTION bool "Fault-injection framework" depends on DEBUG_KERNEL
lib/Makefile +2 -0
@@ -94,6 +94,8 @@ obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o +obj-$(CONFIG_PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT) += \ + pSeries-reconfig-notifier-error-inject.o lib-$(CONFIG_GENERIC_BUG) += bug.o
lib/pSeries-reconfig-notifier-error-inject.c new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Andrew Morton
maintainerQuoted 3 lines · On Sat, 30 Jun 2012 14:59:24 +0900 Akinobu Mita <[email protected]> wrote:
This provides kernel modules that can be used to test the error handling of notifier call chain failures by injecting artifical errors to the following notifier chain callbacks.
No updates to Documentation/fault-injection/?
2012/7/4 Andrew Morton <[email protected]>:
Quoted 8 lines
Quoted 3 lines · On Sat, 30 Jun 2012 14:59:24 +0900 Akinobu Mita <[email protected]> wrote:
This provides kernel modules that can be used to test the error handling of notifier call chain failures by injecting artifical errors to the following notifier chain callbacks.
No updates to
Documentation/fault-injection/?
Thanks for the remainder.
I'll prepare to add a document to it.