vmscan.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. #undef TRACE_SYSTEM
  2. #define TRACE_SYSTEM vmscan
  3. #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
  4. #define _TRACE_VMSCAN_H
  5. #include <linux/types.h>
  6. #include <linux/tracepoint.h>
  7. #include <linux/mm.h>
  8. #include <linux/memcontrol.h>
  9. #include <trace/events/mmflags.h>
  10. #define RECLAIM_WB_ANON 0x0001u
  11. #define RECLAIM_WB_FILE 0x0002u
  12. #define RECLAIM_WB_MIXED 0x0010u
  13. #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
  14. #define RECLAIM_WB_ASYNC 0x0008u
  15. #define show_reclaim_flags(flags) \
  16. (flags) ? __print_flags(flags, "|", \
  17. {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
  18. {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
  19. {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
  20. {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
  21. {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
  22. ) : "RECLAIM_WB_NONE"
  23. #define trace_reclaim_flags(page) ( \
  24. (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
  25. (RECLAIM_WB_ASYNC) \
  26. )
  27. #define trace_shrink_flags(file) \
  28. ( \
  29. (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
  30. (RECLAIM_WB_ASYNC) \
  31. )
  32. TRACE_EVENT(mm_vmscan_kswapd_sleep,
  33. TP_PROTO(int nid),
  34. TP_ARGS(nid),
  35. TP_STRUCT__entry(
  36. __field( int, nid )
  37. ),
  38. TP_fast_assign(
  39. __entry->nid = nid;
  40. ),
  41. TP_printk("nid=%d", __entry->nid)
  42. );
  43. TRACE_EVENT(mm_vmscan_kswapd_wake,
  44. TP_PROTO(int nid, int zid, int order),
  45. TP_ARGS(nid, zid, order),
  46. TP_STRUCT__entry(
  47. __field( int, nid )
  48. __field( int, zid )
  49. __field( int, order )
  50. ),
  51. TP_fast_assign(
  52. __entry->nid = nid;
  53. __entry->zid = zid;
  54. __entry->order = order;
  55. ),
  56. TP_printk("nid=%d zid=%d order=%d", __entry->nid, __entry->zid, __entry->order)
  57. );
  58. TRACE_EVENT(mm_vmscan_wakeup_kswapd,
  59. TP_PROTO(int nid, int zid, int order),
  60. TP_ARGS(nid, zid, order),
  61. TP_STRUCT__entry(
  62. __field( int, nid )
  63. __field( int, zid )
  64. __field( int, order )
  65. ),
  66. TP_fast_assign(
  67. __entry->nid = nid;
  68. __entry->zid = zid;
  69. __entry->order = order;
  70. ),
  71. TP_printk("nid=%d zid=%d order=%d",
  72. __entry->nid,
  73. __entry->zid,
  74. __entry->order)
  75. );
  76. DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
  77. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  78. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx),
  79. TP_STRUCT__entry(
  80. __field( int, order )
  81. __field( int, may_writepage )
  82. __field( gfp_t, gfp_flags )
  83. __field( int, classzone_idx )
  84. ),
  85. TP_fast_assign(
  86. __entry->order = order;
  87. __entry->may_writepage = may_writepage;
  88. __entry->gfp_flags = gfp_flags;
  89. __entry->classzone_idx = classzone_idx;
  90. ),
  91. TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
  92. __entry->order,
  93. __entry->may_writepage,
  94. show_gfp_flags(__entry->gfp_flags),
  95. __entry->classzone_idx)
  96. );
  97. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
  98. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  99. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
  100. );
  101. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
  102. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  103. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
  104. );
  105. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
  106. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  107. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
  108. );
  109. DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
  110. TP_PROTO(unsigned long nr_reclaimed),
  111. TP_ARGS(nr_reclaimed),
  112. TP_STRUCT__entry(
  113. __field( unsigned long, nr_reclaimed )
  114. ),
  115. TP_fast_assign(
  116. __entry->nr_reclaimed = nr_reclaimed;
  117. ),
  118. TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
  119. );
  120. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
  121. TP_PROTO(unsigned long nr_reclaimed),
  122. TP_ARGS(nr_reclaimed)
  123. );
  124. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
  125. TP_PROTO(unsigned long nr_reclaimed),
  126. TP_ARGS(nr_reclaimed)
  127. );
  128. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
  129. TP_PROTO(unsigned long nr_reclaimed),
  130. TP_ARGS(nr_reclaimed)
  131. );
  132. TRACE_EVENT(mm_shrink_slab_start,
  133. TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
  134. long nr_objects_to_shrink, unsigned long pgs_scanned,
  135. unsigned long lru_pgs, unsigned long cache_items,
  136. unsigned long long delta, unsigned long total_scan),
  137. TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
  138. cache_items, delta, total_scan),
  139. TP_STRUCT__entry(
  140. __field(struct shrinker *, shr)
  141. __field(void *, shrink)
  142. __field(int, nid)
  143. __field(long, nr_objects_to_shrink)
  144. __field(gfp_t, gfp_flags)
  145. __field(unsigned long, pgs_scanned)
  146. __field(unsigned long, lru_pgs)
  147. __field(unsigned long, cache_items)
  148. __field(unsigned long long, delta)
  149. __field(unsigned long, total_scan)
  150. ),
  151. TP_fast_assign(
  152. __entry->shr = shr;
  153. __entry->shrink = shr->scan_objects;
  154. __entry->nid = sc->nid;
  155. __entry->nr_objects_to_shrink = nr_objects_to_shrink;
  156. __entry->gfp_flags = sc->gfp_mask;
  157. __entry->pgs_scanned = pgs_scanned;
  158. __entry->lru_pgs = lru_pgs;
  159. __entry->cache_items = cache_items;
  160. __entry->delta = delta;
  161. __entry->total_scan = total_scan;
  162. ),
  163. TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
  164. __entry->shrink,
  165. __entry->shr,
  166. __entry->nid,
  167. __entry->nr_objects_to_shrink,
  168. show_gfp_flags(__entry->gfp_flags),
  169. __entry->pgs_scanned,
  170. __entry->lru_pgs,
  171. __entry->cache_items,
  172. __entry->delta,
  173. __entry->total_scan)
  174. );
  175. TRACE_EVENT(mm_shrink_slab_end,
  176. TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
  177. long unused_scan_cnt, long new_scan_cnt, long total_scan),
  178. TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
  179. total_scan),
  180. TP_STRUCT__entry(
  181. __field(struct shrinker *, shr)
  182. __field(int, nid)
  183. __field(void *, shrink)
  184. __field(long, unused_scan)
  185. __field(long, new_scan)
  186. __field(int, retval)
  187. __field(long, total_scan)
  188. ),
  189. TP_fast_assign(
  190. __entry->shr = shr;
  191. __entry->nid = nid;
  192. __entry->shrink = shr->scan_objects;
  193. __entry->unused_scan = unused_scan_cnt;
  194. __entry->new_scan = new_scan_cnt;
  195. __entry->retval = shrinker_retval;
  196. __entry->total_scan = total_scan;
  197. ),
  198. TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
  199. __entry->shrink,
  200. __entry->shr,
  201. __entry->nid,
  202. __entry->unused_scan,
  203. __entry->new_scan,
  204. __entry->total_scan,
  205. __entry->retval)
  206. );
  207. TRACE_EVENT(mm_vmscan_lru_isolate,
  208. TP_PROTO(int classzone_idx,
  209. int order,
  210. unsigned long nr_requested,
  211. unsigned long nr_scanned,
  212. unsigned long nr_skipped,
  213. unsigned long nr_taken,
  214. isolate_mode_t isolate_mode,
  215. int file),
  216. TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, file),
  217. TP_STRUCT__entry(
  218. __field(int, classzone_idx)
  219. __field(int, order)
  220. __field(unsigned long, nr_requested)
  221. __field(unsigned long, nr_scanned)
  222. __field(unsigned long, nr_skipped)
  223. __field(unsigned long, nr_taken)
  224. __field(isolate_mode_t, isolate_mode)
  225. __field(int, file)
  226. ),
  227. TP_fast_assign(
  228. __entry->classzone_idx = classzone_idx;
  229. __entry->order = order;
  230. __entry->nr_requested = nr_requested;
  231. __entry->nr_scanned = nr_scanned;
  232. __entry->nr_skipped = nr_skipped;
  233. __entry->nr_taken = nr_taken;
  234. __entry->isolate_mode = isolate_mode;
  235. __entry->file = file;
  236. ),
  237. TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu file=%d",
  238. __entry->isolate_mode,
  239. __entry->classzone_idx,
  240. __entry->order,
  241. __entry->nr_requested,
  242. __entry->nr_scanned,
  243. __entry->nr_skipped,
  244. __entry->nr_taken,
  245. __entry->file)
  246. );
  247. TRACE_EVENT(mm_vmscan_writepage,
  248. TP_PROTO(struct page *page),
  249. TP_ARGS(page),
  250. TP_STRUCT__entry(
  251. __field(unsigned long, pfn)
  252. __field(int, reclaim_flags)
  253. ),
  254. TP_fast_assign(
  255. __entry->pfn = page_to_pfn(page);
  256. __entry->reclaim_flags = trace_reclaim_flags(page);
  257. ),
  258. TP_printk("page=%p pfn=%lu flags=%s",
  259. pfn_to_page(__entry->pfn),
  260. __entry->pfn,
  261. show_reclaim_flags(__entry->reclaim_flags))
  262. );
  263. TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
  264. TP_PROTO(int nid,
  265. unsigned long nr_scanned, unsigned long nr_reclaimed,
  266. int priority, int file),
  267. TP_ARGS(nid, nr_scanned, nr_reclaimed, priority, file),
  268. TP_STRUCT__entry(
  269. __field(int, nid)
  270. __field(unsigned long, nr_scanned)
  271. __field(unsigned long, nr_reclaimed)
  272. __field(int, priority)
  273. __field(int, reclaim_flags)
  274. ),
  275. TP_fast_assign(
  276. __entry->nid = nid;
  277. __entry->nr_scanned = nr_scanned;
  278. __entry->nr_reclaimed = nr_reclaimed;
  279. __entry->priority = priority;
  280. __entry->reclaim_flags = trace_shrink_flags(file);
  281. ),
  282. TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
  283. __entry->nid,
  284. __entry->nr_scanned, __entry->nr_reclaimed,
  285. __entry->priority,
  286. show_reclaim_flags(__entry->reclaim_flags))
  287. );
  288. #endif /* _TRACE_VMSCAN_H */
  289. /* This part must be outside protection */
  290. #include <trace/define_trace.h>