summaryrefslogtreecommitdiffstats
path: root/Documentation/RCU/torture.txt
blob: 6714b5361158f01cdb038ef33c4f7f4f9305c66e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
RCU Torture Test Operation


CONFIG_RCU_TORTURE_TEST

The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
implementations.  It creates an rcutorture kernel module that can
be loaded to run a torture test.  The test periodically outputs
status messages via printk(), which can be examined via the dmesg
command (perhaps grepping for "torture").  The test is started
when the module is loaded, and stops when the module is unloaded.

However, actually setting this config option to "y" results in the system
running the test immediately upon boot, and ending only when the system
is taken down.  Normally, one will instead want to build the system
with CONFIG_RCU_TORTURE_TEST=m and to use modprobe and rmmod to control
the test, perhaps using a script similar to the one shown at the end of
this document.  Note that you will need CONFIG_MODULE_UNLOAD in order
to be able to end the test.


MODULE PARAMETERS

This module has the following parameters:

nreaders	This is the number of RCU reading threads supported.
		The default is twice the number of CPUs.  Why twice?
		To properly exercise RCU implementations with preemptible
		read-side critical sections.

nfakewriters	This is the number of RCU fake writer threads to run.  Fake
		writer threads repeatedly use the synchronous "wait for
		current readers" function of the interface selected by
		torture_type, with a delay between calls to allow for various
		different numbers of writers running in parallel.
		nfakewriters defaults to 4, which provides enough parallelism
		to trigger special cases caused by multiple writers, such as
		the synchronize_srcu() early return optimization.

stat_interval	The number of seconds between output of torture
		statistics (via printk()).  Regardless of the interval,
		statistics are printed when the module is unloaded.
		Setting the interval to zero causes the statistics to
		be printed -only- when the module is unloaded, and this
		is the default.

shuffle_interval
		The number of seconds to keep the test threads affinitied
		to a particular subset of the CPUs.  Used in conjunction
		with test_no_idle_hz.

test_no_idle_hz	Whether or not to test the ability of RCU to operate in
		a kernel that disables the scheduling-clock interrupt to
		idle CPUs.  Boolean parameter, "1" to test, "0" otherwise.

torture_type	The type of RCU to test: "rcu" for the rcu_read_lock() API,
		"rcu_sync" for rcu_read_lock() with synchronous reclamation,
		"rcu_bh" for the rcu_read_lock_bh() API, and "srcu" for the
		"srcu_read_lock()" API.

verbose		Enable debug printk()s.  Default is disabled.


OUTPUT

The statistics output is as follows:

	rcu-torture: --- Start of test: nreaders=16 stat_interval=0 verbose=0
	rcu-torture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915
	rcu-torture: Reader Pipe:  1466408 9747 0 0 0 0 0 0 0 0 0
	rcu-torture: Reader Batch:  1464477 11678 0 0 0 0 0 0 0 0
	rcu-torture: Free-Block Circulation:  1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0
	rcu-torture: --- End of test

The command "dmesg | grep torture:" will extract this information on
most systems.  On more esoteric configurations, it may be necessary to
use other commands to access the output of the printk()s used by
the RCU torture test.  The printk()s use KERN_ALERT, so they should
be evident.  ;-)

The entries are as follows:

o	"ggp": The number of counter flips (or batches) since boot.

o	"rtc": The hexadecimal address of the structure currently visible
	to readers.

o	"ver": The number of times since boot that the rcutw writer task
	has changed the structure visible to readers.

o	"tfle": If non-zero, indicates that the "torture freelist"
	containing structure to be placed into the "rtc" area is empty.
	This condition is important, since it can fool you into thinking
	that RCU is working when it is not.  :-/

o	"rta": Number of structures allocated from the torture freelist.

o	"rtaf": Number of allocations from the torture freelist that have
	failed due to the list being empty.

o	"rtf": Number of frees into the torture freelist.

o	"Reader Pipe": Histogram of "ages" of structures seen by readers.
	If any entries past the first two are non-zero, RCU is broken.
	And rcutorture prints the error flag string "!!!" to make sure
	you notice.  The age of a newly allocated structure is zero,
	it becomes one when removed from reader visibility, and is
	incremented once per grace period subsequently -- and is freed
	after passing through (RCU_TORTURE_PIPE_LEN-2) grace periods.

	The output displayed above was taken from a correctly working
	RCU.  If you want to see what it looks like when broken, break
	it yourself.  ;-)

o	"Reader Batch": Another histogram of "ages" of structures seen
	by readers, but in terms of counter flips (or batches) rather
	than in terms of grace periods.  The legal number of non-zero
	entries is again two.  The reason for this separate view is
	that it is easier to get the third entry to show up in the
	"Reader Batch" list than in the "Reader Pipe" list.

o	"Free-Block Circulation": Shows the number of torture structures
	that have reached a given point in the pipeline.  The first element
	should closely correspond to the number of structures allocated,
	the second to the number that have been removed from reader view,
	and all but the last remaining to the corresponding number of
	passes through a grace period.  The last entry should be zero,
	as it is only incremented if a torture structure's counter
	somehow gets incremented farther than it should.

Different implementations of RCU can provide implementation-specific
additional information.  For example, SRCU provides the following:

	srcu-torture: rtc: f8cf46a8 ver: 355 tfle: 0 rta: 356 rtaf: 0 rtf: 346 rtmbe: 0
	srcu-torture: Reader Pipe:  559738 939 0 0 0 0 0 0 0 0 0
	srcu-torture: Reader Batch:  560434 243 0 0 0 0 0 0 0 0
	srcu-torture: Free-Block Circulation:  355 354 353 352 351 350 349 348 347 346 0
	srcu-torture: per-CPU(idx=1): 0(0,1) 1(0,1) 2(0,0) 3(0,1)

The first four lines are similar to those for RCU.  The last line shows
the per-CPU counter state.  The numbers in parentheses are the values
of the "old" and "current" counters for the corresponding CPU.  The
"idx" value maps the "old" and "current" values to the underlying array,
and is useful for debugging.


USAGE

The following script may be used to torture RCU:

	#!/bin/sh

	modprobe rcutorture
	sleep 100
	rmmod rcutorture
	dmesg | grep torture:

The output can be manually inspected for the error flag of "!!!".
One could of course create a more elaborate script that automatically
checked for such errors.  The "rmmod" command forces a "SUCCESS" or
"FAILURE" indication to be printk()ed.
OpenPOWER on IntegriCloud