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