wbt.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. strncpy(__entry->name, dev_name(bdi->dev), 32);
  30. __entry->rmean = stat[0].mean;
  31. __entry->rmin = stat[0].min;
  32. __entry->rmax = stat[0].max;
  33. __entry->rnr_samples = stat[0].nr_samples;
  34. __entry->wmean = stat[1].mean;
  35. __entry->wmin = stat[1].min;
  36. __entry->wmax = stat[1].max;
  37. __entry->wnr_samples = stat[1].nr_samples;
  38. ),
  39. TP_printk("%s: rmean=%llu, rmin=%llu, rmax=%llu, rsamples=%llu, "
  40. "wmean=%llu, wmin=%llu, wmax=%llu, wsamples=%llu\n",
  41. __entry->name, __entry->rmean, __entry->rmin, __entry->rmax,
  42. __entry->rnr_samples, __entry->wmean, __entry->wmin,
  43. __entry->wmax, __entry->wnr_samples)
  44. );
  45. /**
  46. * wbt_lat - trace latency event
  47. * @lat: latency trigger
  48. */
  49. TRACE_EVENT(wbt_lat,
  50. TP_PROTO(struct backing_dev_info *bdi, unsigned long lat),
  51. TP_ARGS(bdi, lat),
  52. TP_STRUCT__entry(
  53. __array(char, name, 32)
  54. __field(unsigned long, lat)
  55. ),
  56. TP_fast_assign(
  57. strncpy(__entry->name, dev_name(bdi->dev), 32);
  58. __entry->lat = div_u64(lat, 1000);
  59. ),
  60. TP_printk("%s: latency %lluus\n", __entry->name,
  61. (unsigned long long) __entry->lat)
  62. );
  63. /**
  64. * wbt_step - trace wb event step
  65. * @msg: context message
  66. * @step: the current scale step count
  67. * @window: the current monitoring window
  68. * @bg: the current background queue limit
  69. * @normal: the current normal writeback limit
  70. * @max: the current max throughput writeback limit
  71. */
  72. TRACE_EVENT(wbt_step,
  73. TP_PROTO(struct backing_dev_info *bdi, const char *msg,
  74. int step, unsigned long window, unsigned int bg,
  75. unsigned int normal, unsigned int max),
  76. TP_ARGS(bdi, msg, step, window, bg, normal, max),
  77. TP_STRUCT__entry(
  78. __array(char, name, 32)
  79. __field(const char *, msg)
  80. __field(int, step)
  81. __field(unsigned long, window)
  82. __field(unsigned int, bg)
  83. __field(unsigned int, normal)
  84. __field(unsigned int, max)
  85. ),
  86. TP_fast_assign(
  87. strncpy(__entry->name, dev_name(bdi->dev), 32);
  88. __entry->msg = msg;
  89. __entry->step = step;
  90. __entry->window = div_u64(window, 1000);
  91. __entry->bg = bg;
  92. __entry->normal = normal;
  93. __entry->max = max;
  94. ),
  95. TP_printk("%s: %s: step=%d, window=%luus, background=%u, normal=%u, max=%u\n",
  96. __entry->name, __entry->msg, __entry->step, __entry->window,
  97. __entry->bg, __entry->normal, __entry->max)
  98. );
  99. /**
  100. * wbt_timer - trace wb timer event
  101. * @status: timer state status
  102. * @step: the current scale step count
  103. * @inflight: tracked writes inflight
  104. */
  105. TRACE_EVENT(wbt_timer,
  106. TP_PROTO(struct backing_dev_info *bdi, unsigned int status,
  107. int step, unsigned int inflight),
  108. TP_ARGS(bdi, status, step, inflight),
  109. TP_STRUCT__entry(
  110. __array(char, name, 32)
  111. __field(unsigned int, status)
  112. __field(int, step)
  113. __field(unsigned int, inflight)
  114. ),
  115. TP_fast_assign(
  116. strncpy(__entry->name, dev_name(bdi->dev), 32);
  117. __entry->status = status;
  118. __entry->step = step;
  119. __entry->inflight = inflight;
  120. ),
  121. TP_printk("%s: status=%u, step=%d, inflight=%u\n", __entry->name,
  122. __entry->status, __entry->step, __entry->inflight)
  123. );
  124. #endif /* _TRACE_WBT_H */
  125. /* This part must be outside protection */
  126. #include <trace/define_trace.h>