Skip to content

Commit d6dd50e

Browse files
committed
Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull RCU updates from Ingo Molnar: "The main changes in this cycle were: - changes related to No-CBs CPUs and NO_HZ_FULL - RCU-tasks implementation - torture-test updates - miscellaneous fixes - locktorture updates - RCU documentation updates" * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (81 commits) workqueue: Use cond_resched_rcu_qs macro workqueue: Add quiescent state between work items locktorture: Cleanup header usage locktorture: Cannot hold read and write lock locktorture: Fix __acquire annotation for spinlock irq locktorture: Support rwlocks rcu: Eliminate deadlock between CPU hotplug and expedited grace periods locktorture: Document boot/module parameters rcutorture: Rename rcutorture_runnable parameter locktorture: Add test scenario for rwsem_lock locktorture: Add test scenario for mutex_lock locktorture: Make torture scripting account for new _runnable name locktorture: Introduce torture context locktorture: Support rwsems locktorture: Add infrastructure for torturing read locks torture: Address race in module cleanup locktorture: Make statistics generic locktorture: Teach about lock debugging locktorture: Support mutexes locktorture: Add documentation ...
2 parents 5ff0b9e + fd19bda commit d6dd50e

63 files changed

Lines changed: 1936 additions & 547 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/RCU/stallwarn.txt‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,20 @@ RCU_STALL_RAT_DELAY
5656
two jiffies. (This is a cpp macro, not a kernel configuration
5757
parameter.)
5858

59-
When a CPU detects that it is stalling, it will print a message similar
60-
to the following:
59+
rcupdate.rcu_task_stall_timeout
60+
61+
This boot/sysfs parameter controls the RCU-tasks stall warning
62+
interval. A value of zero or less suppresses RCU-tasks stall
63+
warnings. A positive value sets the stall-warning interval
64+
in jiffies. An RCU-tasks stall warning starts wtih the line:
65+
66+
INFO: rcu_tasks detected stalls on tasks:
67+
68+
And continues with the output of sched_show_task() for each
69+
task stalling the current RCU-tasks grace period.
70+
71+
For non-RCU-tasks flavors of RCU, when a CPU detects that it is stalling,
72+
it will print a message similar to the following:
6173

6274
INFO: rcu_sched_state detected stall on CPU 5 (t=2500 jiffies)
6375

@@ -174,8 +186,12 @@ o A CPU looping with preemption disabled. This condition can
174186
o A CPU looping with bottom halves disabled. This condition can
175187
result in RCU-sched and RCU-bh stalls.
176188

177-
o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the kernel
178-
without invoking schedule().
189+
o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the
190+
kernel without invoking schedule(). Note that cond_resched()
191+
does not necessarily prevent RCU CPU stall warnings. Therefore,
192+
if the looping in the kernel is really expected and desirable
193+
behavior, you might need to replace some of the cond_resched()
194+
calls with calls to cond_resched_rcu_qs().
179195

180196
o A CPU-bound real-time task in a CONFIG_PREEMPT kernel, which might
181197
happen to preempt a low-priority task in the middle of an RCU
@@ -208,11 +224,10 @@ o A hardware failure. This is quite unlikely, but has occurred
208224
This resulted in a series of RCU CPU stall warnings, eventually
209225
leading the realization that the CPU had failed.
210226

211-
The RCU, RCU-sched, and RCU-bh implementations have CPU stall warning.
212-
SRCU does not have its own CPU stall warnings, but its calls to
213-
synchronize_sched() will result in RCU-sched detecting RCU-sched-related
214-
CPU stalls. Please note that RCU only detects CPU stalls when there is
215-
a grace period in progress. No grace period, no CPU stall warnings.
227+
The RCU, RCU-sched, RCU-bh, and RCU-tasks implementations have CPU stall
228+
warning. Note that SRCU does -not- have CPU stall warnings. Please note
229+
that RCU only detects CPU stalls when there is a grace period in progress.
230+
No grace period, no CPU stall warnings.
216231

