Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vmstat fix the kvm version of counting pool pages fo...



details:   https://anonhg.NetBSD.org/src/rev/07f349fc979c
branches:  trunk
changeset: 828232:07f349fc979c
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Dec 03 21:09:01 2017 +0000

description:
fix the kvm version of counting pool pages for vmstat -s.

diffstat:

 usr.bin/vmstat/vmstat.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (50 lines):

diff -r d41078b4a437 -r 07f349fc979c usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Sun Dec 03 19:07:10 2017 +0000
+++ b/usr.bin/vmstat/vmstat.c   Sun Dec 03 21:09:01 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.221 2017/12/02 08:15:43 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.222 2017/12/03 21:09:01 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.221 2017/12/02 08:15:43 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.222 2017/12/03 21:09:01 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -893,8 +893,10 @@
        } else {
                struct uvmexp uvmexp_kernel;
                struct pool pool, *pp = &pool;
+               struct pool_allocator pa;
                TAILQ_HEAD(,pool) pool_head;
                void *addr;
+               uint64_t bytes;
 
                kread(namelist, X_UVMEXP, &uvmexp_kernel, sizeof(uvmexp_kernel));
 #define COPY(field) uvmexp.field = uvmexp_kernel.field
@@ -963,13 +965,15 @@
 #undef COPY
                kread(namelist, X_POOLHEAD, &pool_head, sizeof(pool_head));
                addr = TAILQ_FIRST(&pool_head);
+               uvmexp.poolpages = 0;
                for (; addr != NULL; addr = TAILQ_NEXT(pp, pr_poollist)) {
                        deref_kptr(addr, pp, sizeof(*pp), "pool chain trashed");
-                       /*
-                        * XXXMRG
-                       if ((pp->pr_roflags & PR_RECURSIVE) == 0)
-                        */
-                               uvmexp.poolpages += pp->pr_npages;
+                       deref_kptr(addr, &pa, sizeof(pa), "pool_allocator trashed");
+                        // XXX deref pr_alloc first
+                       bytes = pp->pr_npages * pa.pa_pagesz;
+                       if ((pp->pr_roflags & PR_RECURSIVE) != 0)
+                               bytes -= (pp->pr_nout * pp->pr_size);
+                       uvmexp.poolpages += bytes / uvmexp.pagesize;
                }
        }
 



Home | Main Index | Thread Index | Old Index