Documentation/fault-injection/notifier-error-inject.rst GitHub 원문 ↗

Linux 6.18.37 · Fault Injection

Notifier error injection

PM·memory hotplug·pSeries·netdevice notifier callback 오류를 debugfs로 주입하는 방법의 한국어 전문 번역입니다.

Source pathDocumentation/fault-injection/notifier-error-inject.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

notifier-error-inject.rst:1-98

Notifier error injection은 PM, memory hotplug, pSeries reconfiguration, netdevice callback이 지정한 errno를 반환하게 만들어 드문 chain-failure 복구 경로를 시험합니다.

Notifier 오류 시험
Choose notifier chainSet event error in debugfsRun the real transitionVerify caller receives errnoClear injected error

정상 전환과 강제 거부를 비교합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Notifier callback 오류 주입 범위

1-13

Notifier error injection은 지정한 notifier chain callback이 인위적인 오류를 반환하도록 합니다. 정상 운영에서는 거의 실행되지 않는 notifier call-chain failure의 오류 처리 경로를 시험할 때 유용합니다.

제공되는 kernel module은 PM notifier, memory hotplug notifier, powerpc pSeries reconfiguration notifier, netdevice notifier를 대상으로 합니다.

지원 notifier chain
Notifier대표 시험
PMSuspend·hibernation·restore 준비 실패
Memory hotplugMemory online·offline 준비 실패
pSeries reconfigDevice·DRCONF memory add/remove 실패
Netdevice등록·MTU·이름·상위 장치 변경 실패

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.

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

PM notifier 오류 주입

14-32

PM notifier는 `/sys/kernel/debug/notifier-error-inject/pm/actions/<notifier event>/error`에서 제어합니다.

실패시킬 수 있는 event는 `PM_HIBERNATION_PREPARE`, `PM_SUSPEND_PREPARE`, `PM_RESTORE_PREPARE`입니다.

예제는 `PM_SUSPEND_PREPARE/error`에 `-12`(`-ENOMEM`)를 쓰고 `/sys/power/state`에 `mem`을 요청합니다. Suspend 준비 callback이 강제로 실패하므로 shell은 `Cannot allocate memory` write error를 받습니다.

PM suspend 실패 시험
Open PM notifier debugfs directoryWrite -ENOMEM to `PM_SUSPEND_PREPARE/error`Request `mem` sleep stateVerify suspend aborts with allocation error

준비 notifier의 반환값을 설정한 뒤 실제 power-state 전환을 요청합니다.

PM notifier error injection module
----------------------------------
This feature is controlled through debugfs interface

  /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

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

Memory hotplug notifier 오류 주입

33-50

Memory hotplug notifier는 `/sys/kernel/debug/notifier-error-inject/memory/actions/<notifier event>/error`에서 제어하며 `MEM_GOING_ONLINE`과 `MEM_GOING_OFFLINE` event를 실패시킬 수 있습니다.

예제는 `MEM_GOING_OFFLINE/error`에 `-12`를 쓰고 `/sys/devices/system/memory/memoryXXX/state`에 `offline`을 요청합니다. Callback이 `-ENOMEM`을 반환하므로 memory block의 offline 전환이 거부됩니다.

Memory hotplug event
Event시험하는 전환
`MEM_GOING_ONLINE`Memory block online 준비
`MEM_GOING_OFFLINE`Memory block offline 준비

Memory hotplug notifier error injection module
----------------------------------------------
This feature is controlled through debugfs interface

  /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

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

PowerPC pSeries 재구성 notifier

51-63

pSeries reconfiguration notifier는 `/sys/kernel/debug/notifier-error-inject/pSeries-reconfig/actions/<notifier event>/error`에서 제어합니다.

`PSERIES_RECONFIG_ADD`·`PSERIES_RECONFIG_REMOVE`은 pSeries 구성 개체 추가·제거를, `PSERIES_DRCONF_MEM_ADD`·`PSERIES_DRCONF_MEM_REMOVE`은 dynamic reconfiguration memory 추가·제거를 시험합니다.

pSeries reconfig event
Event동작
`PSERIES_RECONFIG_ADD`구성 개체 추가
`PSERIES_RECONFIG_REMOVE`구성 개체 제거
`PSERIES_DRCONF_MEM_ADD`DRCONF memory 추가
`PSERIES_DRCONF_MEM_REMOVE`DRCONF memory 제거

powerpc pSeries reconfig notifier error injection module
--------------------------------------------------------
This feature is controlled through debugfs interface

  /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

Netdevice notifier 오류 주입

64-88

Netdevice notifier는 `/sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error`에서 제어합니다.

실패 가능한 event는 `NETDEV_REGISTER`, `NETDEV_CHANGEMTU`, `NETDEV_CHANGENAME`, `NETDEV_PRE_UP`, `NETDEV_PRE_TYPE_CHANGE`, `NETDEV_POST_INIT`, `NETDEV_PRECHANGEMTU`, `NETDEV_PRECHANGEUPPER`, `NETDEV_CHANGEUPPER`입니다.

예제는 `NETDEV_CHANGEMTU/error`에 `-22`(`-EINVAL`)를 쓰고 `ip link set eth0 mtu 1024`를 실행합니다. Notifier가 요청을 거부하므로 rtnetlink는 `Invalid argument`를 반환합니다.

Netdevice fault 범주
범주Event
Lifecycle`REGISTER`, `POST_INIT`, `PRE_UP`
속성 변경`CHANGEMTU`, `PRECHANGEMTU`, `CHANGENAME`, `PRE_TYPE_CHANGE`
상위 장치 관계`PRECHANGEUPPER`, `CHANGEUPPER`

Netdevice notifier error injection module
----------------------------------------------
This feature is controlled through debugfs interface

  /sys/kernel/debug/notifier-error-inject/netdev/actions/<notifier event>/error

Netdevice notifier events which can be failed are:

 * NETDEV_REGISTER
 * NETDEV_CHANGEMTU
 * NETDEV_CHANGENAME
 * NETDEV_PRE_UP
 * NETDEV_PRE_TYPE_CHANGE
 * NETDEV_POST_INIT
 * NETDEV_PRECHANGEMTU
 * NETDEV_PRECHANGEUPPER
 * NETDEV_CHANGEUPPER

Example: Inject netdevice mtu change error (-22 == -EINVAL)::

        # cd /sys/kernel/debug/notifier-error-inject/netdev
        # echo -22 > actions/NETDEV_CHANGEMTU/error
        # ip link set eth0 mtu 1024
        RTNETLINK answers: Invalid argument

CPU·memory hotplug selftest

89-98

`tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh`와 `tools/testing/selftests/memory-hotplug/mem-on-off-test.sh`는 notifier error injection을 사용하는 추가 예제입니다.

두 script는 먼저 단순 online·offline 동작을 검증하고, notifier error injection module을 사용할 수 있으면 이어서 fault injection test를 실행합니다.

Hotplug selftest 단계
Run simple online testRun simple offline testDetect notifier error-injection moduleInject callback failureVerify hotplug operation handles rejection

정상 경로를 먼저 확인한 뒤 오류 callback 경로를 시험합니다.

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/cpu-on-off-test.sh
 * tools/testing/selftests/memory-hotplug/mem-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.