1 RCU Torture Test Operation
4 CONFIG_RCU_TORTURE_TEST
6 The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
7 implementations. It creates an rcutorture kernel module that can
8 be loaded to run a torture test. The test periodically outputs
9 status messages via printk(), which can be examined via the dmesg
10 command (perhaps grepping for "rcutorture"). The test is started
11 when the module is loaded, and stops when the module is unloaded.
13 However, actually setting this config option to "y" results in the system
14 running the test immediately upon boot, and ending only when the system
15 is taken down. Normally, one will instead want to build the system
16 with CONFIG_RCU_TORTURE_TEST=m and to use modprobe and rmmod to control
17 the test, perhaps using a script similar to the one shown at the end of
18 this document. Note that you will need CONFIG_MODULE_UNLOAD in order
19 to be able to end the test.
24 This module has the following parameters:
26 nreaders This is the number of RCU reading threads supported.
27 The default is twice the number of CPUs. Why twice?
28 To properly exercise RCU implementations with preemptible
29 read-side critical sections.
31 stat_interval The number of seconds between output of torture
32 statistics (via printk()). Regardless of the interval,
33 statistics are printed when the module is unloaded.
34 Setting the interval to zero causes the statistics to
35 be printed -only- when the module is unloaded, and this
39 The number of seconds to keep the test threads affinitied
40 to a particular subset of the CPUs. Used in conjunction
43 test_no_idle_hz Whether or not to test the ability of RCU to operate in
44 a kernel that disables the scheduling-clock interrupt to
45 idle CPUs. Boolean parameter, "1" to test, "0" otherwise.
47 verbose Enable debug printk()s. Default is disabled.
52 The statistics output is as follows:
54 rcutorture: --- Start of test: nreaders=16 stat_interval=0 verbose=0
55 rcutorture: rtc: 0000000000000000 ver: 1916 tfle: 0 rta: 1916 rtaf: 0 rtf: 1915
56 rcutorture: Reader Pipe: 1466408 9747 0 0 0 0 0 0 0 0 0
57 rcutorture: Reader Batch: 1464477 11678 0 0 0 0 0 0 0 0
58 rcutorture: Free-Block Circulation: 1915 1915 1915 1915 1915 1915 1915 1915 1915 1915 0
59 rcutorture: --- End of test
61 The command "dmesg | grep rcutorture:" will extract this information on
62 most systems. On more esoteric configurations, it may be necessary to
63 use other commands to access the output of the printk()s used by
64 the RCU torture test. The printk()s use KERN_ALERT, so they should
67 The entries are as follows:
69 o "ggp": The number of counter flips (or batches) since boot.
71 o "rtc": The hexadecimal address of the structure currently visible
74 o "ver": The number of times since boot that the rcutw writer task
75 has changed the structure visible to readers.
77 o "tfle": If non-zero, indicates that the "torture freelist"
78 containing structure to be placed into the "rtc" area is empty.
79 This condition is important, since it can fool you into thinking
80 that RCU is working when it is not. :-/
82 o "rta": Number of structures allocated from the torture freelist.
84 o "rtaf": Number of allocations from the torture freelist that have
85 failed due to the list being empty.
87 o "rtf": Number of frees into the torture freelist.
89 o "Reader Pipe": Histogram of "ages" of structures seen by readers.
90 If any entries past the first two are non-zero, RCU is broken.
91 And rcutorture prints the error flag string "!!!" to make sure
92 you notice. The age of a newly allocated structure is zero,
93 it becomes one when removed from reader visibility, and is
94 incremented once per grace period subsequently -- and is freed
95 after passing through (RCU_TORTURE_PIPE_LEN-2) grace periods.
97 The output displayed above was taken from a correctly working
98 RCU. If you want to see what it looks like when broken, break
101 o "Reader Batch": Another histogram of "ages" of structures seen
102 by readers, but in terms of counter flips (or batches) rather
103 than in terms of grace periods. The legal number of non-zero
104 entries is again two. The reason for this separate view is
105 that it is easier to get the third entry to show up in the
106 "Reader Batch" list than in the "Reader Pipe" list.
108 o "Free-Block Circulation": Shows the number of torture structures
109 that have reached a given point in the pipeline. The first element
110 should closely correspond to the number of structures allocated,
111 the second to the number that have been removed from reader view,
112 and all but the last remaining to the corresponding number of
113 passes through a grace period. The last entry should be zero,
114 as it is only incremented if a torture structure's counter
115 somehow gets incremented farther than it should.
120 The following script may be used to torture RCU:
127 dmesg | grep rcutorture:
129 The output can be manually inspected for the error flag of "!!!".
130 One could of course create a more elaborate script that automatically
131 checked for such errors. The "rmmod" command forces a "SUCCESS" or
132 "FAILURE" indication to be printk()ed.