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/gfpflags.h>
12 DECLARE_EVENT_CLASS(mm_compaction_isolate_template
,
15 unsigned long start_pfn
,
16 unsigned long end_pfn
,
17 unsigned long nr_scanned
,
18 unsigned long nr_taken
),
20 TP_ARGS(start_pfn
, end_pfn
, nr_scanned
, nr_taken
),
23 __field(unsigned long, start_pfn
)
24 __field(unsigned long, end_pfn
)
25 __field(unsigned long, nr_scanned
)
26 __field(unsigned long, nr_taken
)
30 __entry
->start_pfn
= start_pfn
;
31 __entry
->end_pfn
= end_pfn
;
32 __entry
->nr_scanned
= nr_scanned
;
33 __entry
->nr_taken
= nr_taken
;
36 TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
43 DEFINE_EVENT(mm_compaction_isolate_template
, mm_compaction_isolate_migratepages
,
46 unsigned long start_pfn
,
47 unsigned long end_pfn
,
48 unsigned long nr_scanned
,
49 unsigned long nr_taken
),
51 TP_ARGS(start_pfn
, end_pfn
, nr_scanned
, nr_taken
)
54 DEFINE_EVENT(mm_compaction_isolate_template
, mm_compaction_isolate_freepages
,
57 unsigned long start_pfn
,
58 unsigned long end_pfn
,
59 unsigned long nr_scanned
,
60 unsigned long nr_taken
),
62 TP_ARGS(start_pfn
, end_pfn
, nr_scanned
, nr_taken
)
65 TRACE_EVENT(mm_compaction_migratepages
,
67 TP_PROTO(unsigned long nr_all
,
69 struct list_head
*migratepages
),
71 TP_ARGS(nr_all
, migrate_rc
, migratepages
),
74 __field(unsigned long, nr_migrated
)
75 __field(unsigned long, nr_failed
)
79 unsigned long nr_failed
= 0;
80 struct list_head
*page_lru
;
83 * migrate_pages() returns either a non-negative number
84 * with the number of pages that failed migration, or an
85 * error code, in which case we need to count the remaining
89 nr_failed
= migrate_rc
;
91 list_for_each(page_lru
, migratepages
)
94 __entry
->nr_migrated
= nr_all
- nr_failed
;
95 __entry
->nr_failed
= nr_failed
;
98 TP_printk("nr_migrated=%lu nr_failed=%lu",
103 TRACE_EVENT(mm_compaction_begin
,
104 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
105 unsigned long free_pfn
, unsigned long zone_end
, bool sync
),
107 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
),
110 __field(unsigned long, zone_start
)
111 __field(unsigned long, migrate_pfn
)
112 __field(unsigned long, free_pfn
)
113 __field(unsigned long, zone_end
)
118 __entry
->zone_start
= zone_start
;
119 __entry
->migrate_pfn
= migrate_pfn
;
120 __entry
->free_pfn
= free_pfn
;
121 __entry
->zone_end
= zone_end
;
122 __entry
->sync
= sync
;
125 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
127 __entry
->migrate_pfn
,
130 __entry
->sync
? "sync" : "async")
133 TRACE_EVENT(mm_compaction_end
,
134 TP_PROTO(unsigned long zone_start
, unsigned long migrate_pfn
,
135 unsigned long free_pfn
, unsigned long zone_end
, bool sync
,
138 TP_ARGS(zone_start
, migrate_pfn
, free_pfn
, zone_end
, sync
, status
),
141 __field(unsigned long, zone_start
)
142 __field(unsigned long, migrate_pfn
)
143 __field(unsigned long, free_pfn
)
144 __field(unsigned long, zone_end
)
150 __entry
->zone_start
= zone_start
;
151 __entry
->migrate_pfn
= migrate_pfn
;
152 __entry
->free_pfn
= free_pfn
;
153 __entry
->zone_end
= zone_end
;
154 __entry
->sync
= sync
;
155 __entry
->status
= status
;
158 TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
160 __entry
->migrate_pfn
,
163 __entry
->sync
? "sync" : "async",
164 compaction_status_string
[__entry
->status
])
167 TRACE_EVENT(mm_compaction_try_to_compact_pages
,
172 enum migrate_mode mode
),
174 TP_ARGS(order
, gfp_mask
, mode
),
178 __field(gfp_t
, gfp_mask
)
179 __field(enum migrate_mode
, mode
)
183 __entry
->order
= order
;
184 __entry
->gfp_mask
= gfp_mask
;
185 __entry
->mode
= mode
;
188 TP_printk("order=%d gfp_mask=0x%x mode=%d",
194 DECLARE_EVENT_CLASS(mm_compaction_suitable_template
,
196 TP_PROTO(struct zone
*zone
,
200 TP_ARGS(zone
, order
, ret
),
204 __field(char *, name
)
210 __entry
->nid
= zone_to_nid(zone
);
211 __entry
->name
= (char *)zone
->name
;
212 __entry
->order
= order
;
216 TP_printk("node=%d zone=%-8s order=%d ret=%s",
220 compaction_status_string
[__entry
->ret
])
223 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_finished
,
225 TP_PROTO(struct zone
*zone
,
229 TP_ARGS(zone
, order
, ret
)
232 DEFINE_EVENT(mm_compaction_suitable_template
, mm_compaction_suitable
,
234 TP_PROTO(struct zone
*zone
,
238 TP_ARGS(zone
, order
, ret
)
241 #ifdef CONFIG_COMPACTION
242 DECLARE_EVENT_CLASS(mm_compaction_defer_template
,
244 TP_PROTO(struct zone
*zone
, int order
),
246 TP_ARGS(zone
, order
),
250 __field(char *, name
)
252 __field(unsigned int, considered
)
253 __field(unsigned int, defer_shift
)
254 __field(int, order_failed
)
258 __entry
->nid
= zone_to_nid(zone
);
259 __entry
->name
= (char *)zone
->name
;
260 __entry
->order
= order
;
261 __entry
->considered
= zone
->compact_considered
;
262 __entry
->defer_shift
= zone
->compact_defer_shift
;
263 __entry
->order_failed
= zone
->compact_order_failed
;
266 TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
270 __entry
->order_failed
,
272 1UL << __entry
->defer_shift
)
275 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_deferred
,
277 TP_PROTO(struct zone
*zone
, int order
),
282 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_compaction
,
284 TP_PROTO(struct zone
*zone
, int order
),
289 DEFINE_EVENT(mm_compaction_defer_template
, mm_compaction_defer_reset
,
291 TP_PROTO(struct zone
*zone
, int order
),
297 #endif /* _TRACE_COMPACTION_H */
299 /* This part must be outside protection */
300 #include <trace/define_trace.h>