torture: Address race in module cleanup
[deliverable/linux.git] / Documentation / locking / locktorture.txt
CommitLineData
cdf26bb1
DB
1Kernel Lock Torture Test Operation
2
3CONFIG_LOCK_TORTURE_TEST
4
5The CONFIG LOCK_TORTURE_TEST config option provides a kernel module
6that runs torture tests on core kernel locking primitives. The kernel
7module, 'locktorture', may be built after the fact on the running
8kernel to be tested, if desired. The tests periodically output status
9messages via printk(), which can be examined via the dmesg (perhaps
10grepping for "torture"). The test is started when the module is loaded,
11and stops when the module is unloaded. This program is based on how RCU
12is tortured, via rcutorture.
13
14This torture test consists of creating a number of kernel threads which
15acquire the lock and hold it for specific amount of time, thus simulating
16different critical region behaviors. The amount of contention on the lock
17can be simulated by either enlarging this critical region hold time and/or
18creating more kthreads.
19
20
21MODULE PARAMETERS
22
23This module has the following parameters:
24
25
26 ** Locktorture-specific **
27
28nwriters_stress Number of kernel threads that will stress exclusive lock
29 ownership (writers). The default value is twice the number
30 of online CPUs.
31
32torture_type Type of lock to torture. By default, only spinlocks will
33 be tortured. This module can torture the following locks,
34 with string values as follows:
35
36 o "lock_busted": Simulates a buggy lock implementation.
37
38 o "spin_lock": spin_lock() and spin_unlock() pairs.
39
40 o "spin_lock_irq": spin_lock_irq() and spin_unlock_irq()
41 pairs.
42
42ddc75d
DB
43 o "mutex_lock": mutex_lock() and mutex_unlock() pairs.
44
cdf26bb1
DB
45torture_runnable Start locktorture at boot time in the case where the
46 module is built into the kernel, otherwise wait for
47 torture_runnable to be set via sysfs before starting.
48 By default it will begin once the module is loaded.
49
50
51 ** Torture-framework (RCU + locking) **
52
53shutdown_secs The number of seconds to run the test before terminating
54 the test and powering off the system. The default is
55 zero, which disables test termination and system shutdown.
56 This capability is useful for automated testing.
57
58onoff_interval The number of seconds between each attempt to execute a
59 randomly selected CPU-hotplug operation. Defaults
60 to zero, which disables CPU hotplugging. In
61 CONFIG_HOTPLUG_CPU=n kernels, locktorture will silently
62 refuse to do any CPU-hotplug operations regardless of
63 what value is specified for onoff_interval.
64
65onoff_holdoff The number of seconds to wait until starting CPU-hotplug
66 operations. This would normally only be used when
67 locktorture was built into the kernel and started
68 automatically at boot time, in which case it is useful
69 in order to avoid confusing boot-time code with CPUs
70 coming and going. This parameter is only useful if
71 CONFIG_HOTPLUG_CPU is enabled.
72
73stat_interval Number of seconds between statistics-related printk()s.
74 By default, locktorture will report stats every 60 seconds.
75 Setting the interval to zero causes the statistics to
76 be printed -only- when the module is unloaded, and this
77 is the default.
78
79stutter The length of time to run the test before pausing for this
80 same period of time. Defaults to "stutter=5", so as
81 to run and pause for (roughly) five-second intervals.
82 Specifying "stutter=0" causes the test to run continuously
83 without pausing, which is the old default behavior.
84
85shuffle_interval The number of seconds to keep the test threads affinitied
86 to a particular subset of the CPUs, defaults to 3 seconds.
87 Used in conjunction with test_no_idle_hz.
88
89verbose Enable verbose debugging printing, via printk(). Enabled
90 by default. This extra information is mostly related to
91 high-level errors and reports from the main 'torture'
92 framework.
93
94
95STATISTICS
96
97Statistics are printed in the following format:
98
99spin_lock-torture: Writes: Total: 93746064 Max/Min: 0/0 Fail: 0
100 (A) (B) (C) (D)
101
102(A): Lock type that is being tortured -- torture_type parameter.
103
104(B): Number of times the lock was acquired.
105
106(C): Min and max number of times threads failed to acquire the lock.
107
108(D): true/false values if there were errors acquiring the lock. This should
109 -only- be positive if there is a bug in the locking primitive's
110 implementation. Otherwise a lock should never fail (i.e., spin_lock()).
111 Of course, the same applies for (C), above. A dummy example of this is
112 the "lock_busted" type.
113
114USAGE
115
116The following script may be used to torture locks:
117
118 #!/bin/sh
119
120 modprobe locktorture
121 sleep 3600
122 rmmod locktorture
123 dmesg | grep torture:
124
125The output can be manually inspected for the error flag of "!!!".
126One could of course create a more elaborate script that automatically
127checked for such errors. The "rmmod" command forces a "SUCCESS",
128"FAILURE", or "RCU_HOTPLUG" indication to be printk()ed. The first
129two are self-explanatory, while the last indicates that while there
130were no locking failures, CPU-hotplug problems were detected.
131
132Also see: Documentation/RCU/torture.txt
This page took 0.027425 seconds and 5 git commands to generate.