blob: a41a0384d20c81e327856c87b5a0827ab075e821 [file] [log] [blame]
Paul E. McKenneya241ec62005-10-30 15:03:12 -08001RCU Torture Test Operation
2
3
4CONFIG_RCU_TORTURE_TEST
5
6The CONFIG_RCU_TORTURE_TEST config option is available for all RCU
7implementations. It creates an rcutorture kernel module that can
8be loaded to run a torture test. The test periodically outputs
9status messages via printk(), which can be examined via the dmesg
Paul E. McKenney72e9bb52006-06-27 02:54:03 -070010command (perhaps grepping for "torture"). The test is started
Paul E. McKenneya241ec62005-10-30 15:03:12 -080011when the module is loaded, and stops when the module is unloaded.
12
Junchang Wang66848802019-01-03 22:24:51 +080013Module parameters are prefixed by "rcutorture." in
14Documentation/admin-guide/kernel-parameters.txt.
Paul E. McKenneya241ec62005-10-30 15:03:12 -080015
16OUTPUT
17
18The statistics output is as follows:
19
Paul E. McKenney63cd7582011-06-05 10:07:18 -070020 rcu-torture:--- Start of test: nreaders=16 nfakewriters=4 stat_interval=30 verbose=0 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4
Paul E. McKenneyfae4b542012-02-20 17:51:45 -080021 rcu-torture: rtc: (null) ver: 155441 tfle: 0 rta: 155441 rtaf: 8884 rtf: 155440 rtmbe: 0 rtbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 3055767
Paul E. McKenney63cd7582011-06-05 10:07:18 -070022 rcu-torture: Reader Pipe: 727860534 34213 0 0 0 0 0 0 0 0 0
23 rcu-torture: Reader Batch: 727877838 17003 0 0 0 0 0 0 0 0 0
24 rcu-torture: Free-Block Circulation: 155440 155440 155440 155440 155440 155440 155440 155440 155440 155440 0
25 rcu-torture:--- End of test: SUCCESS: nreaders=16 nfakewriters=4 stat_interval=30 verbose=0 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4
Paul E. McKenneya241ec62005-10-30 15:03:12 -080026
Paul E. McKenney72e9bb52006-06-27 02:54:03 -070027The command "dmesg | grep torture:" will extract this information on
Paul E. McKenneya241ec62005-10-30 15:03:12 -080028most systems. On more esoteric configurations, it may be necessary to
29use other commands to access the output of the printk()s used by
30the RCU torture test. The printk()s use KERN_ALERT, so they should
31be evident. ;-)
32
Paul E. McKenney63cd7582011-06-05 10:07:18 -070033The first and last lines show the rcutorture module parameters, and the
34last line shows either "SUCCESS" or "FAILURE", based on rcutorture's
35automatic determination as to whether RCU operated correctly.
36
Paul E. McKenneya241ec62005-10-30 15:03:12 -080037The entries are as follows:
38
Paul E. McKenneya241ec62005-10-30 15:03:12 -080039o "rtc": The hexadecimal address of the structure currently visible
40 to readers.
41
Paul E. McKenney63cd7582011-06-05 10:07:18 -070042o "ver": The number of times since boot that the RCU writer task
Paul E. McKenneya241ec62005-10-30 15:03:12 -080043 has changed the structure visible to readers.
44
45o "tfle": If non-zero, indicates that the "torture freelist"
Paul E. McKenney63cd7582011-06-05 10:07:18 -070046 containing structures to be placed into the "rtc" area is empty.
Paul E. McKenneya241ec62005-10-30 15:03:12 -080047 This condition is important, since it can fool you into thinking
48 that RCU is working when it is not. :-/
49
50o "rta": Number of structures allocated from the torture freelist.
51
52o "rtaf": Number of allocations from the torture freelist that have
Paul E. McKenney63cd7582011-06-05 10:07:18 -070053 failed due to the list being empty. It is not unusual for this
54 to be non-zero, but it is bad for it to be a large fraction of
55 the value indicated by "rta".
Paul E. McKenneya241ec62005-10-30 15:03:12 -080056
57o "rtf": Number of frees into the torture freelist.
58
Paul E. McKenney63cd7582011-06-05 10:07:18 -070059o "rtmbe": A non-zero value indicates that rcutorture believes that
60 rcu_assign_pointer() and rcu_dereference() are not working
61 correctly. This value should be zero.
62
Paul E. McKenneyfae4b542012-02-20 17:51:45 -080063o "rtbe": A non-zero value indicates that one of the rcu_barrier()
64 family of functions is not working correctly.
65
Paul E. McKenney63cd7582011-06-05 10:07:18 -070066o "rtbke": rcutorture was unable to create the real-time kthreads
67 used to force RCU priority inversion. This value should be zero.
68
69o "rtbre": Although rcutorture successfully created the kthreads
70 used to force RCU priority inversion, it was unable to set them
71 to the real-time priority level of 1. This value should be zero.
72
73o "rtbf": The number of times that RCU priority boosting failed
74 to resolve RCU priority inversion.
75
76o "rtb": The number of times that rcutorture attempted to force
77 an RCU priority inversion condition. If you are testing RCU
78 priority boosting via the "test_boost" module parameter, this
79 value should be non-zero.
80
81o "nt": The number of times rcutorture ran RCU read-side code from
82 within a timer handler. This value should be non-zero only
83 if you specified the "irqreader" module parameter.
84
Paul E. McKenneya241ec62005-10-30 15:03:12 -080085o "Reader Pipe": Histogram of "ages" of structures seen by readers.
86 If any entries past the first two are non-zero, RCU is broken.
87 And rcutorture prints the error flag string "!!!" to make sure
88 you notice. The age of a newly allocated structure is zero,
89 it becomes one when removed from reader visibility, and is
90 incremented once per grace period subsequently -- and is freed
91 after passing through (RCU_TORTURE_PIPE_LEN-2) grace periods.
92
93 The output displayed above was taken from a correctly working
94 RCU. If you want to see what it looks like when broken, break
95 it yourself. ;-)
96
97o "Reader Batch": Another histogram of "ages" of structures seen
98 by readers, but in terms of counter flips (or batches) rather
99 than in terms of grace periods. The legal number of non-zero
Paul E. McKenneyf85d6c72008-01-25 21:08:25 +0100100 entries is again two. The reason for this separate view is that
101 it is sometimes easier to get the third entry to show up in the
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800102 "Reader Batch" list than in the "Reader Pipe" list.
103
104o "Free-Block Circulation": Shows the number of torture structures
105 that have reached a given point in the pipeline. The first element
106 should closely correspond to the number of structures allocated,
107 the second to the number that have been removed from reader view,
108 and all but the last remaining to the corresponding number of
109 passes through a grace period. The last entry should be zero,
110 as it is only incremented if a torture structure's counter
111 somehow gets incremented farther than it should.
112
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700113Different implementations of RCU can provide implementation-specific
Paul E. McKenney4de5f892017-06-06 15:04:03 -0700114additional information. For example, Tree SRCU provides the following
Paul E. McKenney63cd7582011-06-05 10:07:18 -0700115additional line:
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700116
Paul E. McKenney4de5f892017-06-06 15:04:03 -0700117 srcud-torture: Tree SRCU per-CPU(idx=0): 0(35,-21) 1(-4,24) 2(1,1) 3(-26,20) 4(28,-47) 5(-9,4) 6(-10,14) 7(-14,11) T(1,6)
Paul E. McKenneyb2896d22006-10-04 02:17:03 -0700118
Paul E. McKenney4de5f892017-06-06 15:04:03 -0700119This line shows the per-CPU counter state, in this case for Tree SRCU
120using a dynamically allocated srcu_struct (hence "srcud-" rather than
121"srcu-"). The numbers in parentheses are the values of the "old" and
122"current" counters for the corresponding CPU. The "idx" value maps the
123"old" and "current" values to the underlying array, and is useful for
124debugging. The final "T" entry contains the totals of the counters.
Paul E. McKenney240ebbf2009-06-25 09:08:18 -0700125
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800126
127USAGE
128
129The following script may be used to torture RCU:
130
131 #!/bin/sh
132
133 modprobe rcutorture
Paul E. McKenney105617d2012-02-02 11:27:02 -0800134 sleep 3600
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800135 rmmod rcutorture
Paul E. McKenney72e9bb52006-06-27 02:54:03 -0700136 dmesg | grep torture:
Paul E. McKenneya241ec62005-10-30 15:03:12 -0800137
138The output can be manually inspected for the error flag of "!!!".
139One could of course create a more elaborate script that automatically
Paul E. McKenney9b9ec9b2012-01-17 14:36:51 -0800140checked for such errors. The "rmmod" command forces a "SUCCESS",
141"FAILURE", or "RCU_HOTPLUG" indication to be printk()ed. The first
142two are self-explanatory, while the last indicates that while there
143were no RCU failures, CPU-hotplug problems were detected.
Paul E. McKenney4de5f892017-06-06 15:04:03 -0700144
145However, the tools/testing/selftests/rcutorture/bin/kvm.sh script
146provides better automation, including automatic failure analysis.
147It assumes a qemu/kvm-enabled platform, and runs guest OSes out of initrd.
148See tools/testing/selftests/rcutorture/doc/initrd.txt for instructions
149on setting up such an initrd.