2 #define TRACE_SYSTEM compaction
4 #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_COMPACTION_H
7 #include <linux/types.h>
8 #include <linux/list.h>
9 #include <linux/tracepoint.h>
10 #include <trace/events/gfpflags.h>
12 #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")
22 * First define the enums in the above macros to be exported to userspace
23 * via TRACE_DEFINE_ENUM().
27 #define EM(a, b) TRACE_DEFINE_ENUM(a);
28 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
33 * Now redefine the EM() and EMe() macros to map the enums to the strings
34 * that will be printed in the output.
38 #define EM(a, b) {a, b},
39 #define EMe(a, b) {a, b}
41 DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
44 unsigned long start_pfn,
45 unsigned long end_pfn,
46 unsigned long nr_scanned,
47 unsigned long nr_taken),
49 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
52 __field(unsigned long, start_pfn)
53 __field(unsigned long, end_pfn)
54 __field(unsigned long, nr_scanned)
55 __field(unsigned long, nr_taken)
59 __entry->start_pfn = start_pfn;
60 __entry->end_pfn = end_pfn;
61 __entry->nr_scanned = nr_scanned;
62 __entry->nr_taken = nr_taken;
65 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
72 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
75 unsigned long start_pfn,
76 unsigned long end_pfn,
77 unsigned long nr_scanned,
78 unsigned long nr_taken),
80 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
83 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
86 unsigned long start_pfn,
87 unsigned long end_pfn,
88 unsigned long nr_scanned,
89 unsigned long nr_taken),
91 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
94 TRACE_EVENT(mm_compaction_migratepages,
96 TP_PROTO(unsigned long nr_all,
98 struct list_head *migratepages),
100 TP_ARGS(nr_all, migrate_rc, migratepages),
103 __field(unsigned long, nr_migrated)
104 __field(unsigned long, nr_failed)
108 unsigned long nr_failed = 0;
109 struct list_head *page_lru;
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
118 nr_failed = migrate_rc;
120 list_for_each(page_lru, migratepages)
123 __entry->nr_migrated = nr_all - nr_failed;
124 __entry->nr_failed = nr_failed;
127 TP_printk("nr_migrated=%lu nr_failed=%lu",
128 __entry->nr_migrated,
132 TRACE_EVENT(mm_compaction_begin,
133 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
134 unsigned long free_pfn, unsigned long zone_end, bool sync),
136 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
139 __field(unsigned long, zone_start)
140 __field(unsigned long, migrate_pfn)
141 __field(unsigned long, free_pfn)
142 __field(unsigned long, zone_end)
147 __entry->zone_start = zone_start;
148 __entry->migrate_pfn = migrate_pfn;
149 __entry->free_pfn = free_pfn;
150 __entry->zone_end = zone_end;
151 __entry->sync = sync;
154 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
156 __entry->migrate_pfn,
159 __entry->sync ? "sync" : "async")
162 TRACE_EVENT(mm_compaction_end,
163 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
164 unsigned long free_pfn, unsigned long zone_end, bool sync,
167 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
170 __field(unsigned long, zone_start)
171 __field(unsigned long, migrate_pfn)
172 __field(unsigned long, free_pfn)
173 __field(unsigned long, zone_end)
179 __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;
184 __entry->status = status;
187 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
189 __entry->migrate_pfn,
192 __entry->sync ? "sync" : "async",
193 __print_symbolic(__entry->status, COMPACTION_STATUS))
196 TRACE_EVENT(mm_compaction_try_to_compact_pages,
201 enum migrate_mode mode),
203 TP_ARGS(order, gfp_mask, mode),
207 __field(gfp_t, gfp_mask)
208 __field(enum migrate_mode, mode)
212 __entry->order = order;
213 __entry->gfp_mask = gfp_mask;
214 __entry->mode = mode;
217 TP_printk("order=%d gfp_mask=0x%x mode=%d",
223 DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
225 TP_PROTO(struct zone *zone,
229 TP_ARGS(zone, order, ret),
233 __field(char *, name)
239 __entry->nid = zone_to_nid(zone);
240 __entry->name = (char *)zone->name;
241 __entry->order = order;
245 TP_printk("node=%d zone=%-8s order=%d ret=%s",
249 __print_symbolic(__entry->ret, COMPACTION_STATUS))
252 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
254 TP_PROTO(struct zone *zone,
258 TP_ARGS(zone, order, ret)
261 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
263 TP_PROTO(struct zone *zone,
267 TP_ARGS(zone, order, ret)
270 #ifdef CONFIG_COMPACTION
271 DECLARE_EVENT_CLASS(mm_compaction_defer_template,
273 TP_PROTO(struct zone *zone, int order),
275 TP_ARGS(zone, order),
279 __field(char *, name)
281 __field(unsigned int, considered)
282 __field(unsigned int, defer_shift)
283 __field(int, order_failed)
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;
295 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
299 __entry->order_failed,
301 1UL << __entry->defer_shift)
304 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
306 TP_PROTO(struct zone *zone, int order),
311 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
313 TP_PROTO(struct zone *zone, int order),
318 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
320 TP_PROTO(struct zone *zone, int order),
326 #endif /* _TRACE_COMPACTION_H */
328 /* This part must be outside protection */
329 #include <trace/define_trace.h>