writeback.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM writeback
  3. #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_WRITEBACK_H
  5. #include <linux/backing-dev.h>
  6. #include <linux/device.h>
  7. #include <linux/writeback.h>
  8. struct wb_writeback_work;
  9. DECLARE_EVENT_CLASS(writeback_work_class,
  10. TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
  11. TP_ARGS(bdi, work),
  12. TP_STRUCT__entry(
  13. __array(char, name, 32)
  14. __field(long, nr_pages)
  15. __field(dev_t, sb_dev)
  16. __field(int, sync_mode)
  17. __field(int, for_kupdate)
  18. __field(int, range_cyclic)
  19. __field(int, for_background)
  20. ),
  21. TP_fast_assign(
  22. struct device *dev = bdi->dev;
  23. if (!dev)
  24. dev = default_backing_dev_info.dev;
  25. strncpy(__entry->name, dev_name(dev), 32);
  26. __entry->nr_pages = work->nr_pages;
  27. __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
  28. __entry->sync_mode = work->sync_mode;
  29. __entry->for_kupdate = work->for_kupdate;
  30. __entry->range_cyclic = work->range_cyclic;
  31. __entry->for_background = work->for_background;
  32. ),
  33. TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
  34. "kupdate=%d range_cyclic=%d background=%d",
  35. __entry->name,
  36. MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
  37. __entry->nr_pages,
  38. __entry->sync_mode,
  39. __entry->for_kupdate,
  40. __entry->range_cyclic,
  41. __entry->for_background
  42. )
  43. );
  44. #define DEFINE_WRITEBACK_WORK_EVENT(name) \
  45. DEFINE_EVENT(writeback_work_class, name, \
  46. TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
  47. TP_ARGS(bdi, work))
  48. DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
  49. DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
  50. DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
  51. TRACE_EVENT(writeback_pages_written,
  52. TP_PROTO(long pages_written),
  53. TP_ARGS(pages_written),
  54. TP_STRUCT__entry(
  55. __field(long, pages)
  56. ),
  57. TP_fast_assign(
  58. __entry->pages = pages_written;
  59. ),
  60. TP_printk("%ld", __entry->pages)
  61. );
  62. DECLARE_EVENT_CLASS(writeback_class,
  63. TP_PROTO(struct backing_dev_info *bdi),
  64. TP_ARGS(bdi),
  65. TP_STRUCT__entry(
  66. __array(char, name, 32)
  67. ),
  68. TP_fast_assign(
  69. strncpy(__entry->name, dev_name(bdi->dev), 32);
  70. ),
  71. TP_printk("bdi %s",
  72. __entry->name
  73. )
  74. );
  75. #define DEFINE_WRITEBACK_EVENT(name) \
  76. DEFINE_EVENT(writeback_class, name, \
  77. TP_PROTO(struct backing_dev_info *bdi), \
  78. TP_ARGS(bdi))
  79. DEFINE_WRITEBACK_EVENT(writeback_nowork);
  80. DEFINE_WRITEBACK_EVENT(writeback_wake_background);
  81. DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
  82. DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
  83. DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
  84. DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
  85. DEFINE_WRITEBACK_EVENT(writeback_thread_start);
  86. DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
  87. DECLARE_EVENT_CLASS(wbc_class,
  88. TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
  89. TP_ARGS(wbc, bdi),
  90. TP_STRUCT__entry(
  91. __array(char, name, 32)
  92. __field(long, nr_to_write)
  93. __field(long, pages_skipped)
  94. __field(int, sync_mode)
  95. __field(int, for_kupdate)
  96. __field(int, for_background)
  97. __field(int, for_reclaim)
  98. __field(int, range_cyclic)
  99. __field(int, more_io)
  100. __field(unsigned long, older_than_this)
  101. __field(long, range_start)
  102. __field(long, range_end)
  103. ),
  104. TP_fast_assign(
  105. strncpy(__entry->name, dev_name(bdi->dev), 32);
  106. __entry->nr_to_write = wbc->nr_to_write;
  107. __entry->pages_skipped = wbc->pages_skipped;
  108. __entry->sync_mode = wbc->sync_mode;
  109. __entry->for_kupdate = wbc->for_kupdate;
  110. __entry->for_background = wbc->for_background;
  111. __entry->for_reclaim = wbc->for_reclaim;
  112. __entry->range_cyclic = wbc->range_cyclic;
  113. __entry->more_io = wbc->more_io;
  114. __entry->older_than_this = wbc->older_than_this ?
  115. *wbc->older_than_this : 0;
  116. __entry->range_start = (long)wbc->range_start;
  117. __entry->range_end = (long)wbc->range_end;
  118. ),
  119. TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
  120. "bgrd=%d reclm=%d cyclic=%d more=%d older=0x%lx "
  121. "start=0x%lx end=0x%lx",
  122. __entry->name,
  123. __entry->nr_to_write,
  124. __entry->pages_skipped,
  125. __entry->sync_mode,
  126. __entry->for_kupdate,
  127. __entry->for_background,
  128. __entry->for_reclaim,
  129. __entry->range_cyclic,
  130. __entry->more_io,
  131. __entry->older_than_this,
  132. __entry->range_start,
  133. __entry->range_end)
  134. )
  135. #define DEFINE_WBC_EVENT(name) \
  136. DEFINE_EVENT(wbc_class, name, \
  137. TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
  138. TP_ARGS(wbc, bdi))
  139. DEFINE_WBC_EVENT(wbc_writeback_start);
  140. DEFINE_WBC_EVENT(wbc_writeback_written);
  141. DEFINE_WBC_EVENT(wbc_writeback_wait);
  142. DEFINE_WBC_EVENT(wbc_balance_dirty_start);
  143. DEFINE_WBC_EVENT(wbc_balance_dirty_written);
  144. DEFINE_WBC_EVENT(wbc_balance_dirty_wait);
  145. DEFINE_WBC_EVENT(wbc_writepage);
  146. DECLARE_EVENT_CLASS(writeback_congest_waited_template,
  147. TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
  148. TP_ARGS(usec_timeout, usec_delayed),
  149. TP_STRUCT__entry(
  150. __field( unsigned int, usec_timeout )
  151. __field( unsigned int, usec_delayed )
  152. ),
  153. TP_fast_assign(
  154. __entry->usec_timeout = usec_timeout;
  155. __entry->usec_delayed = usec_delayed;
  156. ),
  157. TP_printk("usec_timeout=%u usec_delayed=%u",
  158. __entry->usec_timeout,
  159. __entry->usec_delayed)
  160. );
  161. DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
  162. TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
  163. TP_ARGS(usec_timeout, usec_delayed)
  164. );
  165. DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
  166. TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
  167. TP_ARGS(usec_timeout, usec_delayed)
  168. );
  169. #endif /* _TRACE_WRITEBACK_H */
  170. /* This part must be outside protection */
  171. #include <trace/define_trace.h>