blob: a43000d766884baffa970b95826f0daea4e2944b [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
Vlastimil Babka1743d052015-11-05 18:47:59 -080021#ifdef CONFIG_ZONE_DMA
22#define IFDEF_ZONE_DMA(X) X
23#else
24#define IFDEF_ZONE_DMA(X)
25#endif
26
27#ifdef CONFIG_ZONE_DMA32
28#define IFDEF_ZONE_DMA32(X) X
29#else
30#define IFDEF_ZONE_DMA32(X)
31#endif
32
33#ifdef CONFIG_HIGHMEM
34#define IFDEF_ZONE_HIGHMEM(X) X
35#else
36#define IFDEF_ZONE_HIGHMEM(X)
37#endif
38
39#define ZONE_TYPE \
40 IFDEF_ZONE_DMA( EM (ZONE_DMA, "DMA")) \
41 IFDEF_ZONE_DMA32( EM (ZONE_DMA32, "DMA32")) \
42 EM (ZONE_NORMAL, "Normal") \
43 IFDEF_ZONE_HIGHMEM( EM (ZONE_HIGHMEM,"HighMem")) \
44 EMe(ZONE_MOVABLE,"Movable")
45
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -080046/*
47 * First define the enums in the above macros to be exported to userspace
48 * via TRACE_DEFINE_ENUM().
49 */
50#undef EM
51#undef EMe
52#define EM(a, b) TRACE_DEFINE_ENUM(a);
53#define EMe(a, b) TRACE_DEFINE_ENUM(a);
54
55COMPACTION_STATUS
Vlastimil Babka1743d052015-11-05 18:47:59 -080056ZONE_TYPE
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -080057
58/*
59 * Now redefine the EM() and EMe() macros to map the enums to the strings
60 * that will be printed in the output.
61 */
62#undef EM
63#undef EMe
64#define EM(a, b) {a, b},
65#define EMe(a, b) {a, b}
66
Mel Gormanb7aba692011-01-13 15:45:54 -080067DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
68
Joonsoo Kime34d85f2015-02-11 15:27:04 -080069 TP_PROTO(
70 unsigned long start_pfn,
71 unsigned long end_pfn,
72 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080073 unsigned long nr_taken),
74
Joonsoo Kime34d85f2015-02-11 15:27:04 -080075 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
Mel Gormanb7aba692011-01-13 15:45:54 -080076
77 TP_STRUCT__entry(
Joonsoo Kime34d85f2015-02-11 15:27:04 -080078 __field(unsigned long, start_pfn)
79 __field(unsigned long, end_pfn)
Mel Gormanb7aba692011-01-13 15:45:54 -080080 __field(unsigned long, nr_scanned)
81 __field(unsigned long, nr_taken)
82 ),
83
84 TP_fast_assign(
Joonsoo Kime34d85f2015-02-11 15:27:04 -080085 __entry->start_pfn = start_pfn;
86 __entry->end_pfn = end_pfn;
Mel Gormanb7aba692011-01-13 15:45:54 -080087 __entry->nr_scanned = nr_scanned;
88 __entry->nr_taken = nr_taken;
89 ),
90
Joonsoo Kime34d85f2015-02-11 15:27:04 -080091 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
92 __entry->start_pfn,
93 __entry->end_pfn,
Mel Gormanb7aba692011-01-13 15:45:54 -080094 __entry->nr_scanned,
95 __entry->nr_taken)
96);
97
98DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
99
Joonsoo Kime34d85f2015-02-11 15:27:04 -0800100 TP_PROTO(
101 unsigned long start_pfn,
102 unsigned long end_pfn,
103 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -0800104 unsigned long nr_taken),
105
Joonsoo Kime34d85f2015-02-11 15:27:04 -0800106 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
Mel Gormanb7aba692011-01-13 15:45:54 -0800107);
108
109DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
Joonsoo Kime34d85f2015-02-11 15:27:04 -0800110
111 TP_PROTO(
112 unsigned long start_pfn,
113 unsigned long end_pfn,
114 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -0800115 unsigned long nr_taken),
116
Joonsoo Kime34d85f2015-02-11 15:27:04 -0800117 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
Mel Gormanb7aba692011-01-13 15:45:54 -0800118);
119
120TRACE_EVENT(mm_compaction_migratepages,
121
Vlastimil Babkaf8c93012014-06-04 16:08:32 -0700122 TP_PROTO(unsigned long nr_all,
123 int migrate_rc,
124 struct list_head *migratepages),
Mel Gormanb7aba692011-01-13 15:45:54 -0800125
Vlastimil Babkaf8c93012014-06-04 16:08:32 -0700126 TP_ARGS(nr_all, migrate_rc, migratepages),
Mel Gormanb7aba692011-01-13 15:45:54 -0800127
128 TP_STRUCT__entry(
129 __field(unsigned long, nr_migrated)
130 __field(unsigned long, nr_failed)
131 ),
132
133 TP_fast_assign(
Vlastimil Babkaf8c93012014-06-04 16:08:32 -0700134 unsigned long nr_failed = 0;
135 struct list_head *page_lru;
136
137 /*
138 * migrate_pages() returns either a non-negative number
139 * with the number of pages that failed migration, or an
140 * error code, in which case we need to count the remaining
141 * pages manually
142 */
143 if (migrate_rc >= 0)
144 nr_failed = migrate_rc;
145 else
146 list_for_each(page_lru, migratepages)
147 nr_failed++;
148
149 __entry->nr_migrated = nr_all - nr_failed;
Mel Gormanb7aba692011-01-13 15:45:54 -0800150 __entry->nr_failed = nr_failed;
151 ),
152
153 TP_printk("nr_migrated=%lu nr_failed=%lu",
154 __entry->nr_migrated,
155 __entry->nr_failed)
156);
157
Mel Gorman0eb927c2014-01-21 15:51:05 -0800158TRACE_EVENT(mm_compaction_begin,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800159 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
160 unsigned long free_pfn, unsigned long zone_end, bool sync),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800161
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800162 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800163
164 TP_STRUCT__entry(
165 __field(unsigned long, zone_start)
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800166 __field(unsigned long, migrate_pfn)
167 __field(unsigned long, free_pfn)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800168 __field(unsigned long, zone_end)
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800169 __field(bool, sync)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800170 ),
171
172 TP_fast_assign(
173 __entry->zone_start = zone_start;
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800174 __entry->migrate_pfn = migrate_pfn;
175 __entry->free_pfn = free_pfn;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800176 __entry->zone_end = zone_end;
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800177 __entry->sync = sync;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800178 ),
179
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800180 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 -0800181 __entry->zone_start,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800182 __entry->migrate_pfn,
183 __entry->free_pfn,
184 __entry->zone_end,
185 __entry->sync ? "sync" : "async")
Mel Gorman0eb927c2014-01-21 15:51:05 -0800186);
187
188TRACE_EVENT(mm_compaction_end,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800189 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
190 unsigned long free_pfn, unsigned long zone_end, bool sync,
191 int status),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800192
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800193 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800194
195 TP_STRUCT__entry(
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800196 __field(unsigned long, zone_start)
197 __field(unsigned long, migrate_pfn)
198 __field(unsigned long, free_pfn)
199 __field(unsigned long, zone_end)
200 __field(bool, sync)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800201 __field(int, status)
202 ),
203
204 TP_fast_assign(
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800205 __entry->zone_start = zone_start;
206 __entry->migrate_pfn = migrate_pfn;
207 __entry->free_pfn = free_pfn;
208 __entry->zone_end = zone_end;
209 __entry->sync = sync;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800210 __entry->status = status;
211 ),
212
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800213 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
214 __entry->zone_start,
215 __entry->migrate_pfn,
216 __entry->free_pfn,
217 __entry->zone_end,
218 __entry->sync ? "sync" : "async",
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -0800219 __print_symbolic(__entry->status, COMPACTION_STATUS))
Mel Gorman0eb927c2014-01-21 15:51:05 -0800220);
Mel Gormanb7aba692011-01-13 15:45:54 -0800221
Joonsoo Kim837d0262015-02-11 15:27:06 -0800222TRACE_EVENT(mm_compaction_try_to_compact_pages,
223
224 TP_PROTO(
225 int order,
226 gfp_t gfp_mask,
227 enum migrate_mode mode),
228
229 TP_ARGS(order, gfp_mask, mode),
230
231 TP_STRUCT__entry(
232 __field(int, order)
233 __field(gfp_t, gfp_mask)
234 __field(enum migrate_mode, mode)
235 ),
236
237 TP_fast_assign(
238 __entry->order = order;
239 __entry->gfp_mask = gfp_mask;
240 __entry->mode = mode;
241 ),
242
243 TP_printk("order=%d gfp_mask=0x%x mode=%d",
244 __entry->order,
245 __entry->gfp_mask,
246 (int)__entry->mode)
247);
248
249DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
250
251 TP_PROTO(struct zone *zone,
252 int order,
253 int ret),
254
255 TP_ARGS(zone, order, ret),
256
257 TP_STRUCT__entry(
258 __field(int, nid)
Vlastimil Babka1743d052015-11-05 18:47:59 -0800259 __field(enum zone_type, idx)
Joonsoo Kim837d0262015-02-11 15:27:06 -0800260 __field(int, order)
261 __field(int, ret)
262 ),
263
264 TP_fast_assign(
265 __entry->nid = zone_to_nid(zone);
Vlastimil Babka1743d052015-11-05 18:47:59 -0800266 __entry->idx = zone_idx(zone);
Joonsoo Kim837d0262015-02-11 15:27:06 -0800267 __entry->order = order;
268 __entry->ret = ret;
269 ),
270
271 TP_printk("node=%d zone=%-8s order=%d ret=%s",
272 __entry->nid,
Vlastimil Babka1743d052015-11-05 18:47:59 -0800273 __print_symbolic(__entry->idx, ZONE_TYPE),
Joonsoo Kim837d0262015-02-11 15:27:06 -0800274 __entry->order,
Vlastimil Babkafa6c7b42015-11-05 18:47:56 -0800275 __print_symbolic(__entry->ret, COMPACTION_STATUS))
Joonsoo Kim837d0262015-02-11 15:27:06 -0800276);
277
278DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
279
280 TP_PROTO(struct zone *zone,
281 int order,
282 int ret),
283
284 TP_ARGS(zone, order, ret)
285);
286
287DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
288
289 TP_PROTO(struct zone *zone,
290 int order,
291 int ret),
292
293 TP_ARGS(zone, order, ret)
294);
295
Joonsoo Kim24e27162015-02-11 15:27:09 -0800296#ifdef CONFIG_COMPACTION
297DECLARE_EVENT_CLASS(mm_compaction_defer_template,
298
299 TP_PROTO(struct zone *zone, int order),
300
301 TP_ARGS(zone, order),
302
303 TP_STRUCT__entry(
304 __field(int, nid)
Vlastimil Babka1743d052015-11-05 18:47:59 -0800305 __field(enum zone_type, idx)
Joonsoo Kim24e27162015-02-11 15:27:09 -0800306 __field(int, order)
307 __field(unsigned int, considered)
308 __field(unsigned int, defer_shift)
309 __field(int, order_failed)
310 ),
311
312 TP_fast_assign(
313 __entry->nid = zone_to_nid(zone);
Vlastimil Babka1743d052015-11-05 18:47:59 -0800314 __entry->idx = zone_idx(zone);
Joonsoo Kim24e27162015-02-11 15:27:09 -0800315 __entry->order = order;
316 __entry->considered = zone->compact_considered;
317 __entry->defer_shift = zone->compact_defer_shift;
318 __entry->order_failed = zone->compact_order_failed;
319 ),
320
321 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
322 __entry->nid,
Vlastimil Babka1743d052015-11-05 18:47:59 -0800323 __print_symbolic(__entry->idx, ZONE_TYPE),
Joonsoo Kim24e27162015-02-11 15:27:09 -0800324 __entry->order,
325 __entry->order_failed,
326 __entry->considered,
327 1UL << __entry->defer_shift)
328);
329
330DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
331
332 TP_PROTO(struct zone *zone, int order),
333
334 TP_ARGS(zone, order)
335);
336
337DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
338
339 TP_PROTO(struct zone *zone, int order),
340
341 TP_ARGS(zone, order)
342);
343
344DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
345
346 TP_PROTO(struct zone *zone, int order),
347
348 TP_ARGS(zone, order)
349);
350#endif
351
Mel Gormanb7aba692011-01-13 15:45:54 -0800352#endif /* _TRACE_COMPACTION_H */
353
354/* This part must be outside protection */
355#include <trace/define_trace.h>