• Home
  • Raw
  • Download

Lines Matching +full:fault +full:- +full:inject

2 Fault injection capabilities infrastructure
5 See also drivers/md/md-faulty.c and "every_nth" module option for scsi_debug.
8 Available fault injection capabilities
9 --------------------------------------
11 - failslab
15 - fail_page_alloc
19 - fail_usercopy
23 - fail_futex
25 injects futex deadlock and uaddr fault errors.
27 - fail_make_request
30 /sys/block/<device>/make-it-fail or
31 /sys/block/<device>/<partition>/make-it-fail. (submit_bio_noacct())
33 - fail_mmc_request
38 - fail_function
44 - NVMe fault injection
46 inject NVMe status code and retry flag on devices permitted by setting
52 Configure fault-injection capabilities behavior
53 -----------------------------------------------
58 fault-inject-debugfs kernel module provides some debugfs entries for runtime
59 configuration of fault-injection capabilities.
61 - /sys/kernel/debug/fail*/probability:
67 Note that one-failure-per-hundred is a very high error rate
71 - /sys/kernel/debug/fail*/interval:
79 - /sys/kernel/debug/fail*/times:
81 specifies how many times failures may happen at most. A value of -1
84 - /sys/kernel/debug/fail*/space:
90 - /sys/kernel/debug/fail*/verbose
96 log line per failure; '2' will print a call trace too -- useful
97 to debug the problems revealed by fault injection.
99 - /sys/kernel/debug/fail*/task-filter:
105 /proc/<pid>/make-it-fail==1.
107 - /sys/kernel/debug/fail*/require-start,
108 /sys/kernel/debug/fail*/require-end,
109 /sys/kernel/debug/fail*/reject-start,
110 /sys/kernel/debug/fail*/reject-end:
119 - /sys/kernel/debug/fail*/stacktrace-depth:
122 for a caller within [require-start,require-end) OR
123 [reject-start,reject-end).
125 - /sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem:
129 default is 'N', setting it to 'Y' won't inject failures into
132 - /sys/kernel/debug/failslab/ignore-gfp-wait:
133 - /sys/kernel/debug/fail_page_alloc/ignore-gfp-wait:
137 default is 'N', setting it to 'Y' will inject failures
138 only into non-sleep allocations (GFP_ATOMIC allocations).
140 - /sys/kernel/debug/fail_page_alloc/min-order:
145 - /sys/kernel/debug/fail_futex/ignore-private:
152 - /sys/kernel/debug/fail_function/inject:
154 Format: { 'function-name' | '!function-name' | '' }
161 - /sys/kernel/debug/fail_function/injectable:
166 - NULL: retval must be 0.
167 - ERRNO: retval must be -1 to -MAX_ERRNO (-4096).
168 - ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096).
170 - /sys/kernel/debug/fail_function/<function-name>/retval:
172 specifies the "error" return value to inject to the given function.
176 $ printf %#x -12 > retval
181 In order to inject faults while debugfs is not available (early boot time),
194 - /proc/<pid>/fail-nth,
195 /proc/self/task/<tid>/fail-nth:
197 Write to this file of integer N makes N-th call in the task fail.
199 that the fault setup with a previous write to this file was injected.
200 A positive integer N indicates that the fault wasn't yet injected.
203 like probability, interval, times, etc. But per-capability settings
204 (e.g. fail_futex/ignore-private) take precedence over it.
209 How to add new fault injection capability
210 -----------------------------------------
212 - #include <linux/fault-inject.h>
214 - define the fault attributes
218 Please see the definition of struct fault_attr in fault-inject.h
221 - provide a way to configure fault attributes
223 - boot option
225 If you need to enable the fault injection capability from boot time, you can
230 - debugfs entries
237 - module parameters
239 If the scope of the fault injection capability is limited to a
241 configure the fault attributes.
243 - add a hook to insert failures
245 Upon should_fail() returning true, client code should inject a failure:
250 --------------------
252 - Inject slab allocation failures into module init/exit code::
257 echo Y > /sys/kernel/debug/$FAILTYPE/task-filter
260 echo -1 > /sys/kernel/debug/$FAILTYPE/times
263 echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
267 bash -c "echo 1 > /proc/self/make-it-fail && exec $*"
270 if [ $# -eq 0 ]
282 faulty_system modprobe -r $m
285 ------------------------------------------------------------------------------
287 - Inject page allocation failures only for a specific module::
294 if [ -z $module ]
302 if [ ! -d /sys/module/$module/sections ]
308 cat /sys/module/$module/sections/.text > /sys/kernel/debug/$FAILTYPE/require-start
309 cat /sys/module/$module/sections/.data > /sys/kernel/debug/$FAILTYPE/require-end
311 echo N > /sys/kernel/debug/$FAILTYPE/task-filter
314 echo -1 > /sys/kernel/debug/$FAILTYPE/times
317 echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
318 echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-highmem
319 echo 10 > /sys/kernel/debug/$FAILTYPE/stacktrace-depth
326 ------------------------------------------------------------------------------
328 - Inject open_ctree error while btrfs mount::
332 rm -f testfile.img
334 DEVICE=$(losetup --show -f testfile.img)
335 mkfs.btrfs -f $DEVICE
336 mkdir -p tmpmnt
340 echo $FAILFUNC > /sys/kernel/debug/$FAILTYPE/inject
341 printf %#x -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval
342 echo N > /sys/kernel/debug/$FAILTYPE/task-filter
345 echo -1 > /sys/kernel/debug/$FAILTYPE/times
349 mount -t btrfs $DEVICE tmpmnt
350 if [ $? -ne 0 ]
358 echo > /sys/kernel/debug/$FAILTYPE/inject
361 losetup -d $DEVICE
366 ----------------------------------------------------
368 tools/testing/fault-injection/failcmd.sh. Please run a command
369 "./tools/testing/fault-injection/failcmd.sh --help" for more information and
374 Run a command "make -C tools/testing/selftests/ run_tests" with injecting slab
377 # ./tools/testing/fault-injection/failcmd.sh \
378 -- make -C tools/testing/selftests/ run_tests
383 # ./tools/testing/fault-injection/failcmd.sh --times=100 \
384 -- make -C tools/testing/selftests/ run_tests
386 Same as above except to inject page allocation failure instead of slab
390 ./tools/testing/fault-injection/failcmd.sh --times=100 \
391 -- make -C tools/testing/selftests/ run_tests
393 Systematic faults using fail-nth
394 ---------------------------------
396 The following code systematically faults 0-th, 1-st, 2-nd and so on
415 system("echo N > /sys/kernel/debug/failslab/ignore-gfp-wait");
416 sprintf(buf, "/proc/self/task/%ld/fail-nth", syscall(SYS_gettid));
428 printf("%d-th fault %c: res=%d/%d\n", i, atoi(buf) ? 'N' : 'Y',
438 1-th fault Y: res=-1/23
439 2-th fault Y: res=-1/23
440 3-th fault Y: res=-1/12
441 4-th fault Y: res=-1/12
442 5-th fault Y: res=-1/23
443 6-th fault Y: res=-1/23
444 7-th fault Y: res=-1/23
445 8-th fault Y: res=-1/12
446 9-th fault Y: res=-1/12
447 10-th fault Y: res=-1/12
448 11-th fault Y: res=-1/12
449 12-th fault Y: res=-1/12
450 13-th fault Y: res=-1/12
451 14-th fault Y: res=-1/12
452 15-th fault Y: res=-1/12
453 16-th fault N: res=0/12