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 LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_wake
,
58 TP_PROTO(int nid
, int order
),
63 ctf_integer(int, nid
, nid
)
64 ctf_integer(int, order
, order
)
68 LTTNG_TRACEPOINT_EVENT(mm_vmscan_wakeup_kswapd
,
70 TP_PROTO(int nid
, int zid
, int order
),
72 TP_ARGS(nid
, zid
, order
),
75 ctf_integer(int, nid
, nid
)
76 ctf_integer(int, zid
, zid
)
77 ctf_integer(int, order
, order
)
81 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
83 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
85 TP_ARGS(order
, may_writepage
, gfp_flags
),
88 ctf_integer(int, order
, order
)
89 ctf_integer(int, may_writepage
, may_writepage
)
90 ctf_integer(gfp_t
, gfp_flags
, gfp_flags
)
94 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
96 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
98 TP_ARGS(order
, may_writepage
, gfp_flags
)
101 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
103 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
105 TP_ARGS(order
, may_writepage
, gfp_flags
)
108 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
110 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
),
112 TP_ARGS(order
, may_writepage
, gfp_flags
)
115 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
117 TP_PROTO(unsigned long nr_reclaimed
),
119 TP_ARGS(nr_reclaimed
),
122 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
126 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
128 TP_PROTO(unsigned long nr_reclaimed
),
130 TP_ARGS(nr_reclaimed
)
133 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
135 TP_PROTO(unsigned long nr_reclaimed
),
137 TP_ARGS(nr_reclaimed
)
140 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
142 TP_PROTO(unsigned long nr_reclaimed
),
144 TP_ARGS(nr_reclaimed
)
147 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
148 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_start
,
150 mm_vmscan_shrink_slab_start
,
152 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
153 long nr_objects_to_shrink
, unsigned long pgs_scanned
,
154 unsigned long lru_pgs
, unsigned long cache_items
,
155 unsigned long long delta
, unsigned long total_scan
),
157 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
158 cache_items
, delta
, total_scan
),
161 ctf_integer_hex(struct shrinker
*, shr
, shr
)
162 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
163 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
164 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
165 ctf_integer_hex(void *, shrink
, shr
->shrink
)
166 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
167 ctf_integer(long, nr_objects_to_shrink
, nr_objects_to_shrink
)
168 ctf_integer(gfp_t
, gfp_flags
, sc
->gfp_mask
)
169 ctf_integer(unsigned long, pgs_scanned
, pgs_scanned
)
170 ctf_integer(unsigned long, lru_pgs
, lru_pgs
)
171 ctf_integer(unsigned long, cache_items
, cache_items
)
172 ctf_integer(unsigned long long, delta
, delta
)
173 ctf_integer(unsigned long, total_scan
, total_scan
)
177 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
178 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end
,
180 mm_vmscan_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
),
185 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
189 ctf_integer_hex(struct shrinker
*, shr
, shr
)
190 ctf_integer(int, nid
, nid
)
191 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
192 ctf_integer(long, unused_scan
, unused_scan_cnt
)
193 ctf_integer(long, new_scan
, new_scan_cnt
)
194 ctf_integer(int, retval
, shrinker_retval
)
195 ctf_integer(long, total_scan
, total_scan
)
198 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
199 LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end
,
201 mm_vmscan_shrink_slab_end
,
203 TP_PROTO(struct shrinker
*shr
, int shrinker_retval
,
204 long unused_scan_cnt
, long new_scan_cnt
),
206 TP_ARGS(shr
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
),
209 ctf_integer_hex(struct shrinker
*, shr
, shr
)
210 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
211 ctf_integer_hex(void *, shrink
, shr
->scan_objects
)
212 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
213 ctf_integer_hex(void *, shrink
, shr
->shrink
)
214 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
215 ctf_integer(long, unused_scan
, unused_scan_cnt
)
216 ctf_integer(long, new_scan
, new_scan_cnt
)
217 ctf_integer(int, retval
, shrinker_retval
)
218 ctf_integer(long, total_scan
, new_scan_cnt
- unused_scan_cnt
)
221 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
224 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_lru_isolate_template
,
227 unsigned long nr_requested
,
228 unsigned long nr_scanned
,
229 unsigned long nr_taken
,
230 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
231 unsigned long nr_lumpy_taken
,
232 unsigned long nr_lumpy_dirty
,
233 unsigned long nr_lumpy_failed
,
235 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
236 isolate_mode_t isolate_mode
238 isolate_mode_t isolate_mode
,
243 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
244 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
245 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
247 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
256 ctf_integer(int, order
, order
)
257 ctf_integer(unsigned long, nr_requested
, nr_requested
)
258 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
259 ctf_integer(unsigned long, nr_taken
, nr_taken
)
260 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
261 ctf_integer(unsigned long, nr_lumpy_taken
, nr_lumpy_taken
)
262 ctf_integer(unsigned long, nr_lumpy_dirty
, nr_lumpy_dirty
)
263 ctf_integer(unsigned long, nr_lumpy_failed
, nr_lumpy_failed
)
265 ctf_integer(isolate_mode_t
, isolate_mode
, isolate_mode
)
266 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
267 ctf_integer(int, file
, file
)
272 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_lru_isolate
,
275 unsigned long nr_requested
,
276 unsigned long nr_scanned
,
277 unsigned long nr_taken
,
278 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
279 unsigned long nr_lumpy_taken
,
280 unsigned long nr_lumpy_dirty
,
281 unsigned long nr_lumpy_failed
,
283 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
284 isolate_mode_t isolate_mode
286 isolate_mode_t isolate_mode
,
291 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
292 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
293 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
295 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
304 LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template
, mm_vmscan_memcg_isolate
,
307 unsigned long nr_requested
,
308 unsigned long nr_scanned
,
309 unsigned long nr_taken
,
310 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
311 unsigned long nr_lumpy_taken
,
312 unsigned long nr_lumpy_dirty
,
313 unsigned long nr_lumpy_failed
,
315 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
316 isolate_mode_t isolate_mode
318 isolate_mode_t isolate_mode
,
323 TP_ARGS(order
, nr_requested
, nr_scanned
, nr_taken
,
324 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
325 nr_lumpy_taken
, nr_lumpy_dirty
, nr_lumpy_failed
,
327 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
335 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
336 LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage
,
338 TP_PROTO(struct page
*page
),
343 ctf_integer_hex(struct page
*, page
, page
)
344 ctf_integer(int, reclaim_flags
, trace_reclaim_flags(page
))
348 LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage
,
350 TP_PROTO(struct page
*page
,
353 TP_ARGS(page
, reclaim_flags
),
356 ctf_integer_hex(struct page
*, page
, page
)
357 ctf_integer(int, reclaim_flags
, reclaim_flags
)
362 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
363 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
365 TP_PROTO(struct zone
*zone
,
366 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
367 int priority
, int file
),
369 TP_ARGS(zone
, nr_scanned
, nr_reclaimed
, priority
, file
),
372 ctf_integer(int, nid
, zone_to_nid(zone
))
373 ctf_integer(int, zid
, zone_idx(zone
))
374 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
375 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
376 ctf_integer(int, priority
, priority
)
377 ctf_integer(int, reclaim_flags
, trace_shrink_flags(file
))
380 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
381 LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive
,
383 TP_PROTO(int nid
, int zid
,
384 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
385 int priority
, int reclaim_flags
),
387 TP_ARGS(nid
, zid
, nr_scanned
, nr_reclaimed
, priority
, reclaim_flags
),
390 ctf_integer(int, nid
, nid
)
391 ctf_integer(int, zid
, zid
)
392 ctf_integer(unsigned long, nr_scanned
, nr_scanned
)
393 ctf_integer(unsigned long, nr_reclaimed
, nr_reclaimed
)
394 ctf_integer(int, priority
, priority
)
395 ctf_integer(int, reclaim_flags
, reclaim_flags
)
400 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
401 LTTNG_TRACEPOINT_EVENT_MAP(replace_swap_token
,
403 mm_vmscan_replace_swap_token
,
405 TP_PROTO(struct mm_struct
*old_mm
,
406 struct mm_struct
*new_mm
),
408 TP_ARGS(old_mm
, new_mm
),
411 ctf_integer_hex(struct mm_struct
*, old_mm
, old_mm
)
412 ctf_integer(unsigned int, old_prio
, old_mm
? old_mm
->token_priority
: 0)
413 ctf_integer_hex(struct mm_struct
*, new_mm
, new_mm
)
414 ctf_integer(unsigned int, new_prio
, new_mm
->token_priority
)
418 LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_put_swap_token_template
,
419 TP_PROTO(struct mm_struct
*swap_token_mm
),
421 TP_ARGS(swap_token_mm
),
424 ctf_integer_hex(struct mm_struct
*, swap_token_mm
, swap_token_mm
)
428 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template
, put_swap_token
,
430 mm_vmscan_put_swap_token
,
432 TP_PROTO(struct mm_struct
*swap_token_mm
),
433 TP_ARGS(swap_token_mm
)
436 LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template
, disable_swap_token
,
438 mm_vmscan_disable_swap_token
,
440 TP_PROTO(struct mm_struct
*swap_token_mm
),
441 TP_ARGS(swap_token_mm
)
444 LTTNG_TRACEPOINT_EVENT_MAP(update_swap_token_priority
,
446 mm_vmscan_update_swap_token_priority
,
448 TP_PROTO(struct mm_struct
*mm
,
449 unsigned int old_prio
,
450 struct mm_struct
*swap_token_mm
),
452 TP_ARGS(mm
, old_prio
, swap_token_mm
),
455 ctf_integer_hex(struct mm_struct
*, mm
, mm
)
456 ctf_integer(unsigned int, old_prio
, old_prio
)
457 ctf_integer(unsigned int, new_prio
, mm
->token_priority
)
458 ctf_integer_hex(struct mm_struct
*, swap_token_mm
, swap_token_mm
)
459 ctf_integer(unsigned int, swap_token_prio
, swap_token_mm
? swap_token_mm
->token_priority
: 0)
464 #endif /* LTTNG_TRACE_MM_VMSCAN_H */
466 /* This part must be outside protection */
467 #include <probes/define_trace.h>