compaction.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM compaction
  4. #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_COMPACTION_H
  6. #include <linux/types.h>
  7. #include <linux/list.h>
  8. #include <linux/tracepoint.h>
  9. #include <trace/events/mmflags.h>
  10. DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
  11. TP_PROTO(
  12. unsigned long start_pfn,
  13. unsigned long end_pfn,
  14. unsigned long nr_scanned,
  15. unsigned long nr_taken),
  16. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
  17. TP_STRUCT__entry(
  18. __field(unsigned long, start_pfn)
  19. __field(unsigned long, end_pfn)
  20. __field(unsigned long, nr_scanned)
  21. __field(unsigned long, nr_taken)
  22. ),
  23. TP_fast_assign(
  24. __entry->start_pfn = start_pfn;
  25. __entry->end_pfn = end_pfn;
  26. __entry->nr_scanned = nr_scanned;
  27. __entry->nr_taken = nr_taken;
  28. ),
  29. TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
  30. __entry->start_pfn,
  31. __entry->end_pfn,
  32. __entry->nr_scanned,
  33. __entry->nr_taken)
  34. );
  35. DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
  36. TP_PROTO(
  37. unsigned long start_pfn,
  38. unsigned long end_pfn,
  39. unsigned long nr_scanned,
  40. unsigned long nr_taken),
  41. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
  42. );
  43. DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
  44. TP_PROTO(
  45. unsigned long start_pfn,
  46. unsigned long end_pfn,
  47. unsigned long nr_scanned,
  48. unsigned long nr_taken),
  49. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
  50. );
  51. DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_fast_isolate_freepages,
  52. TP_PROTO(
  53. unsigned long start_pfn,
  54. unsigned long end_pfn,
  55. unsigned long nr_scanned,
  56. unsigned long nr_taken),
  57. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
  58. );
  59. #ifdef CONFIG_COMPACTION
  60. TRACE_EVENT(mm_compaction_migratepages,
  61. TP_PROTO(unsigned int nr_migratepages,
  62. unsigned int nr_succeeded),
  63. TP_ARGS(nr_migratepages, nr_succeeded),
  64. TP_STRUCT__entry(
  65. __field(unsigned long, nr_migrated)
  66. __field(unsigned long, nr_failed)
  67. ),
  68. TP_fast_assign(
  69. __entry->nr_migrated = nr_succeeded;
  70. __entry->nr_failed = nr_migratepages - nr_succeeded;
  71. ),
  72. TP_printk("nr_migrated=%lu nr_failed=%lu",
  73. __entry->nr_migrated,
  74. __entry->nr_failed)
  75. );
  76. TRACE_EVENT(mm_compaction_begin,
  77. TP_PROTO(struct compact_control *cc, unsigned long zone_start,
  78. unsigned long zone_end, bool sync),
  79. TP_ARGS(cc, zone_start, zone_end, sync),
  80. TP_STRUCT__entry(
  81. __field(unsigned long, zone_start)
  82. __field(unsigned long, migrate_pfn)
  83. __field(unsigned long, free_pfn)
  84. __field(unsigned long, zone_end)
  85. __field(bool, sync)
  86. ),
  87. TP_fast_assign(
  88. __entry->zone_start = zone_start;
  89. __entry->migrate_pfn = cc->migrate_pfn;
  90. __entry->free_pfn = cc->free_pfn;
  91. __entry->zone_end = zone_end;
  92. __entry->sync = sync;
  93. ),
  94. TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
  95. __entry->zone_start,
  96. __entry->migrate_pfn,
  97. __entry->free_pfn,
  98. __entry->zone_end,
  99. __entry->sync ? "sync" : "async")
  100. );
  101. TRACE_EVENT(mm_compaction_end,
  102. TP_PROTO(struct compact_control *cc, unsigned long zone_start,
  103. unsigned long zone_end, bool sync,
  104. int status),
  105. TP_ARGS(cc, zone_start, zone_end, sync, status),
  106. TP_STRUCT__entry(
  107. __field(unsigned long, zone_start)
  108. __field(unsigned long, migrate_pfn)
  109. __field(unsigned long, free_pfn)
  110. __field(unsigned long, zone_end)
  111. __field(bool, sync)
  112. __field(int, status)
  113. ),
  114. TP_fast_assign(
  115. __entry->zone_start = zone_start;
  116. __entry->migrate_pfn = cc->migrate_pfn;
  117. __entry->free_pfn = cc->free_pfn;
  118. __entry->zone_end = zone_end;
  119. __entry->sync = sync;
  120. __entry->status = status;
  121. ),
  122. TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
  123. __entry->zone_start,
  124. __entry->migrate_pfn,
  125. __entry->free_pfn,
  126. __entry->zone_end,
  127. __entry->sync ? "sync" : "async",
  128. __print_symbolic(__entry->status, COMPACTION_STATUS))
  129. );
  130. TRACE_EVENT(mm_compaction_try_to_compact_pages,
  131. TP_PROTO(
  132. int order,
  133. gfp_t gfp_mask,
  134. int prio),
  135. TP_ARGS(order, gfp_mask, prio),
  136. TP_STRUCT__entry(
  137. __field(int, order)
  138. __field(unsigned long, gfp_mask)
  139. __field(int, prio)
  140. ),
  141. TP_fast_assign(
  142. __entry->order = order;
  143. __entry->gfp_mask = (__force unsigned long)gfp_mask;
  144. __entry->prio = prio;
  145. ),
  146. TP_printk("order=%d gfp_mask=%s priority=%d",
  147. __entry->order,
  148. show_gfp_flags(__entry->gfp_mask),
  149. __entry->prio)
  150. );
  151. DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
  152. TP_PROTO(struct zone *zone,
  153. int order,
  154. int ret),
  155. TP_ARGS(zone, order, ret),
  156. TP_STRUCT__entry(
  157. __field(int, nid)
  158. __field(enum zone_type, idx)
  159. __field(int, order)
  160. __field(int, ret)
  161. ),
  162. TP_fast_assign(
  163. __entry->nid = zone_to_nid(zone);
  164. __entry->idx = zone_idx(zone);
  165. __entry->order = order;
  166. __entry->ret = ret;
  167. ),
  168. TP_printk("node=%d zone=%-8s order=%d ret=%s",
  169. __entry->nid,
  170. __print_symbolic(__entry->idx, ZONE_TYPE),
  171. __entry->order,
  172. __print_symbolic(__entry->ret, COMPACTION_STATUS))
  173. );
  174. DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
  175. TP_PROTO(struct zone *zone,
  176. int order,
  177. int ret),
  178. TP_ARGS(zone, order, ret)
  179. );
  180. DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
  181. TP_PROTO(struct zone *zone,
  182. int order,
  183. int ret),
  184. TP_ARGS(zone, order, ret)
  185. );
  186. DECLARE_EVENT_CLASS(mm_compaction_defer_template,
  187. TP_PROTO(struct zone *zone, int order),
  188. TP_ARGS(zone, order),
  189. TP_STRUCT__entry(
  190. __field(int, nid)
  191. __field(enum zone_type, idx)
  192. __field(int, order)
  193. __field(unsigned int, considered)
  194. __field(unsigned int, defer_shift)
  195. __field(int, order_failed)
  196. ),
  197. TP_fast_assign(
  198. __entry->nid = zone_to_nid(zone);
  199. __entry->idx = zone_idx(zone);
  200. __entry->order = order;
  201. __entry->considered = zone->compact_considered;
  202. __entry->defer_shift = zone->compact_defer_shift;
  203. __entry->order_failed = zone->compact_order_failed;
  204. ),
  205. TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
  206. __entry->nid,
  207. __print_symbolic(__entry->idx, ZONE_TYPE),
  208. __entry->order,
  209. __entry->order_failed,
  210. __entry->considered,
  211. 1UL << __entry->defer_shift)
  212. );
  213. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
  214. TP_PROTO(struct zone *zone, int order),
  215. TP_ARGS(zone, order)
  216. );
  217. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
  218. TP_PROTO(struct zone *zone, int order),
  219. TP_ARGS(zone, order)
  220. );
  221. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
  222. TP_PROTO(struct zone *zone, int order),
  223. TP_ARGS(zone, order)
  224. );
  225. TRACE_EVENT(mm_compaction_kcompactd_sleep,
  226. TP_PROTO(int nid),
  227. TP_ARGS(nid),
  228. TP_STRUCT__entry(
  229. __field(int, nid)
  230. ),
  231. TP_fast_assign(
  232. __entry->nid = nid;
  233. ),
  234. TP_printk("nid=%d", __entry->nid)
  235. );
  236. DECLARE_EVENT_CLASS(kcompactd_wake_template,
  237. TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
  238. TP_ARGS(nid, order, highest_zoneidx),
  239. TP_STRUCT__entry(
  240. __field(int, nid)
  241. __field(int, order)
  242. __field(enum zone_type, highest_zoneidx)
  243. ),
  244. TP_fast_assign(
  245. __entry->nid = nid;
  246. __entry->order = order;
  247. __entry->highest_zoneidx = highest_zoneidx;
  248. ),
  249. /*
  250. * classzone_idx is previous name of the highest_zoneidx.
  251. * Reason not to change it is the ABI requirement of the tracepoint.
  252. */
  253. TP_printk("nid=%d order=%d classzone_idx=%-8s",
  254. __entry->nid,
  255. __entry->order,
  256. __print_symbolic(__entry->highest_zoneidx, ZONE_TYPE))
  257. );
  258. DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
  259. TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
  260. TP_ARGS(nid, order, highest_zoneidx)
  261. );
  262. DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
  263. TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
  264. TP_ARGS(nid, order, highest_zoneidx)
  265. );
  266. #endif
  267. #endif /* _TRACE_COMPACTION_H */
  268. /* This part must be outside protection */
  269. #include <trace/define_trace.h>