Documentation/fault-injection/notifier-error-inject.txt

内核通知错误注入
本文介绍了一种在Linux内核中实现的人工错误注入技术,主要用于测试不同类型的系统通知链在遇到错误时的行为。该技术涵盖了CPU、电源管理、内存热插拔及PowerPC平台的重新配置等场景。
如果想评论或更新本文的内容,请直接联系原文档的维护者。


如果你使用英文交流有困难的话,也可以向中文版维护者求助。


如果本翻译更新不及时或者翻译存在问题,请联系中文版维护者。


中文版维护者: 陶莹莉  tyl18768122426@163.com


中文版翻译者:  陶莹莉  tyl18768122426@163.com


中文版校译者:  陶莹莉  tyl18768122426@163.com
Notifier error injection
========================
通知错误注入
========================
Notifier error injection provides the ability to inject artificial errors to
specified notifier chain callbacks. It is useful to test the error handling of
notifier call chain failures which is rarely executed.  There are kernel
modules that can be used to test the following notifiers.


 * CPU notifier
 * PM notifier
 * Memory hotplug notifier
 * powerpc pSeries reconfig notifier


 通知错误注入使能够向指定的通知链回调函数注射人工错误。测试很少执行的通知调用链的故障
 的错误处理是非常有用的。有内核模块可用于测试以下通知。


 * CPU通知
 * PM通知
 *内存热插拔通知
 *PowerPC调和级数重新配置的通知


CPU notifier error injection module
-----------------------------------


CPU通知错误注入模块
-----------------------------------


This feature can be used to test the error handling of the CPU notifiers by
injecting artificial errors to CPU notifier chain callbacks.


If the notifier call chain should be failed with some events notified, write
the error code to debugfs interface
/sys/kernel/debug/notifier-error-inject/cpu/actions/<notifier event>/error


此功能可以用来测试CPU通知的错误处理通过向CPU通知链回调函数注入人工错误。


如果通知调用链对于一些事件通知应该失败,写如下的错误代码的调试接口
/sys/kernel/debug/notifier-error-inject/cpu/actions/<notifier event>/error


Possible CPU notifier events to be failed are:


 * CPU_UP_PREPARE
 * CPU_UP_PREPARE_FROZEN
 * CPU_DOWN_PREPARE
 * CPU_DOWN_PREPARE_FROZEN


 CPU通知可能要失败的事件是:


 * CPU_UP_PREPARE
 * CPU_UP_PREPARE_FROZEN
 * CPU_DOWN_PREPARE
 * CPU_DOWN_PREPARE_FROZEN


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)


# echo -2 > actions/CPU_UP_PREPARE/error
# echo 1 > /sys/devices/system/cpu/cpu1/online
bash: echo: write error: No such file or directory


例1: 脱机注入CPU错误 (-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的回音:写错误:操作不允许


例2: 网上注入CPU错误 (-2 == -ENOENT)


# echo -2 > actions/CPU_UP_PREPARE/error
# echo 1 > /sys/devices/system/cpu/cpu1/online
bash: echo: write error: No such file or directory
bash的回音:写错误:没有这样的文件或目录

PM notifier error injection module
----------------------------------
项目管理通知错误注入模块
----------------------------------
This feature is controlled through debugfs interface
/sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error


此功能是通过内核调试接口控制的
/sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error


Possible PM notifier events to be failed are:


 * PM_HIBERNATION_PREPARE
 * PM_SUSPEND_PREPARE
 * PM_RESTORE_PREPARE


 项目管理通知事件可能要失败是:


 * PM_HIBERNATION_PREPARE
 * PM_SUSPEND_PREPARE
 * PM_RESTORE_PREPARE


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


例: 注射项目管理延迟错误 (-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
bash的回音:写入错误:无法分配内存

Memory hotplug notifier error injection module
----------------------------------------------
内存热插拔通知错误注入模块
----------------------------------------------


This feature is controlled through debugfs interface
/sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error


此功能是通过内核调试接口控制的
/sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error


Possible memory notifier events to be failed are:


 * MEM_GOING_ONLINE
 * MEM_GOING_OFFLINE


 内存通知事件可能要失败的是:


 * MEM_GOING_ONLINE
 * MEM_GOING_OFFLINE


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


例: 脱机注入内存热插拔的错误 (-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的回音:写入错误:无法分配内存

powerpc pSeries reconfig notifier error injection module
--------------------------------------------------------
POWERPC的调和级数重新配置的通知错误注入模块
--------------------------------------------------------
This feature is controlled through debugfs interface
/sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error


此功能是通过内核调试接口控制的
/sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error


Possible pSeries reconfig notifier events to be failed are:


 * PSERIES_RECONFIG_ADD
 * PSERIES_RECONFIG_REMOVE
 * PSERIES_DRCONF_MEM_ADD
 * PSERIES_DRCONF_MEM_REMOVE


 可能的pSeries重新配置通知事件要失败的是:


 * PSERIES_RECONFIG_ADD
 * PSERIES_RECONFIG_REMOVE
 * PSERIES_DRCONF_MEM_ADD
 * PSERIES_DRCONF_MEM_REMOVE


For more usage examples
-----------------------
对于更多的用法示例
-----------------------


There are tools/testing/selftests using the notifier error injection features
for CPU and memory notifiers.


 * tools/testing/selftests/cpu-hotplug/on-off-test.sh
 * tools/testing/selftests/memory-hotplug/on-off-test.sh


 tools/testing/selftests 用通知错误注入功能为CPU和内存发出通知。


 * tools/testing/selftests/cpu-hotplug/on-off-test.sh
 * tools/testing/selftests/memory-hotplug/on-off-test.sh


These scripts first do simple online and offline tests and then do fault
injection tests if notifier error injection module is available.


这些脚本首先做简单的在线和离线测试,然后做故障注入测试,如果通知错误注入模块是可以的。ection module is available.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值