aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/fault-injection
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2007-07-16 02:40:24 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:45 -0400
commit185848707e73382ba930857502a0b80ff6039967 (patch)
tree21a4a84ff46b1af4b0a139b3da94c705b6826b89 /Documentation/fault-injection
parent54114994f4de7e8076fc250e44501e55e19b75b5 (diff)
fault-injection: fix example scripts in documentation
Fix and cleanup example scripts in fault injection documentation. 1. Eliminate broken oops() shell function. 2. Fold failcmd.sh and failmodule.sh into example scripts. It makes the example scripts work independent of current working directory. 3. Set "space" parameter to 0 to start injecting errors immediately. 4. Use /sys/module/<modulename>/sections/.data as upper bound of .text section. Because some module doesn't have .exit.text section. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/fault-injection')
-rw-r--r--Documentation/fault-injection/failcmd.sh4
-rw-r--r--Documentation/fault-injection/failmodule.sh31
-rw-r--r--Documentation/fault-injection/fault-injection.txt105
3 files changed, 56 insertions, 84 deletions
diff --git a/Documentation/fault-injection/failcmd.sh b/Documentation/fault-injection/failcmd.sh
deleted file mode 100644
index 63177aba8106..000000000000
--- a/Documentation/fault-injection/failcmd.sh
+++ /dev/null
@@ -1,4 +0,0 @@
1#!/bin/bash
2
3echo 1 > /proc/self/make-it-fail
4exec $*
diff --git a/Documentation/fault-injection/failmodule.sh b/Documentation/fault-injection/failmodule.sh
deleted file mode 100644
index 474a8b971f9c..000000000000
--- a/Documentation/fault-injection/failmodule.sh
+++ /dev/null
@@ -1,31 +0,0 @@
1#!/bin/bash
2#
3# Usage: failmodule <failname> <modulename> [stacktrace-depth]
4#
5# <failname>: "failslab", "fail_alloc_page", or "fail_make_request"
6#
7# <modulename>: module name that you want to inject faults.
8#
9# [stacktrace-depth]: the maximum number of stacktrace walking allowed
10#
11
12STACKTRACE_DEPTH=5
13if [ $# -gt 2 ]; then
14 STACKTRACE_DEPTH=$3
15fi
16
17if [ ! -d /debug/$1 ]; then
18 echo "Fault-injection $1 does not exist" >&2
19 exit 1
20fi
21if [ ! -d /sys/module/$2 ]; then
22 echo "Module $2 does not exist" >&2
23 exit 1
24fi
25
26# Disable any fault injection
27echo 0 > /debug/$1/stacktrace-depth
28
29echo `cat /sys/module/$2/sections/.text` > /debug/$1/require-start
30echo `cat /sys/module/$2/sections/.exit.text` > /debug/$1/require-end
31echo $STACKTRACE_DEPTH > /debug/$1/stacktrace-depth
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt
index 36ece095ff17..4bc374a14345 100644
--- a/Documentation/fault-injection/fault-injection.txt
+++ b/Documentation/fault-injection/fault-injection.txt
@@ -161,70 +161,77 @@ o add a hook to insert failures
161Application Examples 161Application Examples
162-------------------- 162--------------------
163 163
164o inject slab allocation failures into module init/cleanup code 164o Inject slab allocation failures into module init/exit code
165 165
166------------------------------------------------------------------------------
167#!/bin/bash 166#!/bin/bash
168 167
169FAILCMD=Documentation/fault-injection/failcmd.sh 168FAILTYPE=failslab
170BLACKLIST="root_plug evbug" 169echo Y > /debug/$FAILTYPE/task-filter
171 170echo 10 > /debug/$FAILTYPE/probability
172FAILNAME=failslab 171echo 100 > /debug/$FAILTYPE/interval
173echo Y > /debug/$FAILNAME/task-filter 172echo -1 > /debug/$FAILTYPE/times
174echo 10 > /debug/$FAILNAME/probability 173echo 0 > /debug/$FAILTYPE/space
175echo 100 > /debug/$FAILNAME/interval 174echo 2 > /debug/$FAILTYPE/verbose
176echo -1 > /debug/$FAILNAME/times 175echo 1 > /debug/$FAILTYPE/ignore-gfp-wait
177echo 2 > /debug/$FAILNAME/verbose
178echo 1 > /debug/$FAILNAME/ignore-gfp-wait
179 176
180blacklist() 177faulty_system()
181{ 178{
182 echo $BLACKLIST | grep $1 > /dev/null 2>&1 179 bash -c "echo 1 > /proc/self/make-it-fail && exec $*"
183} 180}
184 181
185oops() 182if [ $# -eq 0 ]
186{ 183then
187 dmesg | grep BUG > /dev/null 2>&1 184 echo "Usage: $0 modulename [ modulename ... ]"
188} 185 exit 1
186fi
187
188for m in $*
189do
190 echo inserting $m...
191 faulty_system modprobe $m
189 192
190find /lib/modules/`uname -r` -name '*.ko' -exec basename {} .ko \; | 193 echo removing $m...
191 while read i 194 faulty_system modprobe -r $m
192 do 195done
193 oops && exit 1
194
195 if ! blacklist $i
196 then
197 echo inserting $i...
198 bash $FAILCMD modprobe $i
199 fi
200 done
201
202lsmod | awk '{ if ($3 == 0) { print $1 } }' |
203 while read i
204 do
205 oops && exit 1
206
207 if ! blacklist $i
208 then
209 echo removing $i...
210 bash $FAILCMD modprobe -r $i
211 fi
212 done
213 196
214------------------------------------------------------------------------------ 197------------------------------------------------------------------------------
215 198
216o inject slab allocation failures only for a specific module 199o Inject page allocation failures only for a specific module
217 200
218------------------------------------------------------------------------------
219#!/bin/bash 201#!/bin/bash
220 202
221FAILMOD=Documentation/fault-injection/failmodule.sh 203FAILTYPE=fail_page_alloc
204module=$1
222 205
223echo injecting errors into the module $1... 206if [ -z $module ]
207then
208 echo "Usage: $0 <modulename>"
209 exit 1
210fi
224 211
225modprobe $1 212modprobe $module
226bash $FAILMOD failslab $1 10
227echo 25 > /debug/failslab/probability
228 213
229------------------------------------------------------------------------------ 214if [ ! -d /sys/module/$module/sections ]
215then
216 echo Module $module is not loaded
217 exit 1
218fi
219
220cat /sys/module/$module/sections/.text > /debug/$FAILTYPE/require-start
221cat /sys/module/$module/sections/.data > /debug/$FAILTYPE/require-end
222
223echo N > /debug/$FAILTYPE/task-filter
224echo 10 > /debug/$FAILTYPE/probability
225echo 100 > /debug/$FAILTYPE/interval
226echo -1 > /debug/$FAILTYPE/times
227echo 0 > /debug/$FAILTYPE/space
228echo 2 > /debug/$FAILTYPE/verbose
229echo 1 > /debug/$FAILTYPE/ignore-gfp-wait
230echo 1 > /debug/$FAILTYPE/ignore-gfp-highmem
231echo 10 > /debug/$FAILTYPE/stacktrace-depth
232
233trap "echo 0 > /debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT
234
235echo "Injecting errors into the module $module... (interrupt to stop)"
236sleep 1000000
230 237