1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM vmscan 4 5 #if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_VMSCAN_H 7 8 #include <linux/types.h> 9 #include <linux/tracepoint.h> 10 #include <linux/mm.h> 11 #include <linux/memcontrol.h> 12 #include <trace/events/mmflags.h> 13 14 #define RECLAIM_WB_ANON 0x0001u 15 #define RECLAIM_WB_FILE 0x0002u 16 #define RECLAIM_WB_MIXED 0x0010u 17 #define RECLAIM_WB_SYNC 0x0004u /* Unused, all reclaim async */ 18 #define RECLAIM_WB_ASYNC 0x0008u 19 #define RECLAIM_WB_LRU (RECLAIM_WB_ANON|RECLAIM_WB_FILE) 20 21 #define show_reclaim_flags(flags) \ 22 (flags) ? __print_flags(flags, "|", \ 23 {RECLAIM_WB_ANON, "RECLAIM_WB_ANON"}, \ 24 {RECLAIM_WB_FILE, "RECLAIM_WB_FILE"}, \ 25 {RECLAIM_WB_MIXED, "RECLAIM_WB_MIXED"}, \ 26 {RECLAIM_WB_SYNC, "RECLAIM_WB_SYNC"}, \ 27 {RECLAIM_WB_ASYNC, "RECLAIM_WB_ASYNC"} \ 28 ) : "RECLAIM_WB_NONE" 29 30 #define trace_reclaim_flags(page) ( \ 31 (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \ 32 (RECLAIM_WB_ASYNC) \ 33 ) 34 35 #define trace_shrink_flags(file) \ 36 ( \ 37 (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \ 38 (RECLAIM_WB_ASYNC) \ 39 ) 40 41 TRACE_EVENT(mm_vmscan_kswapd_sleep, 42 43 TP_PROTO(int nid), 44 45 TP_ARGS(nid), 46 47 TP_STRUCT__entry( 48 __field( int, nid ) 49 ), 50 51 TP_fast_assign( 52 __entry->nid = nid; 53 ), 54 55 TP_printk("nid=%d", __entry->nid) 56 ); 57 58 TRACE_EVENT(mm_vmscan_kswapd_wake, 59 60 TP_PROTO(int nid, int zid, int order), 61 62 TP_ARGS(nid, zid, order), 63 64 TP_STRUCT__entry( 65 __field( int, nid ) 66 __field( int, zid ) 67 __field( int, order ) 68 ), 69 70 TP_fast_assign( 71 __entry->nid = nid; 72 __entry->zid = zid; 73 __entry->order = order; 74 ), 75 76 TP_printk("nid=%d zid=%d order=%d", __entry->nid, __entry->zid, __entry->order) 77 ); 78 79 TRACE_EVENT(mm_vmscan_wakeup_kswapd, 80 81 TP_PROTO(int nid, int zid, int order), 82 83 TP_ARGS(nid, zid, order), 84 85 TP_STRUCT__entry( 86 __field( int, nid ) 87 __field( int, zid ) 88 __field( int, order ) 89 ), 90 91 TP_fast_assign( 92 __entry->nid = nid; 93 __entry->zid = zid; 94 __entry->order = order; 95 ), 96 97 TP_printk("nid=%d zid=%d order=%d", 98 __entry->nid, 99 __entry->zid, 100 __entry->order) 101 ); 102 103 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template, 104 105 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), 106 107 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx), 108 109 TP_STRUCT__entry( 110 __field( int, order ) 111 __field( int, may_writepage ) 112 __field( gfp_t, gfp_flags ) 113 __field( int, classzone_idx ) 114 ), 115 116 TP_fast_assign( 117 __entry->order = order; 118 __entry->may_writepage = may_writepage; 119 __entry->gfp_flags = gfp_flags; 120 __entry->classzone_idx = classzone_idx; 121 ), 122 123 TP_printk("order=%d may_writepage=%d gfp_flags=%s classzone_idx=%d", 124 __entry->order, 125 __entry->may_writepage, 126 show_gfp_flags(__entry->gfp_flags), 127 __entry->classzone_idx) 128 ); 129 130 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin, 131 132 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), 133 134 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx) 135 ); 136 137 #ifdef CONFIG_MEMCG 138 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin, 139 140 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), 141 142 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx) 143 ); 144 145 DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin, 146 147 TP_PROTO(int order, int may_writepage, gfp_t gfp_flags, int classzone_idx), 148 149 TP_ARGS(order, may_writepage, gfp_flags, classzone_idx) 150 ); 151 #endif /* CONFIG_MEMCG */ 152 153 DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template, 154 155 TP_PROTO(unsigned long nr_reclaimed), 156 157 TP_ARGS(nr_reclaimed), 158 159 TP_STRUCT__entry( 160 __field( unsigned long, nr_reclaimed ) 161 ), 162 163 TP_fast_assign( 164 __entry->nr_reclaimed = nr_reclaimed; 165 ), 166 167 TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed) 168 ); 169 170 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end, 171 172 TP_PROTO(unsigned long nr_reclaimed), 173 174 TP_ARGS(nr_reclaimed) 175 ); 176 177 #ifdef CONFIG_MEMCG 178 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end, 179 180 TP_PROTO(unsigned long nr_reclaimed), 181 182 TP_ARGS(nr_reclaimed) 183 ); 184 185 DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end, 186 187 TP_PROTO(unsigned long nr_reclaimed), 188 189 TP_ARGS(nr_reclaimed) 190 ); 191 #endif /* CONFIG_MEMCG */ 192 193 TRACE_EVENT(mm_shrink_slab_start, 194 TP_PROTO(struct shrinker *shr, struct shrink_control *sc, 195 long nr_objects_to_shrink, unsigned long pgs_scanned, 196 unsigned long lru_pgs, unsigned long cache_items, 197 unsigned long long delta, unsigned long total_scan), 198 199 TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs, 200 cache_items, delta, total_scan), 201 202 TP_STRUCT__entry( 203 __field(struct shrinker *, shr) 204 __field(void *, shrink) 205 __field(int, nid) 206 __field(long, nr_objects_to_shrink) 207 __field(gfp_t, gfp_flags) 208 __field(unsigned long, pgs_scanned) 209 __field(unsigned long, lru_pgs) 210 __field(unsigned long, cache_items) 211 __field(unsigned long long, delta) 212 __field(unsigned long, total_scan) 213 ), 214 215 TP_fast_assign( 216 __entry->shr = shr; 217 __entry->shrink = shr->scan_objects; 218 __entry->nid = sc->nid; 219 __entry->nr_objects_to_shrink = nr_objects_to_shrink; 220 __entry->gfp_flags = sc->gfp_mask; 221 __entry->pgs_scanned = pgs_scanned; 222 __entry->lru_pgs = lru_pgs; 223 __entry->cache_items = cache_items; 224 __entry->delta = delta; 225 __entry->total_scan = total_scan; 226 ), 227 228 TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld", 229 __entry->shrink, 230 __entry->shr, 231 __entry->nid, 232 __entry->nr_objects_to_shrink, 233 show_gfp_flags(__entry->gfp_flags), 234 __entry->pgs_scanned, 235 __entry->lru_pgs, 236 __entry->cache_items, 237 __entry->delta, 238 __entry->total_scan) 239 ); 240 241 TRACE_EVENT(mm_shrink_slab_end, 242 TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval, 243 long unused_scan_cnt, long new_scan_cnt, long total_scan), 244 245 TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt, 246 total_scan), 247 248 TP_STRUCT__entry( 249 __field(struct shrinker *, shr) 250 __field(int, nid) 251 __field(void *, shrink) 252 __field(long, unused_scan) 253 __field(long, new_scan) 254 __field(int, retval) 255 __field(long, total_scan) 256 ), 257 258 TP_fast_assign( 259 __entry->shr = shr; 260 __entry->nid = nid; 261 __entry->shrink = shr->scan_objects; 262 __entry->unused_scan = unused_scan_cnt; 263 __entry->new_scan = new_scan_cnt; 264 __entry->retval = shrinker_retval; 265 __entry->total_scan = total_scan; 266 ), 267 268 TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d", 269 __entry->shrink, 270 __entry->shr, 271 __entry->nid, 272 __entry->unused_scan, 273 __entry->new_scan, 274 __entry->total_scan, 275 __entry->retval) 276 ); 277 278 TRACE_EVENT(mm_vmscan_lru_isolate, 279 TP_PROTO(int classzone_idx, 280 int order, 281 unsigned long nr_requested, 282 unsigned long nr_scanned, 283 unsigned long nr_skipped, 284 unsigned long nr_taken, 285 isolate_mode_t isolate_mode, 286 int lru), 287 288 TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, lru), 289 290 TP_STRUCT__entry( 291 __field(int, classzone_idx) 292 __field(int, order) 293 __field(unsigned long, nr_requested) 294 __field(unsigned long, nr_scanned) 295 __field(unsigned long, nr_skipped) 296 __field(unsigned long, nr_taken) 297 __field(isolate_mode_t, isolate_mode) 298 __field(int, lru) 299 ), 300 301 TP_fast_assign( 302 __entry->classzone_idx = classzone_idx; 303 __entry->order = order; 304 __entry->nr_requested = nr_requested; 305 __entry->nr_scanned = nr_scanned; 306 __entry->nr_skipped = nr_skipped; 307 __entry->nr_taken = nr_taken; 308 __entry->isolate_mode = isolate_mode; 309 __entry->lru = lru; 310 ), 311 312 TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s", 313 __entry->isolate_mode, 314 __entry->classzone_idx, 315 __entry->order, 316 __entry->nr_requested, 317 __entry->nr_scanned, 318 __entry->nr_skipped, 319 __entry->nr_taken, 320 __print_symbolic(__entry->lru, LRU_NAMES)) 321 ); 322 323 TRACE_EVENT(mm_vmscan_writepage, 324 325 TP_PROTO(struct page *page), 326 327 TP_ARGS(page), 328 329 TP_STRUCT__entry( 330 __field(unsigned long, pfn) 331 __field(int, reclaim_flags) 332 ), 333 334 TP_fast_assign( 335 __entry->pfn = page_to_pfn(page); 336 __entry->reclaim_flags = trace_reclaim_flags(page); 337 ), 338 339 TP_printk("page=%p pfn=%lu flags=%s", 340 pfn_to_page(__entry->pfn), 341 __entry->pfn, 342 show_reclaim_flags(__entry->reclaim_flags)) 343 ); 344 345 TRACE_EVENT(mm_vmscan_lru_shrink_inactive, 346 347 TP_PROTO(int nid, 348 unsigned long nr_scanned, unsigned long nr_reclaimed, 349 unsigned long nr_dirty, unsigned long nr_writeback, 350 unsigned long nr_congested, unsigned long nr_immediate, 351 unsigned long nr_activate, unsigned long nr_ref_keep, 352 unsigned long nr_unmap_fail, 353 int priority, int file), 354 355 TP_ARGS(nid, nr_scanned, nr_reclaimed, nr_dirty, nr_writeback, 356 nr_congested, nr_immediate, nr_activate, nr_ref_keep, 357 nr_unmap_fail, priority, file), 358 359 TP_STRUCT__entry( 360 __field(int, nid) 361 __field(unsigned long, nr_scanned) 362 __field(unsigned long, nr_reclaimed) 363 __field(unsigned long, nr_dirty) 364 __field(unsigned long, nr_writeback) 365 __field(unsigned long, nr_congested) 366 __field(unsigned long, nr_immediate) 367 __field(unsigned long, nr_activate) 368 __field(unsigned long, nr_ref_keep) 369 __field(unsigned long, nr_unmap_fail) 370 __field(int, priority) 371 __field(int, reclaim_flags) 372 ), 373 374 TP_fast_assign( 375 __entry->nid = nid; 376 __entry->nr_scanned = nr_scanned; 377 __entry->nr_reclaimed = nr_reclaimed; 378 __entry->nr_dirty = nr_dirty; 379 __entry->nr_writeback = nr_writeback; 380 __entry->nr_congested = nr_congested; 381 __entry->nr_immediate = nr_immediate; 382 __entry->nr_activate = nr_activate; 383 __entry->nr_ref_keep = nr_ref_keep; 384 __entry->nr_unmap_fail = nr_unmap_fail; 385 __entry->priority = priority; 386 __entry->reclaim_flags = trace_shrink_flags(file); 387 ), 388 389 TP_printk("nid=%d nr_scanned=%ld nr_reclaimed=%ld nr_dirty=%ld nr_writeback=%ld nr_congested=%ld nr_immediate=%ld nr_activate=%ld nr_ref_keep=%ld nr_unmap_fail=%ld priority=%d flags=%s", 390 __entry->nid, 391 __entry->nr_scanned, __entry->nr_reclaimed, 392 __entry->nr_dirty, __entry->nr_writeback, 393 __entry->nr_congested, __entry->nr_immediate, 394 __entry->nr_activate, __entry->nr_ref_keep, 395 __entry->nr_unmap_fail, __entry->priority, 396 show_reclaim_flags(__entry->reclaim_flags)) 397 ); 398 399 TRACE_EVENT(mm_vmscan_lru_shrink_active, 400 401 TP_PROTO(int nid, unsigned long nr_taken, 402 unsigned long nr_active, unsigned long nr_deactivated, 403 unsigned long nr_referenced, int priority, int file), 404 405 TP_ARGS(nid, nr_taken, nr_active, nr_deactivated, nr_referenced, priority, file), 406 407 TP_STRUCT__entry( 408 __field(int, nid) 409 __field(unsigned long, nr_taken) 410 __field(unsigned long, nr_active) 411 __field(unsigned long, nr_deactivated) 412 __field(unsigned long, nr_referenced) 413 __field(int, priority) 414 __field(int, reclaim_flags) 415 ), 416 417 TP_fast_assign( 418 __entry->nid = nid; 419 __entry->nr_taken = nr_taken; 420 __entry->nr_active = nr_active; 421 __entry->nr_deactivated = nr_deactivated; 422 __entry->nr_referenced = nr_referenced; 423 __entry->priority = priority; 424 __entry->reclaim_flags = trace_shrink_flags(file); 425 ), 426 427 TP_printk("nid=%d nr_taken=%ld nr_active=%ld nr_deactivated=%ld nr_referenced=%ld priority=%d flags=%s", 428 __entry->nid, 429 __entry->nr_taken, 430 __entry->nr_active, __entry->nr_deactivated, __entry->nr_referenced, 431 __entry->priority, 432 show_reclaim_flags(__entry->reclaim_flags)) 433 ); 434 435 TRACE_EVENT(mm_vmscan_inactive_list_is_low, 436 437 TP_PROTO(int nid, int reclaim_idx, 438 unsigned long total_inactive, unsigned long inactive, 439 unsigned long total_active, unsigned long active, 440 unsigned long ratio, int file), 441 442 TP_ARGS(nid, reclaim_idx, total_inactive, inactive, total_active, active, ratio, file), 443 444 TP_STRUCT__entry( 445 __field(int, nid) 446 __field(int, reclaim_idx) 447 __field(unsigned long, total_inactive) 448 __field(unsigned long, inactive) 449 __field(unsigned long, total_active) 450 __field(unsigned long, active) 451 __field(unsigned long, ratio) 452 __field(int, reclaim_flags) 453 ), 454 455 TP_fast_assign( 456 __entry->nid = nid; 457 __entry->reclaim_idx = reclaim_idx; 458 __entry->total_inactive = total_inactive; 459 __entry->inactive = inactive; 460 __entry->total_active = total_active; 461 __entry->active = active; 462 __entry->ratio = ratio; 463 __entry->reclaim_flags = trace_shrink_flags(file) & RECLAIM_WB_LRU; 464 ), 465 466 TP_printk("nid=%d reclaim_idx=%d total_inactive=%ld inactive=%ld total_active=%ld active=%ld ratio=%ld flags=%s", 467 __entry->nid, 468 __entry->reclaim_idx, 469 __entry->total_inactive, __entry->inactive, 470 __entry->total_active, __entry->active, 471 __entry->ratio, 472 show_reclaim_flags(__entry->reclaim_flags)) 473 ); 474 #endif /* _TRACE_VMSCAN_H */ 475 476 /* This part must be outside protection */ 477 #include <trace/define_trace.h> 478