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 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_fast_isolate_freepages,
70 unsigned long start_pfn,
71 unsigned long end_pfn,
72 unsigned long nr_scanned,
73 unsigned long nr_taken),
75 TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
78 #ifdef CONFIG_COMPACTION
79 TRACE_EVENT(mm_compaction_migratepages,
81 TP_PROTO(struct compact_control *cc,
82 unsigned int nr_succeeded),
84 TP_ARGS(cc, nr_succeeded),
87 __field(unsigned long, nr_migrated)
88 __field(unsigned long, nr_failed)
92 __entry->nr_migrated = nr_succeeded;
93 __entry->nr_failed = cc->nr_migratepages - nr_succeeded;
96 TP_printk("nr_migrated=%lu nr_failed=%lu",
101 TRACE_EVENT(mm_compaction_begin,
102 TP_PROTO(struct compact_control *cc, unsigned long zone_start,
103 unsigned long zone_end, bool sync),
105 TP_ARGS(cc, zone_start, zone_end, sync),
108 __field(unsigned long, zone_start)
109 __field(unsigned long, migrate_pfn)
110 __field(unsigned long, free_pfn)
111 __field(unsigned long, zone_end)
116 __entry->zone_start = zone_start;
117 __entry->migrate_pfn = cc->migrate_pfn;
118 __entry->free_pfn = cc->free_pfn;
119 __entry->zone_end = zone_end;
120 __entry->sync = sync;
123 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
125 __entry->migrate_pfn,
128 __entry->sync ? "sync" : "async")
131 TRACE_EVENT(mm_compaction_end,
132 TP_PROTO(struct compact_control *cc, unsigned long zone_start,
133 unsigned long zone_end, bool sync,
136 TP_ARGS(cc, zone_start, zone_end, sync, status),
139 __field(unsigned long, zone_start)
140 __field(unsigned long, migrate_pfn)
141 __field(unsigned long, free_pfn)
142 __field(unsigned long, zone_end)
148 __entry->zone_start = zone_start;
149 __entry->migrate_pfn = cc->migrate_pfn;
150 __entry->free_pfn = cc->free_pfn;
151 __entry->zone_end = zone_end;
152 __entry->sync = sync;
153 __entry->status = status;
156 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
158 __entry->migrate_pfn,
161 __entry->sync ? "sync" : "async",
162 __print_symbolic(__entry->status, COMPACTION_STATUS))
165 TRACE_EVENT(mm_compaction_try_to_compact_pages,
172 TP_ARGS(order, gfp_mask, prio),
176 __field(unsigned long, gfp_mask)
181 __entry->order = order;
182 __entry->gfp_mask = (__force unsigned long)gfp_mask;
183 __entry->prio = prio;
186 TP_printk("order=%d gfp_mask=%s priority=%d",
188 show_gfp_flags(__entry->gfp_mask),
192 DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
194 TP_PROTO(struct zone *zone,
198 TP_ARGS(zone, order, ret),
202 __field(enum zone_type, idx)
208 __entry->nid = zone_to_nid(zone);
209 __entry->idx = zone_idx(zone);
210 __entry->order = order;
214 TP_printk("node=%d zone=%-8s order=%d ret=%s",
216 __print_symbolic(__entry->idx, ZONE_TYPE),
218 __print_symbolic(__entry->ret, COMPACTION_STATUS))
221 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
223 TP_PROTO(struct zone *zone,
227 TP_ARGS(zone, order, ret)
230 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
232 TP_PROTO(struct zone *zone,
236 TP_ARGS(zone, order, ret)
239 DECLARE_EVENT_CLASS(mm_compaction_defer_template,
241 TP_PROTO(struct zone *zone, int order),
243 TP_ARGS(zone, order),
247 __field(enum zone_type, idx)
249 __field(unsigned int, considered)
250 __field(unsigned int, defer_shift)
251 __field(int, order_failed)
255 __entry->nid = zone_to_nid(zone);
256 __entry->idx = zone_idx(zone);
257 __entry->order = order;
258 __entry->considered = zone->compact_considered;
259 __entry->defer_shift = zone->compact_defer_shift;
260 __entry->order_failed = zone->compact_order_failed;
263 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
265 __print_symbolic(__entry->idx, ZONE_TYPE),
267 __entry->order_failed,
269 1UL << __entry->defer_shift)
272 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
274 TP_PROTO(struct zone *zone, int order),
279 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
281 TP_PROTO(struct zone *zone, int order),
286 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
288 TP_PROTO(struct zone *zone, int order),
293 TRACE_EVENT(mm_compaction_kcompactd_sleep,
307 TP_printk("nid=%d", __entry->nid)
310 DECLARE_EVENT_CLASS(kcompactd_wake_template,
312 TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
314 TP_ARGS(nid, order, highest_zoneidx),
319 __field(enum zone_type, highest_zoneidx)
324 __entry->order = order;
325 __entry->highest_zoneidx = highest_zoneidx;
329 * classzone_idx is previous name of the highest_zoneidx.
330 * Reason not to change it is the ABI requirement of the tracepoint.
332 TP_printk("nid=%d order=%d classzone_idx=%-8s",
335 __print_symbolic(__entry->highest_zoneidx, ZONE_TYPE))
338 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
340 TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
342 TP_ARGS(nid, order, highest_zoneidx)
345 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
347 TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
349 TP_ARGS(nid, order, highest_zoneidx)
353 #endif /* _TRACE_COMPACTION_H */
355 /* This part must be outside protection */
356 #include <trace/define_trace.h>