1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM compaction
5 #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_COMPACTION_H
8 #include <linux/types.h>
9 #include <linux/list.h>
10 #include <linux/tracepoint.h>
11 #include <trace/events/mmflags.h>
14 DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
17 unsigned long start_pfn,
18 unsigned long end_pfn,
19 unsigned long nr_scanned,
20 unsigned long nr_taken),
22 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
25 __field(unsigned long, start_pfn)
26 __field(unsigned long, end_pfn)
27 __field(unsigned long, nr_scanned)
28 __field(unsigned long, nr_taken)
32 __entry->start_pfn = start_pfn;
33 __entry->end_pfn = end_pfn;
34 __entry->nr_scanned = nr_scanned;
35 __entry->nr_taken = nr_taken;
38 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
45 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
48 unsigned long start_pfn,
49 unsigned long end_pfn,
50 unsigned long nr_scanned,
51 unsigned long nr_taken),
53 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
56 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
59 unsigned long start_pfn,
60 unsigned long end_pfn,
61 unsigned long nr_scanned,
62 unsigned long nr_taken),
64 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
67 #ifdef CONFIG_COMPACTION
68 TRACE_EVENT(mm_compaction_migratepages,
70 TP_PROTO(unsigned long nr_all,
71 unsigned int nr_succeeded),
73 TP_ARGS(nr_all, nr_succeeded),
76 __field(unsigned long, nr_migrated)
77 __field(unsigned long, nr_failed)
81 __entry->nr_migrated = nr_succeeded;
82 __entry->nr_failed = nr_all - nr_succeeded;
85 TP_printk("nr_migrated=%lu nr_failed=%lu",
90 TRACE_EVENT(mm_compaction_begin,
91 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
92 unsigned long free_pfn, unsigned long zone_end, bool sync),
94 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
97 __field(unsigned long, zone_start)
98 __field(unsigned long, migrate_pfn)
99 __field(unsigned long, free_pfn)
100 __field(unsigned long, zone_end)
105 __entry->zone_start = zone_start;
106 __entry->migrate_pfn = migrate_pfn;
107 __entry->free_pfn = free_pfn;
108 __entry->zone_end = zone_end;
109 __entry->sync = sync;
112 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
114 __entry->migrate_pfn,
117 __entry->sync ? "sync" : "async")
120 TRACE_EVENT(mm_compaction_end,
121 TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn,
122 unsigned long free_pfn, unsigned long zone_end, bool sync,
125 TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
128 __field(unsigned long, zone_start)
129 __field(unsigned long, migrate_pfn)
130 __field(unsigned long, free_pfn)
131 __field(unsigned long, zone_end)
137 __entry->zone_start = zone_start;
138 __entry->migrate_pfn = migrate_pfn;
139 __entry->free_pfn = free_pfn;
140 __entry->zone_end = zone_end;
141 __entry->sync = sync;
142 __entry->status = status;
145 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
147 __entry->migrate_pfn,
150 __entry->sync ? "sync" : "async",
151 __print_symbolic(__entry->status, COMPACTION_STATUS))
154 TRACE_EVENT(mm_compaction_try_to_compact_pages,
161 TP_ARGS(order, gfp_mask, prio),
165 __field(gfp_t, gfp_mask)
170 __entry->order = order;
171 __entry->gfp_mask = gfp_mask;
172 __entry->prio = prio;
175 TP_printk("order=%d gfp_mask=%s priority=%d",
177 show_gfp_flags(__entry->gfp_mask),
181 DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
183 TP_PROTO(struct zone *zone,
187 TP_ARGS(zone, order, ret),
191 __field(enum zone_type, idx)
197 __entry->nid = zone_to_nid(zone);
198 __entry->idx = zone_idx(zone);
199 __entry->order = order;
203 TP_printk("node=%d zone=%-8s order=%d ret=%s",
205 __print_symbolic(__entry->idx, ZONE_TYPE),
207 __print_symbolic(__entry->ret, COMPACTION_STATUS))
210 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
212 TP_PROTO(struct zone *zone,
216 TP_ARGS(zone, order, ret)
219 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
221 TP_PROTO(struct zone *zone,
225 TP_ARGS(zone, order, ret)
228 DECLARE_EVENT_CLASS(mm_compaction_defer_template,
230 TP_PROTO(struct zone *zone, int order),
232 TP_ARGS(zone, order),
236 __field(enum zone_type, idx)
238 __field(unsigned int, considered)
239 __field(unsigned int, defer_shift)
240 __field(int, order_failed)
244 __entry->nid = zone_to_nid(zone);
245 __entry->idx = zone_idx(zone);
246 __entry->order = order;
247 __entry->considered = zone->compact_considered;
248 __entry->defer_shift = zone->compact_defer_shift;
249 __entry->order_failed = zone->compact_order_failed;
252 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
254 __print_symbolic(__entry->idx, ZONE_TYPE),
256 __entry->order_failed,
258 1UL << __entry->defer_shift)
261 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
263 TP_PROTO(struct zone *zone, int order),
268 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
270 TP_PROTO(struct zone *zone, int order),
275 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
277 TP_PROTO(struct zone *zone, int order),
282 TRACE_EVENT(mm_compaction_kcompactd_sleep,
296 TP_printk("nid=%d", __entry->nid)
299 DECLARE_EVENT_CLASS(kcompactd_wake_template,
301 TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
303 TP_ARGS(nid, order, highest_zoneidx),
308 __field(enum zone_type, highest_zoneidx)
313 __entry->order = order;
314 __entry->highest_zoneidx = highest_zoneidx;
318 * classzone_idx is previous name of the highest_zoneidx.
319 * Reason not to change it is the ABI requirement of the tracepoint.
321 TP_printk("nid=%d order=%d classzone_idx=%-8s",
324 __print_symbolic(__entry->highest_zoneidx, ZONE_TYPE))
327 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
329 TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
331 TP_ARGS(nid, order, highest_zoneidx)
334 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
336 TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
338 TP_ARGS(nid, order, highest_zoneidx)
342 #endif /* _TRACE_COMPACTION_H */
344 /* This part must be outside protection */
345 #include <trace/define_trace.h>