trace.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. CONFIG_RCU_TRACE debugfs Files and Formats
  2. The rcupreempt and rcutree implementations of RCU provide debugfs trace
  3. output that summarizes counters and state. This information is useful for
  4. debugging RCU itself, and can sometimes also help to debug abuses of RCU.
  5. Note that the rcuclassic implementation of RCU does not provide debugfs
  6. trace output.
  7. The following sections describe the debugfs files and formats for
  8. preemptable RCU (rcupreempt) and hierarchical RCU (rcutree).
  9. Preemptable RCU debugfs Files and Formats
  10. This implementation of RCU provides three debugfs files under the
  11. top-level directory RCU: rcu/rcuctrs (which displays the per-CPU
  12. counters used by preemptable RCU) rcu/rcugp (which displays grace-period
  13. counters), and rcu/rcustats (which internal counters for debugging RCU).
  14. The output of "cat rcu/rcuctrs" looks as follows:
  15. CPU last cur F M
  16. 0 5 -5 0 0
  17. 1 -1 0 0 0
  18. 2 0 1 0 0
  19. 3 0 1 0 0
  20. 4 0 1 0 0
  21. 5 0 1 0 0
  22. 6 0 2 0 0
  23. 7 0 -1 0 0
  24. 8 0 1 0 0
  25. ggp = 26226, state = waitzero
  26. The per-CPU fields are as follows:
  27. o "CPU" gives the CPU number. Offline CPUs are not displayed.
  28. o "last" gives the value of the counter that is being decremented
  29. for the current grace period phase. In the example above,
  30. the counters sum to 4, indicating that there are still four
  31. RCU read-side critical sections still running that started
  32. before the last counter flip.
  33. o "cur" gives the value of the counter that is currently being
  34. both incremented (by rcu_read_lock()) and decremented (by
  35. rcu_read_unlock()). In the example above, the counters sum to
  36. 1, indicating that there is only one RCU read-side critical section
  37. still running that started after the last counter flip.
  38. o "F" indicates whether RCU is waiting for this CPU to acknowledge
  39. a counter flip. In the above example, RCU is not waiting on any,
  40. which is consistent with the state being "waitzero" rather than
  41. "waitack".
  42. o "M" indicates whether RCU is waiting for this CPU to execute a
  43. memory barrier. In the above example, RCU is not waiting on any,
  44. which is consistent with the state being "waitzero" rather than
  45. "waitmb".
  46. o "ggp" is the global grace-period counter.
  47. o "state" is the RCU state, which can be one of the following:
  48. o "idle": there is no grace period in progress.
  49. o "waitack": RCU just incremented the global grace-period
  50. counter, which has the effect of reversing the roles of
  51. the "last" and "cur" counters above, and is waiting for
  52. all the CPUs to acknowledge the flip. Once the flip has
  53. been acknowledged, CPUs will no longer be incrementing
  54. what are now the "last" counters, so that their sum will
  55. decrease monotonically down to zero.
  56. o "waitzero": RCU is waiting for the sum of the "last" counters
  57. to decrease to zero.
  58. o "waitmb": RCU is waiting for each CPU to execute a memory
  59. barrier, which ensures that instructions from a given CPU's
  60. last RCU read-side critical section cannot be reordered
  61. with instructions following the memory-barrier instruction.
  62. The output of "cat rcu/rcugp" looks as follows:
  63. oldggp=48870 newggp=48873
  64. Note that reading from this file provokes a synchronize_rcu(). The
  65. "oldggp" value is that of "ggp" from rcu/rcuctrs above, taken before
  66. executing the synchronize_rcu(), and the "newggp" value is also the
  67. "ggp" value, but taken after the synchronize_rcu() command returns.
  68. The output of "cat rcu/rcugp" looks as follows:
  69. na=1337955 nl=40 wa=1337915 wl=44 da=1337871 dl=0 dr=1337871 di=1337871
  70. 1=50989 e1=6138 i1=49722 ie1=82 g1=49640 a1=315203 ae1=265563 a2=49640
  71. z1=1401244 ze1=1351605 z2=49639 m1=5661253 me1=5611614 m2=49639
  72. These are counters tracking internal preemptable-RCU events, however,
  73. some of them may be useful for debugging algorithms using RCU. In
  74. particular, the "nl", "wl", and "dl" values track the number of RCU
  75. callbacks in various states. The fields are as follows:
  76. o "na" is the total number of RCU callbacks that have been enqueued
  77. since boot.
  78. o "nl" is the number of RCU callbacks waiting for the previous
  79. grace period to end so that they can start waiting on the next
  80. grace period.
  81. o "wa" is the total number of RCU callbacks that have started waiting
  82. for a grace period since boot. "na" should be roughly equal to
  83. "nl" plus "wa".
  84. o "wl" is the number of RCU callbacks currently waiting for their
  85. grace period to end.
  86. o "da" is the total number of RCU callbacks whose grace periods
  87. have completed since boot. "wa" should be roughly equal to
  88. "wl" plus "da".
  89. o "dr" is the total number of RCU callbacks that have been removed
  90. from the list of callbacks ready to invoke. "dr" should be roughly
  91. equal to "da".
  92. o "di" is the total number of RCU callbacks that have been invoked
  93. since boot. "di" should be roughly equal to "da", though some
  94. early versions of preemptable RCU had a bug so that only the
  95. last CPU's count of invocations was displayed, rather than the
  96. sum of all CPU's counts.
  97. o "1" is the number of calls to rcu_try_flip(). This should be
  98. roughly equal to the sum of "e1", "i1", "a1", "z1", and "m1"
  99. described below. In other words, the number of times that
  100. the state machine is visited should be equal to the sum of the
  101. number of times that each state is visited plus the number of
  102. times that the state-machine lock acquisition failed.
  103. o "e1" is the number of times that rcu_try_flip() was unable to
  104. acquire the fliplock.
  105. o "i1" is the number of calls to rcu_try_flip_idle().
  106. o "ie1" is the number of times rcu_try_flip_idle() exited early
  107. due to the calling CPU having no work for RCU.
  108. o "g1" is the number of times that rcu_try_flip_idle() decided
  109. to start a new grace period. "i1" should be roughly equal to
  110. "ie1" plus "g1".
  111. o "a1" is the number of calls to rcu_try_flip_waitack().
  112. o "ae1" is the number of times that rcu_try_flip_waitack() found
  113. that at least one CPU had not yet acknowledge the new grace period
  114. (AKA "counter flip").
  115. o "a2" is the number of time rcu_try_flip_waitack() found that
  116. all CPUs had acknowledged. "a1" should be roughly equal to
  117. "ae1" plus "a2". (This particular output was collected on
  118. a 128-CPU machine, hence the smaller-than-usual fraction of
  119. calls to rcu_try_flip_waitack() finding all CPUs having already
  120. acknowledged.)
  121. o "z1" is the number of calls to rcu_try_flip_waitzero().
  122. o "ze1" is the number of times that rcu_try_flip_waitzero() found
  123. that not all of the old RCU read-side critical sections had
  124. completed.
  125. o "z2" is the number of times that rcu_try_flip_waitzero() finds
  126. the sum of the counters equal to zero, in other words, that
  127. all of the old RCU read-side critical sections had completed.
  128. The value of "z1" should be roughly equal to "ze1" plus
  129. "z2".
  130. o "m1" is the number of calls to rcu_try_flip_waitmb().
  131. o "me1" is the number of times that rcu_try_flip_waitmb() finds
  132. that at least one CPU has not yet executed a memory barrier.
  133. o "m2" is the number of times that rcu_try_flip_waitmb() finds that
  134. all CPUs have executed a memory barrier.
  135. Hierarchical RCU debugfs Files and Formats
  136. This implementation of RCU provides three debugfs files under the
  137. top-level directory RCU: rcu/rcudata (which displays fields in struct
  138. rcu_data), rcu/rcugp (which displays grace-period counters), and
  139. rcu/rcuhier (which displays the struct rcu_node hierarchy).
  140. The output of "cat rcu/rcudata" looks as follows:
  141. rcu:
  142. 0 c=4011 g=4012 pq=1 pqc=4011 qp=0 rpfq=1 rp=3c2a dt=23301/73 dn=2 df=1882 of=0 ri=2126 ql=2 b=10
  143. 1 c=4011 g=4012 pq=1 pqc=4011 qp=0 rpfq=3 rp=39a6 dt=78073/1 dn=2 df=1402 of=0 ri=1875 ql=46 b=10
  144. 2 c=4010 g=4010 pq=1 pqc=4010 qp=0 rpfq=-5 rp=1d12 dt=16646/0 dn=2 df=3140 of=0 ri=2080 ql=0 b=10
  145. 3 c=4012 g=4013 pq=1 pqc=4012 qp=1 rpfq=3 rp=2b50 dt=21159/1 dn=2 df=2230 of=0 ri=1923 ql=72 b=10
  146. 4 c=4012 g=4013 pq=1 pqc=4012 qp=1 rpfq=3 rp=1644 dt=5783/1 dn=2 df=3348 of=0 ri=2805 ql=7 b=10
  147. 5 c=4012 g=4013 pq=0 pqc=4011 qp=1 rpfq=3 rp=1aac dt=5879/1 dn=2 df=3140 of=0 ri=2066 ql=10 b=10
  148. 6 c=4012 g=4013 pq=1 pqc=4012 qp=1 rpfq=3 rp=ed8 dt=5847/1 dn=2 df=3797 of=0 ri=1266 ql=10 b=10
  149. 7 c=4012 g=4013 pq=1 pqc=4012 qp=1 rpfq=3 rp=1fa2 dt=6199/1 dn=2 df=2795 of=0 ri=2162 ql=28 b=10
  150. rcu_bh:
  151. 0 c=-268 g=-268 pq=1 pqc=-268 qp=0 rpfq=-145 rp=21d6 dt=23301/73 dn=2 df=0 of=0 ri=0 ql=0 b=10
  152. 1 c=-268 g=-268 pq=1 pqc=-268 qp=1 rpfq=-170 rp=20ce dt=78073/1 dn=2 df=26 of=0 ri=5 ql=0 b=10
  153. 2 c=-268 g=-268 pq=1 pqc=-268 qp=1 rpfq=-83 rp=fbd dt=16646/0 dn=2 df=28 of=0 ri=4 ql=0 b=10
  154. 3 c=-268 g=-268 pq=1 pqc=-268 qp=0 rpfq=-105 rp=178c dt=21159/1 dn=2 df=28 of=0 ri=2 ql=0 b=10
  155. 4 c=-268 g=-268 pq=1 pqc=-268 qp=1 rpfq=-30 rp=b54 dt=5783/1 dn=2 df=32 of=0 ri=0 ql=0 b=10
  156. 5 c=-268 g=-268 pq=1 pqc=-268 qp=1 rpfq=-29 rp=df5 dt=5879/1 dn=2 df=30 of=0 ri=3 ql=0 b=10
  157. 6 c=-268 g=-268 pq=1 pqc=-268 qp=1 rpfq=-28 rp=788 dt=5847/1 dn=2 df=32 of=0 ri=0 ql=0 b=10
  158. 7 c=-268 g=-268 pq=1 pqc=-268 qp=1 rpfq=-53 rp=1098 dt=6199/1 dn=2 df=30 of=0 ri=3 ql=0 b=10
  159. The first section lists the rcu_data structures for rcu, the second for
  160. rcu_bh. Each section has one line per CPU, or eight for this 8-CPU system.
  161. The fields are as follows:
  162. o The number at the beginning of each line is the CPU number.
  163. CPUs numbers followed by an exclamation mark are offline,
  164. but have been online at least once since boot. There will be
  165. no output for CPUs that have never been online, which can be
  166. a good thing in the surprisingly common case where NR_CPUS is
  167. substantially larger than the number of actual CPUs.
  168. o "c" is the count of grace periods that this CPU believes have
  169. completed. CPUs in dynticks idle mode may lag quite a ways
  170. behind, for example, CPU 4 under "rcu" above, which has slept
  171. through the past 25 RCU grace periods. It is not unusual to
  172. see CPUs lagging by thousands of grace periods.
  173. o "g" is the count of grace periods that this CPU believes have
  174. started. Again, CPUs in dynticks idle mode may lag behind.
  175. If the "c" and "g" values are equal, this CPU has already
  176. reported a quiescent state for the last RCU grace period that
  177. it is aware of, otherwise, the CPU believes that it owes RCU a
  178. quiescent state.
  179. o "pq" indicates that this CPU has passed through a quiescent state
  180. for the current grace period. It is possible for "pq" to be
  181. "1" and "c" different than "g", which indicates that although
  182. the CPU has passed through a quiescent state, either (1) this
  183. CPU has not yet reported that fact, (2) some other CPU has not
  184. yet reported for this grace period, or (3) both.
  185. o "pqc" indicates which grace period the last-observed quiescent
  186. state for this CPU corresponds to. This is important for handling
  187. the race between CPU 0 reporting an extended dynticks-idle
  188. quiescent state for CPU 1 and CPU 1 suddenly waking up and
  189. reporting its own quiescent state. If CPU 1 was the last CPU
  190. for the current grace period, then the CPU that loses this race
  191. will attempt to incorrectly mark CPU 1 as having checked in for
  192. the next grace period!
  193. o "qp" indicates that RCU still expects a quiescent state from
  194. this CPU.
  195. o "rpfq" is the number of rcu_pending() calls on this CPU required
  196. to induce this CPU to invoke force_quiescent_state().
  197. o "rp" is low-order four hex digits of the count of how many times
  198. rcu_pending() has been invoked on this CPU.
  199. o "dt" is the current value of the dyntick counter that is incremented
  200. when entering or leaving dynticks idle state, either by the
  201. scheduler or by irq. The number after the "/" is the interrupt
  202. nesting depth when in dyntick-idle state, or one greater than
  203. the interrupt-nesting depth otherwise.
  204. This field is displayed only for CONFIG_NO_HZ kernels.
  205. o "dn" is the current value of the dyntick counter that is incremented
  206. when entering or leaving dynticks idle state via NMI. If both
  207. the "dt" and "dn" values are even, then this CPU is in dynticks
  208. idle mode and may be ignored by RCU. If either of these two
  209. counters is odd, then RCU must be alert to the possibility of
  210. an RCU read-side critical section running on this CPU.
  211. This field is displayed only for CONFIG_NO_HZ kernels.
  212. o "df" is the number of times that some other CPU has forced a
  213. quiescent state on behalf of this CPU due to this CPU being in
  214. dynticks-idle state.
  215. This field is displayed only for CONFIG_NO_HZ kernels.
  216. o "of" is the number of times that some other CPU has forced a
  217. quiescent state on behalf of this CPU due to this CPU being
  218. offline. In a perfect world, this might neve happen, but it
  219. turns out that offlining and onlining a CPU can take several grace
  220. periods, and so there is likely to be an extended period of time
  221. when RCU believes that the CPU is online when it really is not.
  222. Please note that erring in the other direction (RCU believing a
  223. CPU is offline when it is really alive and kicking) is a fatal
  224. error, so it makes sense to err conservatively.
  225. o "ri" is the number of times that RCU has seen fit to send a
  226. reschedule IPI to this CPU in order to get it to report a
  227. quiescent state.
  228. o "ql" is the number of RCU callbacks currently residing on
  229. this CPU. This is the total number of callbacks, regardless
  230. of what state they are in (new, waiting for grace period to
  231. start, waiting for grace period to end, ready to invoke).
  232. o "b" is the batch limit for this CPU. If more than this number
  233. of RCU callbacks is ready to invoke, then the remainder will
  234. be deferred.
  235. The output of "cat rcu/rcugp" looks as follows:
  236. rcu: completed=33062 gpnum=33063
  237. rcu_bh: completed=464 gpnum=464
  238. Again, this output is for both "rcu" and "rcu_bh". The fields are
  239. taken from the rcu_state structure, and are as follows:
  240. o "completed" is the number of grace periods that have completed.
  241. It is comparable to the "c" field from rcu/rcudata in that a
  242. CPU whose "c" field matches the value of "completed" is aware
  243. that the corresponding RCU grace period has completed.
  244. o "gpnum" is the number of grace periods that have started. It is
  245. comparable to the "g" field from rcu/rcudata in that a CPU
  246. whose "g" field matches the value of "gpnum" is aware that the
  247. corresponding RCU grace period has started.
  248. If these two fields are equal (as they are for "rcu_bh" above),
  249. then there is no grace period in progress, in other words, RCU
  250. is idle. On the other hand, if the two fields differ (as they
  251. do for "rcu" above), then an RCU grace period is in progress.
  252. The output of "cat rcu/rcuhier" looks as follows, with very long lines:
  253. c=6902 g=6903 s=2 jfq=3 j=72c7 nfqs=13142/nfqsng=0(13142) fqlh=6
  254. 1/1 0:127 ^0
  255. 3/3 0:35 ^0 0/0 36:71 ^1 0/0 72:107 ^2 0/0 108:127 ^3
  256. 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
  257. rcu_bh:
  258. c=-226 g=-226 s=1 jfq=-5701 j=72c7 nfqs=88/nfqsng=0(88) fqlh=0
  259. 0/1 0:127 ^0
  260. 0/3 0:35 ^0 0/0 36:71 ^1 0/0 72:107 ^2 0/0 108:127 ^3
  261. 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
  262. This is once again split into "rcu" and "rcu_bh" portions. The fields are
  263. as follows:
  264. o "c" is exactly the same as "completed" under rcu/rcugp.
  265. o "g" is exactly the same as "gpnum" under rcu/rcugp.
  266. o "s" is the "signaled" state that drives force_quiescent_state()'s
  267. state machine.
  268. o "jfq" is the number of jiffies remaining for this grace period
  269. before force_quiescent_state() is invoked to help push things
  270. along. Note that CPUs in dyntick-idle mode thoughout the grace
  271. period will not report on their own, but rather must be check by
  272. some other CPU via force_quiescent_state().
  273. o "j" is the low-order four hex digits of the jiffies counter.
  274. Yes, Paul did run into a number of problems that turned out to
  275. be due to the jiffies counter no longer counting. Why do you ask?
  276. o "nfqs" is the number of calls to force_quiescent_state() since
  277. boot.
  278. o "nfqsng" is the number of useless calls to force_quiescent_state(),
  279. where there wasn't actually a grace period active. This can
  280. happen due to races. The number in parentheses is the difference
  281. between "nfqs" and "nfqsng", or the number of times that
  282. force_quiescent_state() actually did some real work.
  283. o "fqlh" is the number of calls to force_quiescent_state() that
  284. exited immediately (without even being counted in nfqs above)
  285. due to contention on ->fqslock.
  286. o Each element of the form "1/1 0:127 ^0" represents one struct
  287. rcu_node. Each line represents one level of the hierarchy, from
  288. root to leaves. It is best to think of the rcu_data structures
  289. as forming yet another level after the leaves. Note that there
  290. might be either one, two, or three levels of rcu_node structures,
  291. depending on the relationship between CONFIG_RCU_FANOUT and
  292. CONFIG_NR_CPUS.
  293. o The numbers separated by the "/" are the qsmask followed
  294. by the qsmaskinit. The qsmask will have one bit
  295. set for each entity in the next lower level that
  296. has not yet checked in for the current grace period.
  297. The qsmaskinit will have one bit for each entity that is
  298. currently expected to check in during each grace period.
  299. The value of qsmaskinit is assigned to that of qsmask
  300. at the beginning of each grace period.
  301. For example, for "rcu", the qsmask of the first entry
  302. of the lowest level is 0x14, meaning that we are still
  303. waiting for CPUs 2 and 4 to check in for the current
  304. grace period.
  305. o The numbers separated by the ":" are the range of CPUs
  306. served by this struct rcu_node. This can be helpful
  307. in working out how the hierarchy is wired together.
  308. For example, the first entry at the lowest level shows
  309. "0:5", indicating that it covers CPUs 0 through 5.
  310. o The number after the "^" indicates the bit in the
  311. next higher level rcu_node structure that this
  312. rcu_node structure corresponds to.
  313. For example, the first entry at the lowest level shows
  314. "^0", indicating that it corresponds to bit zero in
  315. the first entry at the middle level.