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