GNU Linux-libre 4.14.254-gnu1
[releases.git] / include / trace / events / compaction.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM compaction
4
5 #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_COMPACTION_H
7
8 #include <linux/types.h>
9 #include <linux/list.h>
10 #include <linux/tracepoint.h>
11 #include <trace/events/mmflags.h>
12
13
14 DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
15
16         TP_PROTO(
17                 unsigned long start_pfn,
18                 unsigned long end_pfn,
19                 unsigned long nr_scanned,
20                 unsigned long nr_taken),
21
22         TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken),
23
24         TP_STRUCT__entry(
25                 __field(unsigned long, start_pfn)
26                 __field(unsigned long, end_pfn)
27                 __field(unsigned long, nr_scanned)
28                 __field(unsigned long, nr_taken)
29         ),
30
31         TP_fast_assign(
32                 __entry->start_pfn = start_pfn;
33                 __entry->end_pfn = end_pfn;
34                 __entry->nr_scanned = nr_scanned;
35                 __entry->nr_taken = nr_taken;
36         ),
37
38         TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu",
39                 __entry->start_pfn,
40                 __entry->end_pfn,
41                 __entry->nr_scanned,
42                 __entry->nr_taken)
43 );
44
45 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
46
47         TP_PROTO(
48                 unsigned long start_pfn,
49                 unsigned long end_pfn,
50                 unsigned long nr_scanned,
51                 unsigned long nr_taken),
52
53         TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
54 );
55
56 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
57
58         TP_PROTO(
59                 unsigned long start_pfn,
60                 unsigned long end_pfn,
61                 unsigned long nr_scanned,
62                 unsigned long nr_taken),
63
64         TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken)
65 );
66
67 TRACE_EVENT(mm_compaction_migratepages,
68
69         TP_PROTO(unsigned long nr_all,
70                 int migrate_rc,
71                 struct list_head *migratepages),
72
73         TP_ARGS(nr_all, migrate_rc, migratepages),
74
75         TP_STRUCT__entry(
76                 __field(unsigned long, nr_migrated)
77                 __field(unsigned long, nr_failed)
78         ),
79
80         TP_fast_assign(
81                 unsigned long nr_failed = 0;
82                 struct list_head *page_lru;
83
84                 /*
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
88                  * pages manually
89                  */
90                 if (migrate_rc >= 0)
91                         nr_failed = migrate_rc;
92                 else
93                         list_for_each(page_lru, migratepages)
94                                 nr_failed++;
95
96                 __entry->nr_migrated = nr_all - nr_failed;
97                 __entry->nr_failed = nr_failed;
98         ),
99
100         TP_printk("nr_migrated=%lu nr_failed=%lu",
101                 __entry->nr_migrated,
102                 __entry->nr_failed)
103 );
104
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),
108
109         TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync),
110
111         TP_STRUCT__entry(
112                 __field(unsigned long, zone_start)
113                 __field(unsigned long, migrate_pfn)
114                 __field(unsigned long, free_pfn)
115                 __field(unsigned long, zone_end)
116                 __field(bool, sync)
117         ),
118
119         TP_fast_assign(
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;
125         ),
126
127         TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s",
128                 __entry->zone_start,
129                 __entry->migrate_pfn,
130                 __entry->free_pfn,
131                 __entry->zone_end,
132                 __entry->sync ? "sync" : "async")
133 );
134
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,
139                 int status),
140
141         TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status),
142
143         TP_STRUCT__entry(
144                 __field(unsigned long, zone_start)
145                 __field(unsigned long, migrate_pfn)
146                 __field(unsigned long, free_pfn)
147                 __field(unsigned long, zone_end)
148                 __field(bool, sync)
149                 __field(int, status)
150         ),
151
152         TP_fast_assign(
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;
159         ),
160
161         TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s",
162                 __entry->zone_start,
163                 __entry->migrate_pfn,
164                 __entry->free_pfn,
165                 __entry->zone_end,
166                 __entry->sync ? "sync" : "async",
167                 __print_symbolic(__entry->status, COMPACTION_STATUS))
168 );
169 #endif
170
171 TRACE_EVENT(mm_compaction_try_to_compact_pages,
172
173         TP_PROTO(
174                 int order,
175                 gfp_t gfp_mask,
176                 int prio),
177
178         TP_ARGS(order, gfp_mask, prio),
179
180         TP_STRUCT__entry(
181                 __field(int, order)
182                 __field(gfp_t, gfp_mask)
183                 __field(int, prio)
184         ),
185
186         TP_fast_assign(
187                 __entry->order = order;
188                 __entry->gfp_mask = gfp_mask;
189                 __entry->prio = prio;
190         ),
191
192         TP_printk("order=%d gfp_mask=0x%x priority=%d",
193                 __entry->order,
194                 __entry->gfp_mask,
195                 __entry->prio)
196 );
197
198 #ifdef CONFIG_COMPACTION
199 DECLARE_EVENT_CLASS(mm_compaction_suitable_template,
200
201         TP_PROTO(struct zone *zone,
202                 int order,
203                 int ret),
204
205         TP_ARGS(zone, order, ret),
206
207         TP_STRUCT__entry(
208                 __field(int, nid)
209                 __field(enum zone_type, idx)
210                 __field(int, order)
211                 __field(int, ret)
212         ),
213
214         TP_fast_assign(
215                 __entry->nid = zone_to_nid(zone);
216                 __entry->idx = zone_idx(zone);
217                 __entry->order = order;
218                 __entry->ret = ret;
219         ),
220
221         TP_printk("node=%d zone=%-8s order=%d ret=%s",
222                 __entry->nid,
223                 __print_symbolic(__entry->idx, ZONE_TYPE),
224                 __entry->order,
225                 __print_symbolic(__entry->ret, COMPACTION_STATUS))
226 );
227
228 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished,
229
230         TP_PROTO(struct zone *zone,
231                 int order,
232                 int ret),
233
234         TP_ARGS(zone, order, ret)
235 );
236
237 DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable,
238
239         TP_PROTO(struct zone *zone,
240                 int order,
241                 int ret),
242
243         TP_ARGS(zone, order, ret)
244 );
245
246 DECLARE_EVENT_CLASS(mm_compaction_defer_template,
247
248         TP_PROTO(struct zone *zone, int order),
249
250         TP_ARGS(zone, order),
251
252         TP_STRUCT__entry(
253                 __field(int, nid)
254                 __field(enum zone_type, idx)
255                 __field(int, order)
256                 __field(unsigned int, considered)
257                 __field(unsigned int, defer_shift)
258                 __field(int, order_failed)
259         ),
260
261         TP_fast_assign(
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;
268         ),
269
270         TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu",
271                 __entry->nid,
272                 __print_symbolic(__entry->idx, ZONE_TYPE),
273                 __entry->order,
274                 __entry->order_failed,
275                 __entry->considered,
276                 1UL << __entry->defer_shift)
277 );
278
279 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred,
280
281         TP_PROTO(struct zone *zone, int order),
282
283         TP_ARGS(zone, order)
284 );
285
286 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction,
287
288         TP_PROTO(struct zone *zone, int order),
289
290         TP_ARGS(zone, order)
291 );
292
293 DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset,
294
295         TP_PROTO(struct zone *zone, int order),
296
297         TP_ARGS(zone, order)
298 );
299 #endif
300
301 TRACE_EVENT(mm_compaction_kcompactd_sleep,
302
303         TP_PROTO(int nid),
304
305         TP_ARGS(nid),
306
307         TP_STRUCT__entry(
308                 __field(int, nid)
309         ),
310
311         TP_fast_assign(
312                 __entry->nid = nid;
313         ),
314
315         TP_printk("nid=%d", __entry->nid)
316 );
317
318 DECLARE_EVENT_CLASS(kcompactd_wake_template,
319
320         TP_PROTO(int nid, int order, enum zone_type classzone_idx),
321
322         TP_ARGS(nid, order, classzone_idx),
323
324         TP_STRUCT__entry(
325                 __field(int, nid)
326                 __field(int, order)
327                 __field(enum zone_type, classzone_idx)
328         ),
329
330         TP_fast_assign(
331                 __entry->nid = nid;
332                 __entry->order = order;
333                 __entry->classzone_idx = classzone_idx;
334         ),
335
336         TP_printk("nid=%d order=%d classzone_idx=%-8s",
337                 __entry->nid,
338                 __entry->order,
339                 __print_symbolic(__entry->classzone_idx, ZONE_TYPE))
340 );
341
342 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
343
344         TP_PROTO(int nid, int order, enum zone_type classzone_idx),
345
346         TP_ARGS(nid, order, classzone_idx)
347 );
348
349 DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
350
351         TP_PROTO(int nid, int order, enum zone_type classzone_idx),
352
353         TP_ARGS(nid, order, classzone_idx)
354 );
355
356 #endif /* _TRACE_COMPACTION_H */
357
358 /* This part must be outside protection */
359 #include <trace/define_trace.h>