Index: sys/kern/subr_pool.c =================================================================== RCS file: /cvsroot/src/sys/kern/subr_pool.c,v retrieving revision 1.216 diff -p -u -r1.216 subr_pool.c --- sys/kern/subr_pool.c 14 Nov 2017 15:02:06 -0000 1.216 +++ sys/kern/subr_pool.c 2 Dec 2017 00:24:10 -0000 @@ -1453,6 +1453,23 @@ pool_drain(struct pool **ppp) } /* + * Calculate the total number of pages consumed by pools. + */ +int +pool_totalpages(void) +{ + struct pool *pp; + int total = 0; + + mutex_enter(&pool_head_lock); + TAILQ_FOREACH(pp, &pool_head, pr_poollist) + total += pp->pr_npages; + mutex_exit(&pool_head_lock); + + return total; +} + +/* * Diagnostic helpers. */ Index: sys/uvm/uvm_extern.h =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_extern.h,v retrieving revision 1.206 diff -p -u -r1.206 uvm_extern.h --- sys/uvm/uvm_extern.h 20 May 2017 07:27:15 -0000 1.206 +++ sys/uvm/uvm_extern.h 2 Dec 2017 00:24:10 -0000 @@ -408,6 +408,8 @@ struct uvmexp { int pdreanon; /* anon pages reactivated due to thresholds */ int pdrefile; /* file pages reactivated due to thresholds */ int pdreexec; /* executable pages reactivated due to thresholds */ + + int bootpages; /* number of pages stolen at boot */ }; /* @@ -493,6 +495,8 @@ struct uvmexp_sysctl { int64_t colorhit; int64_t colormiss; int64_t ncolors; + int64_t bootpages; + int64_t poolpages; }; #ifdef _KERNEL Index: sys/uvm/uvm_meter.c =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_meter.c,v retrieving revision 1.66 diff -p -u -r1.66 uvm_meter.c --- sys/uvm/uvm_meter.c 2 Jul 2017 16:41:33 -0000 1.66 +++ sys/uvm/uvm_meter.c 2 Dec 2017 00:24:10 -0000 @@ -177,6 +177,8 @@ sysctl_vm_uvmexp2(SYSCTLFN_ARGS) u.colorhit = uvmexp.colorhit; u.colormiss = uvmexp.colormiss; u.ncolors = uvmexp.ncolors; + u.bootpages = uvmexp.bootpages; + u.poolpages = pool_totalpages(); node = *rnode; node.sysctl_data = &u; Index: sys/uvm/uvm_page.c =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_page.c,v retrieving revision 1.194 diff -p -u -r1.194 uvm_page.c --- sys/uvm/uvm_page.c 28 Oct 2017 00:37:13 -0000 1.194 +++ sys/uvm/uvm_page.c 2 Dec 2017 00:24:10 -0000 @@ -538,6 +538,7 @@ uvm_pageboot_alloc(vsize_t size) /* round to page size */ size = round_page(size); + uvmexp.bootpages += atop(size); #if defined(PMAP_STEAL_MEMORY) Index: sys/uvm/uvm_stat.c =================================================================== RCS file: /cvsroot/src/sys/uvm/uvm_stat.c,v retrieving revision 1.38 diff -p -u -r1.38 uvm_stat.c --- sys/uvm/uvm_stat.c 1 Dec 2016 01:59:17 -0000 1.38 +++ sys/uvm/uvm_stat.c 2 Dec 2017 00:24:10 -0000 @@ -46,6 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v #ifdef DDB +#include + /* * uvmexp_print: ddb hook to print interesting uvm counters */ @@ -54,10 +56,12 @@ uvmexp_print(void (*pr)(const char *, .. __attribute__((__format__(__printf__,1,2)))) { int active, inactive; + int poolpages; CPU_INFO_ITERATOR cii; struct cpu_info *ci; uvm_estimatepageable(&active, &inactive); + poolpages = pool_totalpages(); (*pr)("Current UVM status:\n"); (*pr)(" pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d, ncolors=%d\n", @@ -72,6 +76,8 @@ uvmexp_print(void (*pr)(const char *, .. uvmexp.freemin, uvmexp.freetarg, uvmexp.wiredmax); (*pr)(" resv-pg=%d, resv-kernel=%d, zeropages=%d\n", uvmexp.reserve_pagedaemon, uvmexp.reserve_kernel, uvmexp.zeropages); + (*pr)(" bootpages=%d, poolpages=%d\n", + uvmexp.bootpages, poolpages); for (CPU_INFO_FOREACH(cii, ci)) { (*pr)(" cpu%u:\n", cpu_index(ci)); Index: sys/sys/pool.h =================================================================== RCS file: /cvsroot/src/sys/sys/pool.h,v retrieving revision 1.80 diff -p -u -r1.80 pool.h --- sys/sys/pool.h 28 Oct 2017 19:19:10 -0000 1.80 +++ sys/sys/pool.h 2 Dec 2017 00:24:10 -0000 @@ -307,6 +307,7 @@ void pool_setlowat(struct pool *, int); void pool_sethiwat(struct pool *, int); void pool_sethardlimit(struct pool *, int, const char *, int); bool pool_drain(struct pool **); +int pool_totalpages(void); /* * Debugging and diagnostic aides. Index: usr.bin/vmstat/vmstat.c =================================================================== RCS file: /cvsroot/src/usr.bin/vmstat/vmstat.c,v retrieving revision 1.220 diff -p -u -r1.220 vmstat.c --- usr.bin/vmstat/vmstat.c 3 Nov 2017 22:45:14 -0000 1.220 +++ usr.bin/vmstat/vmstat.c 2 Dec 2017 00:24:10 -0000 @@ -892,6 +892,10 @@ dosum(void) warn("sysctl vm.uvmexp2 failed"); } else { struct uvmexp uvmexp_kernel; + struct pool pool, *pp = &pool; + TAILQ_HEAD(,pool) pool_head; + void *addr; + kread(namelist, X_UVMEXP, &uvmexp_kernel, sizeof(uvmexp_kernel)); #define COPY(field) uvmexp.field = uvmexp_kernel.field COPY(pagesize); @@ -955,7 +959,15 @@ dosum(void) COPY(pdbusy); COPY(pdpending); COPY(pddeact); + COPY(bootpages); #undef COPY + kread(namelist, X_POOLHEAD, &pool_head, sizeof(pool_head)); + addr = TAILQ_FIRST(&pool_head); + for (; addr != NULL; addr = TAILQ_NEXT(pp, pr_poollist)) { + deref_kptr(addr, pp, sizeof(*pp), "pool chain trashed"); + if ((pp->pr_roflags & PR_RECURSIVE) == 0) + uvmexp.poolpages += pp->pr_npages; + } } @@ -976,6 +988,8 @@ dosum(void) (void)printf("%9" PRIu64 " reserve pagedaemon pages\n", uvmexp.reserve_pagedaemon); (void)printf("%9" PRIu64 " reserve kernel pages\n", uvmexp.reserve_kernel); + (void)printf("%9" PRIu64 " boot kernel pages\n", uvmexp.bootpages); + (void)printf("%9" PRIu64 " kernel pool pages\n", uvmexp.poolpages); (void)printf("%9" PRIu64 " anonymous pages\n", uvmexp.anonpages); (void)printf("%9" PRIu64 " cached file pages\n", uvmexp.filepages); (void)printf("%9" PRIu64 " cached executable pages\n", uvmexp.execpages); @@ -2251,9 +2265,9 @@ hist_traverse_sysctl(int todo, const cha /* * Actually dump the history buffer at the specified KVA. */ - void +void hist_dodump_sysctl(int mib[], unsigned int miblen) - { +{ struct sysctl_history *hist; struct timeval tv; struct sysctl_history_event *e;