1
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM compaction
4
5 #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_COMPACTION_H
7
8 #include <linux/types.h>
9 #include <linux/list.h>
10 #include <linux/tracepoint.h>
11 #include <trace/events/mmflags.h>
12
13
14 DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
15
16 TP_PROTO(
17 unsigned long start_pfn,
18 unsigned long end_pfn,
19 unsigned long nr_scanned,
20 unsigned long nr_taken),
21
22 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
23
24 TP_STRUCT__entry(
25 __field(unsigned long, start_pfn)
26 __field(unsigned long, end_pfn)
27 __field(unsigned long, nr_scanned)
28 __field(unsigned long, nr_taken)
29 ),
30
31 TP_fast_assign(
32 __entry->start_pfn = start_pfn;
33 __entry->end_pfn = end_pfn;
34 __entry->nr_scanned = nr_scanned;
35 __entry->nr_taken = nr_taken;
36 ),
37
38 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
39 __entry->start_pfn,
40 __entry->end_pfn,
41 __entry->nr_scanned,
42 __entry->nr_taken)
43 );
44
45 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
46
47 TP_PROTO(
48 unsigned long start_pfn,
49 unsigned long end_pfn,
50 unsigned long nr_scanned,
51 unsigned long nr_taken),
52
53 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
54 );
55
56 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
57
58 TP_PROTO(
59 unsigned long start_pfn,
60 unsigned long end_pfn,
61 unsigned long nr_scanned,
62 unsigned long nr_taken),
63
64 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
65 );
66
67 #ifdef CONFIG_COMPACTION
68 TRACE_EVENT(mm_compaction_migratepages,
69
70 TP_PROTO(unsigned long nr_all,
71 int migrate_rc,
72 struct list_head *migratepages),
73
74 TP_ARGS(nr_all, migrate_rc, migratepages),
75
76 TP_STRUCT__entry(
77 __field(unsigned long, nr_migrated)
78 __field(unsigned long, nr_failed)
79 ),
80
81 TP_fast_assign(
82 unsigned long nr_failed = 0;
83 struct list_head *page_lru;
84
85
86
87
88
89
90
91 if (migrate_rc >= 0)
92 nr_failed = migrate_rc;
93 else
94 list_for_each(page_lru, migratepages)
95 nr_failed++;
96
97 __entry->nr_migrated = nr_all - nr_failed;
98 __entry->nr_failed = nr_failed;
99 ),
100
101 TP_printk("nr_migrated=%lu nr_failed=%lu",
102 __entry->nr_migrated,
103 __entry->nr_failed)
104 );
105
106 TRACE_EVENT(mm_compaction_begin,
107 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
108 unsigned long free_pfn, unsigned long zone_end, bool sync),
109
110 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
111
112 TP_STRUCT__entry(
113 __field(unsigned long, zone_start)
114 __field(unsigned long, migrate_pfn)
115 __field(unsigned long, free_pfn)
116 __field(unsigned long, zone_end)
117 __field(bool, sync)
118 ),
119
120 TP_fast_assign(
121 __entry->zone_start = zone_start;
122 __entry->migrate_pfn = migrate_pfn;
123 __entry->free_pfn = free_pfn;
124 __entry->zone_end = zone_end;
125 __entry->sync = sync;
126 ),
127
128 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
129 __entry->zone_start,
130 __entry->migrate_pfn,
131 __entry->free_pfn,
132 __entry->zone_end,
133 __entry->sync ? "sync" : "async")
134 );
135
136 TRACE_EVENT(mm_compaction_end,
137 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
138 unsigned long free_pfn, unsigned long zone_end, bool sync,
139 int status),
140
141 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
142
143 TP_STRUCT__entry(
144 __field(unsigned long, zone_start)
145 __field(unsigned long, migrate_pfn)
146 __field(unsigned long, free_pfn)
147 __field(unsigned long, zone_end)
148 __field(bool, sync)
149 __field(int, status)
150 ),
151
152 TP_fast_assign(
153 __entry->zone_start = zone_start;
154 __entry->migrate_pfn = migrate_pfn;
155 __entry->free_pfn = free_pfn;
156 __entry->zone_end = zone_end;
157 __entry->sync = sync;
158 __entry->status = status;
159 ),
160
161 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
162 __entry->zone_start,
163 __entry->migrate_pfn,
164 __entry->free_pfn,
165 __entry->zone_end,
166 __entry->sync ? "sync" : "async",
167 __print_symbolic(__entry->status, COMPACTION_STATUS))
168 );
169
170 TRACE_EVENT(mm_compaction_try_to_compact_pages,
171
172 TP_PROTO(
173 int order,
174 gfp_t gfp_mask,
175 int prio),
176
177 TP_ARGS(order, gfp_mask, prio),
178
179 TP_STRUCT__entry(
180 __field(int, order)
181 __field(gfp_t, gfp_mask)
182 __field(int, prio)
183 ),
184
185 TP_fast_assign(
186 __entry->order = order;
187 __entry->gfp_mask = gfp_mask;
188 __entry->prio = prio;
189 ),
190
191 TP_printk("order=%d gfp_mask=%s priority=%d",
192 __entry->order,
193 show_gfp_flags(__entry->gfp_mask),
194 __entry->prio)
195 );
196
197 DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
198
199 TP_PROTO(struct zone *zone,
200 int order,
201 int ret),
202
203 TP_ARGS(zone, order, ret),
204
205 TP_STRUCT__entry(
206 __field(int, nid)
207 __field(enum zone_type, idx)
208 __field(int, order)
209 __field(int, ret)
210 ),
211
212 TP_fast_assign(
213 __entry->nid = zone_to_nid(zone);
214 __entry->idx = zone_idx(zone);
215 __entry->order = order;
216 __entry->ret = ret;
217 ),
218
219 TP_printk("node=%d zone=%-8s order=%d ret=%s",
220 __entry->nid,
221 __print_symbolic(__entry->idx, ZONE_TYPE),
222 __entry->order,
223 __print_symbolic(__entry->ret, COMPACTION_STATUS))
224 );
225
226 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
227
228 TP_PROTO(struct zone *zone,
229 int order,
230 int ret),
231
232 TP_ARGS(zone, order, ret)
233 );
234
235 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
236
237 TP_PROTO(struct zone *zone,
238 int order,
239 int ret),
240
241 TP_ARGS(zone, order, ret)
242 );
243
244 DECLARE_EVENT_CLASS(mm_compaction_defer_template,
245
246 TP_PROTO(struct zone *zone, int order),
247
248 TP_ARGS(zone, order),
249
250 TP_STRUCT__entry(
251 __field(int, nid)
252 __field(enum zone_type, idx)
253 __field(int, order)
254 __field(unsigned int, considered)
255 __field(unsigned int, defer_shift)
256 __field(int, order_failed)
257 ),
258
259 TP_fast_assign(
260 __entry->nid = zone_to_nid(zone);
261 __entry->idx = zone_idx(zone);
262 __entry->order = order;
263 __entry->considered = zone->compact_considered;
264 __entry->defer_shift = zone->compact_defer_shift;
265 __entry->order_failed = zone->compact_order_failed;
266 ),
267
268 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
269 __entry->nid,
270 __print_symbolic(__entry->idx, ZONE_TYPE),
271 __entry->order,
272 __entry->order_failed,
273 __entry->considered,
274 1UL << __entry->defer_shift)
275 );
276
277 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
278
279 TP_PROTO(struct zone *zone, int order),
280
281 TP_ARGS(zone, order)
282 );
283
284 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
285
286 TP_PROTO(struct zone *zone, int order),
287
288 TP_ARGS(zone, order)
289 );
290
291 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
292
293 TP_PROTO(struct zone *zone, int order),
294
295 TP_ARGS(zone, order)
296 );
297
298 TRACE_EVENT(mm_compaction_kcompactd_sleep,
299
300 TP_PROTO(int nid),
301
302 TP_ARGS(nid),
303
304 TP_STRUCT__entry(
305 __field(int, nid)
306 ),
307
308 TP_fast_assign(
309 __entry->nid = nid;
310 ),
311
312 TP_printk("nid=%d", __entry->nid)
313 );
314
315 DECLARE_EVENT_CLASS(kcompactd_wake_template,
316
317 TP_PROTO(int nid, int order, enum zone_type classzone_idx),
318
319 TP_ARGS(nid, order, classzone_idx),
320
321 TP_STRUCT__entry(
322 __field(int, nid)
323 __field(int, order)
324 __field(enum zone_type, classzone_idx)
325 ),
326
327 TP_fast_assign(
328 __entry->nid = nid;
329 __entry->order = order;
330 __entry->classzone_idx = classzone_idx;
331 ),
332
333 TP_printk("nid=%d order=%d classzone_idx=%-8s",
334 __entry->nid,
335 __entry->order,
336 __print_symbolic(__entry->classzone_idx, ZONE_TYPE))
337 );
338
339 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
340
341 TP_PROTO(int nid, int order, enum zone_type classzone_idx),
342
343 TP_ARGS(nid, order, classzone_idx)
344 );
345
346 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
347
348 TP_PROTO(int nid, int order, enum zone_type classzone_idx),
349
350 TP_ARGS(nid, order, classzone_idx)
351 );
352 #endif
353
354 #endif
355
356
357 #include <trace/define_trace.h>