writeback.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM writeback
  4. #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_WRITEBACK_H
  6. #include <linux/tracepoint.h>
  7. #include <linux/backing-dev.h>
  8. #include <linux/writeback.h>
  9. #define show_inode_state(state) \
  10. __print_flags(state, "|", \
  11. {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \
  12. {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \
  13. {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \
  14. {I_NEW, "I_NEW"}, \
  15. {I_WILL_FREE, "I_WILL_FREE"}, \
  16. {I_FREEING, "I_FREEING"}, \
  17. {I_CLEAR, "I_CLEAR"}, \
  18. {I_SYNC, "I_SYNC"}, \
  19. {I_DIRTY_TIME, "I_DIRTY_TIME"}, \
  20. {I_DIRTY_TIME_EXPIRED, "I_DIRTY_TIME_EXPIRED"}, \
  21. {I_REFERENCED, "I_REFERENCED"} \
  22. )
  23. /* enums need to be exported to user space */
  24. #undef EM
  25. #undef EMe
  26. #define EM(a,b) TRACE_DEFINE_ENUM(a);
  27. #define EMe(a,b) TRACE_DEFINE_ENUM(a);
  28. #define WB_WORK_REASON \
  29. EM( WB_REASON_BACKGROUND, "background") \
  30. EM( WB_REASON_VMSCAN, "vmscan") \
  31. EM( WB_REASON_SYNC, "sync") \
  32. EM( WB_REASON_PERIODIC, "periodic") \
  33. EM( WB_REASON_LAPTOP_TIMER, "laptop_timer") \
  34. EM( WB_REASON_FREE_MORE_MEM, "free_more_memory") \
  35. EM( WB_REASON_FS_FREE_SPACE, "fs_free_space") \
  36. EMe(WB_REASON_FORKER_THREAD, "forker_thread")
  37. WB_WORK_REASON
  38. /*
  39. * Now redefine the EM() and EMe() macros to map the enums to the strings
  40. * that will be printed in the output.
  41. */
  42. #undef EM
  43. #undef EMe
  44. #define EM(a,b) { a, b },
  45. #define EMe(a,b) { a, b }
  46. struct wb_writeback_work;
  47. TRACE_EVENT(writeback_dirty_page,
  48. TP_PROTO(struct page *page, struct address_space *mapping),
  49. TP_ARGS(page, mapping),
  50. TP_STRUCT__entry (
  51. __array(char, name, 32)
  52. __field(unsigned long, ino)
  53. __field(pgoff_t, index)
  54. ),
  55. TP_fast_assign(
  56. strncpy(__entry->name,
  57. mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32);
  58. __entry->ino = mapping ? mapping->host->i_ino : 0;
  59. __entry->index = page->index;
  60. ),
  61. TP_printk("bdi %s: ino=%lu index=%lu",
  62. __entry->name,
  63. __entry->ino,
  64. __entry->index
  65. )
  66. );
  67. DECLARE_EVENT_CLASS(writeback_dirty_inode_template,
  68. TP_PROTO(struct inode *inode, int flags),
  69. TP_ARGS(inode, flags),
  70. TP_STRUCT__entry (
  71. __array(char, name, 32)
  72. __field(unsigned long, ino)
  73. __field(unsigned long, state)
  74. __field(unsigned long, flags)
  75. ),
  76. TP_fast_assign(
  77. struct backing_dev_info *bdi = inode_to_bdi(inode);
  78. /* may be called for files on pseudo FSes w/ unregistered bdi */
  79. strncpy(__entry->name,
  80. bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32);
  81. __entry->ino = inode->i_ino;
  82. __entry->state = inode->i_state;
  83. __entry->flags = flags;
  84. ),
  85. TP_printk("bdi %s: ino=%lu state=%s flags=%s",
  86. __entry->name,
  87. __entry->ino,
  88. show_inode_state(__entry->state),
  89. show_inode_state(__entry->flags)
  90. )
  91. );
  92. DEFINE_EVENT(writeback_dirty_inode_template, writeback_mark_inode_dirty,
  93. TP_PROTO(struct inode *inode, int flags),
  94. TP_ARGS(inode, flags)
  95. );
  96. DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode_start,
  97. TP_PROTO(struct inode *inode, int flags),
  98. TP_ARGS(inode, flags)
  99. );
  100. DEFINE_EVENT(writeback_dirty_inode_template, writeback_dirty_inode,
  101. TP_PROTO(struct inode *inode, int flags),
  102. TP_ARGS(inode, flags)
  103. );
  104. #ifdef CREATE_TRACE_POINTS
  105. #ifdef CONFIG_CGROUP_WRITEBACK
  106. static inline unsigned int __trace_wb_assign_cgroup(struct bdi_writeback *wb)
  107. {
  108. return wb->memcg_css->cgroup->kn->id.ino;
  109. }
  110. static inline unsigned int __trace_wbc_assign_cgroup(struct writeback_control *wbc)
  111. {
  112. if (wbc->wb)
  113. return __trace_wb_assign_cgroup(wbc->wb);
  114. else
  115. return -1U;
  116. }
  117. #else /* CONFIG_CGROUP_WRITEBACK */
  118. static inline unsigned int __trace_wb_assign_cgroup(struct bdi_writeback *wb)
  119. {
  120. return -1U;
  121. }
  122. static inline unsigned int __trace_wbc_assign_cgroup(struct writeback_control *wbc)
  123. {
  124. return -1U;
  125. }
  126. #endif /* CONFIG_CGROUP_WRITEBACK */
  127. #endif /* CREATE_TRACE_POINTS */
  128. DECLARE_EVENT_CLASS(writeback_write_inode_template,
  129. TP_PROTO(struct inode *inode, struct writeback_control *wbc),
  130. TP_ARGS(inode, wbc),
  131. TP_STRUCT__entry (
  132. __array(char, name, 32)
  133. __field(unsigned long, ino)
  134. __field(int, sync_mode)
  135. __field(unsigned int, cgroup_ino)
  136. ),
  137. TP_fast_assign(
  138. strncpy(__entry->name,
  139. dev_name(inode_to_bdi(inode)->dev), 32);
  140. __entry->ino = inode->i_ino;
  141. __entry->sync_mode = wbc->sync_mode;
  142. __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
  143. ),
  144. TP_printk("bdi %s: ino=%lu sync_mode=%d cgroup_ino=%u",
  145. __entry->name,
  146. __entry->ino,
  147. __entry->sync_mode,
  148. __entry->cgroup_ino
  149. )
  150. );
  151. DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode_start,
  152. TP_PROTO(struct inode *inode, struct writeback_control *wbc),
  153. TP_ARGS(inode, wbc)
  154. );
  155. DEFINE_EVENT(writeback_write_inode_template, writeback_write_inode,
  156. TP_PROTO(struct inode *inode, struct writeback_control *wbc),
  157. TP_ARGS(inode, wbc)
  158. );
  159. DECLARE_EVENT_CLASS(writeback_work_class,
  160. TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work),
  161. TP_ARGS(wb, work),
  162. TP_STRUCT__entry(
  163. __array(char, name, 32)
  164. __field(long, nr_pages)
  165. __field(dev_t, sb_dev)
  166. __field(int, sync_mode)
  167. __field(int, for_kupdate)
  168. __field(int, range_cyclic)
  169. __field(int, for_background)
  170. __field(int, reason)
  171. __field(unsigned int, cgroup_ino)
  172. ),
  173. TP_fast_assign(
  174. strncpy(__entry->name,
  175. wb->bdi->dev ? dev_name(wb->bdi->dev) : "(unknown)", 32);
  176. __entry->nr_pages = work->nr_pages;
  177. __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
  178. __entry->sync_mode = work->sync_mode;
  179. __entry->for_kupdate = work->for_kupdate;
  180. __entry->range_cyclic = work->range_cyclic;
  181. __entry->for_background = work->for_background;
  182. __entry->reason = work->reason;
  183. __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
  184. ),
  185. TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
  186. "kupdate=%d range_cyclic=%d background=%d reason=%s cgroup_ino=%u",
  187. __entry->name,
  188. MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
  189. __entry->nr_pages,
  190. __entry->sync_mode,
  191. __entry->for_kupdate,
  192. __entry->range_cyclic,
  193. __entry->for_background,
  194. __print_symbolic(__entry->reason, WB_WORK_REASON),
  195. __entry->cgroup_ino
  196. )
  197. );
  198. #define DEFINE_WRITEBACK_WORK_EVENT(name) \
  199. DEFINE_EVENT(writeback_work_class, name, \
  200. TP_PROTO(struct bdi_writeback *wb, struct wb_writeback_work *work), \
  201. TP_ARGS(wb, work))
  202. DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
  203. DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
  204. DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
  205. DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
  206. DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
  207. TRACE_EVENT(writeback_pages_written,
  208. TP_PROTO(long pages_written),
  209. TP_ARGS(pages_written),
  210. TP_STRUCT__entry(
  211. __field(long, pages)
  212. ),
  213. TP_fast_assign(
  214. __entry->pages = pages_written;
  215. ),
  216. TP_printk("%ld", __entry->pages)
  217. );
  218. DECLARE_EVENT_CLASS(writeback_class,
  219. TP_PROTO(struct bdi_writeback *wb),
  220. TP_ARGS(wb),
  221. TP_STRUCT__entry(
  222. __array(char, name, 32)
  223. __field(unsigned int, cgroup_ino)
  224. ),
  225. TP_fast_assign(
  226. strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
  227. __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
  228. ),
  229. TP_printk("bdi %s: cgroup_ino=%u",
  230. __entry->name,
  231. __entry->cgroup_ino
  232. )
  233. );
  234. #define DEFINE_WRITEBACK_EVENT(name) \
  235. DEFINE_EVENT(writeback_class, name, \
  236. TP_PROTO(struct bdi_writeback *wb), \
  237. TP_ARGS(wb))
  238. DEFINE_WRITEBACK_EVENT(writeback_wake_background);
  239. TRACE_EVENT(writeback_bdi_register,
  240. TP_PROTO(struct backing_dev_info *bdi),
  241. TP_ARGS(bdi),
  242. TP_STRUCT__entry(
  243. __array(char, name, 32)
  244. ),
  245. TP_fast_assign(
  246. strncpy(__entry->name, dev_name(bdi->dev), 32);
  247. ),
  248. TP_printk("bdi %s",
  249. __entry->name
  250. )
  251. );
  252. DECLARE_EVENT_CLASS(wbc_class,
  253. TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
  254. TP_ARGS(wbc, bdi),
  255. TP_STRUCT__entry(
  256. __array(char, name, 32)
  257. __field(long, nr_to_write)
  258. __field(long, pages_skipped)
  259. __field(int, sync_mode)
  260. __field(int, for_kupdate)
  261. __field(int, for_background)
  262. __field(int, for_reclaim)
  263. __field(int, range_cyclic)
  264. __field(long, range_start)
  265. __field(long, range_end)
  266. __field(unsigned int, cgroup_ino)
  267. ),
  268. TP_fast_assign(
  269. strncpy(__entry->name, dev_name(bdi->dev), 32);
  270. __entry->nr_to_write = wbc->nr_to_write;
  271. __entry->pages_skipped = wbc->pages_skipped;
  272. __entry->sync_mode = wbc->sync_mode;
  273. __entry->for_kupdate = wbc->for_kupdate;
  274. __entry->for_background = wbc->for_background;
  275. __entry->for_reclaim = wbc->for_reclaim;
  276. __entry->range_cyclic = wbc->range_cyclic;
  277. __entry->range_start = (long)wbc->range_start;
  278. __entry->range_end = (long)wbc->range_end;
  279. __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
  280. ),
  281. TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
  282. "bgrd=%d reclm=%d cyclic=%d "
  283. "start=0x%lx end=0x%lx cgroup_ino=%u",
  284. __entry->name,
  285. __entry->nr_to_write,
  286. __entry->pages_skipped,
  287. __entry->sync_mode,
  288. __entry->for_kupdate,
  289. __entry->for_background,
  290. __entry->for_reclaim,
  291. __entry->range_cyclic,
  292. __entry->range_start,
  293. __entry->range_end,
  294. __entry->cgroup_ino
  295. )
  296. )
  297. #define DEFINE_WBC_EVENT(name) \
  298. DEFINE_EVENT(wbc_class, name, \
  299. TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
  300. TP_ARGS(wbc, bdi))
  301. DEFINE_WBC_EVENT(wbc_writepage);
  302. TRACE_EVENT(writeback_queue_io,
  303. TP_PROTO(struct bdi_writeback *wb,
  304. struct wb_writeback_work *work,
  305. int moved),
  306. TP_ARGS(wb, work, moved),
  307. TP_STRUCT__entry(
  308. __array(char, name, 32)
  309. __field(unsigned long, older)
  310. __field(long, age)
  311. __field(int, moved)
  312. __field(int, reason)
  313. __field(unsigned int, cgroup_ino)
  314. ),
  315. TP_fast_assign(
  316. unsigned long *older_than_this = work->older_than_this;
  317. strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
  318. __entry->older = older_than_this ? *older_than_this : 0;
  319. __entry->age = older_than_this ?
  320. (jiffies - *older_than_this) * 1000 / HZ : -1;
  321. __entry->moved = moved;
  322. __entry->reason = work->reason;
  323. __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
  324. ),
  325. TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%u",
  326. __entry->name,
  327. __entry->older, /* older_than_this in jiffies */
  328. __entry->age, /* older_than_this in relative milliseconds */
  329. __entry->moved,
  330. __print_symbolic(__entry->reason, WB_WORK_REASON),
  331. __entry->cgroup_ino
  332. )
  333. );
  334. TRACE_EVENT(global_dirty_state,
  335. TP_PROTO(unsigned long background_thresh,
  336. unsigned long dirty_thresh
  337. ),
  338. TP_ARGS(background_thresh,
  339. dirty_thresh
  340. ),
  341. TP_STRUCT__entry(
  342. __field(unsigned long, nr_dirty)
  343. __field(unsigned long, nr_writeback)
  344. __field(unsigned long, nr_unstable)
  345. __field(unsigned long, background_thresh)
  346. __field(unsigned long, dirty_thresh)
  347. __field(unsigned long, dirty_limit)
  348. __field(unsigned long, nr_dirtied)
  349. __field(unsigned long, nr_written)
  350. ),
  351. TP_fast_assign(
  352. __entry->nr_dirty = global_node_page_state(NR_FILE_DIRTY);
  353. __entry->nr_writeback = global_node_page_state(NR_WRITEBACK);
  354. __entry->nr_unstable = global_node_page_state(NR_UNSTABLE_NFS);
  355. __entry->nr_dirtied = global_node_page_state(NR_DIRTIED);
  356. __entry->nr_written = global_node_page_state(NR_WRITTEN);
  357. __entry->background_thresh = background_thresh;
  358. __entry->dirty_thresh = dirty_thresh;
  359. __entry->dirty_limit = global_wb_domain.dirty_limit;
  360. ),
  361. TP_printk("dirty=%lu writeback=%lu unstable=%lu "
  362. "bg_thresh=%lu thresh=%lu limit=%lu "
  363. "dirtied=%lu written=%lu",
  364. __entry->nr_dirty,
  365. __entry->nr_writeback,
  366. __entry->nr_unstable,
  367. __entry->background_thresh,
  368. __entry->dirty_thresh,
  369. __entry->dirty_limit,
  370. __entry->nr_dirtied,
  371. __entry->nr_written
  372. )
  373. );
  374. #define KBps(x) ((x) << (PAGE_SHIFT - 10))
  375. TRACE_EVENT(bdi_dirty_ratelimit,
  376. TP_PROTO(struct bdi_writeback *wb,
  377. unsigned long dirty_rate,
  378. unsigned long task_ratelimit),
  379. TP_ARGS(wb, dirty_rate, task_ratelimit),
  380. TP_STRUCT__entry(
  381. __array(char, bdi, 32)
  382. __field(unsigned long, write_bw)
  383. __field(unsigned long, avg_write_bw)
  384. __field(unsigned long, dirty_rate)
  385. __field(unsigned long, dirty_ratelimit)
  386. __field(unsigned long, task_ratelimit)
  387. __field(unsigned long, balanced_dirty_ratelimit)
  388. __field(unsigned int, cgroup_ino)
  389. ),
  390. TP_fast_assign(
  391. strlcpy(__entry->bdi, dev_name(wb->bdi->dev), 32);
  392. __entry->write_bw = KBps(wb->write_bandwidth);
  393. __entry->avg_write_bw = KBps(wb->avg_write_bandwidth);
  394. __entry->dirty_rate = KBps(dirty_rate);
  395. __entry->dirty_ratelimit = KBps(wb->dirty_ratelimit);
  396. __entry->task_ratelimit = KBps(task_ratelimit);
  397. __entry->balanced_dirty_ratelimit =
  398. KBps(wb->balanced_dirty_ratelimit);
  399. __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
  400. ),
  401. TP_printk("bdi %s: "
  402. "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
  403. "dirty_ratelimit=%lu task_ratelimit=%lu "
  404. "balanced_dirty_ratelimit=%lu cgroup_ino=%u",
  405. __entry->bdi,
  406. __entry->write_bw, /* write bandwidth */
  407. __entry->avg_write_bw, /* avg write bandwidth */
  408. __entry->dirty_rate, /* bdi dirty rate */
  409. __entry->dirty_ratelimit, /* base ratelimit */
  410. __entry->task_ratelimit, /* ratelimit with position control */
  411. __entry->balanced_dirty_ratelimit, /* the balanced ratelimit */
  412. __entry->cgroup_ino
  413. )
  414. );
  415. TRACE_EVENT(balance_dirty_pages,
  416. TP_PROTO(struct bdi_writeback *wb,
  417. unsigned long thresh,
  418. unsigned long bg_thresh,
  419. unsigned long dirty,
  420. unsigned long bdi_thresh,
  421. unsigned long bdi_dirty,
  422. unsigned long dirty_ratelimit,
  423. unsigned long task_ratelimit,
  424. unsigned long dirtied,
  425. unsigned long period,
  426. long pause,
  427. unsigned long start_time),
  428. TP_ARGS(wb, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
  429. dirty_ratelimit, task_ratelimit,
  430. dirtied, period, pause, start_time),
  431. TP_STRUCT__entry(
  432. __array( char, bdi, 32)
  433. __field(unsigned long, limit)
  434. __field(unsigned long, setpoint)
  435. __field(unsigned long, dirty)
  436. __field(unsigned long, bdi_setpoint)
  437. __field(unsigned long, bdi_dirty)
  438. __field(unsigned long, dirty_ratelimit)
  439. __field(unsigned long, task_ratelimit)
  440. __field(unsigned int, dirtied)
  441. __field(unsigned int, dirtied_pause)
  442. __field(unsigned long, paused)
  443. __field( long, pause)
  444. __field(unsigned long, period)
  445. __field( long, think)
  446. __field(unsigned int, cgroup_ino)
  447. ),
  448. TP_fast_assign(
  449. unsigned long freerun = (thresh + bg_thresh) / 2;
  450. strlcpy(__entry->bdi, dev_name(wb->bdi->dev), 32);
  451. __entry->limit = global_wb_domain.dirty_limit;
  452. __entry->setpoint = (global_wb_domain.dirty_limit +
  453. freerun) / 2;
  454. __entry->dirty = dirty;
  455. __entry->bdi_setpoint = __entry->setpoint *
  456. bdi_thresh / (thresh + 1);
  457. __entry->bdi_dirty = bdi_dirty;
  458. __entry->dirty_ratelimit = KBps(dirty_ratelimit);
  459. __entry->task_ratelimit = KBps(task_ratelimit);
  460. __entry->dirtied = dirtied;
  461. __entry->dirtied_pause = current->nr_dirtied_pause;
  462. __entry->think = current->dirty_paused_when == 0 ? 0 :
  463. (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
  464. __entry->period = period * 1000 / HZ;
  465. __entry->pause = pause * 1000 / HZ;
  466. __entry->paused = (jiffies - start_time) * 1000 / HZ;
  467. __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
  468. ),
  469. TP_printk("bdi %s: "
  470. "limit=%lu setpoint=%lu dirty=%lu "
  471. "bdi_setpoint=%lu bdi_dirty=%lu "
  472. "dirty_ratelimit=%lu task_ratelimit=%lu "
  473. "dirtied=%u dirtied_pause=%u "
  474. "paused=%lu pause=%ld period=%lu think=%ld cgroup_ino=%u",
  475. __entry->bdi,
  476. __entry->limit,
  477. __entry->setpoint,
  478. __entry->dirty,
  479. __entry->bdi_setpoint,
  480. __entry->bdi_dirty,
  481. __entry->dirty_ratelimit,
  482. __entry->task_ratelimit,
  483. __entry->dirtied,
  484. __entry->dirtied_pause,
  485. __entry->paused, /* ms */
  486. __entry->pause, /* ms */
  487. __entry->period, /* ms */
  488. __entry->think, /* ms */
  489. __entry->cgroup_ino
  490. )
  491. );
  492. TRACE_EVENT(writeback_sb_inodes_requeue,
  493. TP_PROTO(struct inode *inode),
  494. TP_ARGS(inode),
  495. TP_STRUCT__entry(
  496. __array(char, name, 32)
  497. __field(unsigned long, ino)
  498. __field(unsigned long, state)
  499. __field(unsigned long, dirtied_when)
  500. __field(unsigned int, cgroup_ino)
  501. ),
  502. TP_fast_assign(
  503. strncpy(__entry->name,
  504. dev_name(inode_to_bdi(inode)->dev), 32);
  505. __entry->ino = inode->i_ino;
  506. __entry->state = inode->i_state;
  507. __entry->dirtied_when = inode->dirtied_when;
  508. __entry->cgroup_ino = __trace_wb_assign_cgroup(inode_to_wb(inode));
  509. ),
  510. TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu cgroup_ino=%u",
  511. __entry->name,
  512. __entry->ino,
  513. show_inode_state(__entry->state),
  514. __entry->dirtied_when,
  515. (jiffies - __entry->dirtied_when) / HZ,
  516. __entry->cgroup_ino
  517. )
  518. );
  519. DECLARE_EVENT_CLASS(writeback_congest_waited_template,
  520. TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
  521. TP_ARGS(usec_timeout, usec_delayed),
  522. TP_STRUCT__entry(
  523. __field( unsigned int, usec_timeout )
  524. __field( unsigned int, usec_delayed )
  525. ),
  526. TP_fast_assign(
  527. __entry->usec_timeout = usec_timeout;
  528. __entry->usec_delayed = usec_delayed;
  529. ),
  530. TP_printk("usec_timeout=%u usec_delayed=%u",
  531. __entry->usec_timeout,
  532. __entry->usec_delayed)
  533. );
  534. DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
  535. TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
  536. TP_ARGS(usec_timeout, usec_delayed)
  537. );
  538. DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
  539. TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
  540. TP_ARGS(usec_timeout, usec_delayed)
  541. );
  542. DECLARE_EVENT_CLASS(writeback_single_inode_template,
  543. TP_PROTO(struct inode *inode,
  544. struct writeback_control *wbc,
  545. unsigned long nr_to_write
  546. ),
  547. TP_ARGS(inode, wbc, nr_to_write),
  548. TP_STRUCT__entry(
  549. __array(char, name, 32)
  550. __field(unsigned long, ino)
  551. __field(unsigned long, state)
  552. __field(unsigned long, dirtied_when)
  553. __field(unsigned long, writeback_index)
  554. __field(long, nr_to_write)
  555. __field(unsigned long, wrote)
  556. __field(unsigned int, cgroup_ino)
  557. ),
  558. TP_fast_assign(
  559. strncpy(__entry->name,
  560. dev_name(inode_to_bdi(inode)->dev), 32);
  561. __entry->ino = inode->i_ino;
  562. __entry->state = inode->i_state;
  563. __entry->dirtied_when = inode->dirtied_when;
  564. __entry->writeback_index = inode->i_mapping->writeback_index;
  565. __entry->nr_to_write = nr_to_write;
  566. __entry->wrote = nr_to_write - wbc->nr_to_write;
  567. __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc);
  568. ),
  569. TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
  570. "index=%lu to_write=%ld wrote=%lu cgroup_ino=%u",
  571. __entry->name,
  572. __entry->ino,
  573. show_inode_state(__entry->state),
  574. __entry->dirtied_when,
  575. (jiffies - __entry->dirtied_when) / HZ,
  576. __entry->writeback_index,
  577. __entry->nr_to_write,
  578. __entry->wrote,
  579. __entry->cgroup_ino
  580. )
  581. );
  582. DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_start,
  583. TP_PROTO(struct inode *inode,
  584. struct writeback_control *wbc,
  585. unsigned long nr_to_write),
  586. TP_ARGS(inode, wbc, nr_to_write)
  587. );
  588. DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
  589. TP_PROTO(struct inode *inode,
  590. struct writeback_control *wbc,
  591. unsigned long nr_to_write),
  592. TP_ARGS(inode, wbc, nr_to_write)
  593. );
  594. DECLARE_EVENT_CLASS(writeback_inode_template,
  595. TP_PROTO(struct inode *inode),
  596. TP_ARGS(inode),
  597. TP_STRUCT__entry(
  598. __field( dev_t, dev )
  599. __field(unsigned long, ino )
  600. __field(unsigned long, state )
  601. __field( __u16, mode )
  602. __field(unsigned long, dirtied_when )
  603. ),
  604. TP_fast_assign(
  605. __entry->dev = inode->i_sb->s_dev;
  606. __entry->ino = inode->i_ino;
  607. __entry->state = inode->i_state;
  608. __entry->mode = inode->i_mode;
  609. __entry->dirtied_when = inode->dirtied_when;
  610. ),
  611. TP_printk("dev %d,%d ino %lu dirtied %lu state %s mode 0%o",
  612. MAJOR(__entry->dev), MINOR(__entry->dev),
  613. __entry->ino, __entry->dirtied_when,
  614. show_inode_state(__entry->state), __entry->mode)
  615. );
  616. DEFINE_EVENT(writeback_inode_template, writeback_lazytime,
  617. TP_PROTO(struct inode *inode),
  618. TP_ARGS(inode)
  619. );
  620. DEFINE_EVENT(writeback_inode_template, writeback_lazytime_iput,
  621. TP_PROTO(struct inode *inode),
  622. TP_ARGS(inode)
  623. );
  624. DEFINE_EVENT(writeback_inode_template, writeback_dirty_inode_enqueue,
  625. TP_PROTO(struct inode *inode),
  626. TP_ARGS(inode)
  627. );
  628. /*
  629. * Inode writeback list tracking.
  630. */
  631. DEFINE_EVENT(writeback_inode_template, sb_mark_inode_writeback,
  632. TP_PROTO(struct inode *inode),
  633. TP_ARGS(inode)
  634. );
  635. DEFINE_EVENT(writeback_inode_template, sb_clear_inode_writeback,
  636. TP_PROTO(struct inode *inode),
  637. TP_ARGS(inode)
  638. );
  639. #endif /* _TRACE_WRITEBACK_H */
  640. /* This part must be outside protection */
  641. #include <trace/define_trace.h>