wbt.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM wbt
  4. #if !defined(_TRACE_WBT_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_WBT_H
  6. #include <linux/tracepoint.h>
  7. #include "../../../block/blk-wbt.h"
  8. /**
  9. * wbt_stat - trace stats for blk_wb
  10. * @stat: array of read/write stats
  11. */
  12. TRACE_EVENT(wbt_stat,
  13. TP_PROTO(struct backing_dev_info *bdi, struct blk_rq_stat *stat),
  14. TP_ARGS(bdi, stat),
  15. TP_STRUCT__entry(
  16. __array(char, name, 32)
  17. __field(s64, rmean)
  18. __field(u64, rmin)
  19. __field(u64, rmax)
  20. __field(s64, rnr_samples)
  21. __field(s64, rtime)
  22. __field(s64, wmean)
  23. __field(u64, wmin)
  24. __field(u64, wmax)
  25. __field(s64, wnr_samples)
  26. __field(s64, wtime)
  27. ),
  28. TP_fast_assign(
  29. strlcpy(__entry->name, dev_name(bdi->dev),
  30. ARRAY_SIZE(__entry->name));
  31. __entry->rmean = stat[0].mean;
  32. __entry->rmin = stat[0].min;
  33. __entry->rmax = stat[0].max;
  34. __entry->rnr_samples = stat[0].nr_samples;
  35. __entry->wmean = stat[1].mean;
  36. __entry->wmin = stat[1].min;
  37. __entry->wmax = stat[1].max;
  38. __entry->wnr_samples = stat[1].nr_samples;
  39. ),
  40. TP_printk("%s: rmean=%llu, rmin=%llu, rmax=%llu, rsamples=%llu, "
  41. "wmean=%llu, wmin=%llu, wmax=%llu, wsamples=%llu\n",
  42. __entry->name, __entry->rmean, __entry->rmin, __entry->rmax,
  43. __entry->rnr_samples, __entry->wmean, __entry->wmin,
  44. __entry->wmax, __entry->wnr_samples)
  45. );
  46. /**
  47. * wbt_lat - trace latency event
  48. * @lat: latency trigger
  49. */
  50. TRACE_EVENT(wbt_lat,
  51. TP_PROTO(struct backing_dev_info *bdi, unsigned long lat),
  52. TP_ARGS(bdi, lat),
  53. TP_STRUCT__entry(
  54. __array(char, name, 32)
  55. __field(unsigned long, lat)
  56. ),
  57. TP_fast_assign(
  58. strlcpy(__entry->name, dev_name(bdi->dev),
  59. ARRAY_SIZE(__entry->name));
  60. __entry->lat = div_u64(lat, 1000);
  61. ),
  62. TP_printk("%s: latency %lluus\n", __entry->name,
  63. (unsigned long long) __entry->lat)
  64. );
  65. /**
  66. * wbt_step - trace wb event step
  67. * @msg: context message
  68. * @step: the current scale step count
  69. * @window: the current monitoring window
  70. * @bg: the current background queue limit
  71. * @normal: the current normal writeback limit
  72. * @max: the current max throughput writeback limit
  73. */
  74. TRACE_EVENT(wbt_step,
  75. TP_PROTO(struct backing_dev_info *bdi, const char *msg,
  76. int step, unsigned long window, unsigned int bg,
  77. unsigned int normal, unsigned int max),
  78. TP_ARGS(bdi, msg, step, window, bg, normal, max),
  79. TP_STRUCT__entry(
  80. __array(char, name, 32)
  81. __field(const char *, msg)
  82. __field(int, step)
  83. __field(unsigned long, window)
  84. __field(unsigned int, bg)
  85. __field(unsigned int, normal)
  86. __field(unsigned int, max)
  87. ),
  88. TP_fast_assign(
  89. strlcpy(__entry->name, dev_name(bdi->dev),
  90. ARRAY_SIZE(__entry->name));
  91. __entry->msg = msg;
  92. __entry->step = step;
  93. __entry->window = div_u64(window, 1000);
  94. __entry->bg = bg;
  95. __entry->normal = normal;
  96. __entry->max = max;
  97. ),
  98. TP_printk("%s: %s: step=%d, window=%luus, background=%u, normal=%u, max=%u\n",
  99. __entry->name, __entry->msg, __entry->step, __entry->window,
  100. __entry->bg, __entry->normal, __entry->max)
  101. );
  102. /**
  103. * wbt_timer - trace wb timer event
  104. * @status: timer state status
  105. * @step: the current scale step count
  106. * @inflight: tracked writes inflight
  107. */
  108. TRACE_EVENT(wbt_timer,
  109. TP_PROTO(struct backing_dev_info *bdi, unsigned int status,
  110. int step, unsigned int inflight),
  111. TP_ARGS(bdi, status, step, inflight),
  112. TP_STRUCT__entry(
  113. __array(char, name, 32)
  114. __field(unsigned int, status)
  115. __field(int, step)
  116. __field(unsigned int, inflight)
  117. ),
  118. TP_fast_assign(
  119. strlcpy(__entry->name, dev_name(bdi->dev),
  120. ARRAY_SIZE(__entry->name));
  121. __entry->status = status;
  122. __entry->step = step;
  123. __entry->inflight = inflight;
  124. ),
  125. TP_printk("%s: status=%u, step=%d, inflight=%u\n", __entry->name,
  126. __entry->status, __entry->step, __entry->inflight)
  127. );
  128. #endif /* _TRACE_WBT_H */
  129. /* This part must be outside protection */
  130. #include <trace/define_trace.h>