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 _VMSCAN_THROTTLE_WRITEBACK (1 << VMSCAN_THROTTLE_WRITEBACK)
31 #define _VMSCAN_THROTTLE_ISOLATED (1 << VMSCAN_THROTTLE_ISOLATED)
32 #define _VMSCAN_THROTTLE_NOPROGRESS (1 << VMSCAN_THROTTLE_NOPROGRESS)
33 #define _VMSCAN_THROTTLE_CONGESTED (1 << VMSCAN_THROTTLE_CONGESTED)
35 #define show_throttle_flags(flags) \
36 (flags) ? __print_flags(flags, "|", \
37 {_VMSCAN_THROTTLE_WRITEBACK, "VMSCAN_THROTTLE_WRITEBACK"}, \
38 {_VMSCAN_THROTTLE_ISOLATED, "VMSCAN_THROTTLE_ISOLATED"}, \
39 {_VMSCAN_THROTTLE_NOPROGRESS, "VMSCAN_THROTTLE_NOPROGRESS"}, \
40 {_VMSCAN_THROTTLE_CONGESTED, "VMSCAN_THROTTLE_CONGESTED"} \
41 ) : "VMSCAN_THROTTLE_NONE"
44 #define trace_reclaim_flags(file) ( \
45 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
49 TRACE_EVENT(mm_vmscan_kswapd_sleep
,
63 TP_printk("nid=%d", __entry
->nid
)
66 TRACE_EVENT(mm_vmscan_kswapd_wake
,
68 TP_PROTO(int nid
, int zid
, int order
),
70 TP_ARGS(nid
, zid
, order
),
81 __entry
->order
= order
;
84 TP_printk("nid=%d order=%d",
89 TRACE_EVENT(mm_vmscan_wakeup_kswapd
,
91 TP_PROTO(int nid
, int zid
, int order
, gfp_t gfp_flags
),
93 TP_ARGS(nid
, zid
, order
, gfp_flags
),
99 __field( unsigned long, gfp_flags
)
105 __entry
->order
= order
;
106 __entry
->gfp_flags
= (__force
unsigned long)gfp_flags
;
109 TP_printk("nid=%d order=%d gfp_flags=%s",
112 show_gfp_flags(__entry
->gfp_flags
))
115 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template
,
117 TP_PROTO(int order
, gfp_t gfp_flags
),
119 TP_ARGS(order
, gfp_flags
),
122 __field( int, order
)
123 __field( unsigned long, gfp_flags
)
127 __entry
->order
= order
;
128 __entry
->gfp_flags
= (__force
unsigned long)gfp_flags
;
131 TP_printk("order=%d gfp_flags=%s",
133 show_gfp_flags(__entry
->gfp_flags
))
136 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_direct_reclaim_begin
,
138 TP_PROTO(int order
, gfp_t gfp_flags
),
140 TP_ARGS(order
, gfp_flags
)
144 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_reclaim_begin
,
146 TP_PROTO(int order
, gfp_t gfp_flags
),
148 TP_ARGS(order
, gfp_flags
)
151 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template
, mm_vmscan_memcg_softlimit_reclaim_begin
,
153 TP_PROTO(int order
, gfp_t gfp_flags
),
155 TP_ARGS(order
, gfp_flags
)
157 #endif /* CONFIG_MEMCG */
159 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template
,
161 TP_PROTO(unsigned long nr_reclaimed
),
163 TP_ARGS(nr_reclaimed
),
166 __field( unsigned long, nr_reclaimed
)
170 __entry
->nr_reclaimed
= nr_reclaimed
;
173 TP_printk("nr_reclaimed=%lu", __entry
->nr_reclaimed
)
176 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_direct_reclaim_end
,
178 TP_PROTO(unsigned long nr_reclaimed
),
180 TP_ARGS(nr_reclaimed
)
184 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_reclaim_end
,
186 TP_PROTO(unsigned long nr_reclaimed
),
188 TP_ARGS(nr_reclaimed
)
191 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_memcg_softlimit_reclaim_end
,
193 TP_PROTO(unsigned long nr_reclaimed
),
195 TP_ARGS(nr_reclaimed
)
197 #endif /* CONFIG_MEMCG */
199 TRACE_EVENT(mm_shrink_slab_start
,
200 TP_PROTO(struct shrinker
*shr
, struct shrink_control
*sc
,
201 long nr_objects_to_shrink
, unsigned long cache_items
,
202 unsigned long long delta
, unsigned long total_scan
,
205 TP_ARGS(shr
, sc
, nr_objects_to_shrink
, cache_items
, delta
, total_scan
,
209 __field(struct shrinker
*, shr
)
210 __field(void *, shrink
)
212 __field(long, nr_objects_to_shrink
)
213 __field(unsigned long, gfp_flags
)
214 __field(unsigned long, cache_items
)
215 __field(unsigned long long, delta
)
216 __field(unsigned long, total_scan
)
217 __field(int, priority
)
222 __entry
->shrink
= shr
->scan_objects
;
223 __entry
->nid
= sc
->nid
;
224 __entry
->nr_objects_to_shrink
= nr_objects_to_shrink
;
225 __entry
->gfp_flags
= (__force
unsigned long)sc
->gfp_mask
;
226 __entry
->cache_items
= cache_items
;
227 __entry
->delta
= delta
;
228 __entry
->total_scan
= total_scan
;
229 __entry
->priority
= priority
;
232 TP_printk("%pS %p: nid: %d objects to shrink %ld gfp_flags %s cache items %ld delta %lld total_scan %ld priority %d",
236 __entry
->nr_objects_to_shrink
,
237 show_gfp_flags(__entry
->gfp_flags
),
238 __entry
->cache_items
,
244 TRACE_EVENT(mm_shrink_slab_end
,
245 TP_PROTO(struct shrinker
*shr
, int nid
, int shrinker_retval
,
246 long unused_scan_cnt
, long new_scan_cnt
, long total_scan
),
248 TP_ARGS(shr
, nid
, shrinker_retval
, unused_scan_cnt
, new_scan_cnt
,
252 __field(struct shrinker
*, shr
)
254 __field(void *, shrink
)
255 __field(long, unused_scan
)
256 __field(long, new_scan
)
258 __field(long, total_scan
)
264 __entry
->shrink
= shr
->scan_objects
;
265 __entry
->unused_scan
= unused_scan_cnt
;
266 __entry
->new_scan
= new_scan_cnt
;
267 __entry
->retval
= shrinker_retval
;
268 __entry
->total_scan
= total_scan
;
271 TP_printk("%pS %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
275 __entry
->unused_scan
,
281 TRACE_EVENT(mm_vmscan_lru_isolate
,
282 TP_PROTO(int highest_zoneidx
,
284 unsigned long nr_requested
,
285 unsigned long nr_scanned
,
286 unsigned long nr_skipped
,
287 unsigned long nr_taken
,
290 TP_ARGS(highest_zoneidx
, order
, nr_requested
, nr_scanned
, nr_skipped
, nr_taken
, lru
),
293 __field(int, highest_zoneidx
)
295 __field(unsigned long, nr_requested
)
296 __field(unsigned long, nr_scanned
)
297 __field(unsigned long, nr_skipped
)
298 __field(unsigned long, nr_taken
)
303 __entry
->highest_zoneidx
= highest_zoneidx
;
304 __entry
->order
= order
;
305 __entry
->nr_requested
= nr_requested
;
306 __entry
->nr_scanned
= nr_scanned
;
307 __entry
->nr_skipped
= nr_skipped
;
308 __entry
->nr_taken
= nr_taken
;
313 * classzone is previous name of the highest_zoneidx.
314 * Reason not to change it is the ABI requirement of the tracepoint.
316 TP_printk("classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s",
317 __entry
->highest_zoneidx
,
319 __entry
->nr_requested
,
323 __print_symbolic(__entry
->lru
, LRU_NAMES
))
326 TRACE_EVENT(mm_vmscan_write_folio
,
328 TP_PROTO(struct folio
*folio
),
333 __field(unsigned long, pfn
)
334 __field(int, reclaim_flags
)
338 __entry
->pfn
= folio_pfn(folio
);
339 __entry
->reclaim_flags
= trace_reclaim_flags(
340 folio_is_file_lru(folio
));
343 TP_printk("page=%p pfn=0x%lx flags=%s",
344 pfn_to_page(__entry
->pfn
),
346 show_reclaim_flags(__entry
->reclaim_flags
))
349 TRACE_EVENT(mm_vmscan_reclaim_pages
,
352 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
353 struct reclaim_stat
*stat
),
355 TP_ARGS(nid
, nr_scanned
, nr_reclaimed
, stat
),
359 __field(unsigned long, nr_scanned
)
360 __field(unsigned long, nr_reclaimed
)
361 __field(unsigned long, nr_dirty
)
362 __field(unsigned long, nr_writeback
)
363 __field(unsigned long, nr_congested
)
364 __field(unsigned long, nr_immediate
)
365 __field(unsigned int, nr_activate0
)
366 __field(unsigned int, nr_activate1
)
367 __field(unsigned long, nr_ref_keep
)
368 __field(unsigned long, nr_unmap_fail
)
373 __entry
->nr_scanned
= nr_scanned
;
374 __entry
->nr_reclaimed
= nr_reclaimed
;
375 __entry
->nr_dirty
= stat
->nr_dirty
;
376 __entry
->nr_writeback
= stat
->nr_writeback
;
377 __entry
->nr_congested
= stat
->nr_congested
;
378 __entry
->nr_immediate
= stat
->nr_immediate
;
379 __entry
->nr_activate0
= stat
->nr_activate
[0];
380 __entry
->nr_activate1
= stat
->nr_activate
[1];
381 __entry
->nr_ref_keep
= stat
->nr_ref_keep
;
382 __entry
->nr_unmap_fail
= stat
->nr_unmap_fail
;
385 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",
387 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
388 __entry
->nr_dirty
, __entry
->nr_writeback
,
389 __entry
->nr_congested
, __entry
->nr_immediate
,
390 __entry
->nr_activate0
, __entry
->nr_activate1
,
391 __entry
->nr_ref_keep
, __entry
->nr_unmap_fail
)
394 TRACE_EVENT(mm_vmscan_lru_shrink_inactive
,
397 unsigned long nr_scanned
, unsigned long nr_reclaimed
,
398 struct reclaim_stat
*stat
, int priority
, int file
),
400 TP_ARGS(nid
, nr_scanned
, nr_reclaimed
, stat
, priority
, file
),
404 __field(unsigned long, nr_scanned
)
405 __field(unsigned long, nr_reclaimed
)
406 __field(unsigned long, nr_dirty
)
407 __field(unsigned long, nr_writeback
)
408 __field(unsigned long, nr_congested
)
409 __field(unsigned long, nr_immediate
)
410 __field(unsigned int, nr_activate0
)
411 __field(unsigned int, nr_activate1
)
412 __field(unsigned long, nr_ref_keep
)
413 __field(unsigned long, nr_unmap_fail
)
414 __field(int, priority
)
415 __field(int, reclaim_flags
)
420 __entry
->nr_scanned
= nr_scanned
;
421 __entry
->nr_reclaimed
= nr_reclaimed
;
422 __entry
->nr_dirty
= stat
->nr_dirty
;
423 __entry
->nr_writeback
= stat
->nr_writeback
;
424 __entry
->nr_congested
= stat
->nr_congested
;
425 __entry
->nr_immediate
= stat
->nr_immediate
;
426 __entry
->nr_activate0
= stat
->nr_activate
[0];
427 __entry
->nr_activate1
= stat
->nr_activate
[1];
428 __entry
->nr_ref_keep
= stat
->nr_ref_keep
;
429 __entry
->nr_unmap_fail
= stat
->nr_unmap_fail
;
430 __entry
->priority
= priority
;
431 __entry
->reclaim_flags
= trace_reclaim_flags(file
);
434 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",
436 __entry
->nr_scanned
, __entry
->nr_reclaimed
,
437 __entry
->nr_dirty
, __entry
->nr_writeback
,
438 __entry
->nr_congested
, __entry
->nr_immediate
,
439 __entry
->nr_activate0
, __entry
->nr_activate1
,
440 __entry
->nr_ref_keep
, __entry
->nr_unmap_fail
,
442 show_reclaim_flags(__entry
->reclaim_flags
))
445 TRACE_EVENT(mm_vmscan_lru_shrink_active
,
447 TP_PROTO(int nid
, unsigned long nr_taken
,
448 unsigned long nr_active
, unsigned long nr_deactivated
,
449 unsigned long nr_referenced
, int priority
, int file
),
451 TP_ARGS(nid
, nr_taken
, nr_active
, nr_deactivated
, nr_referenced
, priority
, file
),
455 __field(unsigned long, nr_taken
)
456 __field(unsigned long, nr_active
)
457 __field(unsigned long, nr_deactivated
)
458 __field(unsigned long, nr_referenced
)
459 __field(int, priority
)
460 __field(int, reclaim_flags
)
465 __entry
->nr_taken
= nr_taken
;
466 __entry
->nr_active
= nr_active
;
467 __entry
->nr_deactivated
= nr_deactivated
;
468 __entry
->nr_referenced
= nr_referenced
;
469 __entry
->priority
= priority
;
470 __entry
->reclaim_flags
= trace_reclaim_flags(file
);
473 TP_printk("nid=%d nr_taken=%ld nr_active=%ld nr_deactivated=%ld nr_referenced=%ld priority=%d flags=%s",
476 __entry
->nr_active
, __entry
->nr_deactivated
, __entry
->nr_referenced
,
478 show_reclaim_flags(__entry
->reclaim_flags
))
481 TRACE_EVENT(mm_vmscan_node_reclaim_begin
,
483 TP_PROTO(int nid
, int order
, gfp_t gfp_flags
),
485 TP_ARGS(nid
, order
, gfp_flags
),
490 __field(unsigned long, gfp_flags
)
495 __entry
->order
= order
;
496 __entry
->gfp_flags
= (__force
unsigned long)gfp_flags
;
499 TP_printk("nid=%d order=%d gfp_flags=%s",
502 show_gfp_flags(__entry
->gfp_flags
))
505 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template
, mm_vmscan_node_reclaim_end
,
507 TP_PROTO(unsigned long nr_reclaimed
),
509 TP_ARGS(nr_reclaimed
)
512 TRACE_EVENT(mm_vmscan_throttled
,
514 TP_PROTO(int nid
, int usec_timeout
, int usec_delayed
, int reason
),
516 TP_ARGS(nid
, usec_timeout
, usec_delayed
, reason
),
520 __field(int, usec_timeout
)
521 __field(int, usec_delayed
)
527 __entry
->usec_timeout
= usec_timeout
;
528 __entry
->usec_delayed
= usec_delayed
;
529 __entry
->reason
= 1U << reason
;
532 TP_printk("nid=%d usec_timeout=%d usect_delayed=%d reason=%s",
534 __entry
->usec_timeout
,
535 __entry
->usec_delayed
,
536 show_throttle_flags(__entry
->reason
))
538 #endif /* _TRACE_VMSCAN_H */
540 /* This part must be outside protection */
541 #include <trace/define_trace.h>