217232
To diagnose the cause of the stall, inspect the stack traces.
218233
The offending function will usually be near the top of the stack.

‎Documentation/kernel-parameters.txt‎

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,49 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
17231723
lockd.nlm_udpport=M [NFS] Assign UDP port.
17241724
Format: <integer>
17251725

1726+
locktorture.nreaders_stress= [KNL]
1727+
Set the number of locking read-acquisition kthreads.
1728+
Defaults to being automatically set based on the
1729+
number of online CPUs.
1730+
1731+
locktorture.nwriters_stress= [KNL]
1732+
Set the number of locking write-acquisition kthreads.
1733+
1734+
locktorture.onoff_holdoff= [KNL]
1735+
Set time (s) after boot for CPU-hotplug testing.
1736+
1737+
locktorture.onoff_interval= [KNL]
1738+
Set time (s) between CPU-hotplug operations, or
1739+
zero to disable CPU-hotplug testing.
1740+
1741+
locktorture.shuffle_interval= [KNL]
1742+
Set task-shuffle interval (jiffies). Shuffling
1743+
tasks allows some CPUs to go into dyntick-idle
1744+
mode during the locktorture test.
1745+
1746+
locktorture.shutdown_secs= [KNL]
1747+
Set time (s) after boot system shutdown. This
1748+
is useful for hands-off automated testing.
1749+
1750+
locktorture.stat_interval= [KNL]
1751+
Time (s) between statistics printk()s.
1752+
1753+
locktorture.stutter= [KNL]
1754+
Time (s) to stutter testing, for example,
1755+
specifying five seconds causes the test to run for
1756+
five seconds, wait for five seconds, and so on.
1757+
This tests the locking primitive's ability to
1758+
transition abruptly to and from idle.
1759+
1760+
locktorture.torture_runnable= [BOOT]
1761+
Start locktorture running at boot time.
1762+
1763+
locktorture.torture_type= [KNL]
1764+
Specify the locking implementation to test.
1765+
1766+
locktorture.verbose= [KNL]
1767+
Enable additional printk() statements.
1768+
17261769
logibm.irq= [HW,MOUSE] Logitech Bus Mouse Driver
17271770
Format: <irq>
17281771

@@ -2900,6 +2943,24 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
29002943
Lazy RCU callbacks are those which RCU can
29012944
prove do nothing more than free memory.
29022945

2946+
rcutorture.cbflood_inter_holdoff= [KNL]
2947+
Set holdoff time (jiffies) between successive
2948+
callback-flood tests.
2949+
2950+
rcutorture.cbflood_intra_holdoff= [KNL]
2951+
Set holdoff time (jiffies) between successive
2952+
bursts of callbacks within a given callback-flood
2953+
test.
2954+
2955+
rcutorture.cbflood_n_burst= [KNL]
2956+
Set the number of bursts making up a given
2957+
callback-flood test. Set this to zero to
2958+
disable callback-flood testing.
2959+
2960+
rcutorture.cbflood_n_per_burst= [KNL]
2961+
Set the number of callbacks to be registered
2962+
in a given burst of a callback-flood test.
2963+
29032964
rcutorture.fqs_duration= [KNL]
29042965
Set duration of force_quiescent_state bursts.
29052966

@@ -2939,7 +3000,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
29393000
Set time (s) between CPU-hotplug operations, or
29403001
zero to disable CPU-hotplug testing.
29413002

2942-
rcutorture.rcutorture_runnable= [BOOT]
3003+
rcutorture.torture_runnable= [BOOT]
29433004
Start rcutorture running at boot time.
29443005

29453006
rcutorture.shuffle_interval= [KNL]
@@ -3001,6 +3062,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
30013062
rcupdate.rcu_cpu_stall_timeout= [KNL]
30023063
Set timeout for RCU CPU stall warning messages.
30033064

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

0 commit comments

Comments
 (0)