1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM compaction
3 
4 #if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_COMPACTION_H
6 
7 #include <linux/types.h>
8 #include <linux/list.h>
9 #include <linux/tracepoint.h>
10 #include <trace/events/gfpflags.h>
11 
12 DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
13 
14 	TP_PROTO(unsigned long nr_scanned,
15 		unsigned long nr_taken),
16 
17 	TP_ARGS(nr_scanned, nr_taken),
18 
19 	TP_STRUCT__entry(
20 		__field(unsigned long, nr_scanned)
21 		__field(unsigned long, nr_taken)
22 	),
23 
24 	TP_fast_assign(
25 		__entry->nr_scanned = nr_scanned;
26 		__entry->nr_taken = nr_taken;
27 	),
28 
29 	TP_printk("nr_scanned=%lu nr_taken=%lu",
30 		__entry->nr_scanned,
31 		__entry->nr_taken)
32 );
33 
34 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
35 
36 	TP_PROTO(unsigned long nr_scanned,
37 		unsigned long nr_taken),
38 
39 	TP_ARGS(nr_scanned, nr_taken)
40 );
41 
42 DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
43 	TP_PROTO(unsigned long nr_scanned,
44 		unsigned long nr_taken),
45 
46 	TP_ARGS(nr_scanned, nr_taken)
47 );
48 
49 TRACE_EVENT(mm_compaction_migratepages,
50 
51 	TP_PROTO(unsigned long nr_all,
52 		int migrate_rc,
53 		struct list_head *migratepages),
54 
55 	TP_ARGS(nr_all, migrate_rc, migratepages),
56 
57 	TP_STRUCT__entry(
58 		__field(unsigned long, nr_migrated)
59 		__field(unsigned long, nr_failed)
60 	),
61 
62 	TP_fast_assign(
63 		unsigned long nr_failed = 0;
64 		struct list_head *page_lru;
65 
66 		/*
67 		 * migrate_pages() returns either a non-negative number
68 		 * with the number of pages that failed migration, or an
69 		 * error code, in which case we need to count the remaining
70 		 * pages manually
71 		 */
72 		if (migrate_rc >= 0)
73 			nr_failed = migrate_rc;
74 		else
75 			list_for_each(page_lru, migratepages)
76 				nr_failed++;
77 
78 		__entry->nr_migrated = nr_all - nr_failed;
79 		__entry->nr_failed = nr_failed;
80 	),
81 
82 	TP_printk("nr_migrated=%lu nr_failed=%lu",
83 		__entry->nr_migrated,
84 		__entry->nr_failed)
85 );
86 
87 TRACE_EVENT(mm_compaction_begin,
88 	TP_PROTO(unsigned long zone_start, unsigned long migrate_start,
89 		unsigned long free_start, unsigned long zone_end),
90 
91 	TP_ARGS(zone_start, migrate_start, free_start, zone_end),
92 
93 	TP_STRUCT__entry(
94 		__field(unsigned long, zone_start)
95 		__field(unsigned long, migrate_start)
96 		__field(unsigned long, free_start)
97 		__field(unsigned long, zone_end)
98 	),
99 
100 	TP_fast_assign(
101 		__entry->zone_start = zone_start;
102 		__entry->migrate_start = migrate_start;
103 		__entry->free_start = free_start;
104 		__entry->zone_end = zone_end;
105 	),
106 
107 	TP_printk("zone_start=%lu migrate_start=%lu free_start=%lu zone_end=%lu",
108 		__entry->zone_start,
109 		__entry->migrate_start,
110 		__entry->free_start,
111 		__entry->zone_end)
112 );
113 
114 TRACE_EVENT(mm_compaction_end,
115 	TP_PROTO(int status),
116 
117 	TP_ARGS(status),
118 
119 	TP_STRUCT__entry(
120 		__field(int, status)
121 	),
122 
123 	TP_fast_assign(
124 		__entry->status = status;
125 	),
126 
127 	TP_printk("status=%d", __entry->status)
128 );
129 
130 #endif /* _TRACE_COMPACTION_H */
131 
132 /* This part must be outside protection */
133 #include <trace/define_trace.h>
134