1
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM vmscan
4
5 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_VMSCAN_H
7
8 #include <linux/types.h>
9 #include <linux/tracepoint.h>
10 #include <linux/mm.h>
11 #include <linux/memcontrol.h>
12 #include <trace/events/mmflags.h>
13
14 #define RECLAIM_WB_ANON 0x0001u
15 #define RECLAIM_WB_FILE 0x0002u
16 #define RECLAIM_WB_MIXED 0x0010u
17 #define RECLAIM_WB_SYNC 0x0004u
18 #define RECLAIM_WB_ASYNC 0x0008u
19 #define RECLAIM_WB_LRU (RECLAIM_WB_ANON|RECLAIM_WB_FILE)
20
21 #define show_reclaim_flags(flags) \
22 (flags) ? __print_flags(flags, "|", \
23 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
24 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
25 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
26 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
27 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
28 ) : "RECLAIM_WB_NONE"
29
30 #define trace_reclaim_flags(file) ( \
31 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
32 (RECLAIM_WB_ASYNC) \
33 )
34
35 TRACE_EVENT(mm_vmscan_kswapd_sleep,
36
37 TP_PROTO(int nid),
38
39 TP_ARGS(nid),
40
41 TP_STRUCT__entry(
42 __field( int, nid )
43 ),
44
45 TP_fast_assign(
46 __entry->nid = nid;
47 ),
48
49 TP_printk("nid=%d", __entry->nid)
50 );
51
52 TRACE_EVENT(mm_vmscan_kswapd_wake,
53
54 TP_PROTO(int nid, int zid, int order),
55
56 TP_ARGS(nid, zid, order),
57
58 TP_STRUCT__entry(
59 __field( int, nid )
60 __field( int, zid )
61 __field( int, order )
62 ),
63
64 TP_fast_assign(
65 __entry->nid = nid;
66 __entry->zid = zid;
67 __entry->order = order;
68 ),
69
70 TP_printk("nid=%d order=%d",
71 __entry->nid,
72 __entry->order)
73 );
74
75 TRACE_EVENT(mm_vmscan_wakeup_kswapd,
76
77 TP_PROTO(int nid, int zid, int order, gfp_t gfp_flags),
78
79 TP_ARGS(nid, zid, order, gfp_flags),
80
81 TP_STRUCT__entry(
82 __field( int, nid )
83 __field( int, zid )
84 __field( int, order )
85 __field( gfp_t, gfp_flags )
86 ),
87
88 TP_fast_assign(
89 __entry->nid = nid;
90 __entry->zid = zid;
91 __entry->order = order;
92 __entry->gfp_flags = gfp_flags;
93 ),
94
95 TP_printk("nid=%d order=%d gfp_flags=%s",
96 __entry->nid,
97 __entry->order,
98 show_gfp_flags(__entry->gfp_flags))
99 );
100
101 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
102
103 TP_PROTO(int order, gfp_t gfp_flags),
104
105 TP_ARGS(order, gfp_flags),
106
107 TP_STRUCT__entry(
108 __field( int, order )
109 __field( gfp_t, gfp_flags )
110 ),
111
112 TP_fast_assign(
113 __entry->order = order;
114 __entry->gfp_flags = gfp_flags;
115 ),
116
117 TP_printk("order=%d gfp_flags=%s",
118 __entry->order,
119 show_gfp_flags(__entry->gfp_flags))
120 );
121
122 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
123
124 TP_PROTO(int order, gfp_t gfp_flags),
125
126 TP_ARGS(order, gfp_flags)
127 );
128
129 #ifdef CONFIG_MEMCG
130 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
131
132 TP_PROTO(int order, gfp_t gfp_flags),
133
134 TP_ARGS(order, gfp_flags)
135 );
136
137 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
138
139 TP_PROTO(int order, gfp_t gfp_flags),
140
141 TP_ARGS(order, gfp_flags)
142 );
143 #endif
144
145 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
146
147 TP_PROTO(unsigned long nr_reclaimed),
148
149 TP_ARGS(nr_reclaimed),
150
151 TP_STRUCT__entry(
152 __field( unsigned long, nr_reclaimed )
153 ),
154
155 TP_fast_assign(
156 __entry->nr_reclaimed = nr_reclaimed;
157 ),
158
159 TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
160 );
161
162 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
163
164 TP_PROTO(unsigned long nr_reclaimed),
165
166 TP_ARGS(nr_reclaimed)
167 );
168
169 #ifdef CONFIG_MEMCG
170 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
171
172 TP_PROTO(unsigned long nr_reclaimed),
173
174 TP_ARGS(nr_reclaimed)
175 );
176
177 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
178
179 TP_PROTO(unsigned long nr_reclaimed),
180
181 TP_ARGS(nr_reclaimed)
182 );
183 #endif
184
185 TRACE_EVENT(mm_shrink_slab_start,
186 TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
187 long nr_objects_to_shrink, unsigned long cache_items,
188 unsigned long long delta, unsigned long total_scan,
189 int priority),
190
191 TP_ARGS(shr, sc, nr_objects_to_shrink, cache_items, delta, total_scan,
192 priority),
193
194 TP_STRUCT__entry(
195 __field(struct shrinker *, shr)
196 __field(void *, shrink)
197 __field(int, nid)
198 __field(long, nr_objects_to_shrink)
199 __field(gfp_t, gfp_flags)
200 __field(unsigned long, cache_items)
201 __field(unsigned long long, delta)
202 __field(unsigned long, total_scan)
203 __field(int, priority)
204 ),
205
206 TP_fast_assign(
207 __entry->shr = shr;
208 __entry->shrink = shr->scan_objects;
209 __entry->nid = sc->nid;
210 __entry->nr_objects_to_shrink = nr_objects_to_shrink;
211 __entry->gfp_flags = sc->gfp_mask;
212 __entry->cache_items = cache_items;
213 __entry->delta = delta;
214 __entry->total_scan = total_scan;
215 __entry->priority = priority;
216 ),
217
218 TP_printk("%pS %p: nid: %d objects to shrink %ld gfp_flags %s cache items %ld delta %lld total_scan %ld priority %d",
219 __entry->shrink,
220 __entry->shr,
221 __entry->nid,
222 __entry->nr_objects_to_shrink,
223 show_gfp_flags(__entry->gfp_flags),
224 __entry->cache_items,
225 __entry->delta,
226 __entry->total_scan,
227 __entry->priority)
228 );
229
230 TRACE_EVENT(mm_shrink_slab_end,
231 TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
232 long unused_scan_cnt, long new_scan_cnt, long total_scan),
233
234 TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
235 total_scan),
236
237 TP_STRUCT__entry(
238 __field(struct shrinker *, shr)
239 __field(int, nid)
240 __field(void *, shrink)
241 __field(long, unused_scan)
242 __field(long, new_scan)
243 __field(int, retval)
244 __field(long, total_scan)
245 ),
246
247 TP_fast_assign(
248 __entry->shr = shr;
249 __entry->nid = nid;
250 __entry->shrink = shr->scan_objects;
251 __entry->unused_scan = unused_scan_cnt;
252 __entry->new_scan = new_scan_cnt;
253 __entry->retval = shrinker_retval;
254 __entry->total_scan = total_scan;
255 ),
256
257 TP_printk("%pS %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
258 __entry->shrink,
259 __entry->shr,
260 __entry->nid,
261 __entry->unused_scan,
262 __entry->new_scan,
263 __entry->total_scan,
264 __entry->retval)
265 );
266
267 TRACE_EVENT(mm_vmscan_lru_isolate,
268 TP_PROTO(int classzone_idx,
269 int order,
270 unsigned long nr_requested,
271 unsigned long nr_scanned,
272 unsigned long nr_skipped,
273 unsigned long nr_taken,
274 isolate_mode_t isolate_mode,
275 int lru),
276
277 TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, lru),
278
279 TP_STRUCT__entry(
280 __field(int, classzone_idx)
281 __field(int, order)
282 __field(unsigned long, nr_requested)
283 __field(unsigned long, nr_scanned)
284 __field(unsigned long, nr_skipped)
285 __field(unsigned long, nr_taken)
286 __field(isolate_mode_t, isolate_mode)
287 __field(int, lru)
288 ),
289
290 TP_fast_assign(
291 __entry->classzone_idx = classzone_idx;
292 __entry->order = order;
293 __entry->nr_requested = nr_requested;
294 __entry->nr_scanned = nr_scanned;
295 __entry->nr_skipped = nr_skipped;
296 __entry->nr_taken = nr_taken;
297 __entry->isolate_mode = isolate_mode;
298 __entry->lru = lru;
299 ),
300
301 TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s",
302 __entry->isolate_mode,
303 __entry->classzone_idx,
304 __entry->order,
305 __entry->nr_requested,
306 __entry->nr_scanned,
307 __entry->nr_skipped,
308 __entry->nr_taken,
309 __print_symbolic(__entry->lru, LRU_NAMES))
310 );
311
312 TRACE_EVENT(mm_vmscan_writepage,
313
314 TP_PROTO(struct page *page),
315
316 TP_ARGS(page),
317
318 TP_STRUCT__entry(
319 __field(unsigned long, pfn)
320 __field(int, reclaim_flags)
321 ),
322
323 TP_fast_assign(
324 __entry->pfn = page_to_pfn(page);
325 __entry->reclaim_flags = trace_reclaim_flags(
326 page_is_file_cache(page));
327 ),
328
329 TP_printk("page=%p pfn=%lu flags=%s",
330 pfn_to_page(__entry->pfn),
331 __entry->pfn,
332 show_reclaim_flags(__entry->reclaim_flags))
333 );
334
335 TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
336
337 TP_PROTO(int nid,
338 unsigned long nr_scanned, unsigned long nr_reclaimed,
339 struct reclaim_stat *stat, int priority, int file),
340
341 TP_ARGS(nid, nr_scanned, nr_reclaimed, stat, priority, file),
342
343 TP_STRUCT__entry(
344 __field(int, nid)
345 __field(unsigned long, nr_scanned)
346 __field(unsigned long, nr_reclaimed)
347 __field(unsigned long, nr_dirty)
348 __field(unsigned long, nr_writeback)
349 __field(unsigned long, nr_congested)
350 __field(unsigned long, nr_immediate)
351 __field(unsigned int, nr_activate0)
352 __field(unsigned int, nr_activate1)
353 __field(unsigned long, nr_ref_keep)
354 __field(unsigned long, nr_unmap_fail)
355 __field(int, priority)
356 __field(int, reclaim_flags)
357 ),
358
359 TP_fast_assign(
360 __entry->nid = nid;
361 __entry->nr_scanned = nr_scanned;
362 __entry->nr_reclaimed = nr_reclaimed;
363 __entry->nr_dirty = stat->nr_dirty;
364 __entry->nr_writeback = stat->nr_writeback;
365 __entry->nr_congested = stat->nr_congested;
366 __entry->nr_immediate = stat->nr_immediate;
367 __entry->nr_activate0 = stat->nr_activate[0];
368 __entry->nr_activate1 = stat->nr_activate[1];
369 __entry->nr_ref_keep = stat->nr_ref_keep;
370 __entry->nr_unmap_fail = stat->nr_unmap_fail;
371 __entry->priority = priority;
372 __entry->reclaim_flags = trace_reclaim_flags(file);
373 ),
374
375 TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate_anon=%d nr_activate_file=%d nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s",
376 __entry->nid,
377 __entry->nr_scanned, __entry->nr_reclaimed,
378 __entry->nr_dirty, __entry->nr_writeback,
379 __entry->nr_congested, __entry->nr_immediate,
380 __entry->nr_activate0, __entry->nr_activate1,
381 __entry->nr_ref_keep, __entry->nr_unmap_fail,
382 __entry->priority,
383 show_reclaim_flags(__entry->reclaim_flags))
384 );
385
386 TRACE_EVENT(mm_vmscan_lru_shrink_active,
387
388 TP_PROTO(int nid, unsigned long nr_taken,
389 unsigned long nr_active, unsigned long nr_deactivated,
390 unsigned long nr_referenced, int priority, int file),
391
392 TP_ARGS(nid, nr_taken, nr_active, nr_deactivated, nr_referenced, priority, file),
393
394 TP_STRUCT__entry(
395 __field(int, nid)
396 __field(unsigned long, nr_taken)
397 __field(unsigned long, nr_active)
398 __field(unsigned long, nr_deactivated)
399 __field(unsigned long, nr_referenced)
400 __field(int, priority)
401 __field(int, reclaim_flags)
402 ),
403
404 TP_fast_assign(
405 __entry->nid = nid;
406 __entry->nr_taken = nr_taken;
407 __entry->nr_active = nr_active;
408 __entry->nr_deactivated = nr_deactivated;
409 __entry->nr_referenced = nr_referenced;
410 __entry->priority = priority;
411 __entry->reclaim_flags = trace_reclaim_flags(file);
412 ),
413
414 TP_printk("nid=%d nr_taken=%ld nr_active=%ld nr_deactivated=%ld nr_referenced=%ld priority=%d flags=%s",
415 __entry->nid,
416 __entry->nr_taken,
417 __entry->nr_active, __entry->nr_deactivated, __entry->nr_referenced,
418 __entry->priority,
419 show_reclaim_flags(__entry->reclaim_flags))
420 );
421
422 TRACE_EVENT(mm_vmscan_inactive_list_is_low,
423
424 TP_PROTO(int nid, int reclaim_idx,
425 unsigned long total_inactive, unsigned long inactive,
426 unsigned long total_active, unsigned long active,
427 unsigned long ratio, int file),
428
429 TP_ARGS(nid, reclaim_idx, total_inactive, inactive, total_active, active, ratio, file),
430
431 TP_STRUCT__entry(
432 __field(int, nid)
433 __field(int, reclaim_idx)
434 __field(unsigned long, total_inactive)
435 __field(unsigned long, inactive)
436 __field(unsigned long, total_active)
437 __field(unsigned long, active)
438 __field(unsigned long, ratio)
439 __field(int, reclaim_flags)
440 ),
441
442 TP_fast_assign(
443 __entry->nid = nid;
444 __entry->reclaim_idx = reclaim_idx;
445 __entry->total_inactive = total_inactive;
446 __entry->inactive = inactive;
447 __entry->total_active = total_active;
448 __entry->active = active;
449 __entry->ratio = ratio;
450 __entry->reclaim_flags = trace_reclaim_flags(file) &
451 RECLAIM_WB_LRU;
452 ),
453
454 TP_printk("nid=%d reclaim_idx=%d total_inactive=%ld inactive=%ld total_active=%ld active=%ld ratio=%ld flags=%s",
455 __entry->nid,
456 __entry->reclaim_idx,
457 __entry->total_inactive, __entry->inactive,
458 __entry->total_active, __entry->active,
459 __entry->ratio,
460 show_reclaim_flags(__entry->reclaim_flags))
461 );
462
463 TRACE_EVENT(mm_vmscan_node_reclaim_begin,
464
465 TP_PROTO(int nid, int order, gfp_t gfp_flags),
466
467 TP_ARGS(nid, order, gfp_flags),
468
469 TP_STRUCT__entry(
470 __field(int, nid)
471 __field(int, order)
472 __field(gfp_t, gfp_flags)
473 ),
474
475 TP_fast_assign(
476 __entry->nid = nid;
477 __entry->order = order;
478 __entry->gfp_flags = gfp_flags;
479 ),
480
481 TP_printk("nid=%d order=%d gfp_flags=%s",
482 __entry->nid,
483 __entry->order,
484 show_gfp_flags(__entry->gfp_flags))
485 );
486
487 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_node_reclaim_end,
488
489 TP_PROTO(unsigned long nr_reclaimed),
490
491 TP_ARGS(nr_reclaimed)
492 );
493
494 #endif
495
496
497 #include <trace/define_trace.h>