Module Name: src Committed By: mrg Date: Mon Dec 4 03:05:24 UTC 2017
Modified Files: src/sys/kern: subr_pool.c Log Message: properly account PR_RECURSIVE pools like vmstat does. To generate a diff of this commit: cvs rdiff -u -r1.217 -r1.218 src/sys/kern/subr_pool.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_pool.c diff -u src/sys/kern/subr_pool.c:1.217 src/sys/kern/subr_pool.c:1.218 --- src/sys/kern/subr_pool.c:1.217 Sat Dec 2 08:15:42 2017 +++ src/sys/kern/subr_pool.c Mon Dec 4 03:05:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.217 2017/12/02 08:15:42 mrg Exp $ */ +/* $NetBSD: subr_pool.c,v 1.218 2017/12/04 03:05:24 mrg Exp $ */ /*- * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015 @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.217 2017/12/02 08:15:42 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.218 2017/12/04 03:05:24 mrg Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1459,18 +1459,19 @@ int pool_totalpages(void) { struct pool *pp; - int total = 0; + uint64_t total = 0; mutex_enter(&pool_head_lock); - TAILQ_FOREACH(pp, &pool_head, pr_poollist) - /* - * XXXMRG - if ((pp->pr_roflags & PR_RECURSIVE) == 0) - */ - total += pp->pr_npages; + TAILQ_FOREACH(pp, &pool_head, pr_poollist) { + uint64_t bytes = pp->pr_npages * pp->pr_alloc->pa_pagesz; + + if ((pp->pr_roflags & PR_RECURSIVE) != 0) + bytes -= (pp->pr_nout * pp->pr_size); + total += bytes; + } mutex_exit(&pool_head_lock); - return total; + return atop(total); } /*