#!/usr/sbin/dtrace -qCs #pragma D option switchrate=10hz /* pages to MB */ #define MB(x) (x * 4096 / 1024 / 1024) BEGIN { printf("Page scanner monitor started:\n\n"); printf(" Physical memory: %8d (%6d MiB)\n", `physmem, MB(`physmem)); printf(" Lots free: %8d (%6d MiB)\n", `lotsfree, MB(`lotsfree)); printf(" Desired free: %8d (%6d MiB)\n", `desfree, MB(`desfree)); printf(" Minimum free: %8d (%6d MiB)\n", `minfree, MB(`minfree)); printf(" Throttle free: %8d (%6d MiB)\n", `throttlefree, MB(`throttlefree)); printf(" Reserve pool: %8d (%6d MiB)\n", `pageout_reserve, MB(`pageout_reserve)); printf(" Current free: %8d (%6d MiB)\n", `freemem, MB(`freemem)); printf(" Sample count: %8d (rate %d / %d MiB/s)\n", `pageout_sample_pages, `pageout_rate, MB(`pageout_rate)); printf(" Hand spread: %8d (%6d MiB) - scanners: %d\n", `handspreadpages, MB(`handspreadpages), `n_page_scanners); buffer = `total_pages / `n_page_scanners - `handspreadpages; printf(" Intra-pair buffer: %8d (%6d MiB)\n", buffer, MB(buffer)); printf(" Fast scan: %8d (%6d MiB)\n", `fastscan, MB(`fastscan)); printf(" Slow scan: %8d (%6d MiB)\n", `slowscan, MB(`slowscan)); } /* * DTRACE_PROBE4(pageout__start, uint_t, inst, pgcnt_t, nscan_limit, * page_t *, backhand, page_t *, fronthand); */ pageout-start { self->inst = arg0; self->start = timestamp; self->laps = 0; self->freed = 0; printf("start(%u/%u) %4dMiB scanning %7d (%5d MiB) %p - %p\n", self->inst + 1, `n_page_scanners, MB(`freemem), arg1, MB(arg1), arg2, arg3); } /* * DTRACE_PROBE4(pageout__reset, uint_t, inst, * pgcnt_t, regionstart, pgcnt_t, regionend, * pgcnt_t, fronthand); */ pageout-reset { printf("reset(%u/%u) %p - %p (fronthand %p)\n", arg0 + 1, `n_page_scanners, arg1, arg2, arg3); } /* pageout-timeout { printf("~~~ Timeout instance %u\n", arg0); } */ /* * DTRACE_PROBE1(pageout__wrap__front, uint_t, inst); */ pageout-hand-wrap /self->start/ { self->laps = arg1; } pageout-free /self->start/ { self->freed++; } /* * DTRACE_PROBE4(pageout__end, uint_t, inst, uint_t, laps, * pgcnt_t, nscan_cnt, pgcnt_t, pcount) */ pageout-end /self->start/ { delta = timestamp - self->start; pct = delta * 100 / `pageout_nsec; printf( "end(%u/%u) %4dMiB scanned %8d (%4d MiB) %3d%%@%d free %5d (%4d MiB) %u\n", arg0 + 1, `n_page_scanners, MB(`freemem), arg2, MB(arg2), pct, self->laps, self->freed, MB(self->freed), `push_list_size); self->start = 0; } /* schedpage-wake-low,schedpage-wake-zone,pageout-push { printf("~~~ %6d (%8d MiB) -- %s\n", `freemem, MB(`freemem), probename); } */ /* fbt::schedpaging:return /self->pageout_nsec != `pageout_nsec/ { if (self->pageout_nsec != `pageout_nsec) printf("~~~ SCHEDPAGING %u; desscan %u fastscan %u pageout_nsec %u\n", tid, `desscan, `fastscan, `pageout_nsec); self->pageout_nsec = `pageout_nsec } */ tick-10s { printf("------------------ freemem %8d (%6d MiB)\n", `freemem, MB(`freemem)); }