1 CONFIG_RCU_TRACE debugfs Files and Formats
4 The rcupreempt and rcutree implementations of RCU provide debugfs trace
5 output that summarizes counters and state. This information is useful for
6 debugging RCU itself, and can sometimes also help to debug abuses of RCU.
7 Note that the rcuclassic implementation of RCU does not provide debugfs
10 The following sections describe the debugfs files and formats for
11 preemptable RCU (rcupreempt) and hierarchical RCU (rcutree).
14 Preemptable RCU debugfs Files and Formats
16 This implementation of RCU provides three debugfs files under the
17 top-level directory RCU: rcu/rcuctrs (which displays the per-CPU
18 counters used by preemptable RCU) rcu/rcugp (which displays grace-period
19 counters), and rcu/rcustats (which internal counters for debugging RCU).
21 The output of "cat rcu/rcuctrs" looks as follows:
33 ggp = 26226, state = waitzero
35 The per-CPU fields are as follows:
37 o "CPU" gives the CPU number. Offline CPUs are not displayed.
39 o "last" gives the value of the counter that is being decremented
40 for the current grace period phase. In the example above,
41 the counters sum to 4, indicating that there are still four
42 RCU read-side critical sections still running that started
43 before the last counter flip.
45 o "cur" gives the value of the counter that is currently being
46 both incremented (by rcu_read_lock()) and decremented (by
47 rcu_read_unlock()). In the example above, the counters sum to
48 1, indicating that there is only one RCU read-side critical section
49 still running that started after the last counter flip.
51 o "F" indicates whether RCU is waiting for this CPU to acknowledge
52 a counter flip. In the above example, RCU is not waiting on any,
53 which is consistent with the state being "waitzero" rather than
56 o "M" indicates whether RCU is waiting for this CPU to execute a
57 memory barrier. In the above example, RCU is not waiting on any,
58 which is consistent with the state being "waitzero" rather than
61 o "ggp" is the global grace-period counter.
63 o "state" is the RCU state, which can be one of the following:
65 o "idle": there is no grace period in progress.
67 o "waitack": RCU just incremented the global grace-period
68 counter, which has the effect of reversing the roles of
69 the "last" and "cur" counters above, and is waiting for
70 all the CPUs to acknowledge the flip. Once the flip has
71 been acknowledged, CPUs will no longer be incrementing
72 what are now the "last" counters, so that their sum will
73 decrease monotonically down to zero.
75 o "waitzero": RCU is waiting for the sum of the "last" counters
78 o "waitmb": RCU is waiting for each CPU to execute a memory
79 barrier, which ensures that instructions from a given CPU's
80 last RCU read-side critical section cannot be reordered
81 with instructions following the memory-barrier instruction.
83 The output of "cat rcu/rcugp" looks as follows:
85 oldggp=48870 newggp=48873
87 Note that reading from this file provokes a synchronize_rcu(). The
88 "oldggp" value is that of "ggp" from rcu/rcuctrs above, taken before
89 executing the synchronize_rcu(), and the "newggp" value is also the
90 "ggp" value, but taken after the synchronize_rcu() command returns.
93 The output of "cat rcu/rcugp" looks as follows:
95 na=1337955 nl=40 wa=1337915 wl=44 da=1337871 dl=0 dr=1337871 di=1337871
96 1=50989 e1=6138 i1=49722 ie1=82 g1=49640 a1=315203 ae1=265563 a2=49640
97 z1=1401244 ze1=1351605 z2=49639 m1=5661253 me1=5611614 m2=49639
99 These are counters tracking internal preemptable-RCU events, however,
100 some of them may be useful for debugging algorithms using RCU. In
101 particular, the "nl", "wl", and "dl" values track the number of RCU
102 callbacks in various states. The fields are as follows:
104 o "na" is the total number of RCU callbacks that have been enqueued
107 o "nl" is the number of RCU callbacks waiting for the previous
108 grace period to end so that they can start waiting on the next
111 o "wa" is the total number of RCU callbacks that have started waiting
112 for a grace period since boot. "na" should be roughly equal to
115 o "wl" is the number of RCU callbacks currently waiting for their
118 o "da" is the total number of RCU callbacks whose grace periods
119 have completed since boot. "wa" should be roughly equal to
122 o "dr" is the total number of RCU callbacks that have been removed
123 from the list of callbacks ready to invoke. "dr" should be roughly
126 o "di" is the total number of RCU callbacks that have been invoked
127 since boot. "di" should be roughly equal to "da", though some
128 early versions of preemptable RCU had a bug so that only the
129 last CPU's count of invocations was displayed, rather than the
130 sum of all CPU's counts.
132 o "1" is the number of calls to rcu_try_flip(). This should be
133 roughly equal to the sum of "e1", "i1", "a1", "z1", and "m1"
134 described below. In other words, the number of times that
135 the state machine is visited should be equal to the sum of the
136 number of times that each state is visited plus the number of
137 times that the state-machine lock acquisition failed.
139 o "e1" is the number of times that rcu_try_flip() was unable to
140 acquire the fliplock.
142 o "i1" is the number of calls to rcu_try_flip_idle().
144 o "ie1" is the number of times rcu_try_flip_idle() exited early
145 due to the calling CPU having no work for RCU.
147 o "g1" is the number of times that rcu_try_flip_idle() decided
148 to start a new grace period. "i1" should be roughly equal to
151 o "a1" is the number of calls to rcu_try_flip_waitack().
153 o "ae1" is the number of times that rcu_try_flip_waitack() found
154 that at least one CPU had not yet acknowledge the new grace period
155 (AKA "counter flip").
157 o "a2" is the number of time rcu_try_flip_waitack() found that
158 all CPUs had acknowledged. "a1" should be roughly equal to
159 "ae1" plus "a2". (This particular output was collected on
160 a 128-CPU machine, hence the smaller-than-usual fraction of
161 calls to rcu_try_flip_waitack() finding all CPUs having already
164 o "z1" is the number of calls to rcu_try_flip_waitzero().
166 o "ze1" is the number of times that rcu_try_flip_waitzero() found
167 that not all of the old RCU read-side critical sections had
170 o "z2" is the number of times that rcu_try_flip_waitzero() finds
171 the sum of the counters equal to zero, in other words, that
172 all of the old RCU read-side critical sections had completed.
173 The value of "z1" should be roughly equal to "ze1" plus
176 o "m1" is the number of calls to rcu_try_flip_waitmb().
178 o "me1" is the number of times that rcu_try_flip_waitmb() finds
179 that at least one CPU has not yet executed a memory barrier.
181 o "m2" is the number of times that rcu_try_flip_waitmb() finds that
182 all CPUs have executed a memory barrier.
185 Hierarchical RCU debugfs Files and Formats
187 This implementation of RCU provides three debugfs files under the
188 top-level directory RCU: rcu/rcudata (which displays fields in struct
189 rcu_data), rcu/rcugp (which displays grace-period counters), and
190 rcu/rcuhier (which displays the struct rcu_node hierarchy).
192 The output of "cat rcu/rcudata" looks as follows:
196 0 c=17829 g=17829 pq=1 pqc=17829 qp=0 dt=10951/1 dn=0 df=1101 of=0 ri=36 ql=0 b=10
197 1 c=17829 g=17829 pq=1 pqc=17829 qp=0 dt=16117/1 dn=0 df=1015 of=0 ri=0 ql=0 b=10
198 2 c=17829 g=17829 pq=1 pqc=17829 qp=0 dt=1445/1 dn=0 df=1839 of=0 ri=0 ql=0 b=10
199 3 c=17829 g=17829 pq=1 pqc=17829 qp=0 dt=6681/1 dn=0 df=1545 of=0 ri=0 ql=0 b=10
200 4 c=17829 g=17829 pq=1 pqc=17829 qp=0 dt=1003/1 dn=0 df=1992 of=0 ri=0 ql=0 b=10
201 5 c=17829 g=17830 pq=1 pqc=17829 qp=1 dt=3887/1 dn=0 df=3331 of=0 ri=4 ql=2 b=10
202 6 c=17829 g=17829 pq=1 pqc=17829 qp=0 dt=859/1 dn=0 df=3224 of=0 ri=0 ql=0 b=10
203 7 c=17829 g=17830 pq=0 pqc=17829 qp=1 dt=3761/1 dn=0 df=1818 of=0 ri=0 ql=2 b=10
205 0 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=10951/1 dn=0 df=0 of=0 ri=0 ql=0 b=10
206 1 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=16117/1 dn=0 df=13 of=0 ri=0 ql=0 b=10
207 2 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=1445/1 dn=0 df=15 of=0 ri=0 ql=0 b=10
208 3 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=6681/1 dn=0 df=9 of=0 ri=0 ql=0 b=10
209 4 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=1003/1 dn=0 df=15 of=0 ri=0 ql=0 b=10
210 5 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=3887/1 dn=0 df=15 of=0 ri=0 ql=0 b=10
211 6 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=859/1 dn=0 df=15 of=0 ri=0 ql=0 b=10
212 7 c=-275 g=-275 pq=1 pqc=-275 qp=0 dt=3761/1 dn=0 df=15 of=0 ri=0 ql=0 b=10
214 The first section lists the rcu_data structures for rcu, the second for
215 rcu_bh. Each section has one line per CPU, or eight for this 8-CPU system.
216 The fields are as follows:
218 o The number at the beginning of each line is the CPU number.
219 CPUs numbers followed by an exclamation mark are offline,
220 but have been online at least once since boot. There will be
221 no output for CPUs that have never been online, which can be
222 a good thing in the surprisingly common case where NR_CPUS is
223 substantially larger than the number of actual CPUs.
225 o "c" is the count of grace periods that this CPU believes have
226 completed. CPUs in dynticks idle mode may lag quite a ways
227 behind, for example, CPU 4 under "rcu" above, which has slept
228 through the past 25 RCU grace periods. It is not unusual to
229 see CPUs lagging by thousands of grace periods.
231 o "g" is the count of grace periods that this CPU believes have
232 started. Again, CPUs in dynticks idle mode may lag behind.
233 If the "c" and "g" values are equal, this CPU has already
234 reported a quiescent state for the last RCU grace period that
235 it is aware of, otherwise, the CPU believes that it owes RCU a
238 o "pq" indicates that this CPU has passed through a quiescent state
239 for the current grace period. It is possible for "pq" to be
240 "1" and "c" different than "g", which indicates that although
241 the CPU has passed through a quiescent state, either (1) this
242 CPU has not yet reported that fact, (2) some other CPU has not
243 yet reported for this grace period, or (3) both.
245 o "pqc" indicates which grace period the last-observed quiescent
246 state for this CPU corresponds to. This is important for handling
247 the race between CPU 0 reporting an extended dynticks-idle
248 quiescent state for CPU 1 and CPU 1 suddenly waking up and
249 reporting its own quiescent state. If CPU 1 was the last CPU
250 for the current grace period, then the CPU that loses this race
251 will attempt to incorrectly mark CPU 1 as having checked in for
252 the next grace period!
254 o "qp" indicates that RCU still expects a quiescent state from
257 o "dt" is the current value of the dyntick counter that is incremented
258 when entering or leaving dynticks idle state, either by the
259 scheduler or by irq. The number after the "/" is the interrupt
260 nesting depth when in dyntick-idle state, or one greater than
261 the interrupt-nesting depth otherwise.
263 This field is displayed only for CONFIG_NO_HZ kernels.
265 o "dn" is the current value of the dyntick counter that is incremented
266 when entering or leaving dynticks idle state via NMI. If both
267 the "dt" and "dn" values are even, then this CPU is in dynticks
268 idle mode and may be ignored by RCU. If either of these two
269 counters is odd, then RCU must be alert to the possibility of
270 an RCU read-side critical section running on this CPU.
272 This field is displayed only for CONFIG_NO_HZ kernels.
274 o "df" is the number of times that some other CPU has forced a
275 quiescent state on behalf of this CPU due to this CPU being in
278 This field is displayed only for CONFIG_NO_HZ kernels.
280 o "of" is the number of times that some other CPU has forced a
281 quiescent state on behalf of this CPU due to this CPU being
282 offline. In a perfect world, this might neve happen, but it
283 turns out that offlining and onlining a CPU can take several grace
284 periods, and so there is likely to be an extended period of time
285 when RCU believes that the CPU is online when it really is not.
286 Please note that erring in the other direction (RCU believing a
287 CPU is offline when it is really alive and kicking) is a fatal
288 error, so it makes sense to err conservatively.
290 o "ri" is the number of times that RCU has seen fit to send a
291 reschedule IPI to this CPU in order to get it to report a
294 o "ql" is the number of RCU callbacks currently residing on
295 this CPU. This is the total number of callbacks, regardless
296 of what state they are in (new, waiting for grace period to
297 start, waiting for grace period to end, ready to invoke).
299 o "b" is the batch limit for this CPU. If more than this number
300 of RCU callbacks is ready to invoke, then the remainder will
303 There is also an rcu/rcudata.csv file with the same information in
304 comma-separated-variable spreadsheet format.
307 The output of "cat rcu/rcugp" looks as follows:
309 rcu: completed=33062 gpnum=33063
310 rcu_bh: completed=464 gpnum=464
312 Again, this output is for both "rcu" and "rcu_bh". The fields are
313 taken from the rcu_state structure, and are as follows:
315 o "completed" is the number of grace periods that have completed.
316 It is comparable to the "c" field from rcu/rcudata in that a
317 CPU whose "c" field matches the value of "completed" is aware
318 that the corresponding RCU grace period has completed.
320 o "gpnum" is the number of grace periods that have started. It is
321 comparable to the "g" field from rcu/rcudata in that a CPU
322 whose "g" field matches the value of "gpnum" is aware that the
323 corresponding RCU grace period has started.
325 If these two fields are equal (as they are for "rcu_bh" above),
326 then there is no grace period in progress, in other words, RCU
327 is idle. On the other hand, if the two fields differ (as they
328 do for "rcu" above), then an RCU grace period is in progress.
331 The output of "cat rcu/rcuhier" looks as follows, with very long lines:
333 c=6902 g=6903 s=2 jfq=3 j=72c7 nfqs=13142/nfqsng=0(13142) fqlh=6
335 3/3 0:35 ^0 0/0 36:71 ^1 0/0 72:107 ^2 0/0 108:127 ^3
336 3/3f 0:5 ^0 2/3 6:11 ^1 0/0 12:17 ^2 0/0 18:23 ^3 0/0 24:29 ^4 0/0 30:35 ^5 0/0 36:41 ^0 0/0 42:47 ^1 0/0 48:53 ^2 0/0 54:59 ^3 0/0 60:65 ^4 0/0 66:71 ^5 0/0 72:77 ^0 0/0 78:83 ^1 0/0 84:89 ^2 0/0 90:95 ^3 0/0 96:101 ^4 0/0 102:107 ^5 0/0 108:113 ^0 0/0 114:119 ^1 0/0 120:125 ^2 0/0 126:127 ^3
338 c=-226 g=-226 s=1 jfq=-5701 j=72c7 nfqs=88/nfqsng=0(88) fqlh=0
340 0/3 0:35 ^0 0/0 36:71 ^1 0/0 72:107 ^2 0/0 108:127 ^3
341 0/3f 0:5 ^0 0/3 6:11 ^1 0/0 12:17 ^2 0/0 18:23 ^3 0/0 24:29 ^4 0/0 30:35 ^5 0/0 36:41 ^0 0/0 42:47 ^1 0/0 48:53 ^2 0/0 54:59 ^3 0/0 60:65 ^4 0/0 66:71 ^5 0/0 72:77 ^0 0/0 78:83 ^1 0/0 84:89 ^2 0/0 90:95 ^3 0/0 96:101 ^4 0/0 102:107 ^5 0/0 108:113 ^0 0/0 114:119 ^1 0/0 120:125 ^2 0/0 126:127 ^3
343 This is once again split into "rcu" and "rcu_bh" portions. The fields are
346 o "c" is exactly the same as "completed" under rcu/rcugp.
348 o "g" is exactly the same as "gpnum" under rcu/rcugp.
350 o "s" is the "signaled" state that drives force_quiescent_state()'s
353 o "jfq" is the number of jiffies remaining for this grace period
354 before force_quiescent_state() is invoked to help push things
355 along. Note that CPUs in dyntick-idle mode thoughout the grace
356 period will not report on their own, but rather must be check by
357 some other CPU via force_quiescent_state().
359 o "j" is the low-order four hex digits of the jiffies counter.
360 Yes, Paul did run into a number of problems that turned out to
361 be due to the jiffies counter no longer counting. Why do you ask?
363 o "nfqs" is the number of calls to force_quiescent_state() since
366 o "nfqsng" is the number of useless calls to force_quiescent_state(),
367 where there wasn't actually a grace period active. This can
368 happen due to races. The number in parentheses is the difference
369 between "nfqs" and "nfqsng", or the number of times that
370 force_quiescent_state() actually did some real work.
372 o "fqlh" is the number of calls to force_quiescent_state() that
373 exited immediately (without even being counted in nfqs above)
374 due to contention on ->fqslock.
376 o Each element of the form "1/1 0:127 ^0" represents one struct
377 rcu_node. Each line represents one level of the hierarchy, from
378 root to leaves. It is best to think of the rcu_data structures
379 as forming yet another level after the leaves. Note that there
380 might be either one, two, or three levels of rcu_node structures,
381 depending on the relationship between CONFIG_RCU_FANOUT and
384 o The numbers separated by the "/" are the qsmask followed
385 by the qsmaskinit. The qsmask will have one bit
386 set for each entity in the next lower level that
387 has not yet checked in for the current grace period.
388 The qsmaskinit will have one bit for each entity that is
389 currently expected to check in during each grace period.
390 The value of qsmaskinit is assigned to that of qsmask
391 at the beginning of each grace period.
393 For example, for "rcu", the qsmask of the first entry
394 of the lowest level is 0x14, meaning that we are still
395 waiting for CPUs 2 and 4 to check in for the current
398 o The numbers separated by the ":" are the range of CPUs
399 served by this struct rcu_node. This can be helpful
400 in working out how the hierarchy is wired together.
402 For example, the first entry at the lowest level shows
403 "0:5", indicating that it covers CPUs 0 through 5.
405 o The number after the "^" indicates the bit in the
406 next higher level rcu_node structure that this
407 rcu_node structure corresponds to.
409 For example, the first entry at the lowest level shows
410 "^0", indicating that it corresponds to bit zero in
411 the first entry at the middle level.
414 The output of "cat rcu/rcu_pending" looks as follows:
417 0 np=255892 qsp=53936 cbr=0 cng=14417 gpc=10033 gps=24320 nf=6445 nn=146741
418 1 np=261224 qsp=54638 cbr=0 cng=25723 gpc=16310 gps=2849 nf=5912 nn=155792
419 2 np=237496 qsp=49664 cbr=0 cng=2762 gpc=45478 gps=1762 nf=1201 nn=136629
420 3 np=236249 qsp=48766 cbr=0 cng=286 gpc=48049 gps=1218 nf=207 nn=137723
421 4 np=221310 qsp=46850 cbr=0 cng=26 gpc=43161 gps=4634 nf=3529 nn=123110
422 5 np=237332 qsp=48449 cbr=0 cng=54 gpc=47920 gps=3252 nf=201 nn=137456
423 6 np=219995 qsp=46718 cbr=0 cng=50 gpc=42098 gps=6093 nf=4202 nn=120834
424 7 np=249893 qsp=49390 cbr=0 cng=72 gpc=38400 gps=17102 nf=41 nn=144888
426 0 np=146741 qsp=1419 cbr=0 cng=6 gpc=0 gps=0 nf=2 nn=145314
427 1 np=155792 qsp=12597 cbr=0 cng=0 gpc=4 gps=8 nf=3 nn=143180
428 2 np=136629 qsp=18680 cbr=0 cng=0 gpc=7 gps=6 nf=0 nn=117936
429 3 np=137723 qsp=2843 cbr=0 cng=0 gpc=10 gps=7 nf=0 nn=134863
430 4 np=123110 qsp=12433 cbr=0 cng=0 gpc=4 gps=2 nf=0 nn=110671
431 5 np=137456 qsp=4210 cbr=0 cng=0 gpc=6 gps=5 nf=0 nn=133235
432 6 np=120834 qsp=9902 cbr=0 cng=0 gpc=6 gps=3 nf=2 nn=110921
433 7 np=144888 qsp=26336 cbr=0 cng=0 gpc=8 gps=2 nf=0 nn=118542
435 As always, this is once again split into "rcu" and "rcu_bh" portions.
436 The fields are as follows:
438 o "np" is the number of times that __rcu_pending() has been invoked
439 for the corresponding flavor of RCU.
441 o "qsp" is the number of times that the RCU was waiting for a
442 quiescent state from this CPU.
444 o "cbr" is the number of times that this CPU had RCU callbacks
445 that had passed through a grace period, and were thus ready
448 o "cng" is the number of times that this CPU needed another
449 grace period while RCU was idle.
451 o "gpc" is the number of times that an old grace period had
452 completed, but this CPU was not yet aware of it.
454 o "gps" is the number of times that a new grace period had started,
455 but this CPU was not yet aware of it.
457 o "nf" is the number of times that this CPU suspected that the
458 current grace period had run for too long, and thus needed to
461 Please note that "forcing" consists of sending resched IPIs
462 to holdout CPUs. If that CPU really still is in an old RCU
463 read-side critical section, then we really do have to wait for it.
464 The assumption behing "forcing" is that the CPU is not still in
465 an old RCU read-side critical section, but has not yet responded
466 for some other reason.
468 o "nn" is the number of times that this CPU needed nothing. Alert
469 readers will note that the rcu "nn" number for a given CPU very
470 closely matches the rcu_bh "np" number for that same CPU. This
471 is due to short-circuit evaluation in rcu_pending().