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