2 #define TRACE_SYSTEM vmscan
4 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_VMSCAN_H
7 #include <linux/types.h>
8 #include <linux/tracepoint.h>
10 #include <linux/memcontrol.h>
11 #include <trace/events/gfpflags.h>
12 #include <linux/version.h>
14 #ifndef _TRACE_VMSCAN_DEF
15 #define _TRACE_VMSCAN_DEF
16 #define RECLAIM_WB_ANON 0x0001u
17 #define RECLAIM_WB_FILE 0x0002u
18 #define RECLAIM_WB_MIXED 0x0010u
19 #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
20 #define RECLAIM_WB_ASYNC 0x0008u
22 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
23 #define show_reclaim_flags(flags) \
24 (flags) ? __print_flags(flags, "|", \
25 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
26 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
27 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
28 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
29 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
32 #define show_reclaim_flags(flags) \
33 (flags) ? __print_flags(flags, "|", \
34 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
35 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
36 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
37 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
41 #if ((LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,38)) || \
42 LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
43 typedef int isolate_mode_t
;
48 TRACE_EVENT(mm_vmscan_kswapd_sleep
,
62 TP_printk("nid=%d", __entry
->nid
)
65 TRACE_EVENT(mm_vmscan_kswapd_wake
,
67 TP_PROTO(int nid
, int order
),
78 tp_assign(order
, order
)
81 TP_printk("nid=%d order=%d", __entry
->nid
, __entry
->order
)
84 TRACE_EVENT(mm_vmscan_wakeup_kswapd
,
86 TP_PROTO(int nid
, int zid
, int order
),
88 TP_ARGS(nid
, zid
, order
),
99 tp_assign(order
, order
)
102 TP_printk("nid=%d zid=%d order=%d",
108 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
110 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
112 TP_ARGS(order
, may_writepage
, gfp_flags
),
115 __field( int, order
)
116 __field( int, may_writepage
)
117 __field( gfp_t
, gfp_flags
)
121 tp_assign(order
, order
)
122 tp_assign(may_writepage
, may_writepage
)
123 tp_assign(gfp_flags
, gfp_flags
)
126 TP_printk("order=%d may_writepage=%d gfp_flags=%s",
128 __entry
->may_writepage
,
129 show_gfp_flags(__entry
->gfp_flags
))
132 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
134 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
136 TP_ARGS(order
, may_writepage
, gfp_flags
)
139 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
141 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
143 TP_ARGS(order
, may_writepage
, gfp_flags
)
146 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
148 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
150 TP_ARGS(order
, may_writepage
, gfp_flags
)
153 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
155 TP_PROTO(unsigned long nr_reclaimed
),
157 TP_ARGS(nr_reclaimed
),
160 __field( unsigned long, nr_reclaimed
)
164 tp_assign(nr_reclaimed
, nr_reclaimed
)
167 TP_printk("nr_reclaimed=%lu", __entry
->nr_reclaimed
)
170 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
172 TP_PROTO(unsigned long nr_reclaimed
),
174 TP_ARGS(nr_reclaimed
)
177 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
179 TP_PROTO(unsigned long nr_reclaimed
),
181 TP_ARGS(nr_reclaimed
)
184 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
186 TP_PROTO(unsigned long nr_reclaimed
),
188 TP_ARGS(nr_reclaimed
)
191 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
192 TRACE_EVENT(mm_shrink_slab_start
,
193 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
194 long nr_objects_to_shrink
, unsigned long pgs_scanned
,
195 unsigned long lru_pgs
, unsigned long cache_items
,
196 unsigned long long delta
, unsigned long total_scan
),
198 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
199 cache_items
, delta
, total_scan
),
202 __field(struct shrinker
*, shr
)
203 __field(void *, shrink
)
204 __field(long, nr_objects_to_shrink
)
205 __field(gfp_t
, gfp_flags
)
206 __field(unsigned long, pgs_scanned
)
207 __field(unsigned long, lru_pgs
)
208 __field(unsigned long, cache_items
)
209 __field(unsigned long long, delta
)
210 __field(unsigned long, total_scan
)
215 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
216 tp_assign(shrink
, shr
->scan_objects
)
217 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
218 tp_assign(shrink
, shr
->shrink
)
219 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
220 tp_assign(nr_objects_to_shrink
, nr_objects_to_shrink
)
221 tp_assign(gfp_flags
, sc
->gfp_mask
)
222 tp_assign(pgs_scanned
, pgs_scanned
)
223 tp_assign(lru_pgs
, lru_pgs
)
224 tp_assign(cache_items
, cache_items
)
225 tp_assign(delta
, delta
)
226 tp_assign(total_scan
, total_scan
)
229 TP_printk("%pF %p: objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
232 __entry
->nr_objects_to_shrink
,
233 show_gfp_flags(__entry
->gfp_flags
),
234 __entry
->pgs_scanned
,
236 __entry
->cache_items
,
241 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
242 TRACE_EVENT(mm_shrink_slab_end
,
243 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
244 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
246 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
250 __field(struct shrinker
*, shr
)
252 __field(void *, shrink
)
253 __field(long, unused_scan
)
254 __field(long, new_scan
)
256 __field(long, total_scan
)
262 tp_assign(shrink
, shr
->scan_objects
)
263 tp_assign(unused_scan
, unused_scan_cnt
)
264 tp_assign(new_scan
, new_scan_cnt
)
265 tp_assign(retval
, shrinker_retval
)
266 tp_assign(total_scan
, total_scan
)
269 TP_printk("%pF %p: nid %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
273 __entry
->unused_scan
,
278 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
279 TRACE_EVENT(mm_shrink_slab_end
,
280 TP_PROTO(struct shrinker
*shr
, int shrinker_retval
,
281 long unused_scan_cnt
, long new_scan_cnt
),
283 TP_ARGS(shr
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
),
286 __field(struct shrinker
*, shr
)
287 __field(void *, shrink
)
288 __field(long, unused_scan
)
289 __field(long, new_scan
)
291 __field(long, total_scan
)
296 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
297 tp_assign(shrink
, shr
->scan_objects
)
298 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
299 tp_assign(shrink
, shr
->shrink
)
300 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
301 tp_assign(unused_scan
, unused_scan_cnt
)
302 tp_assign(new_scan
, new_scan_cnt
)
303 tp_assign(retval
, shrinker_retval
)
304 tp_assign(total_scan
, new_scan_cnt
- unused_scan_cnt
)
307 TP_printk("%pF %p: unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
310 __entry
->unused_scan
,
315 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
318 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
321 unsigned long nr_requested
,
322 unsigned long nr_scanned
,
323 unsigned long nr_taken
,
324 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
325 unsigned long nr_lumpy_taken
,
326 unsigned long nr_lumpy_dirty
,
327 unsigned long nr_lumpy_failed
,
329 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
330 isolate_mode_t isolate_mode
332 isolate_mode_t isolate_mode
,
337 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
338 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
339 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
341 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
351 __field(unsigned long, nr_requested
)
352 __field(unsigned long, nr_scanned
)
353 __field(unsigned long, nr_taken
)
354 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
355 __field(unsigned long, nr_lumpy_taken
)
356 __field(unsigned long, nr_lumpy_dirty
)
357 __field(unsigned long, nr_lumpy_failed
)
359 __field(isolate_mode_t
, isolate_mode
)
360 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
366 tp_assign(order
, order
)
367 tp_assign(nr_requested
, nr_requested
)
368 tp_assign(nr_scanned
, nr_scanned
)
369 tp_assign(nr_taken
, nr_taken
)
370 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
371 tp_assign(nr_lumpy_taken
, nr_lumpy_taken
)
372 tp_assign(nr_lumpy_dirty
, nr_lumpy_dirty
)
373 tp_assign(nr_lumpy_failed
, nr_lumpy_failed
)
375 tp_assign(isolate_mode
, isolate_mode
)
376 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
377 tp_assign(file
, file
)
381 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
382 TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu contig_taken=%lu contig_dirty=%lu contig_failed=%lu",
383 __entry
->isolate_mode
,
385 __entry
->nr_requested
,
388 __entry
->nr_lumpy_taken
,
389 __entry
->nr_lumpy_dirty
,
390 __entry
->nr_lumpy_failed
)
391 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
392 TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu contig_taken=%lu contig_dirty=%lu contig_failed=%lu file=%d",
393 __entry
->isolate_mode
,
395 __entry
->nr_requested
,
398 __entry
->nr_lumpy_taken
,
399 __entry
->nr_lumpy_dirty
,
400 __entry
->nr_lumpy_failed
,
403 TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
404 __entry
->isolate_mode
,
406 __entry
->nr_requested
,
413 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
416 unsigned long nr_requested
,
417 unsigned long nr_scanned
,
418 unsigned long nr_taken
,
419 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
420 unsigned long nr_lumpy_taken
,
421 unsigned long nr_lumpy_dirty
,
422 unsigned long nr_lumpy_failed
,
424 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
425 isolate_mode_t isolate_mode
427 isolate_mode_t isolate_mode
,
432 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
433 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
434 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
436 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
445 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
448 unsigned long nr_requested
,
449 unsigned long nr_scanned
,
450 unsigned long nr_taken
,
451 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
452 unsigned long nr_lumpy_taken
,
453 unsigned long nr_lumpy_dirty
,
454 unsigned long nr_lumpy_failed
,
456 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
457 isolate_mode_t isolate_mode
459 isolate_mode_t isolate_mode
,
464 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
465 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
466 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
468 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
476 TRACE_EVENT(mm_vmscan_writepage
,
478 TP_PROTO(struct page
*page
,
481 TP_ARGS(page
, reclaim_flags
),
484 __field(struct page
*, page
)
485 __field(int, reclaim_flags
)
489 tp_assign(page
, page
)
490 tp_assign(reclaim_flags
, reclaim_flags
)
493 TP_printk("page=%p pfn=%lu flags=%s",
495 page_to_pfn(__entry
->page
),
496 show_reclaim_flags(__entry
->reclaim_flags
))
499 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
500 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
502 TP_PROTO(int nid
, int zid
,
503 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
504 int priority
, int reclaim_flags
),
506 TP_ARGS(nid
, zid
, nr_scanned
, nr_reclaimed
, priority
, reclaim_flags
),
511 __field(unsigned long, nr_scanned
)
512 __field(unsigned long, nr_reclaimed
)
513 __field(int, priority
)
514 __field(int, reclaim_flags
)
520 tp_assign(nr_scanned
, nr_scanned
)
521 tp_assign(nr_reclaimed
, nr_reclaimed
)
522 tp_assign(priority
, priority
)
523 tp_assign(reclaim_flags
, reclaim_flags
)
526 TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
527 __entry
->nid
, __entry
->zid
,
528 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
530 show_reclaim_flags(__entry
->reclaim_flags
))
534 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
535 TRACE_EVENT_MAP(replace_swap_token
,
537 mm_vmscan_replace_swap_token
,
539 TP_PROTO(struct mm_struct
*old_mm
,
540 struct mm_struct
*new_mm
),
542 TP_ARGS(old_mm
, new_mm
),
545 __field(struct mm_struct
*, old_mm
)
546 __field(unsigned int, old_prio
)
547 __field(struct mm_struct
*, new_mm
)
548 __field(unsigned int, new_prio
)
552 tp_assign(old_mm
, old_mm
)
553 tp_assign(old_prio
, old_mm
? old_mm
->token_priority
: 0)
554 tp_assign(new_mm
, new_mm
)
555 tp_assign(new_prio
, new_mm
->token_priority
)
558 TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
559 __entry
->old_mm
, __entry
->old_prio
,
560 __entry
->new_mm
, __entry
->new_prio
)
563 DECLARE_EVENT_CLASS(mm_vmscan_put_swap_token_template
,
564 TP_PROTO(struct mm_struct
*swap_token_mm
),
566 TP_ARGS(swap_token_mm
),
569 __field(struct mm_struct
*, swap_token_mm
)
573 tp_assign(swap_token_mm
, swap_token_mm
)
576 TP_printk("token_mm=%p", __entry
->swap_token_mm
)
579 DEFINE_EVENT_MAP(mm_vmscan_put_swap_token_template
, put_swap_token
,
581 mm_vmscan_put_swap_token
,
583 TP_PROTO(struct mm_struct
*swap_token_mm
),
584 TP_ARGS(swap_token_mm
)
587 DEFINE_EVENT_CONDITION_MAP(mm_vmscan_put_swap_token_template
, disable_swap_token
,
589 mm_vmscan_disable_swap_token
,
591 TP_PROTO(struct mm_struct
*swap_token_mm
),
592 TP_ARGS(swap_token_mm
),
593 TP_CONDITION(swap_token_mm
!= NULL
)
596 TRACE_EVENT_CONDITION_MAP(update_swap_token_priority
,
598 mm_vmscan_update_swap_token_priority
,
600 TP_PROTO(struct mm_struct
*mm
,
601 unsigned int old_prio
,
602 struct mm_struct
*swap_token_mm
),
604 TP_ARGS(mm
, old_prio
, swap_token_mm
),
606 TP_CONDITION(mm
->token_priority
!= old_prio
),
609 __field(struct mm_struct
*, mm
)
610 __field(unsigned int, old_prio
)
611 __field(unsigned int, new_prio
)
612 __field(struct mm_struct
*, swap_token_mm
)
613 __field(unsigned int, swap_token_prio
)
618 tp_assign(old_prio
, old_prio
)
619 tp_assign(new_prio
, mm
->token_priority
)
620 tp_assign(swap_token_mm
, swap_token_mm
)
621 tp_assign(swap_token_prio
, swap_token_mm
? swap_token_mm
->token_priority
: 0)
624 TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
625 __entry
->mm
, __entry
->old_prio
, __entry
->new_prio
,
626 __entry
->swap_token_mm
, __entry
->swap_token_prio
)
630 #endif /* _TRACE_VMSCAN_H */
632 /* This part must be outside protection */
633 #include "../../../probes/define_trace.h"