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 "gfpflags.h"
10 
11 #define RECLAIM_WB_ANON		0x0001u
12 #define RECLAIM_WB_FILE		0x0002u
13 #define RECLAIM_WB_MIXED	0x0010u
14 #define RECLAIM_WB_SYNC		0x0004u
15 #define RECLAIM_WB_ASYNC	0x0008u
16 
17 #define show_reclaim_flags(flags)				\
18 	(flags) ? __print_flags(flags, "|",			\
19 		{RECLAIM_WB_ANON,	"RECLAIM_WB_ANON"},	\
20 		{RECLAIM_WB_FILE,	"RECLAIM_WB_FILE"},	\
21 		{RECLAIM_WB_MIXED,	"RECLAIM_WB_MIXED"},	\
22 		{RECLAIM_WB_SYNC,	"RECLAIM_WB_SYNC"},	\
23 		{RECLAIM_WB_ASYNC,	"RECLAIM_WB_ASYNC"}	\
24 		) : "RECLAIM_WB_NONE"
25 
26 #define trace_reclaim_flags(page, sync) ( \
27 	(page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
28 	(sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC)   \
29 	)
30 
31 #define trace_shrink_flags(file, sync) ( \
32 	(sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_MIXED : \
33 			(file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON)) |  \
34 	(sync & RECLAIM_MODE_SYNC ? RECLAIM_WB_SYNC : RECLAIM_WB_ASYNC) \
35 	)
36 
37 TRACE_EVENT(mm_vmscan_kswapd_sleep,
38 
39 	TP_PROTO(int nid),
40 
41 	TP_ARGS(nid),
42 
43 	TP_STRUCT__entry(
44 		__field(	int,	nid	)
45 	),
46 
47 	TP_fast_assign(
48 		__entry->nid	= nid;
49 	),
50 
51 	TP_printk("nid=%d", __entry->nid)
52 );
53 
54 TRACE_EVENT(mm_vmscan_kswapd_wake,
55 
56 	TP_PROTO(int nid, int order),
57 
58 	TP_ARGS(nid, order),
59 
60 	TP_STRUCT__entry(
61 		__field(	int,	nid	)
62 		__field(	int,	order	)
63 	),
64 
65 	TP_fast_assign(
66 		__entry->nid	= nid;
67 		__entry->order	= order;
68 	),
69 
70 	TP_printk("nid=%d order=%d", __entry->nid, __entry->order)
71 );
72 
73 TRACE_EVENT(mm_vmscan_wakeup_kswapd,
74 
75 	TP_PROTO(int nid, int zid, int order),
76 
77 	TP_ARGS(nid, zid, order),
78 
79 	TP_STRUCT__entry(
80 		__field(	int,		nid	)
81 		__field(	int,		zid	)
82 		__field(	int,		order	)
83 	),
84 
85 	TP_fast_assign(
86 		__entry->nid		= nid;
87 		__entry->zid		= zid;
88 		__entry->order		= order;
89 	),
90 
91 	TP_printk("nid=%d zid=%d order=%d",
92 		__entry->nid,
93 		__entry->zid,
94 		__entry->order)
95 );
96 
97 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
98 
99 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
100 
101 	TP_ARGS(order, may_writepage, gfp_flags),
102 
103 	TP_STRUCT__entry(
104 		__field(	int,	order		)
105 		__field(	int,	may_writepage	)
106 		__field(	gfp_t,	gfp_flags	)
107 	),
108 
109 	TP_fast_assign(
110 		__entry->order		= order;
111 		__entry->may_writepage	= may_writepage;
112 		__entry->gfp_flags	= gfp_flags;
113 	),
114 
115 	TP_printk("order=%d may_writepage=%d gfp_flags=%s",
116 		__entry->order,
117 		__entry->may_writepage,
118 		show_gfp_flags(__entry->gfp_flags))
119 );
120 
121 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
122 
123 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
124 
125 	TP_ARGS(order, may_writepage, gfp_flags)
126 );
127 
128 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
129 
130 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
131 
132 	TP_ARGS(order, may_writepage, gfp_flags)
133 );
134 
135 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
136 
137 	TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
138 
139 	TP_ARGS(order, may_writepage, gfp_flags)
140 );
141 
142 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
143 
144 	TP_PROTO(unsigned long nr_reclaimed),
145 
146 	TP_ARGS(nr_reclaimed),
147 
148 	TP_STRUCT__entry(
149 		__field(	unsigned long,	nr_reclaimed	)
150 	),
151 
152 	TP_fast_assign(
153 		__entry->nr_reclaimed	= nr_reclaimed;
154 	),
155 
156 	TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
157 );
158 
159 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
160 
161 	TP_PROTO(unsigned long nr_reclaimed),
162 
163 	TP_ARGS(nr_reclaimed)
164 );
165 
166 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_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_softlimit_reclaim_end,
174 
175 	TP_PROTO(unsigned long nr_reclaimed),
176 
177 	TP_ARGS(nr_reclaimed)
178 );
179 
180 
181 DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
182 
183 	TP_PROTO(int order,
184 		unsigned long nr_requested,
185 		unsigned long nr_scanned,
186 		unsigned long nr_taken,
187 		unsigned long nr_lumpy_taken,
188 		unsigned long nr_lumpy_dirty,
189 		unsigned long nr_lumpy_failed,
190 		int isolate_mode),
191 
192 	TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode),
193 
194 	TP_STRUCT__entry(
195 		__field(int, order)
196 		__field(unsigned long, nr_requested)
197 		__field(unsigned long, nr_scanned)
198 		__field(unsigned long, nr_taken)
199 		__field(unsigned long, nr_lumpy_taken)
200 		__field(unsigned long, nr_lumpy_dirty)
201 		__field(unsigned long, nr_lumpy_failed)
202 		__field(int, isolate_mode)
203 	),
204 
205 	TP_fast_assign(
206 		__entry->order = order;
207 		__entry->nr_requested = nr_requested;
208 		__entry->nr_scanned = nr_scanned;
209 		__entry->nr_taken = nr_taken;
210 		__entry->nr_lumpy_taken = nr_lumpy_taken;
211 		__entry->nr_lumpy_dirty = nr_lumpy_dirty;
212 		__entry->nr_lumpy_failed = nr_lumpy_failed;
213 		__entry->isolate_mode = isolate_mode;
214 	),
215 
216 	TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu contig_taken=%lu contig_dirty=%lu contig_failed=%lu",
217 		__entry->isolate_mode,
218 		__entry->order,
219 		__entry->nr_requested,
220 		__entry->nr_scanned,
221 		__entry->nr_taken,
222 		__entry->nr_lumpy_taken,
223 		__entry->nr_lumpy_dirty,
224 		__entry->nr_lumpy_failed)
225 );
226 
227 DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
228 
229 	TP_PROTO(int order,
230 		unsigned long nr_requested,
231 		unsigned long nr_scanned,
232 		unsigned long nr_taken,
233 		unsigned long nr_lumpy_taken,
234 		unsigned long nr_lumpy_dirty,
235 		unsigned long nr_lumpy_failed,
236 		int isolate_mode),
237 
238 	TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode)
239 
240 );
241 
242 DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
243 
244 	TP_PROTO(int order,
245 		unsigned long nr_requested,
246 		unsigned long nr_scanned,
247 		unsigned long nr_taken,
248 		unsigned long nr_lumpy_taken,
249 		unsigned long nr_lumpy_dirty,
250 		unsigned long nr_lumpy_failed,
251 		int isolate_mode),
252 
253 	TP_ARGS(order, nr_requested, nr_scanned, nr_taken, nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed, isolate_mode)
254 
255 );
256 
257 TRACE_EVENT(mm_vmscan_writepage,
258 
259 	TP_PROTO(struct page *page,
260 		int reclaim_flags),
261 
262 	TP_ARGS(page, reclaim_flags),
263 
264 	TP_STRUCT__entry(
265 		__field(struct page *, page)
266 		__field(int, reclaim_flags)
267 	),
268 
269 	TP_fast_assign(
270 		__entry->page = page;
271 		__entry->reclaim_flags = reclaim_flags;
272 	),
273 
274 	TP_printk("page=%p pfn=%lu flags=%s",
275 		__entry->page,
276 		page_to_pfn(__entry->page),
277 		show_reclaim_flags(__entry->reclaim_flags))
278 );
279 
280 TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
281 
282 	TP_PROTO(int nid, int zid,
283 			unsigned long nr_scanned, unsigned long nr_reclaimed,
284 			int priority, int reclaim_flags),
285 
286 	TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags),
287 
288 	TP_STRUCT__entry(
289 		__field(int, nid)
290 		__field(int, zid)
291 		__field(unsigned long, nr_scanned)
292 		__field(unsigned long, nr_reclaimed)
293 		__field(int, priority)
294 		__field(int, reclaim_flags)
295 	),
296 
297 	TP_fast_assign(
298 		__entry->nid = nid;
299 		__entry->zid = zid;
300 		__entry->nr_scanned = nr_scanned;
301 		__entry->nr_reclaimed = nr_reclaimed;
302 		__entry->priority = priority;
303 		__entry->reclaim_flags = reclaim_flags;
304 	),
305 
306 	TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
307 		__entry->nid, __entry->zid,
308 		__entry->nr_scanned, __entry->nr_reclaimed,
309 		__entry->priority,
310 		show_reclaim_flags(__entry->reclaim_flags))
311 );
312 
313 
314 #endif /* _TRACE_VMSCAN_H */
315 
316 /* This part must be outside protection */
317 #include <trace/define_trace.h>
318