thermal_trace.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM thermal
  4. #if !defined(_TRACE_THERMAL_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_THERMAL_H
  6. #include <linux/devfreq.h>
  7. #include <linux/thermal.h>
  8. #include <linux/tracepoint.h>
  9. #include "thermal_core.h"
  10. TRACE_DEFINE_ENUM(THERMAL_TRIP_CRITICAL);
  11. TRACE_DEFINE_ENUM(THERMAL_TRIP_HOT);
  12. TRACE_DEFINE_ENUM(THERMAL_TRIP_PASSIVE);
  13. TRACE_DEFINE_ENUM(THERMAL_TRIP_ACTIVE);
  14. #define show_tzt_type(type) \
  15. __print_symbolic(type, \
  16. { THERMAL_TRIP_CRITICAL, "CRITICAL"}, \
  17. { THERMAL_TRIP_HOT, "HOT"}, \
  18. { THERMAL_TRIP_PASSIVE, "PASSIVE"}, \
  19. { THERMAL_TRIP_ACTIVE, "ACTIVE"})
  20. TRACE_EVENT(thermal_temperature,
  21. TP_PROTO(struct thermal_zone_device *tz),
  22. TP_ARGS(tz),
  23. TP_STRUCT__entry(
  24. __string(thermal_zone, tz->type)
  25. __field(int, id)
  26. __field(int, temp_prev)
  27. __field(int, temp)
  28. ),
  29. TP_fast_assign(
  30. __assign_str(thermal_zone);
  31. __entry->id = tz->id;
  32. __entry->temp_prev = tz->last_temperature;
  33. __entry->temp = tz->temperature;
  34. ),
  35. TP_printk("thermal_zone=%s id=%d temp_prev=%d temp=%d",
  36. __get_str(thermal_zone), __entry->id, __entry->temp_prev,
  37. __entry->temp)
  38. );
  39. TRACE_EVENT(cdev_update,
  40. TP_PROTO(struct thermal_cooling_device *cdev, unsigned long target),
  41. TP_ARGS(cdev, target),
  42. TP_STRUCT__entry(
  43. __string(type, cdev->type)
  44. __field(unsigned long, target)
  45. ),
  46. TP_fast_assign(
  47. __assign_str(type);
  48. __entry->target = target;
  49. ),
  50. TP_printk("type=%s target=%lu", __get_str(type), __entry->target)
  51. );
  52. TRACE_EVENT(thermal_zone_trip,
  53. TP_PROTO(struct thermal_zone_device *tz, int trip,
  54. enum thermal_trip_type trip_type),
  55. TP_ARGS(tz, trip, trip_type),
  56. TP_STRUCT__entry(
  57. __string(thermal_zone, tz->type)
  58. __field(int, id)
  59. __field(int, trip)
  60. __field(enum thermal_trip_type, trip_type)
  61. ),
  62. TP_fast_assign(
  63. __assign_str(thermal_zone);
  64. __entry->id = tz->id;
  65. __entry->trip = trip;
  66. __entry->trip_type = trip_type;
  67. ),
  68. TP_printk("thermal_zone=%s id=%d trip=%d trip_type=%s",
  69. __get_str(thermal_zone), __entry->id, __entry->trip,
  70. show_tzt_type(__entry->trip_type))
  71. );
  72. #ifdef CONFIG_CPU_THERMAL
  73. TRACE_EVENT(thermal_power_cpu_get_power_simple,
  74. TP_PROTO(int cpu, u32 power),
  75. TP_ARGS(cpu, power),
  76. TP_STRUCT__entry(
  77. __field(int, cpu)
  78. __field(u32, power)
  79. ),
  80. TP_fast_assign(
  81. __entry->cpu = cpu;
  82. __entry->power = power;
  83. ),
  84. TP_printk("cpu=%d power=%u", __entry->cpu, __entry->power)
  85. );
  86. TRACE_EVENT(thermal_power_cpu_limit,
  87. TP_PROTO(const struct cpumask *cpus, unsigned int freq,
  88. unsigned long cdev_state, u32 power),
  89. TP_ARGS(cpus, freq, cdev_state, power),
  90. TP_STRUCT__entry(
  91. __bitmask(cpumask, num_possible_cpus())
  92. __field(unsigned int, freq )
  93. __field(unsigned long, cdev_state)
  94. __field(u32, power )
  95. ),
  96. TP_fast_assign(
  97. __assign_bitmask(cpumask, cpumask_bits(cpus),
  98. num_possible_cpus());
  99. __entry->freq = freq;
  100. __entry->cdev_state = cdev_state;
  101. __entry->power = power;
  102. ),
  103. TP_printk("cpus=%s freq=%u cdev_state=%lu power=%u",
  104. __get_bitmask(cpumask), __entry->freq, __entry->cdev_state,
  105. __entry->power)
  106. );
  107. #endif /* CONFIG_CPU_THERMAL */
  108. #ifdef CONFIG_DEVFREQ_THERMAL
  109. TRACE_EVENT(thermal_power_devfreq_get_power,
  110. TP_PROTO(struct thermal_cooling_device *cdev,
  111. struct devfreq_dev_status *status, unsigned long freq,
  112. u32 power),
  113. TP_ARGS(cdev, status, freq, power),
  114. TP_STRUCT__entry(
  115. __string(type, cdev->type )
  116. __field(unsigned long, freq )
  117. __field(u32, busy_time)
  118. __field(u32, total_time)
  119. __field(u32, power)
  120. ),
  121. TP_fast_assign(
  122. __assign_str(type);
  123. __entry->freq = freq;
  124. __entry->busy_time = status->busy_time;
  125. __entry->total_time = status->total_time;
  126. __entry->power = power;
  127. ),
  128. TP_printk("type=%s freq=%lu load=%u power=%u",
  129. __get_str(type), __entry->freq,
  130. __entry->total_time == 0 ? 0 :
  131. (100 * __entry->busy_time) / __entry->total_time,
  132. __entry->power)
  133. );
  134. TRACE_EVENT(thermal_power_devfreq_limit,
  135. TP_PROTO(struct thermal_cooling_device *cdev, unsigned long freq,
  136. unsigned long cdev_state, u32 power),
  137. TP_ARGS(cdev, freq, cdev_state, power),
  138. TP_STRUCT__entry(
  139. __string(type, cdev->type)
  140. __field(unsigned int, freq )
  141. __field(unsigned long, cdev_state)
  142. __field(u32, power )
  143. ),
  144. TP_fast_assign(
  145. __assign_str(type);
  146. __entry->freq = freq;
  147. __entry->cdev_state = cdev_state;
  148. __entry->power = power;
  149. ),
  150. TP_printk("type=%s freq=%u cdev_state=%lu power=%u",
  151. __get_str(type), __entry->freq, __entry->cdev_state,
  152. __entry->power)
  153. );
  154. #endif /* CONFIG_DEVFREQ_THERMAL */
  155. #endif /* _TRACE_THERMAL_H */
  156. #undef TRACE_INCLUDE_PATH
  157. #define TRACE_INCLUDE_PATH .
  158. #undef TRACE_INCLUDE_FILE
  159. #define TRACE_INCLUDE_FILE thermal_trace
  160. /* This part must be outside protection */
  161. #include <trace/define_trace.h>