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 TRACE_EVENT(mm_shrink_slab_end
,
242 TP_PROTO(struct shrinker
*shr
, int shrinker_retval
,
243 long unused_scan_cnt
, long new_scan_cnt
),
245 TP_ARGS(shr
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
),
248 __field(struct shrinker
*, shr
)
249 __field(void *, shrink
)
250 __field(long, unused_scan
)
251 __field(long, new_scan
)
253 __field(long, total_scan
)
258 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
259 tp_assign(shrink
, shr
->scan_objects
)
260 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
261 tp_assign(shrink
, shr
->shrink
)
262 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
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
, new_scan_cnt
- unused_scan_cnt
)
269 TP_printk("%pF %p: unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
272 __entry
->unused_scan
,
279 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
282 unsigned long nr_requested
,
283 unsigned long nr_scanned
,
284 unsigned long nr_taken
,
285 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
286 unsigned long nr_lumpy_taken
,
287 unsigned long nr_lumpy_dirty
,
288 unsigned long nr_lumpy_failed
,
290 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
291 isolate_mode_t isolate_mode
293 isolate_mode_t isolate_mode
,
298 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
299 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
300 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
302 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
312 __field(unsigned long, nr_requested
)
313 __field(unsigned long, nr_scanned
)
314 __field(unsigned long, nr_taken
)
315 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
316 __field(unsigned long, nr_lumpy_taken
)
317 __field(unsigned long, nr_lumpy_dirty
)
318 __field(unsigned long, nr_lumpy_failed
)
320 __field(isolate_mode_t
, isolate_mode
)
321 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
327 tp_assign(order
, order
)
328 tp_assign(nr_requested
, nr_requested
)
329 tp_assign(nr_scanned
, nr_scanned
)
330 tp_assign(nr_taken
, nr_taken
)
331 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
332 tp_assign(nr_lumpy_taken
, nr_lumpy_taken
)
333 tp_assign(nr_lumpy_dirty
, nr_lumpy_dirty
)
334 tp_assign(nr_lumpy_failed
, nr_lumpy_failed
)
336 tp_assign(isolate_mode
, isolate_mode
)
337 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
338 tp_assign(file
, file
)
342 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
343 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",
344 __entry
->isolate_mode
,
346 __entry
->nr_requested
,
349 __entry
->nr_lumpy_taken
,
350 __entry
->nr_lumpy_dirty
,
351 __entry
->nr_lumpy_failed
)
352 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
353 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",
354 __entry
->isolate_mode
,
356 __entry
->nr_requested
,
359 __entry
->nr_lumpy_taken
,
360 __entry
->nr_lumpy_dirty
,
361 __entry
->nr_lumpy_failed
,
364 TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
365 __entry
->isolate_mode
,
367 __entry
->nr_requested
,
374 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
377 unsigned long nr_requested
,
378 unsigned long nr_scanned
,
379 unsigned long nr_taken
,
380 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
381 unsigned long nr_lumpy_taken
,
382 unsigned long nr_lumpy_dirty
,
383 unsigned long nr_lumpy_failed
,
385 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
386 isolate_mode_t isolate_mode
388 isolate_mode_t isolate_mode
,
393 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
394 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
395 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
397 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
406 DEFINE_EVENT(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
409 unsigned long nr_requested
,
410 unsigned long nr_scanned
,
411 unsigned long nr_taken
,
412 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
413 unsigned long nr_lumpy_taken
,
414 unsigned long nr_lumpy_dirty
,
415 unsigned long nr_lumpy_failed
,
417 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
418 isolate_mode_t isolate_mode
420 isolate_mode_t isolate_mode
,
425 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
426 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
427 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
429 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
437 TRACE_EVENT(mm_vmscan_writepage
,
439 TP_PROTO(struct page
*page
,
442 TP_ARGS(page
, reclaim_flags
),
445 __field(struct page
*, page
)
446 __field(int, reclaim_flags
)
450 tp_assign(page
, page
)
451 tp_assign(reclaim_flags
, reclaim_flags
)
454 TP_printk("page=%p pfn=%lu flags=%s",
456 page_to_pfn(__entry
->page
),
457 show_reclaim_flags(__entry
->reclaim_flags
))
460 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
461 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
463 TP_PROTO(int nid
, int zid
,
464 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
465 int priority
, int reclaim_flags
),
467 TP_ARGS(nid
, zid
, nr_scanned
, nr_reclaimed
, priority
, reclaim_flags
),
472 __field(unsigned long, nr_scanned
)
473 __field(unsigned long, nr_reclaimed
)
474 __field(int, priority
)
475 __field(int, reclaim_flags
)
481 tp_assign(nr_scanned
, nr_scanned
)
482 tp_assign(nr_reclaimed
, nr_reclaimed
)
483 tp_assign(priority
, priority
)
484 tp_assign(reclaim_flags
, reclaim_flags
)
487 TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
488 __entry
->nid
, __entry
->zid
,
489 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
491 show_reclaim_flags(__entry
->reclaim_flags
))
495 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
496 TRACE_EVENT_MAP(replace_swap_token
,
498 mm_vmscan_replace_swap_token
,
500 TP_PROTO(struct mm_struct
*old_mm
,
501 struct mm_struct
*new_mm
),
503 TP_ARGS(old_mm
, new_mm
),
506 __field(struct mm_struct
*, old_mm
)
507 __field(unsigned int, old_prio
)
508 __field(struct mm_struct
*, new_mm
)
509 __field(unsigned int, new_prio
)
513 tp_assign(old_mm
, old_mm
)
514 tp_assign(old_prio
, old_mm
? old_mm
->token_priority
: 0)
515 tp_assign(new_mm
, new_mm
)
516 tp_assign(new_prio
, new_mm
->token_priority
)
519 TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
520 __entry
->old_mm
, __entry
->old_prio
,
521 __entry
->new_mm
, __entry
->new_prio
)
524 DECLARE_EVENT_CLASS(mm_vmscan_put_swap_token_template
,
525 TP_PROTO(struct mm_struct
*swap_token_mm
),
527 TP_ARGS(swap_token_mm
),
530 __field(struct mm_struct
*, swap_token_mm
)
534 tp_assign(swap_token_mm
, swap_token_mm
)
537 TP_printk("token_mm=%p", __entry
->swap_token_mm
)
540 DEFINE_EVENT_MAP(mm_vmscan_put_swap_token_template
, put_swap_token
,
542 mm_vmscan_put_swap_token
,
544 TP_PROTO(struct mm_struct
*swap_token_mm
),
545 TP_ARGS(swap_token_mm
)
548 DEFINE_EVENT_CONDITION_MAP(mm_vmscan_put_swap_token_template
, disable_swap_token
,
550 mm_vmscan_disable_swap_token
,
552 TP_PROTO(struct mm_struct
*swap_token_mm
),
553 TP_ARGS(swap_token_mm
),
554 TP_CONDITION(swap_token_mm
!= NULL
)
557 TRACE_EVENT_CONDITION_MAP(update_swap_token_priority
,
559 mm_vmscan_update_swap_token_priority
,
561 TP_PROTO(struct mm_struct
*mm
,
562 unsigned int old_prio
,
563 struct mm_struct
*swap_token_mm
),
565 TP_ARGS(mm
, old_prio
, swap_token_mm
),
567 TP_CONDITION(mm
->token_priority
!= old_prio
),
570 __field(struct mm_struct
*, mm
)
571 __field(unsigned int, old_prio
)
572 __field(unsigned int, new_prio
)
573 __field(struct mm_struct
*, swap_token_mm
)
574 __field(unsigned int, swap_token_prio
)
579 tp_assign(old_prio
, old_prio
)
580 tp_assign(new_prio
, mm
->token_priority
)
581 tp_assign(swap_token_mm
, swap_token_mm
)
582 tp_assign(swap_token_prio
, swap_token_mm
? swap_token_mm
->token_priority
: 0)
585 TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
586 __entry
->mm
, __entry
->old_prio
, __entry
->new_prio
,
587 __entry
->swap_token_mm
, __entry
->swap_token_prio
)
591 #endif /* _TRACE_VMSCAN_H */
593 /* This part must be outside protection */
594 #include "../../../probes/define_trace.h"