xref: /openbmc/linux/include/trace/events/vmscan.h (revision 293d5b43)
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM vmscan
3 
4 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_VMSCAN_H
6 
7 #include <linux/types.h>
8 #include <linux/tracepoint.h>
9 #include <linux/mm.h>
10 #include <linux/memcontrol.h>
11 #include <trace/events/mmflags.h>
12 
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 
19 #define show_reclaim_flags(flags)				\
20 	(flags) ? __print_flags(flags, "|",			\
21 		{RECLAIM_WB_ANON,	"RECLAIM_WB_ANON"},	\
22 		{RECLAIM_WB_FILE,	"RECLAIM_WB_FILE"},	\
23 		{RECLAIM_WB_MIXED,	"RECLAIM_WB_MIXED"},	\
24 		{RECLAIM_WB_SYNC,	"RECLAIM_WB_SYNC"},	\
25 		{RECLAIM_WB_ASYNC,	"RECLAIM_WB_ASYNC"}	\
26 		) : "RECLAIM_WB_NONE"
27 
28 #define trace_reclaim_flags(page) ( \
29 	(page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
30 	(RECLAIM_WB_ASYNC) \
31 	)
32 
33 #define trace_shrink_flags(file) \
34 	( \
35 		(file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
36 		(RECLAIM_WB_ASYNC) \
37 	)
38 
39 TRACE_EVENT(mm_vmscan_kswapd_sleep,
40 
41 	TP_PROTO(int nid),
42 
43 	TP_ARGS(nid),
44 
45 	TP_STRUCT__entry(
46 		__field(	int,	nid	)
47 	),
48 
49 	TP_fast_assign(
50 		__entry->nid	= nid;
51 	),
52 
53 	TP_printk("nid=%d", __entry->nid)
54 );
55 
56 TRACE_EVENT(mm_vmscan_kswapd_wake,
57 
58 	TP_PROTO(int nid, int zid, int order),
59 
60 	TP_ARGS(nid, zid, order),
61 
62 	TP_STRUCT__entry(
63 		__field(	int,	nid	)
64 		__field(	int,	zid	)
65 		__field(	int,	order	)
66 	),
67 
68 	TP_fast_assign(
69 		__entry->nid	= nid;
70 		__entry->zid    = zid;
71 		__entry->order	= order;
72 	),
73 
74 	TP_printk("nid=%d zid=%d order=%d", __entry->nid, __entry->zid, __entry->order)
75 );
76 
77 TRACE_EVENT(mm_vmscan_wakeup_kswapd,
78 
79 	TP_PROTO(int nid, int zid, int order),
80 
81 	TP_ARGS(nid, zid, order),
82 
83 	TP_STRUCT__entry(
84 		__field(	int,		nid	)
85 		__field(	int,		zid	)
86 		__field(	int,		order	)
87 	),
88 
89 	TP_fast_assign(
90 		__entry->nid		= nid;
91 		__entry->zid		= zid;
92 		__entry->order		= order;
93 	),
94 
95 	TP_printk("nid=%d zid=%d order=%d",
96 		__entry->nid,
97 		__entry->zid,
98 		__entry->order)
99 );
100 
101 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
102 
103 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
104 
105 	TP_ARGS(order, may_writepage, gfp_flags, classzone_idx),
106 
107 	TP_STRUCT__entry(
108 		__field(	int,	order		)
109 		__field(	int,	may_writepage	)
110 		__field(	gfp_t,	gfp_flags	)
111 		__field(	int,	classzone_idx	)
112 	),
113 
114 	TP_fast_assign(
115 		__entry->order		= order;
116 		__entry->may_writepage	= may_writepage;
117 		__entry->gfp_flags	= gfp_flags;
118 		__entry->classzone_idx	= classzone_idx;
119 	),
120 
121 	TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d",
122 		__entry->order,
123 		__entry->may_writepage,
124 		show_gfp_flags(__entry->gfp_flags),
125 		__entry->classzone_idx)
126 );
127 
128 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
129 
130 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
131 
132 	TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
133 );
134 
135 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
136 
137 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
138 
139 	TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
140 );
141 
142 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
143 
144 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx),
145 
146 	TP_ARGS(order, may_writepage, gfp_flags, classzone_idx)
147 );
148 
149 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
150 
151 	TP_PROTO(unsigned long nr_reclaimed),
152 
153 	TP_ARGS(nr_reclaimed),
154 
155 	TP_STRUCT__entry(
156 		__field(	unsigned long,	nr_reclaimed	)
157 	),
158 
159 	TP_fast_assign(
160 		__entry->nr_reclaimed	= nr_reclaimed;
161 	),
162 
163 	TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
164 );
165 
166 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
167 
168 	TP_PROTO(unsigned long nr_reclaimed),
169 
170 	TP_ARGS(nr_reclaimed)
171 );
172 
173 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
174 
175 	TP_PROTO(unsigned long nr_reclaimed),
176 
177 	TP_ARGS(nr_reclaimed)
178 );
179 
180 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
181 
182 	TP_PROTO(unsigned long nr_reclaimed),
183 
184 	TP_ARGS(nr_reclaimed)
185 );
186 
187 TRACE_EVENT(mm_shrink_slab_start,
188 	TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
189 		long nr_objects_to_shrink, unsigned long pgs_scanned,
190 		unsigned long lru_pgs, unsigned long cache_items,
191 		unsigned long long delta, unsigned long total_scan),
192 
193 	TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
194 		cache_items, delta, total_scan),
195 
196 	TP_STRUCT__entry(
197 		__field(struct shrinker *, shr)
198 		__field(void *, shrink)
199 		__field(int, nid)
200 		__field(long, nr_objects_to_shrink)
201 		__field(gfp_t, gfp_flags)
202 		__field(unsigned long, pgs_scanned)
203 		__field(unsigned long, lru_pgs)
204 		__field(unsigned long, cache_items)
205 		__field(unsigned long long, delta)
206 		__field(unsigned long, total_scan)
207 	),
208 
209 	TP_fast_assign(
210 		__entry->shr = shr;
211 		__entry->shrink = shr->scan_objects;
212 		__entry->nid = sc->nid;
213 		__entry->nr_objects_to_shrink = nr_objects_to_shrink;
214 		__entry->gfp_flags = sc->gfp_mask;
215 		__entry->pgs_scanned = pgs_scanned;
216 		__entry->lru_pgs = lru_pgs;
217 		__entry->cache_items = cache_items;
218 		__entry->delta = delta;
219 		__entry->total_scan = total_scan;
220 	),
221 
222 	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",
223 		__entry->shrink,
224 		__entry->shr,
225 		__entry->nid,
226 		__entry->nr_objects_to_shrink,
227 		show_gfp_flags(__entry->gfp_flags),
228 		__entry->pgs_scanned,
229 		__entry->lru_pgs,
230 		__entry->cache_items,
231 		__entry->delta,
232 		__entry->total_scan)
233 );
234 
235 TRACE_EVENT(mm_shrink_slab_end,
236 	TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
237 		long unused_scan_cnt, long new_scan_cnt, long total_scan),
238 
239 	TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
240 		total_scan),
241 
242 	TP_STRUCT__entry(
243 		__field(struct shrinker *, shr)
244 		__field(int, nid)
245 		__field(void *, shrink)
246 		__field(long, unused_scan)
247 		__field(long, new_scan)
248 		__field(int, retval)
249 		__field(long, total_scan)
250 	),
251 
252 	TP_fast_assign(
253 		__entry->shr = shr;
254 		__entry->nid = nid;
255 		__entry->shrink = shr->scan_objects;
256 		__entry->unused_scan = unused_scan_cnt;
257 		__entry->new_scan = new_scan_cnt;
258 		__entry->retval = shrinker_retval;
259 		__entry->total_scan = total_scan;
260 	),
261 
262 	TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
263 		__entry->shrink,
264 		__entry->shr,
265 		__entry->nid,
266 		__entry->unused_scan,
267 		__entry->new_scan,
268 		__entry->total_scan,
269 		__entry->retval)
270 );
271 
272 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
273 
274 	TP_PROTO(int classzone_idx,
275 		int order,
276 		unsigned long nr_requested,
277 		unsigned long nr_scanned,
278 		unsigned long nr_taken,
279 		isolate_mode_t isolate_mode,
280 		int file),
281 
282 	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file),
283 
284 	TP_STRUCT__entry(
285 		__field(int, classzone_idx)
286 		__field(int, order)
287 		__field(unsigned long, nr_requested)
288 		__field(unsigned long, nr_scanned)
289 		__field(unsigned long, nr_taken)
290 		__field(isolate_mode_t, isolate_mode)
291 		__field(int, file)
292 	),
293 
294 	TP_fast_assign(
295 		__entry->classzone_idx = classzone_idx;
296 		__entry->order = order;
297 		__entry->nr_requested = nr_requested;
298 		__entry->nr_scanned = nr_scanned;
299 		__entry->nr_taken = nr_taken;
300 		__entry->isolate_mode = isolate_mode;
301 		__entry->file = file;
302 	),
303 
304 	TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
305 		__entry->isolate_mode,
306 		__entry->classzone_idx,
307 		__entry->order,
308 		__entry->nr_requested,
309 		__entry->nr_scanned,
310 		__entry->nr_taken,
311 		__entry->file)
312 );
313 
314 DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
315 
316 	TP_PROTO(int classzone_idx,
317 		int order,
318 		unsigned long nr_requested,
319 		unsigned long nr_scanned,
320 		unsigned long nr_taken,
321 		isolate_mode_t isolate_mode,
322 		int file),
323 
324 	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
325 
326 );
327 
328 DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
329 
330 	TP_PROTO(int classzone_idx,
331 		int order,
332 		unsigned long nr_requested,
333 		unsigned long nr_scanned,
334 		unsigned long nr_taken,
335 		isolate_mode_t isolate_mode,
336 		int file),
337 
338 	TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
339 
340 );
341 
342 TRACE_EVENT(mm_vmscan_writepage,
343 
344 	TP_PROTO(struct page *page),
345 
346 	TP_ARGS(page),
347 
348 	TP_STRUCT__entry(
349 		__field(unsigned long, pfn)
350 		__field(int, reclaim_flags)
351 	),
352 
353 	TP_fast_assign(
354 		__entry->pfn = page_to_pfn(page);
355 		__entry->reclaim_flags = trace_reclaim_flags(page);
356 	),
357 
358 	TP_printk("page=%p pfn=%lu flags=%s",
359 		pfn_to_page(__entry->pfn),
360 		__entry->pfn,
361 		show_reclaim_flags(__entry->reclaim_flags))
362 );
363 
364 TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
365 
366 	TP_PROTO(int nid,
367 		unsigned long nr_scanned, unsigned long nr_reclaimed,
368 		int priority, int file),
369 
370 	TP_ARGS(nid, nr_scanned, nr_reclaimed, priority, file),
371 
372 	TP_STRUCT__entry(
373 		__field(int, nid)
374 		__field(unsigned long, nr_scanned)
375 		__field(unsigned long, nr_reclaimed)
376 		__field(int, priority)
377 		__field(int, reclaim_flags)
378 	),
379 
380 	TP_fast_assign(
381 		__entry->nid = nid;
382 		__entry->nr_scanned = nr_scanned;
383 		__entry->nr_reclaimed = nr_reclaimed;
384 		__entry->priority = priority;
385 		__entry->reclaim_flags = trace_shrink_flags(file);
386 	),
387 
388 	TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
389 		__entry->nid,
390 		__entry->nr_scanned, __entry->nr_reclaimed,
391 		__entry->priority,
392 		show_reclaim_flags(__entry->reclaim_flags))
393 );
394 
395 #endif /* _TRACE_VMSCAN_H */
396 
397 /* This part must be outside protection */
398 #include <trace/define_trace.h>
399