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