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