Fix: napi instrumentation for 4.8 kernels
[lttng-modules.git] / instrumentation / events / lttng-module / mm_vmscan.h
CommitLineData
b283666f 1#undef TRACE_SYSTEM
9bbf98da 2#define TRACE_SYSTEM mm_vmscan
b283666f 3
9bbf98da
MD
4#if !defined(LTTNG_TRACE_MM_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
5#define LTTNG_TRACE_MM_VMSCAN_H
b283666f 6
6ec43db8 7#include <probes/lttng-tracepoint-event.h>
7c68b363 8#include <linux/types.h>
7c68b363
AG
9#include <linux/mm.h>
10#include <linux/memcontrol.h>
7c68b363
AG
11#include <linux/version.h>
12
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
20
7c68b363
AG
21#if ((LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,38)) || \
22 LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
23typedef int isolate_mode_t;
24#endif
25
26#endif
27
01e289f7
MD
28#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
29
30#include <linux/mm_inline.h>
31
32#define trace_reclaim_flags(page) ( \
33 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
34 (RECLAIM_WB_ASYNC) \
35 )
36
37#define trace_shrink_flags(file) \
38 ( \
39 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
40 (RECLAIM_WB_ASYNC) \
41 )
42
43#endif
44
3bc29f0a 45LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_sleep,
b283666f
PW
46
47 TP_PROTO(int nid),
48
49 TP_ARGS(nid),
50
f127e61e
MD
51 TP_FIELDS(
52 ctf_integer(int, nid, nid)
53 )
b283666f
PW
54)
55
3bc29f0a 56LTTNG_TRACEPOINT_EVENT(mm_vmscan_kswapd_wake,
b283666f
PW
57
58 TP_PROTO(int nid, int order),
59
60 TP_ARGS(nid, order),
61
f127e61e
MD
62 TP_FIELDS(
63 ctf_integer(int, nid, nid)
64 ctf_integer(int, order, order)
65 )
b283666f
PW
66)
67
3bc29f0a 68LTTNG_TRACEPOINT_EVENT(mm_vmscan_wakeup_kswapd,
b283666f
PW
69
70 TP_PROTO(int nid, int zid, int order),
71
72 TP_ARGS(nid, zid, order),
73
f127e61e
MD
74 TP_FIELDS(
75 ctf_integer(int, nid, nid)
76 ctf_integer(int, zid, zid)
77 ctf_integer(int, order, order)
78 )
b283666f
PW
79)
80
3bc29f0a 81LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
b283666f
PW
82
83 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
84
85 TP_ARGS(order, may_writepage, gfp_flags),
86
f127e61e
MD
87 TP_FIELDS(
88 ctf_integer(int, order, order)
89 ctf_integer(int, may_writepage, may_writepage)
90 ctf_integer(gfp_t, gfp_flags, gfp_flags)
91 )
b283666f
PW
92)
93
3bc29f0a 94LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
b283666f
PW
95
96 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
97
98 TP_ARGS(order, may_writepage, gfp_flags)
99)
100
3bc29f0a 101LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
b283666f
PW
102
103 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
104
105 TP_ARGS(order, may_writepage, gfp_flags)
106)
107
3bc29f0a 108LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
b283666f
PW
109
110 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
111
112 TP_ARGS(order, may_writepage, gfp_flags)
113)
114
3bc29f0a 115LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
b283666f
PW
116
117 TP_PROTO(unsigned long nr_reclaimed),
118
119 TP_ARGS(nr_reclaimed),
120
f127e61e
MD
121 TP_FIELDS(
122 ctf_integer(unsigned long, nr_reclaimed, nr_reclaimed)
123 )
b283666f
PW
124)
125
3bc29f0a 126LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
b283666f
PW
127
128 TP_PROTO(unsigned long nr_reclaimed),
129
130 TP_ARGS(nr_reclaimed)
131)
132
3bc29f0a 133LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
b283666f
PW
134
135 TP_PROTO(unsigned long nr_reclaimed),
136
137 TP_ARGS(nr_reclaimed)
138)
139
3bc29f0a 140LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
b283666f
PW
141
142 TP_PROTO(unsigned long nr_reclaimed),
143
144 TP_ARGS(nr_reclaimed)
145)
146
7c68b363 147#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
9bbf98da
MD
148LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_start,
149
150 mm_vmscan_shrink_slab_start,
151
b283666f
PW
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),
156
157 TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
158 cache_items, delta, total_scan),
159
f127e61e 160 TP_FIELDS(
fa91fcac 161 ctf_integer_hex(struct shrinker *, shr, shr)
5465fedd 162#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
fa91fcac 163 ctf_integer_hex(void *, shrink, shr->scan_objects)
5465fedd 164#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
fa91fcac 165 ctf_integer_hex(void *, shrink, shr->shrink)
5465fedd 166#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
f127e61e
MD
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)
174 )
b283666f
PW
175)
176
5defe623 177#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0))
9bbf98da
MD
178LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end,
179
180 mm_vmscan_shrink_slab_end,
181
5defe623
MD
182 TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
183 long unused_scan_cnt, long new_scan_cnt, long total_scan),
184
185 TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
186 total_scan),
187
f127e61e 188 TP_FIELDS(
fa91fcac 189 ctf_integer_hex(struct shrinker *, shr, shr)
f127e61e 190 ctf_integer(int, nid, nid)
fa91fcac 191 ctf_integer_hex(void *, shrink, shr->scan_objects)
f127e61e
MD
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)
196 )
5defe623
MD
197)
198#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
9bbf98da
MD
199LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end,
200
201 mm_vmscan_shrink_slab_end,
202
b283666f
PW
203 TP_PROTO(struct shrinker *shr, int shrinker_retval,
204 long unused_scan_cnt, long new_scan_cnt),
205
206 TP_ARGS(shr, shrinker_retval, unused_scan_cnt, new_scan_cnt),
207
f127e61e 208 TP_FIELDS(
fa91fcac 209 ctf_integer_hex(struct shrinker *, shr, shr)
5465fedd 210#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
fa91fcac 211 ctf_integer_hex(void *, shrink, shr->scan_objects)
5465fedd 212#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
fa91fcac 213 ctf_integer_hex(void *, shrink, shr->shrink)
5465fedd 214#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
f127e61e
MD
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)
219 )
b283666f 220)
5defe623 221#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0)) */
7c68b363 222#endif
b283666f 223
3bc29f0a 224LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_lru_isolate_template,
b283666f
PW
225
226 TP_PROTO(int order,
227 unsigned long nr_requested,
228 unsigned long nr_scanned,
229 unsigned long nr_taken,
7c68b363 230#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
b283666f
PW
231 unsigned long nr_lumpy_taken,
232 unsigned long nr_lumpy_dirty,
233 unsigned long nr_lumpy_failed,
7c68b363 234#endif
b283666f 235#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
7c68b363 236 isolate_mode_t isolate_mode
b283666f
PW
237#else
238 isolate_mode_t isolate_mode,
7c68b363 239 int file
b283666f 240#endif
7c68b363 241 ),
b283666f 242
7c68b363
AG
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,
246#endif
b283666f 247#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
7c68b363 248 isolate_mode
b283666f 249#else
7c68b363 250 isolate_mode, file
b283666f 251#endif
7c68b363
AG
252 ),
253
b283666f 254
f127e61e
MD
255 TP_FIELDS(
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)
7c68b363 260#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
f127e61e
MD
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)
7c68b363 264#endif
f127e61e 265 ctf_integer(isolate_mode_t, isolate_mode, isolate_mode)
b283666f 266#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
f127e61e 267 ctf_integer(int, file, file)
b283666f 268#endif
f127e61e 269 )
b283666f
PW
270)
271
3bc29f0a 272LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
b283666f
PW
273
274 TP_PROTO(int order,
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,
282#endif
283#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
7c68b363 284 isolate_mode_t isolate_mode
b283666f
PW
285#else
286 isolate_mode_t isolate_mode,
7c68b363 287 int file
b283666f 288#endif
7c68b363 289 ),
b283666f 290
7c68b363
AG
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,
294#endif
b283666f 295#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
7c68b363 296 isolate_mode
b283666f 297#else
7c68b363 298 isolate_mode, file
b283666f 299#endif
7c68b363 300 )
b283666f
PW
301
302)
303
3bc29f0a 304LTTNG_TRACEPOINT_EVENT_INSTANCE(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
b283666f
PW
305
306 TP_PROTO(int order,
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,
314#endif
315#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
7c68b363 316 isolate_mode_t isolate_mode
b283666f
PW
317#else
318 isolate_mode_t isolate_mode,
7c68b363 319 int file
b283666f 320#endif
7c68b363 321 ),
b283666f 322
7c68b363
AG
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,
326#endif
b283666f 327#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
7c68b363 328 isolate_mode
b283666f 329#else
7c68b363 330 isolate_mode, file
b283666f 331#endif
7c68b363 332 )
b283666f
PW
333)
334
01e289f7
MD
335#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
336LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage,
337
338 TP_PROTO(struct page *page),
339
340 TP_ARGS(page),
341
342 TP_FIELDS(
fa91fcac 343 ctf_integer_hex(struct page *, page, page)
01e289f7
MD
344 ctf_integer(int, reclaim_flags, trace_reclaim_flags(page))
345 )
346)
347#else
3bc29f0a 348LTTNG_TRACEPOINT_EVENT(mm_vmscan_writepage,
b283666f
PW
349
350 TP_PROTO(struct page *page,
351 int reclaim_flags),
352
353 TP_ARGS(page, reclaim_flags),
354
f127e61e 355 TP_FIELDS(
fa91fcac 356 ctf_integer_hex(struct page *, page, page)
f127e61e
MD
357 ctf_integer(int, reclaim_flags, reclaim_flags)
358 )
b283666f 359)
01e289f7
MD
360#endif
361
362#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0))
363LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive,
364
365 TP_PROTO(struct zone *zone,
366 unsigned long nr_scanned, unsigned long nr_reclaimed,
367 int priority, int file),
b283666f 368
01e289f7
MD
369 TP_ARGS(zone, nr_scanned, nr_reclaimed, priority, file),
370
371 TP_FIELDS(
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))
378 )
379)
380#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
3bc29f0a 381LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_shrink_inactive,
b283666f
PW
382
383 TP_PROTO(int nid, int zid,
384 unsigned long nr_scanned, unsigned long nr_reclaimed,
385 int priority, int reclaim_flags),
386
387 TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags),
388
f127e61e
MD
389 TP_FIELDS(
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)
396 )
b283666f 397)
7c68b363 398#endif
b283666f
PW
399
400#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
3bc29f0a 401LTTNG_TRACEPOINT_EVENT_MAP(replace_swap_token,
9cf29d3e
MD
402
403 mm_vmscan_replace_swap_token,
404
b283666f
PW
405 TP_PROTO(struct mm_struct *old_mm,
406 struct mm_struct *new_mm),
407
408 TP_ARGS(old_mm, new_mm),
409
f127e61e 410 TP_FIELDS(
fa91fcac 411 ctf_integer_hex(struct mm_struct *, old_mm, old_mm)
f127e61e 412 ctf_integer(unsigned int, old_prio, old_mm ? old_mm->token_priority : 0)
fa91fcac 413 ctf_integer_hex(struct mm_struct *, new_mm, new_mm)
f127e61e
MD
414 ctf_integer(unsigned int, new_prio, new_mm->token_priority)
415 )
b283666f
PW
416)
417
3bc29f0a 418LTTNG_TRACEPOINT_EVENT_CLASS(mm_vmscan_put_swap_token_template,
b283666f
PW
419 TP_PROTO(struct mm_struct *swap_token_mm),
420
421 TP_ARGS(swap_token_mm),
422
f127e61e 423 TP_FIELDS(
fa91fcac 424 ctf_integer_hex(struct mm_struct*, swap_token_mm, swap_token_mm)
f127e61e 425 )
b283666f
PW
426)
427
3bc29f0a 428LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template, put_swap_token,
9cf29d3e
MD
429
430 mm_vmscan_put_swap_token,
431
b283666f
PW
432 TP_PROTO(struct mm_struct *swap_token_mm),
433 TP_ARGS(swap_token_mm)
434)
435
f127e61e 436LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(mm_vmscan_put_swap_token_template, disable_swap_token,
9cf29d3e
MD
437
438 mm_vmscan_disable_swap_token,
439
b283666f 440 TP_PROTO(struct mm_struct *swap_token_mm),
f127e61e 441 TP_ARGS(swap_token_mm)
b283666f
PW
442)
443
f127e61e 444LTTNG_TRACEPOINT_EVENT_MAP(update_swap_token_priority,
9cf29d3e
MD
445
446 mm_vmscan_update_swap_token_priority,
447
b283666f
PW
448 TP_PROTO(struct mm_struct *mm,
449 unsigned int old_prio,
450 struct mm_struct *swap_token_mm),
451
452 TP_ARGS(mm, old_prio, swap_token_mm),
453
f127e61e 454 TP_FIELDS(
fa91fcac 455 ctf_integer_hex(struct mm_struct *, mm, mm)
f127e61e
MD
456 ctf_integer(unsigned int, old_prio, old_prio)
457 ctf_integer(unsigned int, new_prio, mm->token_priority)
fa91fcac 458 ctf_integer_hex(struct mm_struct *, swap_token_mm, swap_token_mm)
f127e61e
MD
459 ctf_integer(unsigned int, swap_token_prio, swap_token_mm ? swap_token_mm->token_priority : 0)
460 )
b283666f 461)
b283666f
PW
462#endif
463
9bbf98da 464#endif /* LTTNG_TRACE_MM_VMSCAN_H */
b283666f
PW
465
466/* This part must be outside protection */
6ec43db8 467#include <probes/define_trace.h>
This page took 0.05214 seconds and 4 git commands to generate.