Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / trace / events / vmscan.h
blob490958fa10deed4f62df64e485fa515fc20f07b8
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
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>
10 #include <linux/mm.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"} \
28 ) : "RECLAIM_WB_NONE"
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) | \
46 (RECLAIM_WB_ASYNC) \
49 TRACE_EVENT(mm_vmscan_kswapd_sleep,
51 TP_PROTO(int nid),
53 TP_ARGS(nid),
55 TP_STRUCT__entry(
56 __field( int, nid )
59 TP_fast_assign(
60 __entry->nid = nid;
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),
72 TP_STRUCT__entry(
73 __field( int, nid )
74 __field( int, zid )
75 __field( int, order )
78 TP_fast_assign(
79 __entry->nid = nid;
80 __entry->zid = zid;
81 __entry->order = order;
84 TP_printk("nid=%d order=%d",
85 __entry->nid,
86 __entry->order)
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),
95 TP_STRUCT__entry(
96 __field( int, nid )
97 __field( int, zid )
98 __field( int, order )
99 __field( unsigned long, gfp_flags )
102 TP_fast_assign(
103 __entry->nid = nid;
104 __entry->zid = zid;
105 __entry->order = order;
106 __entry->gfp_flags = (__force unsigned long)gfp_flags;
109 TP_printk("nid=%d order=%d gfp_flags=%s",
110 __entry->nid,
111 __entry->order,
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),
121 TP_STRUCT__entry(
122 __field( int, order )
123 __field( unsigned long, gfp_flags )
126 TP_fast_assign(
127 __entry->order = order;
128 __entry->gfp_flags = (__force unsigned long)gfp_flags;
131 TP_printk("order=%d gfp_flags=%s",
132 __entry->order,
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)
143 #ifdef CONFIG_MEMCG
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),
165 TP_STRUCT__entry(
166 __field( unsigned long, nr_reclaimed )
169 TP_fast_assign(
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)
183 #ifdef CONFIG_MEMCG
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,
203 int priority),
205 TP_ARGS(shr, sc, nr_objects_to_shrink, cache_items, delta, total_scan,
206 priority),
208 TP_STRUCT__entry(
209 __field(struct shrinker *, shr)
210 __field(void *, shrink)
211 __field(int, nid)
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)
220 TP_fast_assign(
221 __entry->shr = shr;
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",
233 __entry->shrink,
234 __entry->shr,
235 __entry->nid,
236 __entry->nr_objects_to_shrink,
237 show_gfp_flags(__entry->gfp_flags),
238 __entry->cache_items,
239 __entry->delta,
240 __entry->total_scan,
241 __entry->priority)
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,
249 total_scan),
251 TP_STRUCT__entry(
252 __field(struct shrinker *, shr)
253 __field(int, nid)
254 __field(void *, shrink)
255 __field(long, unused_scan)
256 __field(long, new_scan)
257 __field(int, retval)
258 __field(long, total_scan)
261 TP_fast_assign(
262 __entry->shr = shr;
263 __entry->nid = nid;
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",
272 __entry->shrink,
273 __entry->shr,
274 __entry->nid,
275 __entry->unused_scan,
276 __entry->new_scan,
277 __entry->total_scan,
278 __entry->retval)
281 TRACE_EVENT(mm_vmscan_lru_isolate,
282 TP_PROTO(int highest_zoneidx,
283 int order,
284 unsigned long nr_requested,
285 unsigned long nr_scanned,
286 unsigned long nr_skipped,
287 unsigned long nr_taken,
288 int lru),
290 TP_ARGS(highest_zoneidx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, lru),
292 TP_STRUCT__entry(
293 __field(int, highest_zoneidx)
294 __field(int, order)
295 __field(unsigned long, nr_requested)
296 __field(unsigned long, nr_scanned)
297 __field(unsigned long, nr_skipped)
298 __field(unsigned long, nr_taken)
299 __field(int, lru)
302 TP_fast_assign(
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;
309 __entry->lru = lru;
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,
318 __entry->order,
319 __entry->nr_requested,
320 __entry->nr_scanned,
321 __entry->nr_skipped,
322 __entry->nr_taken,
323 __print_symbolic(__entry->lru, LRU_NAMES))
326 TRACE_EVENT(mm_vmscan_write_folio,
328 TP_PROTO(struct folio *folio),
330 TP_ARGS(folio),
332 TP_STRUCT__entry(
333 __field(unsigned long, pfn)
334 __field(int, reclaim_flags)
337 TP_fast_assign(
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),
345 __entry->pfn,
346 show_reclaim_flags(__entry->reclaim_flags))
349 TRACE_EVENT(mm_vmscan_reclaim_pages,
351 TP_PROTO(int nid,
352 unsigned long nr_scanned, unsigned long nr_reclaimed,
353 struct reclaim_stat *stat),
355 TP_ARGS(nid, nr_scanned, nr_reclaimed, stat),
357 TP_STRUCT__entry(
358 __field(int, nid)
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)
371 TP_fast_assign(
372 __entry->nid = nid;
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",
386 __entry->nid,
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,
396 TP_PROTO(int nid,
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),
402 TP_STRUCT__entry(
403 __field(int, nid)
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)
418 TP_fast_assign(
419 __entry->nid = nid;
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",
435 __entry->nid,
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,
441 __entry->priority,
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),
453 TP_STRUCT__entry(
454 __field(int, nid)
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)
463 TP_fast_assign(
464 __entry->nid = nid;
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",
474 __entry->nid,
475 __entry->nr_taken,
476 __entry->nr_active, __entry->nr_deactivated, __entry->nr_referenced,
477 __entry->priority,
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),
487 TP_STRUCT__entry(
488 __field(int, nid)
489 __field(int, order)
490 __field(unsigned long, gfp_flags)
493 TP_fast_assign(
494 __entry->nid = nid;
495 __entry->order = order;
496 __entry->gfp_flags = (__force unsigned long)gfp_flags;
499 TP_printk("nid=%d order=%d gfp_flags=%s",
500 __entry->nid,
501 __entry->order,
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),
518 TP_STRUCT__entry(
519 __field(int, nid)
520 __field(int, usec_timeout)
521 __field(int, usec_delayed)
522 __field(int, reason)
525 TP_fast_assign(
526 __entry->nid = nid;
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",
533 __entry->nid,
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>