Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 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> |
Vlastimil Babka | f8c9301 | 2014-06-04 16:08:32 -0700 | [diff] [blame] | 8 | #include <linux/list.h> |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 9 | #include <linux/tracepoint.h> |
David Howells | a1ce392 | 2012-10-02 18:01:25 +0100 | [diff] [blame] | 10 | #include <trace/events/gfpflags.h> |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 11 | |
Vlastimil Babka | fa6c7b4 | 2015-11-05 18:47:56 -0800 | [diff] [blame^] | 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 | EMe(COMPACT_NOT_SUITABLE_ZONE, "not_suitable_zone") |
| 20 | |
| 21 | /* |
| 22 | * First define the enums in the above macros to be exported to userspace |
| 23 | * via TRACE_DEFINE_ENUM(). |
| 24 | */ |
| 25 | #undef EM |
| 26 | #undef EMe |
| 27 | #define EM(a, b) TRACE_DEFINE_ENUM(a); |
| 28 | #define EMe(a, b) TRACE_DEFINE_ENUM(a); |
| 29 | |
| 30 | COMPACTION_STATUS |
| 31 | |
| 32 | /* |
| 33 | * Now redefine the EM() and EMe() macros to map the enums to the strings |
| 34 | * that will be printed in the output. |
| 35 | */ |
| 36 | #undef EM |
| 37 | #undef EMe |
| 38 | #define EM(a, b) {a, b}, |
| 39 | #define EMe(a, b) {a, b} |
| 40 | |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 41 | DECLARE_EVENT_CLASS(mm_compaction_isolate_template, |
| 42 | |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 43 | TP_PROTO( |
| 44 | unsigned long start_pfn, |
| 45 | unsigned long end_pfn, |
| 46 | unsigned long nr_scanned, |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 47 | unsigned long nr_taken), |
| 48 | |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 49 | TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken), |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 50 | |
| 51 | TP_STRUCT__entry( |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 52 | __field(unsigned long, start_pfn) |
| 53 | __field(unsigned long, end_pfn) |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 54 | __field(unsigned long, nr_scanned) |
| 55 | __field(unsigned long, nr_taken) |
| 56 | ), |
| 57 | |
| 58 | TP_fast_assign( |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 59 | __entry->start_pfn = start_pfn; |
| 60 | __entry->end_pfn = end_pfn; |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 61 | __entry->nr_scanned = nr_scanned; |
| 62 | __entry->nr_taken = nr_taken; |
| 63 | ), |
| 64 | |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 65 | TP_printk("range=(0x%lx ~ 0x%lx) nr_scanned=%lu nr_taken=%lu", |
| 66 | __entry->start_pfn, |
| 67 | __entry->end_pfn, |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 68 | __entry->nr_scanned, |
| 69 | __entry->nr_taken) |
| 70 | ); |
| 71 | |
| 72 | DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages, |
| 73 | |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 74 | TP_PROTO( |
| 75 | unsigned long start_pfn, |
| 76 | unsigned long end_pfn, |
| 77 | unsigned long nr_scanned, |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 78 | unsigned long nr_taken), |
| 79 | |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 80 | TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken) |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 81 | ); |
| 82 | |
| 83 | DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages, |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 84 | |
| 85 | TP_PROTO( |
| 86 | unsigned long start_pfn, |
| 87 | unsigned long end_pfn, |
| 88 | unsigned long nr_scanned, |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 89 | unsigned long nr_taken), |
| 90 | |
Joonsoo Kim | e34d85f | 2015-02-11 15:27:04 -0800 | [diff] [blame] | 91 | TP_ARGS(start_pfn, end_pfn, nr_scanned, nr_taken) |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 92 | ); |
| 93 | |
| 94 | TRACE_EVENT(mm_compaction_migratepages, |
| 95 | |
Vlastimil Babka | f8c9301 | 2014-06-04 16:08:32 -0700 | [diff] [blame] | 96 | TP_PROTO(unsigned long nr_all, |
| 97 | int migrate_rc, |
| 98 | struct list_head *migratepages), |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 99 | |
Vlastimil Babka | f8c9301 | 2014-06-04 16:08:32 -0700 | [diff] [blame] | 100 | TP_ARGS(nr_all, migrate_rc, migratepages), |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 101 | |
| 102 | TP_STRUCT__entry( |
| 103 | __field(unsigned long, nr_migrated) |
| 104 | __field(unsigned long, nr_failed) |
| 105 | ), |
| 106 | |
| 107 | TP_fast_assign( |
Vlastimil Babka | f8c9301 | 2014-06-04 16:08:32 -0700 | [diff] [blame] | 108 | unsigned long nr_failed = 0; |
| 109 | struct list_head *page_lru; |
| 110 | |
| 111 | /* |
| 112 | * migrate_pages() returns either a non-negative number |
| 113 | * with the number of pages that failed migration, or an |
| 114 | * error code, in which case we need to count the remaining |
| 115 | * pages manually |
| 116 | */ |
| 117 | if (migrate_rc >= 0) |
| 118 | nr_failed = migrate_rc; |
| 119 | else |
| 120 | list_for_each(page_lru, migratepages) |
| 121 | nr_failed++; |
| 122 | |
| 123 | __entry->nr_migrated = nr_all - nr_failed; |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 124 | __entry->nr_failed = nr_failed; |
| 125 | ), |
| 126 | |
| 127 | TP_printk("nr_migrated=%lu nr_failed=%lu", |
| 128 | __entry->nr_migrated, |
| 129 | __entry->nr_failed) |
| 130 | ); |
| 131 | |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 132 | TRACE_EVENT(mm_compaction_begin, |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 133 | TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn, |
| 134 | unsigned long free_pfn, unsigned long zone_end, bool sync), |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 135 | |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 136 | TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync), |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 137 | |
| 138 | TP_STRUCT__entry( |
| 139 | __field(unsigned long, zone_start) |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 140 | __field(unsigned long, migrate_pfn) |
| 141 | __field(unsigned long, free_pfn) |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 142 | __field(unsigned long, zone_end) |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 143 | __field(bool, sync) |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 144 | ), |
| 145 | |
| 146 | TP_fast_assign( |
| 147 | __entry->zone_start = zone_start; |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 148 | __entry->migrate_pfn = migrate_pfn; |
| 149 | __entry->free_pfn = free_pfn; |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 150 | __entry->zone_end = zone_end; |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 151 | __entry->sync = sync; |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 152 | ), |
| 153 | |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 154 | TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s", |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 155 | __entry->zone_start, |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 156 | __entry->migrate_pfn, |
| 157 | __entry->free_pfn, |
| 158 | __entry->zone_end, |
| 159 | __entry->sync ? "sync" : "async") |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 160 | ); |
| 161 | |
| 162 | TRACE_EVENT(mm_compaction_end, |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 163 | TP_PROTO(unsigned long zone_start, unsigned long migrate_pfn, |
| 164 | unsigned long free_pfn, unsigned long zone_end, bool sync, |
| 165 | int status), |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 166 | |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 167 | TP_ARGS(zone_start, migrate_pfn, free_pfn, zone_end, sync, status), |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 168 | |
| 169 | TP_STRUCT__entry( |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 170 | __field(unsigned long, zone_start) |
| 171 | __field(unsigned long, migrate_pfn) |
| 172 | __field(unsigned long, free_pfn) |
| 173 | __field(unsigned long, zone_end) |
| 174 | __field(bool, sync) |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 175 | __field(int, status) |
| 176 | ), |
| 177 | |
| 178 | TP_fast_assign( |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 179 | __entry->zone_start = zone_start; |
| 180 | __entry->migrate_pfn = migrate_pfn; |
| 181 | __entry->free_pfn = free_pfn; |
| 182 | __entry->zone_end = zone_end; |
| 183 | __entry->sync = sync; |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 184 | __entry->status = status; |
| 185 | ), |
| 186 | |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 187 | TP_printk("zone_start=0x%lx migrate_pfn=0x%lx free_pfn=0x%lx zone_end=0x%lx, mode=%s status=%s", |
| 188 | __entry->zone_start, |
| 189 | __entry->migrate_pfn, |
| 190 | __entry->free_pfn, |
| 191 | __entry->zone_end, |
| 192 | __entry->sync ? "sync" : "async", |
Vlastimil Babka | fa6c7b4 | 2015-11-05 18:47:56 -0800 | [diff] [blame^] | 193 | __print_symbolic(__entry->status, COMPACTION_STATUS)) |
Mel Gorman | 0eb927c | 2014-01-21 15:51:05 -0800 | [diff] [blame] | 194 | ); |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 195 | |
Joonsoo Kim | 837d026 | 2015-02-11 15:27:06 -0800 | [diff] [blame] | 196 | TRACE_EVENT(mm_compaction_try_to_compact_pages, |
| 197 | |
| 198 | TP_PROTO( |
| 199 | int order, |
| 200 | gfp_t gfp_mask, |
| 201 | enum migrate_mode mode), |
| 202 | |
| 203 | TP_ARGS(order, gfp_mask, mode), |
| 204 | |
| 205 | TP_STRUCT__entry( |
| 206 | __field(int, order) |
| 207 | __field(gfp_t, gfp_mask) |
| 208 | __field(enum migrate_mode, mode) |
| 209 | ), |
| 210 | |
| 211 | TP_fast_assign( |
| 212 | __entry->order = order; |
| 213 | __entry->gfp_mask = gfp_mask; |
| 214 | __entry->mode = mode; |
| 215 | ), |
| 216 | |
| 217 | TP_printk("order=%d gfp_mask=0x%x mode=%d", |
| 218 | __entry->order, |
| 219 | __entry->gfp_mask, |
| 220 | (int)__entry->mode) |
| 221 | ); |
| 222 | |
| 223 | DECLARE_EVENT_CLASS(mm_compaction_suitable_template, |
| 224 | |
| 225 | TP_PROTO(struct zone *zone, |
| 226 | int order, |
| 227 | int ret), |
| 228 | |
| 229 | TP_ARGS(zone, order, ret), |
| 230 | |
| 231 | TP_STRUCT__entry( |
| 232 | __field(int, nid) |
| 233 | __field(char *, name) |
| 234 | __field(int, order) |
| 235 | __field(int, ret) |
| 236 | ), |
| 237 | |
| 238 | TP_fast_assign( |
| 239 | __entry->nid = zone_to_nid(zone); |
| 240 | __entry->name = (char *)zone->name; |
| 241 | __entry->order = order; |
| 242 | __entry->ret = ret; |
| 243 | ), |
| 244 | |
| 245 | TP_printk("node=%d zone=%-8s order=%d ret=%s", |
| 246 | __entry->nid, |
| 247 | __entry->name, |
| 248 | __entry->order, |
Vlastimil Babka | fa6c7b4 | 2015-11-05 18:47:56 -0800 | [diff] [blame^] | 249 | __print_symbolic(__entry->ret, COMPACTION_STATUS)) |
Joonsoo Kim | 837d026 | 2015-02-11 15:27:06 -0800 | [diff] [blame] | 250 | ); |
| 251 | |
| 252 | DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_finished, |
| 253 | |
| 254 | TP_PROTO(struct zone *zone, |
| 255 | int order, |
| 256 | int ret), |
| 257 | |
| 258 | TP_ARGS(zone, order, ret) |
| 259 | ); |
| 260 | |
| 261 | DEFINE_EVENT(mm_compaction_suitable_template, mm_compaction_suitable, |
| 262 | |
| 263 | TP_PROTO(struct zone *zone, |
| 264 | int order, |
| 265 | int ret), |
| 266 | |
| 267 | TP_ARGS(zone, order, ret) |
| 268 | ); |
| 269 | |
Joonsoo Kim | 24e2716 | 2015-02-11 15:27:09 -0800 | [diff] [blame] | 270 | #ifdef CONFIG_COMPACTION |
| 271 | DECLARE_EVENT_CLASS(mm_compaction_defer_template, |
| 272 | |
| 273 | TP_PROTO(struct zone *zone, int order), |
| 274 | |
| 275 | TP_ARGS(zone, order), |
| 276 | |
| 277 | TP_STRUCT__entry( |
| 278 | __field(int, nid) |
| 279 | __field(char *, name) |
| 280 | __field(int, order) |
| 281 | __field(unsigned int, considered) |
| 282 | __field(unsigned int, defer_shift) |
| 283 | __field(int, order_failed) |
| 284 | ), |
| 285 | |
| 286 | TP_fast_assign( |
| 287 | __entry->nid = zone_to_nid(zone); |
| 288 | __entry->name = (char *)zone->name; |
| 289 | __entry->order = order; |
| 290 | __entry->considered = zone->compact_considered; |
| 291 | __entry->defer_shift = zone->compact_defer_shift; |
| 292 | __entry->order_failed = zone->compact_order_failed; |
| 293 | ), |
| 294 | |
| 295 | TP_printk("node=%d zone=%-8s order=%d order_failed=%d consider=%u limit=%lu", |
| 296 | __entry->nid, |
| 297 | __entry->name, |
| 298 | __entry->order, |
| 299 | __entry->order_failed, |
| 300 | __entry->considered, |
| 301 | 1UL << __entry->defer_shift) |
| 302 | ); |
| 303 | |
| 304 | DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_deferred, |
| 305 | |
| 306 | TP_PROTO(struct zone *zone, int order), |
| 307 | |
| 308 | TP_ARGS(zone, order) |
| 309 | ); |
| 310 | |
| 311 | DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_compaction, |
| 312 | |
| 313 | TP_PROTO(struct zone *zone, int order), |
| 314 | |
| 315 | TP_ARGS(zone, order) |
| 316 | ); |
| 317 | |
| 318 | DEFINE_EVENT(mm_compaction_defer_template, mm_compaction_defer_reset, |
| 319 | |
| 320 | TP_PROTO(struct zone *zone, int order), |
| 321 | |
| 322 | TP_ARGS(zone, order) |
| 323 | ); |
| 324 | #endif |
| 325 | |
Mel Gorman | b7aba69 | 2011-01-13 15:45:54 -0800 | [diff] [blame] | 326 | #endif /* _TRACE_COMPACTION_H */ |
| 327 | |
| 328 | /* This part must be outside protection */ |
| 329 | #include <trace/define_trace.h> |