blob: 1275a555199af293be6b0e246fe367cc8471e118 [file] [log] [blame]
Mel Gormanb7aba692011-01-13 15:45:54 -08001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM compaction
3
4#if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_COMPACTION_H
6
7#include <linux/types.h>
Vlastimil Babkaf8c93012014-06-04 16:08:32 -07008#include <linux/list.h>
Mel Gormanb7aba692011-01-13 15:45:54 -08009#include <linux/tracepoint.h>
David Howellsa1ce3922012-10-02 18:01:25 +010010#include <trace/events/gfpflags.h>
Mel Gormanb7aba692011-01-13 15:45:54 -080011
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -080012#define COMPACTION_STATUS \
13 EM( COMPACT_DEFERRED, "deferred") \
14 EM( COMPACT_SKIPPED, "skipped") \
15 EM( COMPACT_CONTINUE, "continue") \
16 EM( COMPACT_PARTIAL, "partial") \
17 EM( COMPACT_COMPLETE, "complete") \
18 EM( COMPACT_NO_SUITABLE_PAGE, "no_suitable_page") \
19 EMe(COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone")
20
21/*
22 * First define the enums in the above macros to be exported to userspace
23 * via TRACE_DEFINE_ENUM().
24 */
25#undef EM
26#undef EMe
27#define EM(a, b) TRACE_DEFINE_ENUM(a);
28#define EMe(a, b) TRACE_DEFINE_ENUM(a);
29
30COMPACTION_STATUS
31
32/*
33 * Now redefine the EM() and EMe() macros to map the enums to the strings
34 * that will be printed in the output.
35 */
36#undef EM
37#undef EMe
38#define EM(a, b) {a, b},
39#define EMe(a, b) {a, b}
40
Mel Gormanb7aba692011-01-13 15:45:54 -080041DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
42
Joonsoo Kime34d85f2015-02-11 15:27:04 -080043 TP_PROTO(
44 unsigned long start_pfn,
45 unsigned long end_pfn,
46 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080047 unsigned long nr_taken),
48
Joonsoo Kime34d85f2015-02-11 15:27:04 -080049 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
Mel Gormanb7aba692011-01-13 15:45:54 -080050
51 TP_STRUCT__entry(
Joonsoo Kime34d85f2015-02-11 15:27:04 -080052 __field(unsigned long, start_pfn)
53 __field(unsigned long, end_pfn)
Mel Gormanb7aba692011-01-13 15:45:54 -080054 __field(unsigned long, nr_scanned)
55 __field(unsigned long, nr_taken)
56 ),
57
58 TP_fast_assign(
Joonsoo Kime34d85f2015-02-11 15:27:04 -080059 __entry->start_pfn = start_pfn;
60 __entry->end_pfn = end_pfn;
Mel Gormanb7aba692011-01-13 15:45:54 -080061 __entry->nr_scanned = nr_scanned;
62 __entry->nr_taken = nr_taken;
63 ),
64
Joonsoo Kime34d85f2015-02-11 15:27:04 -080065 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
66 __entry->start_pfn,
67 __entry->end_pfn,
Mel Gormanb7aba692011-01-13 15:45:54 -080068 __entry->nr_scanned,
69 __entry->nr_taken)
70);
71
72DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
73
Joonsoo Kime34d85f2015-02-11 15:27:04 -080074 TP_PROTO(
75 unsigned long start_pfn,
76 unsigned long end_pfn,
77 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080078 unsigned long nr_taken),
79
Joonsoo Kime34d85f2015-02-11 15:27:04 -080080 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
Mel Gormanb7aba692011-01-13 15:45:54 -080081);
82
83DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
Joonsoo Kime34d85f2015-02-11 15:27:04 -080084
85 TP_PROTO(
86 unsigned long start_pfn,
87 unsigned long end_pfn,
88 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080089 unsigned long nr_taken),
90
Joonsoo Kime34d85f2015-02-11 15:27:04 -080091 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
Mel Gormanb7aba692011-01-13 15:45:54 -080092);
93
94TRACE_EVENT(mm_compaction_migratepages,
95
Vlastimil Babkaf8c93012014-06-04 16:08:32 -070096 TP_PROTO(unsigned long nr_all,
97 int migrate_rc,
98 struct list_head *migratepages),
Mel Gormanb7aba692011-01-13 15:45:54 -080099
Vlastimil Babkaf8c93012014-06-04 16:08:32 -0700100 TP_ARGS(nr_all, migrate_rc, migratepages),
Mel Gormanb7aba692011-01-13 15:45:54 -0800101
102 TP_STRUCT__entry(
103 __field(unsigned long, nr_migrated)
104 __field(unsigned long, nr_failed)
105 ),
106
107 TP_fast_assign(
Vlastimil Babkaf8c93012014-06-04 16:08:32 -0700108 unsigned long nr_failed = 0;
109 struct list_head *page_lru;
110
111 /*
112 * migrate_pages() returns either a non-negative number
113 * with the number of pages that failed migration, or an
114 * error code, in which case we need to count the remaining
115 * pages manually
116 */
117 if (migrate_rc >= 0)
118 nr_failed = migrate_rc;
119 else
120 list_for_each(page_lru, migratepages)
121 nr_failed++;
122
123 __entry->nr_migrated = nr_all - nr_failed;
Mel Gormanb7aba692011-01-13 15:45:54 -0800124 __entry->nr_failed = nr_failed;
125 ),
126
127 TP_printk("nr_migrated=%lu nr_failed=%lu",
128 __entry->nr_migrated,
129 __entry->nr_failed)
130);
131
Mel Gorman0eb927c2014-01-21 15:51:05 -0800132TRACE_EVENT(mm_compaction_begin,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800133 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
134 unsigned long free_pfn, unsigned long zone_end, bool sync),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800135
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800136 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800137
138 TP_STRUCT__entry(
139 __field(unsigned long, zone_start)
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800140 __field(unsigned long, migrate_pfn)
141 __field(unsigned long, free_pfn)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800142 __field(unsigned long, zone_end)
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800143 __field(bool, sync)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800144 ),
145
146 TP_fast_assign(
147 __entry->zone_start = zone_start;
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800148 __entry->migrate_pfn = migrate_pfn;
149 __entry->free_pfn = free_pfn;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800150 __entry->zone_end = zone_end;
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800151 __entry->sync = sync;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800152 ),
153
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800154 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
Mel Gorman0eb927c2014-01-21 15:51:05 -0800155 __entry->zone_start,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800156 __entry->migrate_pfn,
157 __entry->free_pfn,
158 __entry->zone_end,
159 __entry->sync ? "sync" : "async")
Mel Gorman0eb927c2014-01-21 15:51:05 -0800160);
161
162TRACE_EVENT(mm_compaction_end,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800163 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
164 unsigned long free_pfn, unsigned long zone_end, bool sync,
165 int status),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800166
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800167 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800168
169 TP_STRUCT__entry(
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800170 __field(unsigned long, zone_start)
171 __field(unsigned long, migrate_pfn)
172 __field(unsigned long, free_pfn)
173 __field(unsigned long, zone_end)
174 __field(bool, sync)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800175 __field(int, status)
176 ),
177
178 TP_fast_assign(
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800179 __entry->zone_start = zone_start;
180 __entry->migrate_pfn = migrate_pfn;
181 __entry->free_pfn = free_pfn;
182 __entry->zone_end = zone_end;
183 __entry->sync = sync;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800184 __entry->status = status;
185 ),
186
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800187 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
188 __entry->zone_start,
189 __entry->migrate_pfn,
190 __entry->free_pfn,
191 __entry->zone_end,
192 __entry->sync ? "sync" : "async",
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -0800193 __print_symbolic(__entry->status, COMPACTION_STATUS))
Mel Gorman0eb927c2014-01-21 15:51:05 -0800194);
Mel Gormanb7aba692011-01-13 15:45:54 -0800195
Joonsoo Kim837d0262015-02-11 15:27:06 -0800196TRACE_EVENT(mm_compaction_try_to_compact_pages,
197
198 TP_PROTO(
199 int order,
200 gfp_t gfp_mask,
201 enum migrate_mode mode),
202
203 TP_ARGS(order, gfp_mask, mode),
204
205 TP_STRUCT__entry(
206 __field(int, order)
207 __field(gfp_t, gfp_mask)
208 __field(enum migrate_mode, mode)
209 ),
210
211 TP_fast_assign(
212 __entry->order = order;
213 __entry->gfp_mask = gfp_mask;
214 __entry->mode = mode;
215 ),
216
217 TP_printk("order=%d gfp_mask=0x%x mode=%d",
218 __entry->order,
219 __entry->gfp_mask,
220 (int)__entry->mode)
221);
222
223DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
224
225 TP_PROTO(struct zone *zone,
226 int order,
227 int ret),
228
229 TP_ARGS(zone, order, ret),
230
231 TP_STRUCT__entry(
232 __field(int, nid)
233 __field(char *, name)
234 __field(int, order)
235 __field(int, ret)
236 ),
237
238 TP_fast_assign(
239 __entry->nid = zone_to_nid(zone);
240 __entry->name = (char *)zone->name;
241 __entry->order = order;
242 __entry->ret = ret;
243 ),
244
245 TP_printk("node=%d zone=%-8s order=%d ret=%s",
246 __entry->nid,
247 __entry->name,
248 __entry->order,
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -0800249 __print_symbolic(__entry->ret, COMPACTION_STATUS))
Joonsoo Kim837d0262015-02-11 15:27:06 -0800250);
251
252DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
253
254 TP_PROTO(struct zone *zone,
255 int order,
256 int ret),
257
258 TP_ARGS(zone, order, ret)
259);
260
261DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
262
263 TP_PROTO(struct zone *zone,
264 int order,
265 int ret),
266
267 TP_ARGS(zone, order, ret)
268);
269
Joonsoo Kim24e27162015-02-11 15:27:09 -0800270#ifdef CONFIG_COMPACTION
271DECLARE_EVENT_CLASS(mm_compaction_defer_template,
272
273 TP_PROTO(struct zone *zone, int order),
274
275 TP_ARGS(zone, order),
276
277 TP_STRUCT__entry(
278 __field(int, nid)
279 __field(char *, name)
280 __field(int, order)
281 __field(unsigned int, considered)
282 __field(unsigned int, defer_shift)
283 __field(int, order_failed)
284 ),
285
286 TP_fast_assign(
287 __entry->nid = zone_to_nid(zone);
288 __entry->name = (char *)zone->name;
289 __entry->order = order;
290 __entry->considered = zone->compact_considered;
291 __entry->defer_shift = zone->compact_defer_shift;
292 __entry->order_failed = zone->compact_order_failed;
293 ),
294
295 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
296 __entry->nid,
297 __entry->name,
298 __entry->order,
299 __entry->order_failed,
300 __entry->considered,
301 1UL << __entry->defer_shift)
302);
303
304DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
305
306 TP_PROTO(struct zone *zone, int order),
307
308 TP_ARGS(zone, order)
309);
310
311DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
312
313 TP_PROTO(struct zone *zone, int order),
314
315 TP_ARGS(zone, order)
316);
317
318DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
319
320 TP_PROTO(struct zone *zone, int order),
321
322 TP_ARGS(zone, order)
323);
324#endif
325
Mel Gormanb7aba692011-01-13 15:45:54 -0800326#endif /* _TRACE_COMPACTION_H */
327
328/* This part must be outside protection */
329#include <trace/define_trace.h>