vmscan.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM vmscan
  4. #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_VMSCAN_H
  6. #include <linux/types.h>
  7. #include <linux/tracepoint.h>
  8. #include <linux/mm.h>
  9. #include <linux/memcontrol.h>
  10. #include <trace/events/mmflags.h>
  11. #define RECLAIM_WB_ANON 0x0001u
  12. #define RECLAIM_WB_FILE 0x0002u
  13. #define RECLAIM_WB_MIXED 0x0010u
  14. #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
  15. #define RECLAIM_WB_ASYNC 0x0008u
  16. #define RECLAIM_WB_LRU (RECLAIM_WB_ANON|RECLAIM_WB_FILE)
  17. #define show_reclaim_flags(flags) \
  18. (flags) ? __print_flags(flags, "|", \
  19. {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
  20. {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
  21. {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
  22. {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
  23. {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
  24. ) : "RECLAIM_WB_NONE"
  25. #define trace_reclaim_flags(page) ( \
  26. (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
  27. (RECLAIM_WB_ASYNC) \
  28. )
  29. #define trace_shrink_flags(file) \
  30. ( \
  31. (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
  32. (RECLAIM_WB_ASYNC) \
  33. )
  34. TRACE_EVENT(mm_vmscan_kswapd_sleep,
  35. TP_PROTO(int nid),
  36. TP_ARGS(nid),
  37. TP_STRUCT__entry(
  38. __field( int, nid )
  39. ),
  40. TP_fast_assign(
  41. __entry->nid = nid;
  42. ),
  43. TP_printk("nid=%d", __entry->nid)
  44. );
  45. TRACE_EVENT(mm_vmscan_kswapd_wake,
  46. TP_PROTO(int nid, int zid, int order),
  47. TP_ARGS(nid, zid, order),
  48. TP_STRUCT__entry(
  49. __field( int, nid )
  50. __field( int, zid )
  51. __field( int, order )
  52. ),
  53. TP_fast_assign(
  54. __entry->nid = nid;
  55. __entry->zid = zid;
  56. __entry->order = order;
  57. ),
  58. TP_printk("nid=%d zid=%d order=%d", __entry->nid, __entry->zid, __entry->order)
  59. );
  60. TRACE_EVENT(mm_vmscan_wakeup_kswapd,
  61. TP_PROTO(int nid, int zid, int order, gfp_t gfp_flags),
  62. TP_ARGS(nid, zid, order, gfp_flags),
  63. TP_STRUCT__entry(
  64. __field( int, nid )
  65. __field( int, zid )
  66. __field( int, order )
  67. __field( gfp_t, gfp_flags )
  68. ),
  69. TP_fast_assign(
  70. __entry->nid = nid;
  71. __entry->zid = zid;
  72. __entry->order = order;
  73. __entry->gfp_flags = gfp_flags;
  74. ),
  75. TP_printk("nid=%d zid=%d order=%d gfp_flags=%s",
  76. __entry->nid,
  77. __entry->zid,
  78. __entry->order,
  79. show_gfp_flags(__entry->gfp_flags))
  80. );
  81. DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
  82. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  83. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx),
  84. TP_STRUCT__entry(
  85. __field( int, order )
  86. __field( int, may_writepage )
  87. __field( gfp_t, gfp_flags )
  88. __field( int, classzone_idx )
  89. ),
  90. TP_fast_assign(
  91. __entry->order = order;
  92. __entry->may_writepage = may_writepage;
  93. __entry->gfp_flags = gfp_flags;
  94. __entry->classzone_idx = classzone_idx;
  95. ),
  96. TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
  97. __entry->order,
  98. __entry->may_writepage,
  99. show_gfp_flags(__entry->gfp_flags),
  100. __entry->classzone_idx)
  101. );
  102. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
  103. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  104. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
  105. );
  106. #ifdef CONFIG_MEMCG
  107. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
  108. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  109. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
  110. );
  111. DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
  112. TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
  113. TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
  114. );
  115. #endif /* CONFIG_MEMCG */
  116. DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
  117. TP_PROTO(unsigned long nr_reclaimed),
  118. TP_ARGS(nr_reclaimed),
  119. TP_STRUCT__entry(
  120. __field( unsigned long, nr_reclaimed )
  121. ),
  122. TP_fast_assign(
  123. __entry->nr_reclaimed = nr_reclaimed;
  124. ),
  125. TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
  126. );
  127. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
  128. TP_PROTO(unsigned long nr_reclaimed),
  129. TP_ARGS(nr_reclaimed)
  130. );
  131. #ifdef CONFIG_MEMCG
  132. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
  133. TP_PROTO(unsigned long nr_reclaimed),
  134. TP_ARGS(nr_reclaimed)
  135. );
  136. DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
  137. TP_PROTO(unsigned long nr_reclaimed),
  138. TP_ARGS(nr_reclaimed)
  139. );
  140. #endif /* CONFIG_MEMCG */
  141. TRACE_EVENT(mm_shrink_slab_start,
  142. TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
  143. long nr_objects_to_shrink, unsigned long cache_items,
  144. unsigned long long delta, unsigned long total_scan,
  145. int priority),
  146. TP_ARGS(shr, sc, nr_objects_to_shrink, cache_items, delta, total_scan,
  147. priority),
  148. TP_STRUCT__entry(
  149. __field(struct shrinker *, shr)
  150. __field(void *, shrink)
  151. __field(int, nid)
  152. __field(long, nr_objects_to_shrink)
  153. __field(gfp_t, gfp_flags)
  154. __field(unsigned long, cache_items)
  155. __field(unsigned long long, delta)
  156. __field(unsigned long, total_scan)
  157. __field(int, priority)
  158. ),
  159. TP_fast_assign(
  160. __entry->shr = shr;
  161. __entry->shrink = shr->scan_objects;
  162. __entry->nid = sc->nid;
  163. __entry->nr_objects_to_shrink = nr_objects_to_shrink;
  164. __entry->gfp_flags = sc->gfp_mask;
  165. __entry->cache_items = cache_items;
  166. __entry->delta = delta;
  167. __entry->total_scan = total_scan;
  168. __entry->priority = priority;
  169. ),
  170. TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s cache items %ld delta %lld total_scan %ld priority %d",
  171. __entry->shrink,
  172. __entry->shr,
  173. __entry->nid,
  174. __entry->nr_objects_to_shrink,
  175. show_gfp_flags(__entry->gfp_flags),
  176. __entry->cache_items,
  177. __entry->delta,
  178. __entry->total_scan,
  179. __entry->priority)
  180. );
  181. TRACE_EVENT(mm_shrink_slab_end,
  182. TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
  183. long unused_scan_cnt, long new_scan_cnt, long total_scan),
  184. TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
  185. total_scan),
  186. TP_STRUCT__entry(
  187. __field(struct shrinker *, shr)
  188. __field(int, nid)
  189. __field(void *, shrink)
  190. __field(long, unused_scan)
  191. __field(long, new_scan)
  192. __field(int, retval)
  193. __field(long, total_scan)
  194. ),
  195. TP_fast_assign(
  196. __entry->shr = shr;
  197. __entry->nid = nid;
  198. __entry->shrink = shr->scan_objects;
  199. __entry->unused_scan = unused_scan_cnt;
  200. __entry->new_scan = new_scan_cnt;
  201. __entry->retval = shrinker_retval;
  202. __entry->total_scan = total_scan;
  203. ),
  204. TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
  205. __entry->shrink,
  206. __entry->shr,
  207. __entry->nid,
  208. __entry->unused_scan,
  209. __entry->new_scan,
  210. __entry->total_scan,
  211. __entry->retval)
  212. );
  213. TRACE_EVENT(mm_vmscan_lru_isolate,
  214. TP_PROTO(int classzone_idx,
  215. int order,
  216. unsigned long nr_requested,
  217. unsigned long nr_scanned,
  218. unsigned long nr_skipped,
  219. unsigned long nr_taken,
  220. isolate_mode_t isolate_mode,
  221. int lru),
  222. TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, lru),
  223. TP_STRUCT__entry(
  224. __field(int, classzone_idx)
  225. __field(int, order)
  226. __field(unsigned long, nr_requested)
  227. __field(unsigned long, nr_scanned)
  228. __field(unsigned long, nr_skipped)
  229. __field(unsigned long, nr_taken)
  230. __field(isolate_mode_t, isolate_mode)
  231. __field(int, lru)
  232. ),
  233. TP_fast_assign(
  234. __entry->classzone_idx = classzone_idx;
  235. __entry->order = order;
  236. __entry->nr_requested = nr_requested;
  237. __entry->nr_scanned = nr_scanned;
  238. __entry->nr_skipped = nr_skipped;
  239. __entry->nr_taken = nr_taken;
  240. __entry->isolate_mode = isolate_mode;
  241. __entry->lru = lru;
  242. ),
  243. TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s",
  244. __entry->isolate_mode,
  245. __entry->classzone_idx,
  246. __entry->order,
  247. __entry->nr_requested,
  248. __entry->nr_scanned,
  249. __entry->nr_skipped,
  250. __entry->nr_taken,
  251. __print_symbolic(__entry->lru, LRU_NAMES))
  252. );
  253. TRACE_EVENT(mm_vmscan_writepage,
  254. TP_PROTO(struct page *page),
  255. TP_ARGS(page),
  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 = trace_reclaim_flags(page);
  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,
  271. unsigned long nr_scanned, unsigned long nr_reclaimed,
  272. struct reclaim_stat *stat, int priority, int file),
  273. TP_ARGS(nid, nr_scanned, nr_reclaimed, stat, priority, file),
  274. TP_STRUCT__entry(
  275. __field(int, nid)
  276. __field(unsigned long, nr_scanned)
  277. __field(unsigned long, nr_reclaimed)
  278. __field(unsigned long, nr_dirty)
  279. __field(unsigned long, nr_writeback)
  280. __field(unsigned long, nr_congested)
  281. __field(unsigned long, nr_immediate)
  282. __field(unsigned long, nr_activate)
  283. __field(unsigned long, nr_ref_keep)
  284. __field(unsigned long, nr_unmap_fail)
  285. __field(int, priority)
  286. __field(int, reclaim_flags)
  287. ),
  288. TP_fast_assign(
  289. __entry->nid = nid;
  290. __entry->nr_scanned = nr_scanned;
  291. __entry->nr_reclaimed = nr_reclaimed;
  292. __entry->nr_dirty = stat->nr_dirty;
  293. __entry->nr_writeback = stat->nr_writeback;
  294. __entry->nr_congested = stat->nr_congested;
  295. __entry->nr_immediate = stat->nr_immediate;
  296. __entry->nr_activate = stat->nr_activate;
  297. __entry->nr_ref_keep = stat->nr_ref_keep;
  298. __entry->nr_unmap_fail = stat->nr_unmap_fail;
  299. __entry->priority = priority;
  300. __entry->reclaim_flags = trace_shrink_flags(file);
  301. ),
  302. TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate=%ld nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s",
  303. __entry->nid,
  304. __entry->nr_scanned, __entry->nr_reclaimed,
  305. __entry->nr_dirty, __entry->nr_writeback,
  306. __entry->nr_congested, __entry->nr_immediate,
  307. __entry->nr_activate, __entry->nr_ref_keep,
  308. __entry->nr_unmap_fail, __entry->priority,
  309. show_reclaim_flags(__entry->reclaim_flags))
  310. );
  311. TRACE_EVENT(mm_vmscan_lru_shrink_active,
  312. TP_PROTO(int nid, unsigned long nr_taken,
  313. unsigned long nr_active, unsigned long nr_deactivated,
  314. unsigned long nr_referenced, int priority, int file),
  315. TP_ARGS(nid, nr_taken, nr_active, nr_deactivated, nr_referenced, priority, file),
  316. TP_STRUCT__entry(
  317. __field(int, nid)
  318. __field(unsigned long, nr_taken)
  319. __field(unsigned long, nr_active)
  320. __field(unsigned long, nr_deactivated)
  321. __field(unsigned long, nr_referenced)
  322. __field(int, priority)
  323. __field(int, reclaim_flags)
  324. ),
  325. TP_fast_assign(
  326. __entry->nid = nid;
  327. __entry->nr_taken = nr_taken;
  328. __entry->nr_active = nr_active;
  329. __entry->nr_deactivated = nr_deactivated;
  330. __entry->nr_referenced = nr_referenced;
  331. __entry->priority = priority;
  332. __entry->reclaim_flags = trace_shrink_flags(file);
  333. ),
  334. TP_printk("nid=%d nr_taken=%ld nr_active=%ld nr_deactivated=%ld nr_referenced=%ld priority=%d flags=%s",
  335. __entry->nid,
  336. __entry->nr_taken,
  337. __entry->nr_active, __entry->nr_deactivated, __entry->nr_referenced,
  338. __entry->priority,
  339. show_reclaim_flags(__entry->reclaim_flags))
  340. );
  341. TRACE_EVENT(mm_vmscan_inactive_list_is_low,
  342. TP_PROTO(int nid, int reclaim_idx,
  343. unsigned long total_inactive, unsigned long inactive,
  344. unsigned long total_active, unsigned long active,
  345. unsigned long ratio, int file),
  346. TP_ARGS(nid, reclaim_idx, total_inactive, inactive, total_active, active, ratio, file),
  347. TP_STRUCT__entry(
  348. __field(int, nid)
  349. __field(int, reclaim_idx)
  350. __field(unsigned long, total_inactive)
  351. __field(unsigned long, inactive)
  352. __field(unsigned long, total_active)
  353. __field(unsigned long, active)
  354. __field(unsigned long, ratio)
  355. __field(int, reclaim_flags)
  356. ),
  357. TP_fast_assign(
  358. __entry->nid = nid;
  359. __entry->reclaim_idx = reclaim_idx;
  360. __entry->total_inactive = total_inactive;
  361. __entry->inactive = inactive;
  362. __entry->total_active = total_active;
  363. __entry->active = active;
  364. __entry->ratio = ratio;
  365. __entry->reclaim_flags = trace_shrink_flags(file) & RECLAIM_WB_LRU;
  366. ),
  367. TP_printk("nid=%d reclaim_idx=%d total_inactive=%ld inactive=%ld total_active=%ld active=%ld ratio=%ld flags=%s",
  368. __entry->nid,
  369. __entry->reclaim_idx,
  370. __entry->total_inactive, __entry->inactive,
  371. __entry->total_active, __entry->active,
  372. __entry->ratio,
  373. show_reclaim_flags(__entry->reclaim_flags))
  374. );
  375. #endif /* _TRACE_VMSCAN_H */
  376. /* This part must be outside protection */
  377. #include <trace/define_trace.h>