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/mmflags.h>
13 #define RECLAIM_WB_ANON 0x0001u
14 #define RECLAIM_WB_FILE 0x0002u
15 #define RECLAIM_WB_MIXED 0x0010u
16 #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
17 #define RECLAIM_WB_ASYNC 0x0008u
18 #define RECLAIM_WB_LRU (RECLAIM_WB_ANON|RECLAIM_WB_FILE)
20 #define show_reclaim_flags(flags) \
21 (flags) ? __print_flags(flags, "|", \
22 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \
23 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \
24 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \
25 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \
26 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \
29 #define trace_reclaim_flags(page) ( \
30 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
34 #define trace_shrink_flags(file) \
36 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
40 TRACE_EVENT(mm_vmscan_kswapd_sleep
,
54 TP_printk("nid=%d", __entry
->nid
)
57 TRACE_EVENT(mm_vmscan_kswapd_wake
,
59 TP_PROTO(int nid
, int zid
, int order
),
61 TP_ARGS(nid
, zid
, order
),
72 __entry
->order
= order
;
75 TP_printk("nid=%d zid=%d order=%d", __entry
->nid
, __entry
->zid
, __entry
->order
)
78 TRACE_EVENT(mm_vmscan_wakeup_kswapd
,
80 TP_PROTO(int nid
, int zid
, int order
),
82 TP_ARGS(nid
, zid
, order
),
93 __entry
->order
= order
;
96 TP_printk("nid=%d zid=%d order=%d",
102 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
104 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
106 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
),
109 __field( int, order
)
110 __field( int, may_writepage
)
111 __field( gfp_t
, gfp_flags
)
112 __field( int, classzone_idx
)
116 __entry
->order
= order
;
117 __entry
->may_writepage
= may_writepage
;
118 __entry
->gfp_flags
= gfp_flags
;
119 __entry
->classzone_idx
= classzone_idx
;
122 TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
124 __entry
->may_writepage
,
125 show_gfp_flags(__entry
->gfp_flags
),
126 __entry
->classzone_idx
)
129 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
131 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
133 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
136 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
138 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
140 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
143 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
145 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
147 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
150 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
152 TP_PROTO(unsigned long nr_reclaimed
),
154 TP_ARGS(nr_reclaimed
),
157 __field( unsigned long, nr_reclaimed
)
161 __entry
->nr_reclaimed
= nr_reclaimed
;
164 TP_printk("nr_reclaimed=%lu", __entry
->nr_reclaimed
)
167 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
169 TP_PROTO(unsigned long nr_reclaimed
),
171 TP_ARGS(nr_reclaimed
)
174 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
176 TP_PROTO(unsigned long nr_reclaimed
),
178 TP_ARGS(nr_reclaimed
)
181 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
183 TP_PROTO(unsigned long nr_reclaimed
),
185 TP_ARGS(nr_reclaimed
)
188 TRACE_EVENT(mm_shrink_slab_start
,
189 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
190 long nr_objects_to_shrink
, unsigned long pgs_scanned
,
191 unsigned long lru_pgs
, unsigned long cache_items
,
192 unsigned long long delta
, unsigned long total_scan
),
194 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, pgs_scanned
, lru_pgs
,
195 cache_items
, delta
, total_scan
),
198 __field(struct shrinker
*, shr
)
199 __field(void *, shrink
)
201 __field(long, nr_objects_to_shrink
)
202 __field(gfp_t
, gfp_flags
)
203 __field(unsigned long, pgs_scanned
)
204 __field(unsigned long, lru_pgs
)
205 __field(unsigned long, cache_items
)
206 __field(unsigned long long, delta
)
207 __field(unsigned long, total_scan
)
212 __entry
->shrink
= shr
->scan_objects
;
213 __entry
->nid
= sc
->nid
;
214 __entry
->nr_objects_to_shrink
= nr_objects_to_shrink
;
215 __entry
->gfp_flags
= sc
->gfp_mask
;
216 __entry
->pgs_scanned
= pgs_scanned
;
217 __entry
->lru_pgs
= lru_pgs
;
218 __entry
->cache_items
= cache_items
;
219 __entry
->delta
= delta
;
220 __entry
->total_scan
= total_scan
;
223 TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
227 __entry
->nr_objects_to_shrink
,
228 show_gfp_flags(__entry
->gfp_flags
),
229 __entry
->pgs_scanned
,
231 __entry
->cache_items
,
236 TRACE_EVENT(mm_shrink_slab_end
,
237 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
238 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
240 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
244 __field(struct shrinker
*, shr
)
246 __field(void *, shrink
)
247 __field(long, unused_scan
)
248 __field(long, new_scan
)
250 __field(long, total_scan
)
256 __entry
->shrink
= shr
->scan_objects
;
257 __entry
->unused_scan
= unused_scan_cnt
;
258 __entry
->new_scan
= new_scan_cnt
;
259 __entry
->retval
= shrinker_retval
;
260 __entry
->total_scan
= total_scan
;
263 TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
267 __entry
->unused_scan
,
273 TRACE_EVENT(mm_vmscan_lru_isolate
,
274 TP_PROTO(int classzone_idx
,
276 unsigned long nr_requested
,
277 unsigned long nr_scanned
,
278 unsigned long nr_skipped
,
279 unsigned long nr_taken
,
280 isolate_mode_t isolate_mode
,
283 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_skipped
, nr_taken
, isolate_mode
, lru
),
286 __field(int, classzone_idx
)
288 __field(unsigned long, nr_requested
)
289 __field(unsigned long, nr_scanned
)
290 __field(unsigned long, nr_skipped
)
291 __field(unsigned long, nr_taken
)
292 __field(isolate_mode_t
, isolate_mode
)
297 __entry
->classzone_idx
= classzone_idx
;
298 __entry
->order
= order
;
299 __entry
->nr_requested
= nr_requested
;
300 __entry
->nr_scanned
= nr_scanned
;
301 __entry
->nr_skipped
= nr_skipped
;
302 __entry
->nr_taken
= nr_taken
;
303 __entry
->isolate_mode
= isolate_mode
;
307 TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s",
308 __entry
->isolate_mode
,
309 __entry
->classzone_idx
,
311 __entry
->nr_requested
,
315 __print_symbolic(__entry
->lru
, LRU_NAMES
))
318 TRACE_EVENT(mm_vmscan_writepage
,
320 TP_PROTO(struct page
*page
),
325 __field(unsigned long, pfn
)
326 __field(int, reclaim_flags
)
330 __entry
->pfn
= page_to_pfn(page
);
331 __entry
->reclaim_flags
= trace_reclaim_flags(page
);
334 TP_printk("page=%p pfn=%lu flags=%s",
335 pfn_to_page(__entry
->pfn
),
337 show_reclaim_flags(__entry
->reclaim_flags
))
340 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
343 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
344 unsigned long nr_dirty
, unsigned long nr_writeback
,
345 unsigned long nr_congested
, unsigned long nr_immediate
,
346 unsigned long nr_activate
, unsigned long nr_ref_keep
,
347 unsigned long nr_unmap_fail
,
348 int priority
, int file
),
350 TP_ARGS(nid
, nr_scanned
, nr_reclaimed
, nr_dirty
, nr_writeback
,
351 nr_congested
, nr_immediate
, nr_activate
, nr_ref_keep
,
352 nr_unmap_fail
, priority
, file
),
356 __field(unsigned long, nr_scanned
)
357 __field(unsigned long, nr_reclaimed
)
358 __field(unsigned long, nr_dirty
)
359 __field(unsigned long, nr_writeback
)
360 __field(unsigned long, nr_congested
)
361 __field(unsigned long, nr_immediate
)
362 __field(unsigned long, nr_activate
)
363 __field(unsigned long, nr_ref_keep
)
364 __field(unsigned long, nr_unmap_fail
)
365 __field(int, priority
)
366 __field(int, reclaim_flags
)
371 __entry
->nr_scanned
= nr_scanned
;
372 __entry
->nr_reclaimed
= nr_reclaimed
;
373 __entry
->nr_dirty
= nr_dirty
;
374 __entry
->nr_writeback
= nr_writeback
;
375 __entry
->nr_congested
= nr_congested
;
376 __entry
->nr_immediate
= nr_immediate
;
377 __entry
->nr_activate
= nr_activate
;
378 __entry
->nr_ref_keep
= nr_ref_keep
;
379 __entry
->nr_unmap_fail
= nr_unmap_fail
;
380 __entry
->priority
= priority
;
381 __entry
->reclaim_flags
= trace_shrink_flags(file
);
384 TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate=%ld nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s",
386 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
387 __entry
->nr_dirty
, __entry
->nr_writeback
,
388 __entry
->nr_congested
, __entry
->nr_immediate
,
389 __entry
->nr_activate
, __entry
->nr_ref_keep
,
390 __entry
->nr_unmap_fail
, __entry
->priority
,
391 show_reclaim_flags(__entry
->reclaim_flags
))
394 TRACE_EVENT(mm_vmscan_lru_shrink_active
,
396 TP_PROTO(int nid
, unsigned long nr_taken
,
397 unsigned long nr_active
, unsigned long nr_deactivated
,
398 unsigned long nr_referenced
, int priority
, int file
),
400 TP_ARGS(nid
, nr_taken
, nr_active
, nr_deactivated
, nr_referenced
, priority
, file
),
404 __field(unsigned long, nr_taken
)
405 __field(unsigned long, nr_active
)
406 __field(unsigned long, nr_deactivated
)
407 __field(unsigned long, nr_referenced
)
408 __field(int, priority
)
409 __field(int, reclaim_flags
)
414 __entry
->nr_taken
= nr_taken
;
415 __entry
->nr_active
= nr_active
;
416 __entry
->nr_deactivated
= nr_deactivated
;
417 __entry
->nr_referenced
= nr_referenced
;
418 __entry
->priority
= priority
;
419 __entry
->reclaim_flags
= trace_shrink_flags(file
);
422 TP_printk("nid=%d nr_taken=%ld nr_active=%ld nr_deactivated=%ld nr_referenced=%ld priority=%d flags=%s",
425 __entry
->nr_active
, __entry
->nr_deactivated
, __entry
->nr_referenced
,
427 show_reclaim_flags(__entry
->reclaim_flags
))
430 TRACE_EVENT(mm_vmscan_inactive_list_is_low
,
432 TP_PROTO(int nid
, int reclaim_idx
,
433 unsigned long total_inactive
, unsigned long inactive
,
434 unsigned long total_active
, unsigned long active
,
435 unsigned long ratio
, int file
),
437 TP_ARGS(nid
, reclaim_idx
, total_inactive
, inactive
, total_active
, active
, ratio
, file
),
441 __field(int, reclaim_idx
)
442 __field(unsigned long, total_inactive
)
443 __field(unsigned long, inactive
)
444 __field(unsigned long, total_active
)
445 __field(unsigned long, active
)
446 __field(unsigned long, ratio
)
447 __field(int, reclaim_flags
)
452 __entry
->reclaim_idx
= reclaim_idx
;
453 __entry
->total_inactive
= total_inactive
;
454 __entry
->inactive
= inactive
;
455 __entry
->total_active
= total_active
;
456 __entry
->active
= active
;
457 __entry
->ratio
= ratio
;
458 __entry
->reclaim_flags
= trace_shrink_flags(file
) & RECLAIM_WB_LRU
;
461 TP_printk("nid=%d reclaim_idx=%d total_inactive=%ld inactive=%ld total_active=%ld active=%ld ratio=%ld flags=%s",
463 __entry
->reclaim_idx
,
464 __entry
->total_inactive
, __entry
->inactive
,
465 __entry
->total_active
, __entry
->active
,
467 show_reclaim_flags(__entry
->reclaim_flags
))
469 #endif /* _TRACE_VMSCAN_H */
471 /* This part must be outside protection */
472 #include <trace/define_trace.h>