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/mmflags.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 EM( COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone") \
20 EMe(COMPACT_CONTENDED, "contended")
22 #ifdef CONFIG_ZONE_DMA
23 #define IFDEF_ZONE_DMA(X) X
25 #define IFDEF_ZONE_DMA(X)
28 #ifdef CONFIG_ZONE_DMA32
29 #define IFDEF_ZONE_DMA32(X) X
31 #define IFDEF_ZONE_DMA32(X)
35 #define IFDEF_ZONE_HIGHMEM(X) X
37 #define IFDEF_ZONE_HIGHMEM(X)
41 IFDEF_ZONE_DMA( EM (ZONE_DMA, "DMA")) \
42 IFDEF_ZONE_DMA32( EM (ZONE_DMA32, "DMA32")) \
43 EM (ZONE_NORMAL, "Normal") \
44 IFDEF_ZONE_HIGHMEM( EM (ZONE_HIGHMEM,"HighMem")) \
45 EMe(ZONE_MOVABLE,"Movable")
48 * First define the enums in the above macros to be exported to userspace
49 * via TRACE_DEFINE_ENUM().
53 #define EM(a, b) TRACE_DEFINE_ENUM(a);
54 #define EMe(a, b) TRACE_DEFINE_ENUM(a);
60 * Now redefine the EM() and EMe() macros to map the enums to the strings
61 * that will be printed in the output.
65 #define EM(a, b) {a, b},
66 #define EMe(a, b) {a, b}
68 DECLARE_EVENT_CLASS(mm_compaction_isolate_template
,
71 unsigned long start_pfn
,
72 unsigned long end_pfn
,
73 unsigned long nr_scanned
,
74 unsigned long nr_taken
),
76 TP_ARGS(start_pfn
, end_pfn
, nr_scanned
, nr_taken
),
79 __field(unsigned long, start_pfn
)
80 __field(unsigned long, end_pfn
)
81 __field(unsigned long, nr_scanned
)
82 __field(unsigned long, nr_taken
)
86 __entry
->start_pfn
= start_pfn
;
87 __entry
->end_pfn
= end_pfn
;
88 __entry
->nr_scanned
= nr_scanned
;
89 __entry
->nr_taken
= nr_taken
;
92 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
99 DEFINE_EVENT(mm_compaction_isolate_template
, mm_compaction_isolate_migratepages
,
102 unsigned long start_pfn
,
103 unsigned long end_pfn
,
104 unsigned long nr_scanned
,
105 unsigned long nr_taken
),
107 TP_ARGS(start_pfn
, end_pfn
, nr_scanned
, nr_taken
)
110 DEFINE_EVENT(mm_compaction_isolate_template
, mm_compaction_isolate_freepages
,
113 unsigned long start_pfn
,
114 unsigned long end_pfn
,
115 unsigned long nr_scanned
,
116 unsigned long nr_taken
),
118 TP_ARGS(start_pfn
, end_pfn
, nr_scanned
, nr_taken
)
121 TRACE_EVENT(mm_compaction_migratepages
,
123 TP_PROTO(unsigned long nr_all
,
125 struct list_head
*migratepages
),
127 TP_ARGS(nr_all
, migrate_rc
, migratepages
),
130 __field(unsigned long, nr_migrated
)
131 __field(unsigned long, nr_failed
)
135 unsigned long nr_failed
= 0;
136 struct list_head
*page_lru
;
139 * migrate_pages() returns either a non-negative number
140 * with the number of pages that failed migration, or an
141 * error code, in which case we need to count the remaining
145 nr_failed
= migrate_rc
;
147 list_for_each(page_lru
, migratepages
)
150 __entry
->nr_migrated
= nr_all
- nr_failed
;
151 __entry
->nr_failed
= nr_failed
;
154 TP_printk("nr_migrated=%lu nr_failed=%lu",
155 __entry
->nr_migrated
,
159 TRACE_EVENT(mm_compaction_begin
,
160 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
161 unsigned long free_pfn
, unsigned long zone_end
, bool sync
),
163 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
),
166 __field(unsigned long, zone_start
)
167 __field(unsigned long, migrate_pfn
)
168 __field(unsigned long, free_pfn
)
169 __field(unsigned long, zone_end
)
174 __entry
->zone_start
= zone_start
;
175 __entry
->migrate_pfn
= migrate_pfn
;
176 __entry
->free_pfn
= free_pfn
;
177 __entry
->zone_end
= zone_end
;
178 __entry
->sync
= sync
;
181 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
183 __entry
->migrate_pfn
,
186 __entry
->sync
? "sync" : "async")
189 TRACE_EVENT(mm_compaction_end
,
190 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
191 unsigned long free_pfn
, unsigned long zone_end
, bool sync
,
194 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
, status
),
197 __field(unsigned long, zone_start
)
198 __field(unsigned long, migrate_pfn
)
199 __field(unsigned long, free_pfn
)
200 __field(unsigned long, zone_end
)
206 __entry
->zone_start
= zone_start
;
207 __entry
->migrate_pfn
= migrate_pfn
;
208 __entry
->free_pfn
= free_pfn
;
209 __entry
->zone_end
= zone_end
;
210 __entry
->sync
= sync
;
211 __entry
->status
= status
;
214 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
216 __entry
->migrate_pfn
,
219 __entry
->sync
? "sync" : "async",
220 __print_symbolic(__entry
->status
, COMPACTION_STATUS
))
223 TRACE_EVENT(mm_compaction_try_to_compact_pages
,
228 enum migrate_mode mode
),
230 TP_ARGS(order
, gfp_mask
, mode
),
234 __field(gfp_t
, gfp_mask
)
235 __field(enum migrate_mode
, mode
)
239 __entry
->order
= order
;
240 __entry
->gfp_mask
= gfp_mask
;
241 __entry
->mode
= mode
;
244 TP_printk("order=%d gfp_mask=0x%x mode=%d",
250 DECLARE_EVENT_CLASS(mm_compaction_suitable_template
,
252 TP_PROTO(struct zone
*zone
,
256 TP_ARGS(zone
, order
, ret
),
260 __field(enum zone_type
, idx
)
266 __entry
->nid
= zone_to_nid(zone
);
267 __entry
->idx
= zone_idx(zone
);
268 __entry
->order
= order
;
272 TP_printk("node=%d zone=%-8s order=%d ret=%s",
274 __print_symbolic(__entry
->idx
, ZONE_TYPE
),
276 __print_symbolic(__entry
->ret
, COMPACTION_STATUS
))
279 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_finished
,
281 TP_PROTO(struct zone
*zone
,
285 TP_ARGS(zone
, order
, ret
)
288 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_suitable
,
290 TP_PROTO(struct zone
*zone
,
294 TP_ARGS(zone
, order
, ret
)
297 #ifdef CONFIG_COMPACTION
298 DECLARE_EVENT_CLASS(mm_compaction_defer_template
,
300 TP_PROTO(struct zone
*zone
, int order
),
302 TP_ARGS(zone
, order
),
306 __field(enum zone_type
, idx
)
308 __field(unsigned int, considered
)
309 __field(unsigned int, defer_shift
)
310 __field(int, order_failed
)
314 __entry
->nid
= zone_to_nid(zone
);
315 __entry
->idx
= zone_idx(zone
);
316 __entry
->order
= order
;
317 __entry
->considered
= zone
->compact_considered
;
318 __entry
->defer_shift
= zone
->compact_defer_shift
;
319 __entry
->order_failed
= zone
->compact_order_failed
;
322 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
324 __print_symbolic(__entry
->idx
, ZONE_TYPE
),
326 __entry
->order_failed
,
328 1UL << __entry
->defer_shift
)
331 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_deferred
,
333 TP_PROTO(struct zone
*zone
, int order
),
338 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_compaction
,
340 TP_PROTO(struct zone
*zone
, int order
),
345 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_reset
,
347 TP_PROTO(struct zone
*zone
, int order
),
353 TRACE_EVENT(mm_compaction_kcompactd_sleep
,
367 TP_printk("nid=%d", __entry
->nid
)
370 DECLARE_EVENT_CLASS(kcompactd_wake_template
,
372 TP_PROTO(int nid
, int order
, enum zone_type classzone_idx
),
374 TP_ARGS(nid
, order
, classzone_idx
),
379 __field(enum zone_type
, classzone_idx
)
384 __entry
->order
= order
;
385 __entry
->classzone_idx
= classzone_idx
;
388 TP_printk("nid=%d order=%d classzone_idx=%-8s",
391 __print_symbolic(__entry
->classzone_idx
, ZONE_TYPE
))
394 DEFINE_EVENT(kcompactd_wake_template
, mm_compaction_wakeup_kcompactd
,
396 TP_PROTO(int nid
, int order
, enum zone_type classzone_idx
),
398 TP_ARGS(nid
, order
, classzone_idx
)
401 DEFINE_EVENT(kcompactd_wake_template
, mm_compaction_kcompactd_wake
,
403 TP_PROTO(int nid
, int order
, enum zone_type classzone_idx
),
405 TP_ARGS(nid
, order
, classzone_idx
)
408 #endif /* _TRACE_COMPACTION_H */
410 /* This part must be outside protection */
411 #include <trace/define_trace.h>