compaction.h 8.0 KB

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