1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM vmscan
5 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_VMSCAN_H
8 #include <linux/types.h>
9 #include <linux/tracepoint.h>
11 #include <linux/memcontrol.h>
12 #include <trace/events/mmflags.h>
14 #define RECLAIM_WB_ANON 0x0001u
15 #define RECLAIM_WB_FILE 0x0002u
16 #define RECLAIM_WB_MIXED 0x0010u
17 #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */
18 #define RECLAIM_WB_ASYNC 0x0008u
19 #define RECLAIM_WB_LRU (RECLAIM_WB_ANON|RECLAIM_WB_FILE)
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"} \
30 #define trace_reclaim_flags(page) ( \
31 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
35 #define trace_shrink_flags(file) \
37 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
41 TRACE_EVENT(mm_vmscan_kswapd_sleep
,
55 TP_printk("nid=%d", __entry
->nid
)
58 TRACE_EVENT(mm_vmscan_kswapd_wake
,
60 TP_PROTO(int nid
, int zid
, int order
),
62 TP_ARGS(nid
, zid
, order
),
73 __entry
->order
= order
;
76 TP_printk("nid=%d zid=%d order=%d", __entry
->nid
, __entry
->zid
, __entry
->order
)
79 TRACE_EVENT(mm_vmscan_wakeup_kswapd
,
81 TP_PROTO(int nid
, int zid
, int order
),
83 TP_ARGS(nid
, zid
, order
),
94 __entry
->order
= order
;
97 TP_printk("nid=%d zid=%d order=%d",
103 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
105 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
107 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
),
110 __field( int, order
)
111 __field( int, may_writepage
)
112 __field( gfp_t
, gfp_flags
)
113 __field( int, classzone_idx
)
117 __entry
->order
= order
;
118 __entry
->may_writepage
= may_writepage
;
119 __entry
->gfp_flags
= gfp_flags
;
120 __entry
->classzone_idx
= classzone_idx
;
123 TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
125 __entry
->may_writepage
,
126 show_gfp_flags(__entry
->gfp_flags
),
127 __entry
->classzone_idx
)
130 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
132 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
134 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
138 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
140 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
142 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
145 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
147 TP_PROTO(int order
, int may_writepage
, gfp_t gfp_flags
, int classzone_idx
),
149 TP_ARGS(order
, may_writepage
, gfp_flags
, classzone_idx
)
151 #endif /* CONFIG_MEMCG */
153 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
155 TP_PROTO(unsigned long nr_reclaimed
),
157 TP_ARGS(nr_reclaimed
),
160 __field( unsigned long, nr_reclaimed
)
164 __entry
->nr_reclaimed
= nr_reclaimed
;
167 TP_printk("nr_reclaimed=%lu", __entry
->nr_reclaimed
)
170 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
172 TP_PROTO(unsigned long nr_reclaimed
),
174 TP_ARGS(nr_reclaimed
)
178 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
180 TP_PROTO(unsigned long nr_reclaimed
),
182 TP_ARGS(nr_reclaimed
)
185 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
187 TP_PROTO(unsigned long nr_reclaimed
),
189 TP_ARGS(nr_reclaimed
)
191 #endif /* CONFIG_MEMCG */
193 TRACE_EVENT(mm_shrink_slab_start
,
194 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
195 long nr_objects_to_shrink
, unsigned long cache_items
,
196 unsigned long long delta
, unsigned long total_scan
,
199 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, cache_items
, delta
, total_scan
,
203 __field(struct shrinker
*, shr
)
204 __field(void *, shrink
)
206 __field(long, nr_objects_to_shrink
)
207 __field(gfp_t
, gfp_flags
)
208 __field(unsigned long, cache_items
)
209 __field(unsigned long long, delta
)
210 __field(unsigned long, total_scan
)
211 __field(int, priority
)
216 __entry
->shrink
= shr
->scan_objects
;
217 __entry
->nid
= sc
->nid
;
218 __entry
->nr_objects_to_shrink
= nr_objects_to_shrink
;
219 __entry
->gfp_flags
= sc
->gfp_mask
;
220 __entry
->cache_items
= cache_items
;
221 __entry
->delta
= delta
;
222 __entry
->total_scan
= total_scan
;
223 __entry
->priority
= priority
;
226 TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s cache items %ld delta %lld total_scan %ld priority %d",
230 __entry
->nr_objects_to_shrink
,
231 show_gfp_flags(__entry
->gfp_flags
),
232 __entry
->cache_items
,
238 TRACE_EVENT(mm_shrink_slab_end
,
239 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
240 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
242 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
246 __field(struct shrinker
*, shr
)
248 __field(void *, shrink
)
249 __field(long, unused_scan
)
250 __field(long, new_scan
)
252 __field(long, total_scan
)
258 __entry
->shrink
= shr
->scan_objects
;
259 __entry
->unused_scan
= unused_scan_cnt
;
260 __entry
->new_scan
= new_scan_cnt
;
261 __entry
->retval
= shrinker_retval
;
262 __entry
->total_scan
= total_scan
;
265 TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
269 __entry
->unused_scan
,
275 TRACE_EVENT(mm_vmscan_lru_isolate
,
276 TP_PROTO(int classzone_idx
,
278 unsigned long nr_requested
,
279 unsigned long nr_scanned
,
280 unsigned long nr_skipped
,
281 unsigned long nr_taken
,
282 isolate_mode_t isolate_mode
,
285 TP_ARGS(classzone_idx
, order
, nr_requested
, nr_scanned
, nr_skipped
, nr_taken
, isolate_mode
, lru
),
288 __field(int, classzone_idx
)
290 __field(unsigned long, nr_requested
)
291 __field(unsigned long, nr_scanned
)
292 __field(unsigned long, nr_skipped
)
293 __field(unsigned long, nr_taken
)
294 __field(isolate_mode_t
, isolate_mode
)
299 __entry
->classzone_idx
= classzone_idx
;
300 __entry
->order
= order
;
301 __entry
->nr_requested
= nr_requested
;
302 __entry
->nr_scanned
= nr_scanned
;
303 __entry
->nr_skipped
= nr_skipped
;
304 __entry
->nr_taken
= nr_taken
;
305 __entry
->isolate_mode
= isolate_mode
;
309 TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s",
310 __entry
->isolate_mode
,
311 __entry
->classzone_idx
,
313 __entry
->nr_requested
,
317 __print_symbolic(__entry
->lru
, LRU_NAMES
))
320 TRACE_EVENT(mm_vmscan_writepage
,
322 TP_PROTO(struct page
*page
),
327 __field(unsigned long, pfn
)
328 __field(int, reclaim_flags
)
332 __entry
->pfn
= page_to_pfn(page
);
333 __entry
->reclaim_flags
= trace_reclaim_flags(page
);
336 TP_printk("page=%p pfn=%lu flags=%s",
337 pfn_to_page(__entry
->pfn
),
339 show_reclaim_flags(__entry
->reclaim_flags
))
342 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
345 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
346 unsigned long nr_dirty
, unsigned long nr_writeback
,
347 unsigned long nr_congested
, unsigned long nr_immediate
,
348 unsigned long nr_activate
, unsigned long nr_ref_keep
,
349 unsigned long nr_unmap_fail
,
350 int priority
, int file
),
352 TP_ARGS(nid
, nr_scanned
, nr_reclaimed
, nr_dirty
, nr_writeback
,
353 nr_congested
, nr_immediate
, nr_activate
, nr_ref_keep
,
354 nr_unmap_fail
, priority
, file
),
358 __field(unsigned long, nr_scanned
)
359 __field(unsigned long, nr_reclaimed
)
360 __field(unsigned long, nr_dirty
)
361 __field(unsigned long, nr_writeback
)
362 __field(unsigned long, nr_congested
)
363 __field(unsigned long, nr_immediate
)
364 __field(unsigned long, nr_activate
)
365 __field(unsigned long, nr_ref_keep
)
366 __field(unsigned long, nr_unmap_fail
)
367 __field(int, priority
)
368 __field(int, reclaim_flags
)
373 __entry
->nr_scanned
= nr_scanned
;
374 __entry
->nr_reclaimed
= nr_reclaimed
;
375 __entry
->nr_dirty
= nr_dirty
;
376 __entry
->nr_writeback
= nr_writeback
;
377 __entry
->nr_congested
= nr_congested
;
378 __entry
->nr_immediate
= nr_immediate
;
379 __entry
->nr_activate
= nr_activate
;
380 __entry
->nr_ref_keep
= nr_ref_keep
;
381 __entry
->nr_unmap_fail
= nr_unmap_fail
;
382 __entry
->priority
= priority
;
383 __entry
->reclaim_flags
= trace_shrink_flags(file
);
386 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",
388 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
389 __entry
->nr_dirty
, __entry
->nr_writeback
,
390 __entry
->nr_congested
, __entry
->nr_immediate
,
391 __entry
->nr_activate
, __entry
->nr_ref_keep
,
392 __entry
->nr_unmap_fail
, __entry
->priority
,
393 show_reclaim_flags(__entry
->reclaim_flags
))
396 TRACE_EVENT(mm_vmscan_lru_shrink_active
,
398 TP_PROTO(int nid
, unsigned long nr_taken
,
399 unsigned long nr_active
, unsigned long nr_deactivated
,
400 unsigned long nr_referenced
, int priority
, int file
),
402 TP_ARGS(nid
, nr_taken
, nr_active
, nr_deactivated
, nr_referenced
, priority
, file
),
406 __field(unsigned long, nr_taken
)
407 __field(unsigned long, nr_active
)
408 __field(unsigned long, nr_deactivated
)
409 __field(unsigned long, nr_referenced
)
410 __field(int, priority
)
411 __field(int, reclaim_flags
)
416 __entry
->nr_taken
= nr_taken
;
417 __entry
->nr_active
= nr_active
;
418 __entry
->nr_deactivated
= nr_deactivated
;
419 __entry
->nr_referenced
= nr_referenced
;
420 __entry
->priority
= priority
;
421 __entry
->reclaim_flags
= trace_shrink_flags(file
);
424 TP_printk("nid=%d nr_taken=%ld nr_active=%ld nr_deactivated=%ld nr_referenced=%ld priority=%d flags=%s",
427 __entry
->nr_active
, __entry
->nr_deactivated
, __entry
->nr_referenced
,
429 show_reclaim_flags(__entry
->reclaim_flags
))
432 TRACE_EVENT(mm_vmscan_inactive_list_is_low
,
434 TP_PROTO(int nid
, int reclaim_idx
,
435 unsigned long total_inactive
, unsigned long inactive
,
436 unsigned long total_active
, unsigned long active
,
437 unsigned long ratio
, int file
),
439 TP_ARGS(nid
, reclaim_idx
, total_inactive
, inactive
, total_active
, active
, ratio
, file
),
443 __field(int, reclaim_idx
)
444 __field(unsigned long, total_inactive
)
445 __field(unsigned long, inactive
)
446 __field(unsigned long, total_active
)
447 __field(unsigned long, active
)
448 __field(unsigned long, ratio
)
449 __field(int, reclaim_flags
)
454 __entry
->reclaim_idx
= reclaim_idx
;
455 __entry
->total_inactive
= total_inactive
;
456 __entry
->inactive
= inactive
;
457 __entry
->total_active
= total_active
;
458 __entry
->active
= active
;
459 __entry
->ratio
= ratio
;
460 __entry
->reclaim_flags
= trace_shrink_flags(file
) & RECLAIM_WB_LRU
;
463 TP_printk("nid=%d reclaim_idx=%d total_inactive=%ld inactive=%ld total_active=%ld active=%ld ratio=%ld flags=%s",
465 __entry
->reclaim_idx
,
466 __entry
->total_inactive
, __entry
->inactive
,
467 __entry
->total_active
, __entry
->active
,
469 show_reclaim_flags(__entry
->reclaim_flags
))
471 #endif /* _TRACE_VMSCAN_H */
473 /* This part must be outside protection */
474 #include <trace/define_trace.h>