compaction.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. TRACE_EVENT(mm_compaction_migratepages,
  52. TP_PROTO(unsigned long nr_all,
  53. int migrate_rc,
  54. struct list_head *migratepages),
  55. TP_ARGS(nr_all, migrate_rc, migratepages),
  56. TP_STRUCT__entry(
  57. __field(unsigned long, nr_migrated)
  58. __field(unsigned long, nr_failed)
  59. ),
  60. TP_fast_assign(
  61. unsigned long nr_failed = 0;
  62. struct list_head *page_lru;
  63. /*
  64. * migrate_pages() returns either a non-negative number
  65. * with the number of pages that failed migration, or an
  66. * error code, in which case we need to count the remaining
  67. * pages manually
  68. */
  69. if (migrate_rc >= 0)
  70. nr_failed = migrate_rc;
  71. else
  72. list_for_each(page_lru, migratepages)
  73. nr_failed++;
  74. __entry->nr_migrated = nr_all - nr_failed;
  75. __entry->nr_failed = nr_failed;
  76. ),
  77. TP_printk("nr_migrated=%lu nr_failed=%lu",
  78. __entry->nr_migrated,
  79. __entry->nr_failed)
  80. );
  81. TRACE_EVENT(mm_compaction_begin,
  82. TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
  83. unsigned long free_pfn, unsigned long zone_end, bool sync),
  84. TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
  85. TP_STRUCT__entry(
  86. __field(unsigned long, zone_start)
  87. __field(unsigned long, migrate_pfn)
  88. __field(unsigned long, free_pfn)
  89. __field(unsigned long, zone_end)
  90. __field(bool, sync)
  91. ),
  92. TP_fast_assign(
  93. __entry->zone_start = zone_start;
  94. __entry->migrate_pfn = migrate_pfn;
  95. __entry->free_pfn = free_pfn;
  96. __entry->zone_end = zone_end;
  97. __entry->sync = sync;
  98. ),
  99. TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
  100. __entry->zone_start,
  101. __entry->migrate_pfn,
  102. __entry->free_pfn,
  103. __entry->zone_end,
  104. __entry->sync ? "sync" : "async")
  105. );
  106. #ifdef CONFIG_COMPACTION
  107. TRACE_EVENT(mm_compaction_end,
  108. TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
  109. unsigned long free_pfn, unsigned long zone_end, bool sync,
  110. int status),
  111. TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
  112. TP_STRUCT__entry(
  113. __field(unsigned long, zone_start)
  114. __field(unsigned long, migrate_pfn)
  115. __field(unsigned long, free_pfn)
  116. __field(unsigned long, zone_end)
  117. __field(bool, sync)
  118. __field(int, status)
  119. ),
  120. TP_fast_assign(
  121. __entry->zone_start = zone_start;
  122. __entry->migrate_pfn = migrate_pfn;
  123. __entry->free_pfn = free_pfn;
  124. __entry->zone_end = zone_end;
  125. __entry->sync = sync;
  126. __entry->status = status;
  127. ),
  128. TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
  129. __entry->zone_start,
  130. __entry->migrate_pfn,
  131. __entry->free_pfn,
  132. __entry->zone_end,
  133. __entry->sync ? "sync" : "async",
  134. __print_symbolic(__entry->status, COMPACTION_STATUS))
  135. );
  136. #endif
  137. TRACE_EVENT(mm_compaction_try_to_compact_pages,
  138. TP_PROTO(
  139. int order,
  140. gfp_t gfp_mask,
  141. int prio),
  142. TP_ARGS(order, gfp_mask, prio),
  143. TP_STRUCT__entry(
  144. __field(int, order)
  145. __field(gfp_t, gfp_mask)
  146. __field(int, prio)
  147. ),
  148. TP_fast_assign(
  149. __entry->order = order;
  150. __entry->gfp_mask = gfp_mask;
  151. __entry->prio = prio;
  152. ),
  153. TP_printk("order=%d gfp_mask=0x%x priority=%d",
  154. __entry->order,
  155. __entry->gfp_mask,
  156. __entry->prio)
  157. );
  158. #ifdef CONFIG_COMPACTION
  159. DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
  160. TP_PROTO(struct zone *zone,
  161. int order,
  162. int ret),
  163. TP_ARGS(zone, order, ret),
  164. TP_STRUCT__entry(
  165. __field(int, nid)
  166. __field(enum zone_type, idx)
  167. __field(int, order)
  168. __field(int, ret)
  169. ),
  170. TP_fast_assign(
  171. __entry->nid = zone_to_nid(zone);
  172. __entry->idx = zone_idx(zone);
  173. __entry->order = order;
  174. __entry->ret = ret;
  175. ),
  176. TP_printk("node=%d zone=%-8s order=%d ret=%s",
  177. __entry->nid,
  178. __print_symbolic(__entry->idx, ZONE_TYPE),
  179. __entry->order,
  180. __print_symbolic(__entry->ret, COMPACTION_STATUS))
  181. );
  182. DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
  183. TP_PROTO(struct zone *zone,
  184. int order,
  185. int ret),
  186. TP_ARGS(zone, order, ret)
  187. );
  188. DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
  189. TP_PROTO(struct zone *zone,
  190. int order,
  191. int ret),
  192. TP_ARGS(zone, order, ret)
  193. );
  194. DECLARE_EVENT_CLASS(mm_compaction_defer_template,
  195. TP_PROTO(struct zone *zone, int order),
  196. TP_ARGS(zone, order),
  197. TP_STRUCT__entry(
  198. __field(int, nid)
  199. __field(enum zone_type, idx)
  200. __field(int, order)
  201. __field(unsigned int, considered)
  202. __field(unsigned int, defer_shift)
  203. __field(int, order_failed)
  204. ),
  205. TP_fast_assign(
  206. __entry->nid = zone_to_nid(zone);
  207. __entry->idx = zone_idx(zone);
  208. __entry->order = order;
  209. __entry->considered = zone->compact_considered;
  210. __entry->defer_shift = zone->compact_defer_shift;
  211. __entry->order_failed = zone->compact_order_failed;
  212. ),
  213. TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
  214. __entry->nid,
  215. __print_symbolic(__entry->idx, ZONE_TYPE),
  216. __entry->order,
  217. __entry->order_failed,
  218. __entry->considered,
  219. 1UL << __entry->defer_shift)
  220. );
  221. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
  222. TP_PROTO(struct zone *zone, int order),
  223. TP_ARGS(zone, order)
  224. );
  225. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
  226. TP_PROTO(struct zone *zone, int order),
  227. TP_ARGS(zone, order)
  228. );
  229. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
  230. TP_PROTO(struct zone *zone, int order),
  231. TP_ARGS(zone, order)
  232. );
  233. #endif
  234. TRACE_EVENT(mm_compaction_kcompactd_sleep,
  235. TP_PROTO(int nid),
  236. TP_ARGS(nid),
  237. TP_STRUCT__entry(
  238. __field(int, nid)
  239. ),
  240. TP_fast_assign(
  241. __entry->nid = nid;
  242. ),
  243. TP_printk("nid=%d", __entry->nid)
  244. );
  245. DECLARE_EVENT_CLASS(kcompactd_wake_template,
  246. TP_PROTO(int nid, int order, enum zone_type classzone_idx),
  247. TP_ARGS(nid, order, classzone_idx),
  248. TP_STRUCT__entry(
  249. __field(int, nid)
  250. __field(int, order)
  251. __field(enum zone_type, classzone_idx)
  252. ),
  253. TP_fast_assign(
  254. __entry->nid = nid;
  255. __entry->order = order;
  256. __entry->classzone_idx = classzone_idx;
  257. ),
  258. TP_printk("nid=%d order=%d classzone_idx=%-8s",
  259. __entry->nid,
  260. __entry->order,
  261. __print_symbolic(__entry->classzone_idx, ZONE_TYPE))
  262. );
  263. DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
  264. TP_PROTO(int nid, int order, enum zone_type classzone_idx),
  265. TP_ARGS(nid, order, classzone_idx)
  266. );
  267. DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
  268. TP_PROTO(int nid, int order, enum zone_type classzone_idx),
  269. TP_ARGS(nid, order, classzone_idx)
  270. );
  271. #endif /* _TRACE_COMPACTION_H */
  272. /* This part must be outside protection */
  273. #include <trace/define_trace.h>