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