2 #define TRACE_SYSTEM mm_vmscan
4 #if !defined(LTTNG_TRACE_MM_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_MM_VMSCAN_H
7 #include <probes/lttng-tracepoint-event.h>
8 #include <linux/types.h>
10 #include <linux/memcontrol.h>
11 #include <linux/version.h>
13 #ifndef _TRACE_VMSCAN_DEF
14 #define _TRACE_VMSCAN_DEF
15 #define RECLAIM_WB_ANON 0x0001u
16 #define RECLAIM_WB_FILE 0x0002u
17 #define RECLAIM_WB_MIXED 0x0010u
18 #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
19 #define RECLAIM_WB_ASYNC 0x0008u
21 #if ((LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,38)) || \
22 LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
23 typedef int isolate_mode_t
;
28 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
30 #include <linux/mm_inline.h>
32 #define trace_reclaim_flags(page) ( \
33 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
37 #define trace_shrink_flags(file) \
39 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
45 LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_sleep
,
52 ctf_integer(int, nid
, nid
)
56 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
58 LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_wake
,
60 TP_PROTO(int nid
, int zid
, int order
),
62 TP_ARGS(nid
, zid
, order
),
65 ctf_integer(int, nid
, nid
)
66 ctf_integer(int, zid
, zid
)
67 ctf_integer(int, order
, order
)
73 LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_wake
,
75 TP_PROTO(int nid
, int order
),
80 ctf_integer(int, nid
, nid
)
81 ctf_integer(int, order
, order
)
87 LTTNG_TRACEPOINT_EVENT(mm_vmscan_wakeup_kswapd
,
89 TP_PROTO(int nid
, int zid
, int order
),
91 TP_ARGS(nid
, zid
, order
),
94 ctf_integer(int, nid
, nid
)
95 ctf_integer(int, zid
, zid
)
96 ctf_integer(int, order
, order
)
100 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
102 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
104 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
106 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
),
109 ctf_integer(int, order
, order
)
110 ctf_integer(int, may_writepage
, may_writepage
)
111 ctf_integer(gfp_t
, gfp_flags
, gfp_flags
)
112 ctf_integer(int, classzone_idx
, classzone_idx
)
116 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
118 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
120 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
123 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
125 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
127 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
130 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
132 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
134 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
139 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
141 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
143 TP_ARGS(order
, may_writepage
, gfp_flags
),
146 ctf_integer(int, order
, order
)
147 ctf_integer(int, may_writepage
, may_writepage
)
148 ctf_integer(gfp_t
, gfp_flags
, gfp_flags
)
152 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
154 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
156 TP_ARGS(order
, may_writepage
, gfp_flags
)
159 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
161 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
163 TP_ARGS(order
, may_writepage
, gfp_flags
)
166 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
168 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
170 TP_ARGS(order
, may_writepage
, gfp_flags
)
175 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
177 TP_PROTO(unsigned long nr_reclaimed
),
179 TP_ARGS(nr_reclaimed
),
182 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
186 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
188 TP_PROTO(unsigned long nr_reclaimed
),
190 TP_ARGS(nr_reclaimed
)
193 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
195 TP_PROTO(unsigned long nr_reclaimed
),
197 TP_ARGS(nr_reclaimed
)
200 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
202 TP_PROTO(unsigned long nr_reclaimed
),
204 TP_ARGS(nr_reclaimed
)
207 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
208 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_start
,
210 mm_vmscan_shrink_slab_start
,
212 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
213 long nr_objects_to_shrink
, unsigned long pgs_scanned
,
214 unsigned long lru_pgs
, unsigned long cache_items
,
215 unsigned long long delta
, unsigned long total_scan
),
217 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
218 cache_items
, delta
, total_scan
),
221 ctf_integer_hex(struct shrinker
*, shr
, shr
)
222 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
223 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
224 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
225 ctf_integer_hex(void *, shrink
, shr
->shrink
)
226 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
227 ctf_integer(long, nr_objects_to_shrink
, nr_objects_to_shrink
)
228 ctf_integer(gfp_t
, gfp_flags
, sc
->gfp_mask
)
229 ctf_integer(unsigned long, pgs_scanned
, pgs_scanned
)
230 ctf_integer(unsigned long, lru_pgs
, lru_pgs
)
231 ctf_integer(unsigned long, cache_items
, cache_items
)
232 ctf_integer(unsigned long long, delta
, delta
)
233 ctf_integer(unsigned long, total_scan
, total_scan
)
237 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
238 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end
,
240 mm_vmscan_shrink_slab_end
,
242 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
243 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
245 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
249 ctf_integer_hex(struct shrinker
*, shr
, shr
)
250 ctf_integer(int, nid
, nid
)
251 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
252 ctf_integer(long, unused_scan
, unused_scan_cnt
)
253 ctf_integer(long, new_scan
, new_scan_cnt
)
254 ctf_integer(int, retval
, shrinker_retval
)
255 ctf_integer(long, total_scan
, total_scan
)
258 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
259 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end
,
261 mm_vmscan_shrink_slab_end
,
263 TP_PROTO(struct shrinker
*shr
, int shrinker_retval
,
264 long unused_scan_cnt
, long new_scan_cnt
),
266 TP_ARGS(shr
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
),
269 ctf_integer_hex(struct shrinker
*, shr
, shr
)
270 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
271 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
272 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
273 ctf_integer_hex(void *, shrink
, shr
->shrink
)
274 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
275 ctf_integer(long, unused_scan
, unused_scan_cnt
)
276 ctf_integer(long, new_scan
, new_scan_cnt
)
277 ctf_integer(int, retval
, shrinker_retval
)
278 ctf_integer(long, total_scan
, new_scan_cnt
- unused_scan_cnt
)
281 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
284 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
286 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
288 TP_PROTO(int classzone_idx
,
290 unsigned long nr_requested
,
291 unsigned long nr_scanned
,
292 unsigned long nr_taken
,
293 isolate_mode_t isolate_mode
,
297 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_taken
,
303 ctf_integer(int, classzone_idx
, classzone_idx
)
304 ctf_integer(int, order
, order
)
305 ctf_integer(unsigned long, nr_requested
, nr_requested
)
306 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
307 ctf_integer(unsigned long, nr_taken
, nr_taken
)
308 ctf_integer(isolate_mode_t
, isolate_mode
, isolate_mode
)
309 ctf_integer(int, file
, file
)
313 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
315 TP_PROTO(int classzone_idx
,
317 unsigned long nr_requested
,
318 unsigned long nr_scanned
,
319 unsigned long nr_taken
,
320 isolate_mode_t isolate_mode
,
324 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_taken
,
330 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
332 TP_PROTO(int classzone_idx
,
334 unsigned long nr_requested
,
335 unsigned long nr_scanned
,
336 unsigned long nr_taken
,
337 isolate_mode_t isolate_mode
,
341 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_taken
,
348 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
351 unsigned long nr_requested
,
352 unsigned long nr_scanned
,
353 unsigned long nr_taken
,
354 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
355 unsigned long nr_lumpy_taken
,
356 unsigned long nr_lumpy_dirty
,
357 unsigned long nr_lumpy_failed
,
359 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
360 isolate_mode_t isolate_mode
362 isolate_mode_t isolate_mode
,
367 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
368 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
369 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
371 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
380 ctf_integer(int, order
, order
)
381 ctf_integer(unsigned long, nr_requested
, nr_requested
)
382 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
383 ctf_integer(unsigned long, nr_taken
, nr_taken
)
384 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
385 ctf_integer(unsigned long, nr_lumpy_taken
, nr_lumpy_taken
)
386 ctf_integer(unsigned long, nr_lumpy_dirty
, nr_lumpy_dirty
)
387 ctf_integer(unsigned long, nr_lumpy_failed
, nr_lumpy_failed
)
389 ctf_integer(isolate_mode_t
, isolate_mode
, isolate_mode
)
390 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
391 ctf_integer(int, file
, file
)
396 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
399 unsigned long nr_requested
,
400 unsigned long nr_scanned
,
401 unsigned long nr_taken
,
402 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
403 unsigned long nr_lumpy_taken
,
404 unsigned long nr_lumpy_dirty
,
405 unsigned long nr_lumpy_failed
,
407 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
408 isolate_mode_t isolate_mode
410 isolate_mode_t isolate_mode
,
415 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
416 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
417 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
419 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
428 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
431 unsigned long nr_requested
,
432 unsigned long nr_scanned
,
433 unsigned long nr_taken
,
434 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
435 unsigned long nr_lumpy_taken
,
436 unsigned long nr_lumpy_dirty
,
437 unsigned long nr_lumpy_failed
,
439 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
440 isolate_mode_t isolate_mode
442 isolate_mode_t isolate_mode
,
447 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
448 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
449 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
451 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
461 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
462 LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage
,
464 TP_PROTO(struct page
*page
),
469 ctf_integer_hex(struct page
*, page
, page
)
470 ctf_integer(int, reclaim_flags
, trace_reclaim_flags(page
))
474 LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage
,
476 TP_PROTO(struct page
*page
,
479 TP_ARGS(page
, reclaim_flags
),
482 ctf_integer_hex(struct page
*, page
, page
)
483 ctf_integer(int, reclaim_flags
, reclaim_flags
)
488 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
489 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
492 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
493 int priority
, int file
),
495 TP_ARGS(nid
, nr_scanned
, nr_reclaimed
, priority
, file
),
498 ctf_integer(int, nid
, nid
)
499 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
500 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
501 ctf_integer(int, priority
, priority
)
502 ctf_integer(int, reclaim_flags
, trace_shrink_flags(file
))
505 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
506 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
508 TP_PROTO(struct zone
*zone
,
509 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
510 int priority
, int file
),
512 TP_ARGS(zone
, nr_scanned
, nr_reclaimed
, priority
, file
),
515 ctf_integer(int, nid
, zone_to_nid(zone
))
516 ctf_integer(int, zid
, zone_idx(zone
))
517 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
518 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
519 ctf_integer(int, priority
, priority
)
520 ctf_integer(int, reclaim_flags
, trace_shrink_flags(file
))
523 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
524 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
526 TP_PROTO(int nid
, int zid
,
527 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
528 int priority
, int reclaim_flags
),
530 TP_ARGS(nid
, zid
, nr_scanned
, nr_reclaimed
, priority
, reclaim_flags
),
533 ctf_integer(int, nid
, nid
)
534 ctf_integer(int, zid
, zid
)
535 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
536 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
537 ctf_integer(int, priority
, priority
)
538 ctf_integer(int, reclaim_flags
, reclaim_flags
)
543 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
544 LTTNG_TRACEPOINT_EVENT_MAP(replace_swap_token
,
546 mm_vmscan_replace_swap_token
,
548 TP_PROTO(struct mm_struct
*old_mm
,
549 struct mm_struct
*new_mm
),
551 TP_ARGS(old_mm
, new_mm
),
554 ctf_integer_hex(struct mm_struct
*, old_mm
, old_mm
)
555 ctf_integer(unsigned int, old_prio
, old_mm
? old_mm
->token_priority
: 0)
556 ctf_integer_hex(struct mm_struct
*, new_mm
, new_mm
)
557 ctf_integer(unsigned int, new_prio
, new_mm
->token_priority
)
561 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_put_swap_token_template
,
562 TP_PROTO(struct mm_struct
*swap_token_mm
),
564 TP_ARGS(swap_token_mm
),
567 ctf_integer_hex(struct mm_struct
*, swap_token_mm
, swap_token_mm
)
571 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template
, put_swap_token
,
573 mm_vmscan_put_swap_token
,
575 TP_PROTO(struct mm_struct
*swap_token_mm
),
576 TP_ARGS(swap_token_mm
)
579 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template
, disable_swap_token
,
581 mm_vmscan_disable_swap_token
,
583 TP_PROTO(struct mm_struct
*swap_token_mm
),
584 TP_ARGS(swap_token_mm
)
587 LTTNG_TRACEPOINT_EVENT_MAP(update_swap_token_priority
,
589 mm_vmscan_update_swap_token_priority
,
591 TP_PROTO(struct mm_struct
*mm
,
592 unsigned int old_prio
,
593 struct mm_struct
*swap_token_mm
),
595 TP_ARGS(mm
, old_prio
, swap_token_mm
),
598 ctf_integer_hex(struct mm_struct
*, mm
, mm
)
599 ctf_integer(unsigned int, old_prio
, old_prio
)
600 ctf_integer(unsigned int, new_prio
, mm
->token_priority
)
601 ctf_integer_hex(struct mm_struct
*, swap_token_mm
, swap_token_mm
)
602 ctf_integer(unsigned int, swap_token_prio
, swap_token_mm
? swap_token_mm
->token_priority
: 0)
607 #endif /* LTTNG_TRACE_MM_VMSCAN_H */
609 /* This part must be outside protection */
610 #include <probes/define_trace.h>