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 TRACE_EVENT(mm_compaction_migratepages
,
69 TP_PROTO(unsigned long nr_all
,
71 struct list_head
*migratepages
),
73 TP_ARGS(nr_all
, migrate_rc
, migratepages
),
76 __field(unsigned long, nr_migrated
)
77 __field(unsigned long, nr_failed
)
81 unsigned long nr_failed
= 0;
82 struct list_head
*page_lru
;
85 * migrate_pages() returns either a non-negative number
86 * with the number of pages that failed migration, or an
87 * error code, in which case we need to count the remaining
91 nr_failed
= migrate_rc
;
93 list_for_each(page_lru
, migratepages
)
96 __entry
->nr_migrated
= nr_all
- nr_failed
;
97 __entry
->nr_failed
= nr_failed
;
100 TP_printk("nr_migrated=%lu nr_failed=%lu",
101 __entry
->nr_migrated
,
105 TRACE_EVENT(mm_compaction_begin
,
106 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
107 unsigned long free_pfn
, unsigned long zone_end
, bool sync
),
109 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
),
112 __field(unsigned long, zone_start
)
113 __field(unsigned long, migrate_pfn
)
114 __field(unsigned long, free_pfn
)
115 __field(unsigned long, zone_end
)
120 __entry
->zone_start
= zone_start
;
121 __entry
->migrate_pfn
= migrate_pfn
;
122 __entry
->free_pfn
= free_pfn
;
123 __entry
->zone_end
= zone_end
;
124 __entry
->sync
= sync
;
127 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
129 __entry
->migrate_pfn
,
132 __entry
->sync
? "sync" : "async")
135 #ifdef CONFIG_COMPACTION
136 TRACE_EVENT(mm_compaction_end
,
137 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
138 unsigned long free_pfn
, unsigned long zone_end
, bool sync
,
141 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
, status
),
144 __field(unsigned long, zone_start
)
145 __field(unsigned long, migrate_pfn
)
146 __field(unsigned long, free_pfn
)
147 __field(unsigned long, zone_end
)
153 __entry
->zone_start
= zone_start
;
154 __entry
->migrate_pfn
= migrate_pfn
;
155 __entry
->free_pfn
= free_pfn
;
156 __entry
->zone_end
= zone_end
;
157 __entry
->sync
= sync
;
158 __entry
->status
= status
;
161 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
163 __entry
->migrate_pfn
,
166 __entry
->sync
? "sync" : "async",
167 __print_symbolic(__entry
->status
, COMPACTION_STATUS
))
171 TRACE_EVENT(mm_compaction_try_to_compact_pages
,
178 TP_ARGS(order
, gfp_mask
, prio
),
182 __field(gfp_t
, gfp_mask
)
187 __entry
->order
= order
;
188 __entry
->gfp_mask
= gfp_mask
;
189 __entry
->prio
= prio
;
192 TP_printk("order=%d gfp_mask=0x%x priority=%d",
198 #ifdef CONFIG_COMPACTION
199 DECLARE_EVENT_CLASS(mm_compaction_suitable_template
,
201 TP_PROTO(struct zone
*zone
,
205 TP_ARGS(zone
, order
, ret
),
209 __field(enum zone_type
, idx
)
215 __entry
->nid
= zone_to_nid(zone
);
216 __entry
->idx
= zone_idx(zone
);
217 __entry
->order
= order
;
221 TP_printk("node=%d zone=%-8s order=%d ret=%s",
223 __print_symbolic(__entry
->idx
, ZONE_TYPE
),
225 __print_symbolic(__entry
->ret
, COMPACTION_STATUS
))
228 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_finished
,
230 TP_PROTO(struct zone
*zone
,
234 TP_ARGS(zone
, order
, ret
)
237 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_suitable
,
239 TP_PROTO(struct zone
*zone
,
243 TP_ARGS(zone
, order
, ret
)
246 DECLARE_EVENT_CLASS(mm_compaction_defer_template
,
248 TP_PROTO(struct zone
*zone
, int order
),
250 TP_ARGS(zone
, order
),
254 __field(enum zone_type
, idx
)
256 __field(unsigned int, considered
)
257 __field(unsigned int, defer_shift
)
258 __field(int, order_failed
)
262 __entry
->nid
= zone_to_nid(zone
);
263 __entry
->idx
= zone_idx(zone
);
264 __entry
->order
= order
;
265 __entry
->considered
= zone
->compact_considered
;
266 __entry
->defer_shift
= zone
->compact_defer_shift
;
267 __entry
->order_failed
= zone
->compact_order_failed
;
270 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
272 __print_symbolic(__entry
->idx
, ZONE_TYPE
),
274 __entry
->order_failed
,
276 1UL << __entry
->defer_shift
)
279 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_deferred
,
281 TP_PROTO(struct zone
*zone
, int order
),
286 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_compaction
,
288 TP_PROTO(struct zone
*zone
, int order
),
293 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_reset
,
295 TP_PROTO(struct zone
*zone
, int order
),
301 TRACE_EVENT(mm_compaction_kcompactd_sleep
,
315 TP_printk("nid=%d", __entry
->nid
)
318 DECLARE_EVENT_CLASS(kcompactd_wake_template
,
320 TP_PROTO(int nid
, int order
, enum zone_type classzone_idx
),
322 TP_ARGS(nid
, order
, classzone_idx
),
327 __field(enum zone_type
, classzone_idx
)
332 __entry
->order
= order
;
333 __entry
->classzone_idx
= classzone_idx
;
336 TP_printk("nid=%d order=%d classzone_idx=%-8s",
339 __print_symbolic(__entry
->classzone_idx
, ZONE_TYPE
))
342 DEFINE_EVENT(kcompactd_wake_template
, mm_compaction_wakeup_kcompactd
,
344 TP_PROTO(int nid
, int order
, enum zone_type classzone_idx
),
346 TP_ARGS(nid
, order
, classzone_idx
)
349 DEFINE_EVENT(kcompactd_wake_template
, mm_compaction_kcompactd_wake
,
351 TP_PROTO(int nid
, int order
, enum zone_type classzone_idx
),
353 TP_ARGS(nid
, order
, classzone_idx
)
356 #endif /* _TRACE_COMPACTION_H */
358 /* This part must be outside protection */
359 #include <trace/define_trace.h>