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 <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(3,0,38)) || \
23 LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
24 typedef int isolate_mode_t
;
29 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
31 #include <linux/mm_inline.h>
33 #define trace_reclaim_flags(page) ( \
34 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
38 #define trace_shrink_flags(file) \
40 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
46 LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_sleep
,
53 ctf_integer(int, nid
, nid
)
57 LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_wake
,
59 TP_PROTO(int nid
, int order
),
64 ctf_integer(int, nid
, nid
)
65 ctf_integer(int, order
, order
)
69 LTTNG_TRACEPOINT_EVENT(mm_vmscan_wakeup_kswapd
,
71 TP_PROTO(int nid
, int zid
, int order
),
73 TP_ARGS(nid
, zid
, order
),
76 ctf_integer(int, nid
, nid
)
77 ctf_integer(int, zid
, zid
)
78 ctf_integer(int, order
, order
)
82 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
84 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
86 TP_ARGS(order
, may_writepage
, gfp_flags
),
89 ctf_integer(int, order
, order
)
90 ctf_integer(int, may_writepage
, may_writepage
)
91 ctf_integer(gfp_t
, gfp_flags
, gfp_flags
)
95 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
97 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
99 TP_ARGS(order
, may_writepage
, gfp_flags
)
102 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
104 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
106 TP_ARGS(order
, may_writepage
, gfp_flags
)
109 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
111 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
113 TP_ARGS(order
, may_writepage
, gfp_flags
)
116 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
118 TP_PROTO(unsigned long nr_reclaimed
),
120 TP_ARGS(nr_reclaimed
),
123 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
127 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
129 TP_PROTO(unsigned long nr_reclaimed
),
131 TP_ARGS(nr_reclaimed
)
134 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
136 TP_PROTO(unsigned long nr_reclaimed
),
138 TP_ARGS(nr_reclaimed
)
141 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
143 TP_PROTO(unsigned long nr_reclaimed
),
145 TP_ARGS(nr_reclaimed
)
148 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
149 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_start
,
151 mm_vmscan_shrink_slab_start
,
153 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
154 long nr_objects_to_shrink
, unsigned long pgs_scanned
,
155 unsigned long lru_pgs
, unsigned long cache_items
,
156 unsigned long long delta
, unsigned long total_scan
),
158 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
159 cache_items
, delta
, total_scan
),
162 ctf_integer_hex(struct shrinker
*, shr
, shr
)
163 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
164 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
165 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
166 ctf_integer_hex(void *, shrink
, shr
->shrink
)
167 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
168 ctf_integer(long, nr_objects_to_shrink
, nr_objects_to_shrink
)
169 ctf_integer(gfp_t
, gfp_flags
, sc
->gfp_mask
)
170 ctf_integer(unsigned long, pgs_scanned
, pgs_scanned
)
171 ctf_integer(unsigned long, lru_pgs
, lru_pgs
)
172 ctf_integer(unsigned long, cache_items
, cache_items
)
173 ctf_integer(unsigned long long, delta
, delta
)
174 ctf_integer(unsigned long, total_scan
, total_scan
)
178 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
179 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end
,
181 mm_vmscan_shrink_slab_end
,
183 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
184 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
186 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
190 ctf_integer_hex(struct shrinker
*, shr
, shr
)
191 ctf_integer(int, nid
, nid
)
192 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
193 ctf_integer(long, unused_scan
, unused_scan_cnt
)
194 ctf_integer(long, new_scan
, new_scan_cnt
)
195 ctf_integer(int, retval
, shrinker_retval
)
196 ctf_integer(long, total_scan
, total_scan
)
199 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
200 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end
,
202 mm_vmscan_shrink_slab_end
,
204 TP_PROTO(struct shrinker
*shr
, int shrinker_retval
,
205 long unused_scan_cnt
, long new_scan_cnt
),
207 TP_ARGS(shr
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
),
210 ctf_integer_hex(struct shrinker
*, shr
, shr
)
211 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
212 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
213 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
214 ctf_integer_hex(void *, shrink
, shr
->shrink
)
215 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
216 ctf_integer(long, unused_scan
, unused_scan_cnt
)
217 ctf_integer(long, new_scan
, new_scan_cnt
)
218 ctf_integer(int, retval
, shrinker_retval
)
219 ctf_integer(long, total_scan
, new_scan_cnt
- unused_scan_cnt
)
222 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
225 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
228 unsigned long nr_requested
,
229 unsigned long nr_scanned
,
230 unsigned long nr_taken
,
231 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
232 unsigned long nr_lumpy_taken
,
233 unsigned long nr_lumpy_dirty
,
234 unsigned long nr_lumpy_failed
,
236 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
237 isolate_mode_t isolate_mode
239 isolate_mode_t isolate_mode
,
244 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
245 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
246 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
248 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
257 ctf_integer(int, order
, order
)
258 ctf_integer(unsigned long, nr_requested
, nr_requested
)
259 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
260 ctf_integer(unsigned long, nr_taken
, nr_taken
)
261 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
262 ctf_integer(unsigned long, nr_lumpy_taken
, nr_lumpy_taken
)
263 ctf_integer(unsigned long, nr_lumpy_dirty
, nr_lumpy_dirty
)
264 ctf_integer(unsigned long, nr_lumpy_failed
, nr_lumpy_failed
)
266 ctf_integer(isolate_mode_t
, isolate_mode
, isolate_mode
)
267 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
268 ctf_integer(int, file
, file
)
273 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
276 unsigned long nr_requested
,
277 unsigned long nr_scanned
,
278 unsigned long nr_taken
,
279 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
280 unsigned long nr_lumpy_taken
,
281 unsigned long nr_lumpy_dirty
,
282 unsigned long nr_lumpy_failed
,
284 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
285 isolate_mode_t isolate_mode
287 isolate_mode_t isolate_mode
,
292 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
293 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
294 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
296 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
305 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
308 unsigned long nr_requested
,
309 unsigned long nr_scanned
,
310 unsigned long nr_taken
,
311 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
312 unsigned long nr_lumpy_taken
,
313 unsigned long nr_lumpy_dirty
,
314 unsigned long nr_lumpy_failed
,
316 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
317 isolate_mode_t isolate_mode
319 isolate_mode_t isolate_mode
,
324 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
325 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
326 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
328 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
336 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
337 LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage
,
339 TP_PROTO(struct page
*page
),
344 ctf_integer_hex(struct page
*, page
, page
)
345 ctf_integer(int, reclaim_flags
, trace_reclaim_flags(page
))
349 LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage
,
351 TP_PROTO(struct page
*page
,
354 TP_ARGS(page
, reclaim_flags
),
357 ctf_integer_hex(struct page
*, page
, page
)
358 ctf_integer(int, reclaim_flags
, reclaim_flags
)
363 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
364 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
366 TP_PROTO(struct zone
*zone
,
367 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
368 int priority
, int file
),
370 TP_ARGS(zone
, nr_scanned
, nr_reclaimed
, priority
, file
),
373 ctf_integer(int, nid
, zone_to_nid(zone
))
374 ctf_integer(int, zid
, zone_idx(zone
))
375 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
376 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
377 ctf_integer(int, priority
, priority
)
378 ctf_integer(int, reclaim_flags
, trace_shrink_flags(file
))
381 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
382 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
384 TP_PROTO(int nid
, int zid
,
385 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
386 int priority
, int reclaim_flags
),
388 TP_ARGS(nid
, zid
, nr_scanned
, nr_reclaimed
, priority
, reclaim_flags
),
391 ctf_integer(int, nid
, nid
)
392 ctf_integer(int, zid
, zid
)
393 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
394 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
395 ctf_integer(int, priority
, priority
)
396 ctf_integer(int, reclaim_flags
, reclaim_flags
)
401 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
402 LTTNG_TRACEPOINT_EVENT_MAP(replace_swap_token
,
404 mm_vmscan_replace_swap_token
,
406 TP_PROTO(struct mm_struct
*old_mm
,
407 struct mm_struct
*new_mm
),
409 TP_ARGS(old_mm
, new_mm
),
412 ctf_integer_hex(struct mm_struct
*, old_mm
, old_mm
)
413 ctf_integer(unsigned int, old_prio
, old_mm
? old_mm
->token_priority
: 0)
414 ctf_integer_hex(struct mm_struct
*, new_mm
, new_mm
)
415 ctf_integer(unsigned int, new_prio
, new_mm
->token_priority
)
419 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_put_swap_token_template
,
420 TP_PROTO(struct mm_struct
*swap_token_mm
),
422 TP_ARGS(swap_token_mm
),
425 ctf_integer_hex(struct mm_struct
*, swap_token_mm
, swap_token_mm
)
429 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template
, put_swap_token
,
431 mm_vmscan_put_swap_token
,
433 TP_PROTO(struct mm_struct
*swap_token_mm
),
434 TP_ARGS(swap_token_mm
)
437 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template
, disable_swap_token
,
439 mm_vmscan_disable_swap_token
,
441 TP_PROTO(struct mm_struct
*swap_token_mm
),
442 TP_ARGS(swap_token_mm
)
445 LTTNG_TRACEPOINT_EVENT_MAP(update_swap_token_priority
,
447 mm_vmscan_update_swap_token_priority
,
449 TP_PROTO(struct mm_struct
*mm
,
450 unsigned int old_prio
,
451 struct mm_struct
*swap_token_mm
),
453 TP_ARGS(mm
, old_prio
, swap_token_mm
),
456 ctf_integer_hex(struct mm_struct
*, mm
, mm
)
457 ctf_integer(unsigned int, old_prio
, old_prio
)
458 ctf_integer(unsigned int, new_prio
, mm
->token_priority
)
459 ctf_integer_hex(struct mm_struct
*, swap_token_mm
, swap_token_mm
)
460 ctf_integer(unsigned int, swap_token_prio
, swap_token_mm
? swap_token_mm
->token_priority
: 0)
465 #endif /* LTTNG_TRACE_MM_VMSCAN_H */
467 /* This part must be outside protection */
468 #include "../../../probes/define_trace.h"