blob: 9a6a3fe0fb51adcf0648119388ca9627a57eaf7b [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
12DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
13
Joonsoo Kime34d85f2015-02-11 15:27:04 -080014 TP_PROTO(
15 unsigned long start_pfn,
16 unsigned long end_pfn,
17 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080018 unsigned long nr_taken),
19
Joonsoo Kime34d85f2015-02-11 15:27:04 -080020 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
Mel Gormanb7aba692011-01-13 15:45:54 -080021
22 TP_STRUCT__entry(
Joonsoo Kime34d85f2015-02-11 15:27:04 -080023 __field(unsigned long, start_pfn)
24 __field(unsigned long, end_pfn)
Mel Gormanb7aba692011-01-13 15:45:54 -080025 __field(unsigned long, nr_scanned)
26 __field(unsigned long, nr_taken)
27 ),
28
29 TP_fast_assign(
Joonsoo Kime34d85f2015-02-11 15:27:04 -080030 __entry->start_pfn = start_pfn;
31 __entry->end_pfn = end_pfn;
Mel Gormanb7aba692011-01-13 15:45:54 -080032 __entry->nr_scanned = nr_scanned;
33 __entry->nr_taken = nr_taken;
34 ),
35
Joonsoo Kime34d85f2015-02-11 15:27:04 -080036 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
37 __entry->start_pfn,
38 __entry->end_pfn,
Mel Gormanb7aba692011-01-13 15:45:54 -080039 __entry->nr_scanned,
40 __entry->nr_taken)
41);
42
43DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
44
Joonsoo Kime34d85f2015-02-11 15:27:04 -080045 TP_PROTO(
46 unsigned long start_pfn,
47 unsigned long end_pfn,
48 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080049 unsigned long nr_taken),
50
Joonsoo Kime34d85f2015-02-11 15:27:04 -080051 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
Mel Gormanb7aba692011-01-13 15:45:54 -080052);
53
54DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
Joonsoo Kime34d85f2015-02-11 15:27:04 -080055
56 TP_PROTO(
57 unsigned long start_pfn,
58 unsigned long end_pfn,
59 unsigned long nr_scanned,
Mel Gormanb7aba692011-01-13 15:45:54 -080060 unsigned long nr_taken),
61
Joonsoo Kime34d85f2015-02-11 15:27:04 -080062 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
Mel Gormanb7aba692011-01-13 15:45:54 -080063);
64
65TRACE_EVENT(mm_compaction_migratepages,
66
Vlastimil Babkaf8c93012014-06-04 16:08:32 -070067 TP_PROTO(unsigned long nr_all,
68 int migrate_rc,
69 struct list_head *migratepages),
Mel Gormanb7aba692011-01-13 15:45:54 -080070
Vlastimil Babkaf8c93012014-06-04 16:08:32 -070071 TP_ARGS(nr_all, migrate_rc, migratepages),
Mel Gormanb7aba692011-01-13 15:45:54 -080072
73 TP_STRUCT__entry(
74 __field(unsigned long, nr_migrated)
75 __field(unsigned long, nr_failed)
76 ),
77
78 TP_fast_assign(
Vlastimil Babkaf8c93012014-06-04 16:08:32 -070079 unsigned long nr_failed = 0;
80 struct list_head *page_lru;
81
82 /*
83 * migrate_pages() returns either a non-negative number
84 * with the number of pages that failed migration, or an
85 * error code, in which case we need to count the remaining
86 * pages manually
87 */
88 if (migrate_rc >= 0)
89 nr_failed = migrate_rc;
90 else
91 list_for_each(page_lru, migratepages)
92 nr_failed++;
93
94 __entry->nr_migrated = nr_all - nr_failed;
Mel Gormanb7aba692011-01-13 15:45:54 -080095 __entry->nr_failed = nr_failed;
96 ),
97
98 TP_printk("nr_migrated=%lu nr_failed=%lu",
99 __entry->nr_migrated,
100 __entry->nr_failed)
101);
102
Mel Gorman0eb927c2014-01-21 15:51:05 -0800103TRACE_EVENT(mm_compaction_begin,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800104 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
105 unsigned long free_pfn, unsigned long zone_end, bool sync),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800106
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800107 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800108
109 TP_STRUCT__entry(
110 __field(unsigned long, zone_start)
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800111 __field(unsigned long, migrate_pfn)
112 __field(unsigned long, free_pfn)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800113 __field(unsigned long, zone_end)
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800114 __field(bool, sync)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800115 ),
116
117 TP_fast_assign(
118 __entry->zone_start = zone_start;
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800119 __entry->migrate_pfn = migrate_pfn;
120 __entry->free_pfn = free_pfn;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800121 __entry->zone_end = zone_end;
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800122 __entry->sync = sync;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800123 ),
124
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800125 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 -0800126 __entry->zone_start,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800127 __entry->migrate_pfn,
128 __entry->free_pfn,
129 __entry->zone_end,
130 __entry->sync ? "sync" : "async")
Mel Gorman0eb927c2014-01-21 15:51:05 -0800131);
132
133TRACE_EVENT(mm_compaction_end,
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800134 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
135 unsigned long free_pfn, unsigned long zone_end, bool sync,
136 int status),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800137
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800138 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
Mel Gorman0eb927c2014-01-21 15:51:05 -0800139
140 TP_STRUCT__entry(
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800141 __field(unsigned long, zone_start)
142 __field(unsigned long, migrate_pfn)
143 __field(unsigned long, free_pfn)
144 __field(unsigned long, zone_end)
145 __field(bool, sync)
Mel Gorman0eb927c2014-01-21 15:51:05 -0800146 __field(int, status)
147 ),
148
149 TP_fast_assign(
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800150 __entry->zone_start = zone_start;
151 __entry->migrate_pfn = migrate_pfn;
152 __entry->free_pfn = free_pfn;
153 __entry->zone_end = zone_end;
154 __entry->sync = sync;
Mel Gorman0eb927c2014-01-21 15:51:05 -0800155 __entry->status = status;
156 ),
157
Joonsoo Kim16c4a092015-02-11 15:27:01 -0800158 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
159 __entry->zone_start,
160 __entry->migrate_pfn,
161 __entry->free_pfn,
162 __entry->zone_end,
163 __entry->sync ? "sync" : "async",
164 compaction_status_string[__entry->status])
Mel Gorman0eb927c2014-01-21 15:51:05 -0800165);
Mel Gormanb7aba692011-01-13 15:45:54 -0800166
Joonsoo Kim837d0262015-02-11 15:27:06 -0800167TRACE_EVENT(mm_compaction_try_to_compact_pages,
168
169 TP_PROTO(
170 int order,
171 gfp_t gfp_mask,
172 enum migrate_mode mode),
173
174 TP_ARGS(order, gfp_mask, mode),
175
176 TP_STRUCT__entry(
177 __field(int, order)
178 __field(gfp_t, gfp_mask)
179 __field(enum migrate_mode, mode)
180 ),
181
182 TP_fast_assign(
183 __entry->order = order;
184 __entry->gfp_mask = gfp_mask;
185 __entry->mode = mode;
186 ),
187
188 TP_printk("order=%d gfp_mask=0x%x mode=%d",
189 __entry->order,
190 __entry->gfp_mask,
191 (int)__entry->mode)
192);
193
194DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
195
196 TP_PROTO(struct zone *zone,
197 int order,
198 int ret),
199
200 TP_ARGS(zone, order, ret),
201
202 TP_STRUCT__entry(
203 __field(int, nid)
204 __field(char *, name)
205 __field(int, order)
206 __field(int, ret)
207 ),
208
209 TP_fast_assign(
210 __entry->nid = zone_to_nid(zone);
211 __entry->name = (char *)zone->name;
212 __entry->order = order;
213 __entry->ret = ret;
214 ),
215
216 TP_printk("node=%d zone=%-8s order=%d ret=%s",
217 __entry->nid,
218 __entry->name,
219 __entry->order,
220 compaction_status_string[__entry->ret])
221);
222
223DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
224
225 TP_PROTO(struct zone *zone,
226 int order,
227 int ret),
228
229 TP_ARGS(zone, order, ret)
230);
231
232DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
233
234 TP_PROTO(struct zone *zone,
235 int order,
236 int ret),
237
238 TP_ARGS(zone, order, ret)
239);
240
Joonsoo Kim24e27162015-02-11 15:27:09 -0800241#ifdef CONFIG_COMPACTION
242DECLARE_EVENT_CLASS(mm_compaction_defer_template,
243
244 TP_PROTO(struct zone *zone, int order),
245
246 TP_ARGS(zone, order),
247
248 TP_STRUCT__entry(
249 __field(int, nid)
250 __field(char *, name)
251 __field(int, order)
252 __field(unsigned int, considered)
253 __field(unsigned int, defer_shift)
254 __field(int, order_failed)
255 ),
256
257 TP_fast_assign(
258 __entry->nid = zone_to_nid(zone);
259 __entry->name = (char *)zone->name;
260 __entry->order = order;
261 __entry->considered = zone->compact_considered;
262 __entry->defer_shift = zone->compact_defer_shift;
263 __entry->order_failed = zone->compact_order_failed;
264 ),
265
266 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
267 __entry->nid,
268 __entry->name,
269 __entry->order,
270 __entry->order_failed,
271 __entry->considered,
272 1UL << __entry->defer_shift)
273);
274
275DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
276
277 TP_PROTO(struct zone *zone, int order),
278
279 TP_ARGS(zone, order)
280);
281
282DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
283
284 TP_PROTO(struct zone *zone, int order),
285
286 TP_ARGS(zone, order)
287);
288
289DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
290
291 TP_PROTO(struct zone *zone, int order),
292
293 TP_ARGS(zone, order)
294);
295#endif
296
Mel Gormanb7aba692011-01-13 15:45:54 -0800297#endif /* _TRACE_COMPACTION_H */
298
299/* This part must be outside protection */
300#include <trace/define_trace.h>