rcu.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM rcu
  3. #if !defined(_TRACE_RCU_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_RCU_H
  5. #include <linux/tracepoint.h>
  6. /*
  7. * Tracepoint for start/end markers used for utilization calculations.
  8. * By convention, the string is of the following forms:
  9. *
  10. * "Start <activity>" -- Mark the start of the specified activity,
  11. * such as "context switch". Nesting is permitted.
  12. * "End <activity>" -- Mark the end of the specified activity.
  13. *
  14. * An "@" character within "<activity>" is a comment character: Data
  15. * reduction scripts will ignore the "@" and the remainder of the line.
  16. */
  17. TRACE_EVENT(rcu_utilization,
  18. TP_PROTO(char *s),
  19. TP_ARGS(s),
  20. TP_STRUCT__entry(
  21. __field(char *, s)
  22. ),
  23. TP_fast_assign(
  24. __entry->s = s;
  25. ),
  26. TP_printk("%s", __entry->s)
  27. );
  28. #ifdef CONFIG_RCU_TRACE
  29. #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
  30. /*
  31. * Tracepoint for grace-period events: starting and ending a grace
  32. * period ("start" and "end", respectively), a CPU noting the start
  33. * of a new grace period or the end of an old grace period ("cpustart"
  34. * and "cpuend", respectively), a CPU passing through a quiescent
  35. * state ("cpuqs"), a CPU coming online or going offline ("cpuonl"
  36. * and "cpuofl", respectively), and a CPU being kicked for being too
  37. * long in dyntick-idle mode ("kick").
  38. */
  39. TRACE_EVENT(rcu_grace_period,
  40. TP_PROTO(char *rcuname, unsigned long gpnum, char *gpevent),
  41. TP_ARGS(rcuname, gpnum, gpevent),
  42. TP_STRUCT__entry(
  43. __field(char *, rcuname)
  44. __field(unsigned long, gpnum)
  45. __field(char *, gpevent)
  46. ),
  47. TP_fast_assign(
  48. __entry->rcuname = rcuname;
  49. __entry->gpnum = gpnum;
  50. __entry->gpevent = gpevent;
  51. ),
  52. TP_printk("%s %lu %s",
  53. __entry->rcuname, __entry->gpnum, __entry->gpevent)
  54. );
  55. /*
  56. * Tracepoint for grace-period-initialization events. These are
  57. * distinguished by the type of RCU, the new grace-period number, the
  58. * rcu_node structure level, the starting and ending CPU covered by the
  59. * rcu_node structure, and the mask of CPUs that will be waited for.
  60. * All but the type of RCU are extracted from the rcu_node structure.
  61. */
  62. TRACE_EVENT(rcu_grace_period_init,
  63. TP_PROTO(char *rcuname, unsigned long gpnum, u8 level,
  64. int grplo, int grphi, unsigned long qsmask),
  65. TP_ARGS(rcuname, gpnum, level, grplo, grphi, qsmask),
  66. TP_STRUCT__entry(
  67. __field(char *, rcuname)
  68. __field(unsigned long, gpnum)
  69. __field(u8, level)
  70. __field(int, grplo)
  71. __field(int, grphi)
  72. __field(unsigned long, qsmask)
  73. ),
  74. TP_fast_assign(
  75. __entry->rcuname = rcuname;
  76. __entry->gpnum = gpnum;
  77. __entry->level = level;
  78. __entry->grplo = grplo;
  79. __entry->grphi = grphi;
  80. __entry->qsmask = qsmask;
  81. ),
  82. TP_printk("%s %lu %u %d %d %lx",
  83. __entry->rcuname, __entry->gpnum, __entry->level,
  84. __entry->grplo, __entry->grphi, __entry->qsmask)
  85. );
  86. /*
  87. * Tracepoint for tasks blocking within preemptible-RCU read-side
  88. * critical sections. Track the type of RCU (which one day might
  89. * include SRCU), the grace-period number that the task is blocking
  90. * (the current or the next), and the task's PID.
  91. */
  92. TRACE_EVENT(rcu_preempt_task,
  93. TP_PROTO(char *rcuname, int pid, unsigned long gpnum),
  94. TP_ARGS(rcuname, pid, gpnum),
  95. TP_STRUCT__entry(
  96. __field(char *, rcuname)
  97. __field(unsigned long, gpnum)
  98. __field(int, pid)
  99. ),
  100. TP_fast_assign(
  101. __entry->rcuname = rcuname;
  102. __entry->gpnum = gpnum;
  103. __entry->pid = pid;
  104. ),
  105. TP_printk("%s %lu %d",
  106. __entry->rcuname, __entry->gpnum, __entry->pid)
  107. );
  108. /*
  109. * Tracepoint for tasks that blocked within a given preemptible-RCU
  110. * read-side critical section exiting that critical section. Track the
  111. * type of RCU (which one day might include SRCU) and the task's PID.
  112. */
  113. TRACE_EVENT(rcu_unlock_preempted_task,
  114. TP_PROTO(char *rcuname, unsigned long gpnum, int pid),
  115. TP_ARGS(rcuname, gpnum, pid),
  116. TP_STRUCT__entry(
  117. __field(char *, rcuname)
  118. __field(unsigned long, gpnum)
  119. __field(int, pid)
  120. ),
  121. TP_fast_assign(
  122. __entry->rcuname = rcuname;
  123. __entry->gpnum = gpnum;
  124. __entry->pid = pid;
  125. ),
  126. TP_printk("%s %lu %d", __entry->rcuname, __entry->gpnum, __entry->pid)
  127. );
  128. /*
  129. * Tracepoint for quiescent-state-reporting events. These are
  130. * distinguished by the type of RCU, the grace-period number, the
  131. * mask of quiescent lower-level entities, the rcu_node structure level,
  132. * the starting and ending CPU covered by the rcu_node structure, and
  133. * whether there are any blocked tasks blocking the current grace period.
  134. * All but the type of RCU are extracted from the rcu_node structure.
  135. */
  136. TRACE_EVENT(rcu_quiescent_state_report,
  137. TP_PROTO(char *rcuname, unsigned long gpnum,
  138. unsigned long mask, unsigned long qsmask,
  139. u8 level, int grplo, int grphi, int gp_tasks),
  140. TP_ARGS(rcuname, gpnum, mask, qsmask, level, grplo, grphi, gp_tasks),
  141. TP_STRUCT__entry(
  142. __field(char *, rcuname)
  143. __field(unsigned long, gpnum)
  144. __field(unsigned long, mask)
  145. __field(unsigned long, qsmask)
  146. __field(u8, level)
  147. __field(int, grplo)
  148. __field(int, grphi)
  149. __field(u8, gp_tasks)
  150. ),
  151. TP_fast_assign(
  152. __entry->rcuname = rcuname;
  153. __entry->gpnum = gpnum;
  154. __entry->mask = mask;
  155. __entry->qsmask = qsmask;
  156. __entry->level = level;
  157. __entry->grplo = grplo;
  158. __entry->grphi = grphi;
  159. __entry->gp_tasks = gp_tasks;
  160. ),
  161. TP_printk("%s %lu %lx>%lx %u %d %d %u",
  162. __entry->rcuname, __entry->gpnum,
  163. __entry->mask, __entry->qsmask, __entry->level,
  164. __entry->grplo, __entry->grphi, __entry->gp_tasks)
  165. );
  166. /*
  167. * Tracepoint for quiescent states detected by force_quiescent_state().
  168. * These trace events include the type of RCU, the grace-period number
  169. * that was blocked by the CPU, the CPU itself, and the type of quiescent
  170. * state, which can be "dti" for dyntick-idle mode, "ofl" for CPU offline,
  171. * or "kick" when kicking a CPU that has been in dyntick-idle mode for
  172. * too long.
  173. */
  174. TRACE_EVENT(rcu_fqs,
  175. TP_PROTO(char *rcuname, unsigned long gpnum, int cpu, char *qsevent),
  176. TP_ARGS(rcuname, gpnum, cpu, qsevent),
  177. TP_STRUCT__entry(
  178. __field(char *, rcuname)
  179. __field(unsigned long, gpnum)
  180. __field(int, cpu)
  181. __field(char *, qsevent)
  182. ),
  183. TP_fast_assign(
  184. __entry->rcuname = rcuname;
  185. __entry->gpnum = gpnum;
  186. __entry->cpu = cpu;
  187. __entry->qsevent = qsevent;
  188. ),
  189. TP_printk("%s %lu %d %s",
  190. __entry->rcuname, __entry->gpnum,
  191. __entry->cpu, __entry->qsevent)
  192. );
  193. #endif /* #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) */
  194. /*
  195. * Tracepoint for dyntick-idle entry/exit events. These take a string
  196. * as argument: "Start" for entering dyntick-idle mode, "End" for
  197. * leaving it, "--=" for events moving towards idle, and "++=" for events
  198. * moving away from idle. "Error on entry: not idle task" and "Error on
  199. * exit: not idle task" indicate that a non-idle task is erroneously
  200. * toying with the idle loop.
  201. *
  202. * These events also take a pair of numbers, which indicate the nesting
  203. * depth before and after the event of interest. Note that task-related
  204. * events use the upper bits of each number, while interrupt-related
  205. * events use the lower bits.
  206. */
  207. TRACE_EVENT(rcu_dyntick,
  208. TP_PROTO(char *polarity, long long oldnesting, long long newnesting),
  209. TP_ARGS(polarity, oldnesting, newnesting),
  210. TP_STRUCT__entry(
  211. __field(char *, polarity)
  212. __field(long long, oldnesting)
  213. __field(long long, newnesting)
  214. ),
  215. TP_fast_assign(
  216. __entry->polarity = polarity;
  217. __entry->oldnesting = oldnesting;
  218. __entry->newnesting = newnesting;
  219. ),
  220. TP_printk("%s %llx %llx", __entry->polarity,
  221. __entry->oldnesting, __entry->newnesting)
  222. );
  223. /*
  224. * Tracepoint for RCU preparation for idle, the goal being to get RCU
  225. * processing done so that the current CPU can shut off its scheduling
  226. * clock and enter dyntick-idle mode. One way to accomplish this is
  227. * to drain all RCU callbacks from this CPU, and the other is to have
  228. * done everything RCU requires for the current grace period. In this
  229. * latter case, the CPU will be awakened at the end of the current grace
  230. * period in order to process the remainder of its callbacks.
  231. *
  232. * These tracepoints take a string as argument:
  233. *
  234. * "No callbacks": Nothing to do, no callbacks on this CPU.
  235. * "In holdoff": Nothing to do, holding off after unsuccessful attempt.
  236. * "Begin holdoff": Attempt failed, don't retry until next jiffy.
  237. * "Dyntick with callbacks": Entering dyntick-idle despite callbacks.
  238. * "Dyntick with lazy callbacks": Entering dyntick-idle w/lazy callbacks.
  239. * "More callbacks": Still more callbacks, try again to clear them out.
  240. * "Callbacks drained": All callbacks processed, off to dyntick idle!
  241. * "Timer": Timer fired to cause CPU to continue processing callbacks.
  242. * "Demigrate": Timer fired on wrong CPU, woke up correct CPU.
  243. * "Cleanup after idle": Idle exited, timer canceled.
  244. */
  245. TRACE_EVENT(rcu_prep_idle,
  246. TP_PROTO(char *reason),
  247. TP_ARGS(reason),
  248. TP_STRUCT__entry(
  249. __field(char *, reason)
  250. ),
  251. TP_fast_assign(
  252. __entry->reason = reason;
  253. ),
  254. TP_printk("%s", __entry->reason)
  255. );
  256. /*
  257. * Tracepoint for the registration of a single RCU callback function.
  258. * The first argument is the type of RCU, the second argument is
  259. * a pointer to the RCU callback itself, the third element is the
  260. * number of lazy callbacks queued, and the fourth element is the
  261. * total number of callbacks queued.
  262. */
  263. TRACE_EVENT(rcu_callback,
  264. TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen_lazy,
  265. long qlen),
  266. TP_ARGS(rcuname, rhp, qlen_lazy, qlen),
  267. TP_STRUCT__entry(
  268. __field(char *, rcuname)
  269. __field(void *, rhp)
  270. __field(void *, func)
  271. __field(long, qlen_lazy)
  272. __field(long, qlen)
  273. ),
  274. TP_fast_assign(
  275. __entry->rcuname = rcuname;
  276. __entry->rhp = rhp;
  277. __entry->func = rhp->func;
  278. __entry->qlen_lazy = qlen_lazy;
  279. __entry->qlen = qlen;
  280. ),
  281. TP_printk("%s rhp=%p func=%pf %ld/%ld",
  282. __entry->rcuname, __entry->rhp, __entry->func,
  283. __entry->qlen_lazy, __entry->qlen)
  284. );
  285. /*
  286. * Tracepoint for the registration of a single RCU callback of the special
  287. * kfree() form. The first argument is the RCU type, the second argument
  288. * is a pointer to the RCU callback, the third argument is the offset
  289. * of the callback within the enclosing RCU-protected data structure,
  290. * the fourth argument is the number of lazy callbacks queued, and the
  291. * fifth argument is the total number of callbacks queued.
  292. */
  293. TRACE_EVENT(rcu_kfree_callback,
  294. TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset,
  295. long qlen_lazy, long qlen),
  296. TP_ARGS(rcuname, rhp, offset, qlen_lazy, qlen),
  297. TP_STRUCT__entry(
  298. __field(char *, rcuname)
  299. __field(void *, rhp)
  300. __field(unsigned long, offset)
  301. __field(long, qlen_lazy)
  302. __field(long, qlen)
  303. ),
  304. TP_fast_assign(
  305. __entry->rcuname = rcuname;
  306. __entry->rhp = rhp;
  307. __entry->offset = offset;
  308. __entry->qlen_lazy = qlen_lazy;
  309. __entry->qlen = qlen;
  310. ),
  311. TP_printk("%s rhp=%p func=%ld %ld/%ld",
  312. __entry->rcuname, __entry->rhp, __entry->offset,
  313. __entry->qlen_lazy, __entry->qlen)
  314. );
  315. /*
  316. * Tracepoint for marking the beginning rcu_do_batch, performed to start
  317. * RCU callback invocation. The first argument is the RCU flavor,
  318. * the second is the number of lazy callbacks queued, the third is
  319. * the total number of callbacks queued, and the fourth argument is
  320. * the current RCU-callback batch limit.
  321. */
  322. TRACE_EVENT(rcu_batch_start,
  323. TP_PROTO(char *rcuname, long qlen_lazy, long qlen, int blimit),
  324. TP_ARGS(rcuname, qlen_lazy, qlen, blimit),
  325. TP_STRUCT__entry(
  326. __field(char *, rcuname)
  327. __field(long, qlen_lazy)
  328. __field(long, qlen)
  329. __field(int, blimit)
  330. ),
  331. TP_fast_assign(
  332. __entry->rcuname = rcuname;
  333. __entry->qlen_lazy = qlen_lazy;
  334. __entry->qlen = qlen;
  335. __entry->blimit = blimit;
  336. ),
  337. TP_printk("%s CBs=%ld/%ld bl=%d",
  338. __entry->rcuname, __entry->qlen_lazy, __entry->qlen,
  339. __entry->blimit)
  340. );
  341. /*
  342. * Tracepoint for the invocation of a single RCU callback function.
  343. * The first argument is the type of RCU, and the second argument is
  344. * a pointer to the RCU callback itself.
  345. */
  346. TRACE_EVENT(rcu_invoke_callback,
  347. TP_PROTO(char *rcuname, struct rcu_head *rhp),
  348. TP_ARGS(rcuname, rhp),
  349. TP_STRUCT__entry(
  350. __field(char *, rcuname)
  351. __field(void *, rhp)
  352. __field(void *, func)
  353. ),
  354. TP_fast_assign(
  355. __entry->rcuname = rcuname;
  356. __entry->rhp = rhp;
  357. __entry->func = rhp->func;
  358. ),
  359. TP_printk("%s rhp=%p func=%pf",
  360. __entry->rcuname, __entry->rhp, __entry->func)
  361. );
  362. /*
  363. * Tracepoint for the invocation of a single RCU callback of the special
  364. * kfree() form. The first argument is the RCU flavor, the second
  365. * argument is a pointer to the RCU callback, and the third argument
  366. * is the offset of the callback within the enclosing RCU-protected
  367. * data structure.
  368. */
  369. TRACE_EVENT(rcu_invoke_kfree_callback,
  370. TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset),
  371. TP_ARGS(rcuname, rhp, offset),
  372. TP_STRUCT__entry(
  373. __field(char *, rcuname)
  374. __field(void *, rhp)
  375. __field(unsigned long, offset)
  376. ),
  377. TP_fast_assign(
  378. __entry->rcuname = rcuname;
  379. __entry->rhp = rhp;
  380. __entry->offset = offset;
  381. ),
  382. TP_printk("%s rhp=%p func=%ld",
  383. __entry->rcuname, __entry->rhp, __entry->offset)
  384. );
  385. /*
  386. * Tracepoint for exiting rcu_do_batch after RCU callbacks have been
  387. * invoked. The first argument is the name of the RCU flavor,
  388. * the second argument is number of callbacks actually invoked,
  389. * the third argument (cb) is whether or not any of the callbacks that
  390. * were ready to invoke at the beginning of this batch are still
  391. * queued, the fourth argument (nr) is the return value of need_resched(),
  392. * the fifth argument (iit) is 1 if the current task is the idle task,
  393. * and the sixth argument (risk) is the return value from
  394. * rcu_is_callbacks_kthread().
  395. */
  396. TRACE_EVENT(rcu_batch_end,
  397. TP_PROTO(char *rcuname, int callbacks_invoked,
  398. bool cb, bool nr, bool iit, bool risk),
  399. TP_ARGS(rcuname, callbacks_invoked, cb, nr, iit, risk),
  400. TP_STRUCT__entry(
  401. __field(char *, rcuname)
  402. __field(int, callbacks_invoked)
  403. __field(bool, cb)
  404. __field(bool, nr)
  405. __field(bool, iit)
  406. __field(bool, risk)
  407. ),
  408. TP_fast_assign(
  409. __entry->rcuname = rcuname;
  410. __entry->callbacks_invoked = callbacks_invoked;
  411. __entry->cb = cb;
  412. __entry->nr = nr;
  413. __entry->iit = iit;
  414. __entry->risk = risk;
  415. ),
  416. TP_printk("%s CBs-invoked=%d idle=%c%c%c%c",
  417. __entry->rcuname, __entry->callbacks_invoked,
  418. __entry->cb ? 'C' : '.',
  419. __entry->nr ? 'S' : '.',
  420. __entry->iit ? 'I' : '.',
  421. __entry->risk ? 'R' : '.')
  422. );
  423. /*
  424. * Tracepoint for rcutorture readers. The first argument is the name
  425. * of the RCU flavor from rcutorture's viewpoint and the second argument
  426. * is the callback address.
  427. */
  428. TRACE_EVENT(rcu_torture_read,
  429. TP_PROTO(char *rcutorturename, struct rcu_head *rhp),
  430. TP_ARGS(rcutorturename, rhp),
  431. TP_STRUCT__entry(
  432. __field(char *, rcutorturename)
  433. __field(struct rcu_head *, rhp)
  434. ),
  435. TP_fast_assign(
  436. __entry->rcutorturename = rcutorturename;
  437. __entry->rhp = rhp;
  438. ),
  439. TP_printk("%s torture read %p",
  440. __entry->rcutorturename, __entry->rhp)
  441. );
  442. #else /* #ifdef CONFIG_RCU_TRACE */
  443. #define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0)
  444. #define trace_rcu_grace_period_init(rcuname, gpnum, level, grplo, grphi, \
  445. qsmask) do { } while (0)
  446. #define trace_rcu_preempt_task(rcuname, pid, gpnum) do { } while (0)
  447. #define trace_rcu_unlock_preempted_task(rcuname, gpnum, pid) do { } while (0)
  448. #define trace_rcu_quiescent_state_report(rcuname, gpnum, mask, qsmask, level, \
  449. grplo, grphi, gp_tasks) do { } \
  450. while (0)
  451. #define trace_rcu_fqs(rcuname, gpnum, cpu, qsevent) do { } while (0)
  452. #define trace_rcu_dyntick(polarity, oldnesting, newnesting) do { } while (0)
  453. #define trace_rcu_prep_idle(reason) do { } while (0)
  454. #define trace_rcu_callback(rcuname, rhp, qlen_lazy, qlen) do { } while (0)
  455. #define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \
  456. do { } while (0)
  457. #define trace_rcu_batch_start(rcuname, qlen_lazy, qlen, blimit) \
  458. do { } while (0)
  459. #define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0)
  460. #define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0)
  461. #define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \
  462. do { } while (0)
  463. #define trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
  464. #endif /* #else #ifdef CONFIG_RCU_TRACE */
  465. #endif /* _TRACE_RCU_H */
  466. /* This part must be outside protection */
  467. #include <trace/define_trace.h>