vmscan.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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/gfpflags.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 order),
  45. TP_ARGS(nid, order),
  46. TP_STRUCT__entry(
  47. __field( int, nid )
  48. __field( int, order )
  49. ),
  50. TP_fast_assign(
  51. __entry->nid = nid;
  52. __entry->order = order;
  53. ),
  54. TP_printk("nid=%d order=%d", __entry->nid, __entry->order)
  55. );
  56. TRACE_EVENT(mm_vmscan_wakeup_kswapd,
  57. TP_PROTO(int nid, int zid, int order),
  58. TP_ARGS(nid, zid, order),
  59. TP_STRUCT__entry(
  60. __field( int, nid )
  61. __field( int, zid )
  62. __field( int, order )
  63. ),
  64. TP_fast_assign(
  65. __entry->nid = nid;
  66. __entry->zid = zid;
  67. __entry->order = order;
  68. ),
  69. TP_printk("nid=%d zid=%d order=%d",
  70. __entry->nid,
  71. __entry->zid,
  72. __entry->order)
  73. );
  74. DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
  75. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
  76. TP_ARGS(order, may_writepage, gfp_flags),
  77. TP_STRUCT__entry(
  78. __field( int, order )
  79. __field( int, may_writepage )
  80. __field( gfp_t, gfp_flags )
  81. ),
  82. TP_fast_assign(
  83. __entry->order = order;
  84. __entry->may_writepage = may_writepage;
  85. __entry->gfp_flags = gfp_flags;
  86. ),
  87. TP_printk("order=%d may_writepage=%d gfp_flags=%s",
  88. __entry->order,
  89. __entry->may_writepage,
  90. show_gfp_flags(__entry->gfp_flags))
  91. );
  92. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
  93. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
  94. TP_ARGS(order, may_writepage, gfp_flags)
  95. );
  96. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
  97. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
  98. TP_ARGS(order, may_writepage, gfp_flags)
  99. );
  100. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
  101. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
  102. TP_ARGS(order, may_writepage, gfp_flags)
  103. );
  104. DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
  105. TP_PROTO(unsigned long nr_reclaimed),
  106. TP_ARGS(nr_reclaimed),
  107. TP_STRUCT__entry(
  108. __field( unsigned long, nr_reclaimed )
  109. ),
  110. TP_fast_assign(
  111. __entry->nr_reclaimed = nr_reclaimed;
  112. ),
  113. TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
  114. );
  115. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
  116. TP_PROTO(unsigned long nr_reclaimed),
  117. TP_ARGS(nr_reclaimed)
  118. );
  119. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
  120. TP_PROTO(unsigned long nr_reclaimed),
  121. TP_ARGS(nr_reclaimed)
  122. );
  123. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
  124. TP_PROTO(unsigned long nr_reclaimed),
  125. TP_ARGS(nr_reclaimed)
  126. );
  127. TRACE_EVENT(mm_shrink_slab_start,
  128. TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
  129. long nr_objects_to_shrink, unsigned long pgs_scanned,
  130. unsigned long lru_pgs, unsigned long cache_items,
  131. unsigned long long delta, unsigned long total_scan),
  132. TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
  133. cache_items, delta, total_scan),
  134. TP_STRUCT__entry(
  135. __field(struct shrinker *, shr)
  136. __field(void *, shrink)
  137. __field(int, nid)
  138. __field(long, nr_objects_to_shrink)
  139. __field(gfp_t, gfp_flags)
  140. __field(unsigned long, pgs_scanned)
  141. __field(unsigned long, lru_pgs)
  142. __field(unsigned long, cache_items)
  143. __field(unsigned long long, delta)
  144. __field(unsigned long, total_scan)
  145. ),
  146. TP_fast_assign(
  147. __entry->shr = shr;
  148. __entry->shrink = shr->scan_objects;
  149. __entry->nid = sc->nid;
  150. __entry->nr_objects_to_shrink = nr_objects_to_shrink;
  151. __entry->gfp_flags = sc->gfp_mask;
  152. __entry->pgs_scanned = pgs_scanned;
  153. __entry->lru_pgs = lru_pgs;
  154. __entry->cache_items = cache_items;
  155. __entry->delta = delta;
  156. __entry->total_scan = total_scan;
  157. ),
  158. 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",
  159. __entry->shrink,
  160. __entry->shr,
  161. __entry->nid,
  162. __entry->nr_objects_to_shrink,
  163. show_gfp_flags(__entry->gfp_flags),
  164. __entry->pgs_scanned,
  165. __entry->lru_pgs,
  166. __entry->cache_items,
  167. __entry->delta,
  168. __entry->total_scan)
  169. );
  170. TRACE_EVENT(mm_shrink_slab_end,
  171. TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
  172. long unused_scan_cnt, long new_scan_cnt, long total_scan),
  173. TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
  174. total_scan),
  175. TP_STRUCT__entry(
  176. __field(struct shrinker *, shr)
  177. __field(int, nid)
  178. __field(void *, shrink)
  179. __field(long, unused_scan)
  180. __field(long, new_scan)
  181. __field(int, retval)
  182. __field(long, total_scan)
  183. ),
  184. TP_fast_assign(
  185. __entry->shr = shr;
  186. __entry->nid = nid;
  187. __entry->shrink = shr->scan_objects;
  188. __entry->unused_scan = unused_scan_cnt;
  189. __entry->new_scan = new_scan_cnt;
  190. __entry->retval = shrinker_retval;
  191. __entry->total_scan = total_scan;
  192. ),
  193. TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
  194. __entry->shrink,
  195. __entry->shr,
  196. __entry->nid,
  197. __entry->unused_scan,
  198. __entry->new_scan,
  199. __entry->total_scan,
  200. __entry->retval)
  201. );
  202. DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
  203. TP_PROTO(int order,
  204. unsigned long nr_requested,
  205. unsigned long nr_scanned,
  206. unsigned long nr_taken,
  207. isolate_mode_t isolate_mode,
  208. int file),
  209. TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file),
  210. TP_STRUCT__entry(
  211. __field(int, order)
  212. __field(unsigned long, nr_requested)
  213. __field(unsigned long, nr_scanned)
  214. __field(unsigned long, nr_taken)
  215. __field(isolate_mode_t, isolate_mode)
  216. __field(int, file)
  217. ),
  218. TP_fast_assign(
  219. __entry->order = order;
  220. __entry->nr_requested = nr_requested;
  221. __entry->nr_scanned = nr_scanned;
  222. __entry->nr_taken = nr_taken;
  223. __entry->isolate_mode = isolate_mode;
  224. __entry->file = file;
  225. ),
  226. TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
  227. __entry->isolate_mode,
  228. __entry->order,
  229. __entry->nr_requested,
  230. __entry->nr_scanned,
  231. __entry->nr_taken,
  232. __entry->file)
  233. );
  234. DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
  235. TP_PROTO(int order,
  236. unsigned long nr_requested,
  237. unsigned long nr_scanned,
  238. unsigned long nr_taken,
  239. isolate_mode_t isolate_mode,
  240. int file),
  241. TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
  242. );
  243. DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
  244. TP_PROTO(int order,
  245. unsigned long nr_requested,
  246. unsigned long nr_scanned,
  247. unsigned long nr_taken,
  248. isolate_mode_t isolate_mode,
  249. int file),
  250. TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
  251. );
  252. TRACE_EVENT(mm_vmscan_writepage,
  253. TP_PROTO(struct page *page,
  254. int reclaim_flags),
  255. TP_ARGS(page, reclaim_flags),
  256. TP_STRUCT__entry(
  257. __field(unsigned long, pfn)
  258. __field(int, reclaim_flags)
  259. ),
  260. TP_fast_assign(
  261. __entry->pfn = page_to_pfn(page);
  262. __entry->reclaim_flags = reclaim_flags;
  263. ),
  264. TP_printk("page=%p pfn=%lu flags=%s",
  265. pfn_to_page(__entry->pfn),
  266. __entry->pfn,
  267. show_reclaim_flags(__entry->reclaim_flags))
  268. );
  269. TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
  270. TP_PROTO(int nid, int zid,
  271. unsigned long nr_scanned, unsigned long nr_reclaimed,
  272. int priority, int reclaim_flags),
  273. TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags),
  274. TP_STRUCT__entry(
  275. __field(int, nid)
  276. __field(int, zid)
  277. __field(unsigned long, nr_scanned)
  278. __field(unsigned long, nr_reclaimed)
  279. __field(int, priority)
  280. __field(int, reclaim_flags)
  281. ),
  282. TP_fast_assign(
  283. __entry->nid = nid;
  284. __entry->zid = zid;
  285. __entry->nr_scanned = nr_scanned;
  286. __entry->nr_reclaimed = nr_reclaimed;
  287. __entry->priority = priority;
  288. __entry->reclaim_flags = reclaim_flags;
  289. ),
  290. TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
  291. __entry->nid, __entry->zid,
  292. __entry->nr_scanned, __entry->nr_reclaimed,
  293. __entry->priority,
  294. show_reclaim_flags(__entry->reclaim_flags))
  295. );
  296. #endif /* _TRACE_VMSCAN_H */
  297. /* This part must be outside protection */
  298. #include <trace/define_trace.h>