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