Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src add two new members to uvmexp_sysctl{}: bootpages and poolp...
details: https://anonhg.NetBSD.org/src/rev/7d8f10748ad5
branches: trunk
changeset: 828203:7d8f10748ad5
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Dec 02 08:15:42 2017 +0000
description:
add two new members to uvmexp_sysctl{}: bootpages and poolpages.
bootpages is set to the pages allocated via uvm_pageboot_alloc().
poolpages is calculated from the list of pools nr_pages members.
this brings us closer to having a valid total of pages known by
the system, vs actual pages originally managed.
XXX: poolpages needs some handling for PR_RECURSIVE pools still.
diffstat:
sys/kern/subr_pool.c | 25 +++++++++++++++++++++++--
sys/sys/pool.h | 3 ++-
sys/uvm/uvm_extern.h | 6 +++++-
sys/uvm/uvm_meter.c | 6 ++++--
sys/uvm/uvm_page.c | 5 +++--
sys/uvm/uvm_stat.c | 10 ++++++++--
usr.bin/vmstat/vmstat.c | 25 +++++++++++++++++++++----
7 files changed, 66 insertions(+), 14 deletions(-)
diffs (261 lines):
diff -r 63b543342f97 -r 7d8f10748ad5 sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c Sat Dec 02 01:36:38 2017 +0000
+++ b/sys/kern/subr_pool.c Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pool.c,v 1.216 2017/11/14 15:02:06 christos Exp $ */
+/* $NetBSD: subr_pool.c,v 1.217 2017/12/02 08:15:42 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.216 2017/11/14 15:02:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.217 2017/12/02 08:15:42 mrg Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1453,6 +1453,27 @@
}
/*
+ * 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)
+ /*
+ * XXXMRG
+ if ((pp->pr_roflags & PR_RECURSIVE) == 0)
+ */
+ total += pp->pr_npages;
+ mutex_exit(&pool_head_lock);
+
+ return total;
+}
+
+/*
* Diagnostic helpers.
*/
diff -r 63b543342f97 -r 7d8f10748ad5 sys/sys/pool.h
--- a/sys/sys/pool.h Sat Dec 02 01:36:38 2017 +0000
+++ b/sys/sys/pool.h Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pool.h,v 1.80 2017/10/28 19:19:10 riastradh Exp $ */
+/* $NetBSD: pool.h,v 1.81 2017/12/02 08:15:43 mrg Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2000, 2007 The NetBSD Foundation, Inc.
@@ -307,6 +307,7 @@
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.
diff -r 63b543342f97 -r 7d8f10748ad5 sys/uvm/uvm_extern.h
--- a/sys/uvm/uvm_extern.h Sat Dec 02 01:36:38 2017 +0000
+++ b/sys/uvm/uvm_extern.h Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_extern.h,v 1.206 2017/05/20 07:27:15 chs Exp $ */
+/* $NetBSD: uvm_extern.h,v 1.207 2017/12/02 08:15:43 mrg Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -408,6 +408,8 @@
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 @@
int64_t colorhit;
int64_t colormiss;
int64_t ncolors;
+ int64_t bootpages;
+ int64_t poolpages;
};
#ifdef _KERNEL
diff -r 63b543342f97 -r 7d8f10748ad5 sys/uvm/uvm_meter.c
--- a/sys/uvm/uvm_meter.c Sat Dec 02 01:36:38 2017 +0000
+++ b/sys/uvm/uvm_meter.c Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_meter.c,v 1.66 2017/07/02 16:41:33 joerg Exp $ */
+/* $NetBSD: uvm_meter.c,v 1.67 2017/12/02 08:15:43 mrg Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_meter.c,v 1.66 2017/07/02 16:41:33 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_meter.c,v 1.67 2017/12/02 08:15:43 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -177,6 +177,8 @@
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;
diff -r 63b543342f97 -r 7d8f10748ad5 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c Sat Dec 02 01:36:38 2017 +0000
+++ b/sys/uvm/uvm_page.c Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_page.c,v 1.194 2017/10/28 00:37:13 pgoyette Exp $ */
+/* $NetBSD: uvm_page.c,v 1.195 2017/12/02 08:15:43 mrg Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.194 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.195 2017/12/02 08:15:43 mrg Exp $");
#include "opt_ddb.h"
#include "opt_uvm.h"
@@ -538,6 +538,7 @@
/* round to page size */
size = round_page(size);
+ uvmexp.bootpages += atop(size);
#if defined(PMAP_STEAL_MEMORY)
diff -r 63b543342f97 -r 7d8f10748ad5 sys/uvm/uvm_stat.c
--- a/sys/uvm/uvm_stat.c Sat Dec 02 01:36:38 2017 +0000
+++ b/sys/uvm/uvm_stat.c Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_stat.c,v 1.38 2016/12/01 01:59:17 mrg Exp $ */
+/* $NetBSD: uvm_stat.c,v 1.39 2017/12/02 08:15:43 mrg Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.38 2016/12/01 01:59:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.39 2017/12/02 08:15:43 mrg Exp $");
#include "opt_readahead.h"
#include "opt_ddb.h"
@@ -46,6 +46,8 @@
#ifdef DDB
+#include <sys/pool.h>
+
/*
* uvmexp_print: ddb hook to print interesting uvm counters
*/
@@ -54,10 +56,12 @@
__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.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));
diff -r 63b543342f97 -r 7d8f10748ad5 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Sat Dec 02 01:36:38 2017 +0000
+++ b/usr.bin/vmstat/vmstat.c Sat Dec 02 08:15:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.220 2017/11/03 22:45:14 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.221 2017/12/02 08:15:43 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.220 2017/11/03 22:45:14 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.221 2017/12/02 08:15:43 mrg Exp $");
#endif
#endif /* not lint */
@@ -892,6 +892,10 @@
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,18 @@
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");
+ /*
+ * XXXMRG
+ if ((pp->pr_roflags & PR_RECURSIVE) == 0)
+ */
+ uvmexp.poolpages += pp->pr_npages;
+ }
}
@@ -976,6 +991,8 @@
(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 +2268,9 @@
/*
* 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;
Home |
Main Index |
Thread Index |
Old Index