compaction.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM compaction
  3. #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_COMPACTION_H
  5. #include <linux/types.h>
  6. #include <linux/list.h>
  7. #include <linux/tracepoint.h>
  8. #include <trace/events/mmflags.h>
  9. #define COMPACTION_STATUS \
  10. EM( COMPACT_SKIPPED, "skipped") \
  11. EM( COMPACT_DEFERRED, "deferred") \
  12. EM( COMPACT_CONTINUE, "continue") \
  13. EM( COMPACT_SUCCESS, "success") \
  14. EM( COMPACT_PARTIAL_SKIPPED, "partial_skipped") \
  15. EM( COMPACT_COMPLETE, "complete") \
  16. EM( COMPACT_NO_SUITABLE_PAGE, "no_suitable_page") \
  17. EM( COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone") \
  18. EMe(COMPACT_CONTENDED, "contended")
  19. #ifdef CONFIG_ZONE_DMA
  20. #define IFDEF_ZONE_DMA(X) X
  21. #else
  22. #define IFDEF_ZONE_DMA(X)
  23. #endif
  24. #ifdef CONFIG_ZONE_DMA32
  25. #define IFDEF_ZONE_DMA32(X) X
  26. #else
  27. #define IFDEF_ZONE_DMA32(X)
  28. #endif
  29. #ifdef CONFIG_HIGHMEM
  30. #define IFDEF_ZONE_HIGHMEM(X) X
  31. #else
  32. #define IFDEF_ZONE_HIGHMEM(X)
  33. #endif
  34. #define ZONE_TYPE \
  35. IFDEF_ZONE_DMA( EM (ZONE_DMA, "DMA")) \
  36. IFDEF_ZONE_DMA32( EM (ZONE_DMA32, "DMA32")) \
  37. EM (ZONE_NORMAL, "Normal") \
  38. IFDEF_ZONE_HIGHMEM( EM (ZONE_HIGHMEM,"HighMem")) \
  39. EMe(ZONE_MOVABLE,"Movable")
  40. /*
  41. * First define the enums in the above macros to be exported to userspace
  42. * via TRACE_DEFINE_ENUM().
  43. */
  44. #undef EM
  45. #undef EMe
  46. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  47. #define EMe(a, b) TRACE_DEFINE_ENUM(a);
  48. COMPACTION_STATUS
  49. ZONE_TYPE
  50. /*
  51. * Now redefine the EM() and EMe() macros to map the enums to the strings
  52. * that will be printed in the output.
  53. */
  54. #undef EM
  55. #undef EMe
  56. #define EM(a, b) {a, b},
  57. #define EMe(a, b) {a, b}
  58. DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
  59. TP_PROTO(
  60. unsigned long start_pfn,
  61. unsigned long end_pfn,
  62. unsigned long nr_scanned,
  63. unsigned long nr_taken),
  64. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
  65. TP_STRUCT__entry(
  66. __field(unsigned long, start_pfn)
  67. __field(unsigned long, end_pfn)
  68. __field(unsigned long, nr_scanned)
  69. __field(unsigned long, nr_taken)
  70. ),
  71. TP_fast_assign(
  72. __entry->start_pfn = start_pfn;
  73. __entry->end_pfn = end_pfn;
  74. __entry->nr_scanned = nr_scanned;
  75. __entry->nr_taken = nr_taken;
  76. ),
  77. TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
  78. __entry->start_pfn,
  79. __entry->end_pfn,
  80. __entry->nr_scanned,
  81. __entry->nr_taken)
  82. );
  83. DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
  84. TP_PROTO(
  85. unsigned long start_pfn,
  86. unsigned long end_pfn,
  87. unsigned long nr_scanned,
  88. unsigned long nr_taken),
  89. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
  90. );
  91. DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
  92. TP_PROTO(
  93. unsigned long start_pfn,
  94. unsigned long end_pfn,
  95. unsigned long nr_scanned,
  96. unsigned long nr_taken),
  97. TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
  98. );
  99. TRACE_EVENT(mm_compaction_migratepages,
  100. TP_PROTO(unsigned long nr_all,
  101. int migrate_rc,
  102. struct list_head *migratepages),
  103. TP_ARGS(nr_all, migrate_rc, migratepages),
  104. TP_STRUCT__entry(
  105. __field(unsigned long, nr_migrated)
  106. __field(unsigned long, nr_failed)
  107. ),
  108. TP_fast_assign(
  109. unsigned long nr_failed = 0;
  110. struct list_head *page_lru;
  111. /*
  112. * migrate_pages() returns either a non-negative number
  113. * with the number of pages that failed migration, or an
  114. * error code, in which case we need to count the remaining
  115. * pages manually
  116. */
  117. if (migrate_rc >= 0)
  118. nr_failed = migrate_rc;
  119. else
  120. list_for_each(page_lru, migratepages)
  121. nr_failed++;
  122. __entry->nr_migrated = nr_all - nr_failed;
  123. __entry->nr_failed = nr_failed;
  124. ),
  125. TP_printk("nr_migrated=%lu nr_failed=%lu",
  126. __entry->nr_migrated,
  127. __entry->nr_failed)
  128. );
  129. TRACE_EVENT(mm_compaction_begin,
  130. TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
  131. unsigned long free_pfn, unsigned long zone_end, bool sync),
  132. TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
  133. TP_STRUCT__entry(
  134. __field(unsigned long, zone_start)
  135. __field(unsigned long, migrate_pfn)
  136. __field(unsigned long, free_pfn)
  137. __field(unsigned long, zone_end)
  138. __field(bool, sync)
  139. ),
  140. TP_fast_assign(
  141. __entry->zone_start = zone_start;
  142. __entry->migrate_pfn = migrate_pfn;
  143. __entry->free_pfn = free_pfn;
  144. __entry->zone_end = zone_end;
  145. __entry->sync = sync;
  146. ),
  147. TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
  148. __entry->zone_start,
  149. __entry->migrate_pfn,
  150. __entry->free_pfn,
  151. __entry->zone_end,
  152. __entry->sync ? "sync" : "async")
  153. );
  154. TRACE_EVENT(mm_compaction_end,
  155. TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
  156. unsigned long free_pfn, unsigned long zone_end, bool sync,
  157. int status),
  158. TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
  159. TP_STRUCT__entry(
  160. __field(unsigned long, zone_start)
  161. __field(unsigned long, migrate_pfn)
  162. __field(unsigned long, free_pfn)
  163. __field(unsigned long, zone_end)
  164. __field(bool, sync)
  165. __field(int, status)
  166. ),
  167. TP_fast_assign(
  168. __entry->zone_start = zone_start;
  169. __entry->migrate_pfn = migrate_pfn;
  170. __entry->free_pfn = free_pfn;
  171. __entry->zone_end = zone_end;
  172. __entry->sync = sync;
  173. __entry->status = status;
  174. ),
  175. TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
  176. __entry->zone_start,
  177. __entry->migrate_pfn,
  178. __entry->free_pfn,
  179. __entry->zone_end,
  180. __entry->sync ? "sync" : "async",
  181. __print_symbolic(__entry->status, COMPACTION_STATUS))
  182. );
  183. TRACE_EVENT(mm_compaction_try_to_compact_pages,
  184. TP_PROTO(
  185. int order,
  186. gfp_t gfp_mask,
  187. int prio),
  188. TP_ARGS(order, gfp_mask, prio),
  189. TP_STRUCT__entry(
  190. __field(int, order)
  191. __field(gfp_t, gfp_mask)
  192. __field(int, prio)
  193. ),
  194. TP_fast_assign(
  195. __entry->order = order;
  196. __entry->gfp_mask = gfp_mask;
  197. __entry->prio = prio;
  198. ),
  199. TP_printk("order=%d gfp_mask=0x%x priority=%d",
  200. __entry->order,
  201. __entry->gfp_mask,
  202. __entry->prio)
  203. );
  204. DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
  205. TP_PROTO(struct zone *zone,
  206. int order,
  207. int ret),
  208. TP_ARGS(zone, order, ret),
  209. TP_STRUCT__entry(
  210. __field(int, nid)
  211. __field(enum zone_type, idx)
  212. __field(int, order)
  213. __field(int, ret)
  214. ),
  215. TP_fast_assign(
  216. __entry->nid = zone_to_nid(zone);
  217. __entry->idx = zone_idx(zone);
  218. __entry->order = order;
  219. __entry->ret = ret;
  220. ),
  221. TP_printk("node=%d zone=%-8s order=%d ret=%s",
  222. __entry->nid,
  223. __print_symbolic(__entry->idx, ZONE_TYPE),
  224. __entry->order,
  225. __print_symbolic(__entry->ret, COMPACTION_STATUS))
  226. );
  227. DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
  228. TP_PROTO(struct zone *zone,
  229. int order,
  230. int ret),
  231. TP_ARGS(zone, order, ret)
  232. );
  233. DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
  234. TP_PROTO(struct zone *zone,
  235. int order,
  236. int ret),
  237. TP_ARGS(zone, order, ret)
  238. );
  239. #ifdef CONFIG_COMPACTION
  240. DECLARE_EVENT_CLASS(mm_compaction_defer_template,
  241. TP_PROTO(struct zone *zone, int order),
  242. TP_ARGS(zone, order),
  243. TP_STRUCT__entry(
  244. __field(int, nid)
  245. __field(enum zone_type, idx)
  246. __field(int, order)
  247. __field(unsigned int, considered)
  248. __field(unsigned int, defer_shift)
  249. __field(int, order_failed)
  250. ),
  251. TP_fast_assign(
  252. __entry->nid = zone_to_nid(zone);
  253. __entry->idx = zone_idx(zone);
  254. __entry->order = order;
  255. __entry->considered = zone->compact_considered;
  256. __entry->defer_shift = zone->compact_defer_shift;
  257. __entry->order_failed = zone->compact_order_failed;
  258. ),
  259. TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
  260. __entry->nid,
  261. __print_symbolic(__entry->idx, ZONE_TYPE),
  262. __entry->order,
  263. __entry->order_failed,
  264. __entry->considered,
  265. 1UL << __entry->defer_shift)
  266. );
  267. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
  268. TP_PROTO(struct zone *zone, int order),
  269. TP_ARGS(zone, order)
  270. );
  271. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
  272. TP_PROTO(struct zone *zone, int order),
  273. TP_ARGS(zone, order)
  274. );
  275. DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
  276. TP_PROTO(struct zone *zone, int order),
  277. TP_ARGS(zone, order)
  278. );
  279. #endif
  280. TRACE_EVENT(mm_compaction_kcompactd_sleep,
  281. TP_PROTO(int nid),
  282. TP_ARGS(nid),
  283. TP_STRUCT__entry(
  284. __field(int, nid)
  285. ),
  286. TP_fast_assign(
  287. __entry->nid = nid;
  288. ),
  289. TP_printk("nid=%d", __entry->nid)
  290. );
  291. DECLARE_EVENT_CLASS(kcompactd_wake_template,
  292. TP_PROTO(int nid, int order, enum zone_type classzone_idx),
  293. TP_ARGS(nid, order, classzone_idx),
  294. TP_STRUCT__entry(
  295. __field(int, nid)
  296. __field(int, order)
  297. __field(enum zone_type, classzone_idx)
  298. ),
  299. TP_fast_assign(
  300. __entry->nid = nid;
  301. __entry->order = order;
  302. __entry->classzone_idx = classzone_idx;
  303. ),
  304. TP_printk("nid=%d order=%d classzone_idx=%-8s",
  305. __entry->nid,
  306. __entry->order,
  307. __print_symbolic(__entry->classzone_idx, ZONE_TYPE))
  308. );
  309. DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
  310. TP_PROTO(int nid, int order, enum zone_type classzone_idx),
  311. TP_ARGS(nid, order, classzone_idx)
  312. );
  313. DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
  314. TP_PROTO(int nid, int order, enum zone_type classzone_idx),
  315. TP_ARGS(nid, order, classzone_idx)
  316. );
  317. #endif /* _TRACE_COMPACTION_H */
  318. /* This part must be outside protection */
  319. #include <trace/define_trace.h>