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
,
72 struct list_head
*migratepages
),
74 TP_ARGS(nr_all
, migrate_rc
, migratepages
),
77 __field(unsigned long, nr_migrated
)
78 __field(unsigned long, nr_failed
)
82 unsigned long nr_failed
= 0;
83 struct list_head
*page_lru
;
86 * migrate_pages() returns either a non-negative number
87 * with the number of pages that failed migration, or an
88 * error code, in which case we need to count the remaining
92 nr_failed
= migrate_rc
;
94 list_for_each(page_lru
, migratepages
)
97 __entry
->nr_migrated
= nr_all
- nr_failed
;
98 __entry
->nr_failed
= nr_failed
;
101 TP_printk("nr_migrated=%lu nr_failed=%lu",
102 __entry
->nr_migrated
,
106 TRACE_EVENT(mm_compaction_begin
,
107 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
108 unsigned long free_pfn
, unsigned long zone_end
, bool sync
),
110 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
),
113 __field(unsigned long, zone_start
)
114 __field(unsigned long, migrate_pfn
)
115 __field(unsigned long, free_pfn
)
116 __field(unsigned long, zone_end
)
121 __entry
->zone_start
= zone_start
;
122 __entry
->migrate_pfn
= migrate_pfn
;
123 __entry
->free_pfn
= free_pfn
;
124 __entry
->zone_end
= zone_end
;
125 __entry
->sync
= sync
;
128 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
130 __entry
->migrate_pfn
,
133 __entry
->sync
? "sync" : "async")
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
))
170 TRACE_EVENT(mm_compaction_try_to_compact_pages
,
177 TP_ARGS(order
, gfp_mask
, prio
),
181 __field(gfp_t
, gfp_mask
)
186 __entry
->order
= order
;
187 __entry
->gfp_mask
= gfp_mask
;
188 __entry
->prio
= prio
;
191 TP_printk("order=%d gfp_mask=%s priority=%d",
193 show_gfp_flags(__entry
->gfp_mask
),
197 DECLARE_EVENT_CLASS(mm_compaction_suitable_template
,
199 TP_PROTO(struct zone
*zone
,
203 TP_ARGS(zone
, order
, ret
),
207 __field(enum zone_type
, idx
)
213 __entry
->nid
= zone_to_nid(zone
);
214 __entry
->idx
= zone_idx(zone
);
215 __entry
->order
= order
;
219 TP_printk("node=%d zone=%-8s order=%d ret=%s",
221 __print_symbolic(__entry
->idx
, ZONE_TYPE
),
223 __print_symbolic(__entry
->ret
, COMPACTION_STATUS
))
226 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_finished
,
228 TP_PROTO(struct zone
*zone
,
232 TP_ARGS(zone
, order
, ret
)
235 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_suitable
,
237 TP_PROTO(struct zone
*zone
,
241 TP_ARGS(zone
, order
, ret
)
244 DECLARE_EVENT_CLASS(mm_compaction_defer_template
,
246 TP_PROTO(struct zone
*zone
, int order
),
248 TP_ARGS(zone
, order
),
252 __field(enum zone_type
, idx
)
254 __field(unsigned int, considered
)
255 __field(unsigned int, defer_shift
)
256 __field(int, order_failed
)
260 __entry
->nid
= zone_to_nid(zone
);
261 __entry
->idx
= zone_idx(zone
);
262 __entry
->order
= order
;
263 __entry
->considered
= zone
->compact_considered
;
264 __entry
->defer_shift
= zone
->compact_defer_shift
;
265 __entry
->order_failed
= zone
->compact_order_failed
;
268 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
270 __print_symbolic(__entry
->idx
, ZONE_TYPE
),
272 __entry
->order_failed
,
274 1UL << __entry
->defer_shift
)
277 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_deferred
,
279 TP_PROTO(struct zone
*zone
, int order
),
284 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_compaction
,
286 TP_PROTO(struct zone
*zone
, int order
),
291 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_reset
,
293 TP_PROTO(struct zone
*zone
, int order
),
298 TRACE_EVENT(mm_compaction_kcompactd_sleep
,
312 TP_printk("nid=%d", __entry
->nid
)
315 DECLARE_EVENT_CLASS(kcompactd_wake_template
,
317 TP_PROTO(int nid
, int order
, enum zone_type highest_zoneidx
),
319 TP_ARGS(nid
, order
, highest_zoneidx
),
324 __field(enum zone_type
, highest_zoneidx
)
329 __entry
->order
= order
;
330 __entry
->highest_zoneidx
= highest_zoneidx
;
334 * classzone_idx is previous name of the highest_zoneidx.
335 * Reason not to change it is the ABI requirement of the tracepoint.
337 TP_printk("nid=%d order=%d classzone_idx=%-8s",
340 __print_symbolic(__entry
->highest_zoneidx
, ZONE_TYPE
))
343 DEFINE_EVENT(kcompactd_wake_template
, mm_compaction_wakeup_kcompactd
,
345 TP_PROTO(int nid
, int order
, enum zone_type highest_zoneidx
),
347 TP_ARGS(nid
, order
, highest_zoneidx
)
350 DEFINE_EVENT(kcompactd_wake_template
, mm_compaction_kcompactd_wake
,
352 TP_PROTO(int nid
, int order
, enum zone_type highest_zoneidx
),
354 TP_ARGS(nid
, order
, highest_zoneidx
)
358 #endif /* _TRACE_COMPACTION_H */
360 /* This part must be outside protection */
361 #include <trace/define_trace.h>