Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/vmstat Convert the remaining uvmexp users to the sys...
details: https://anonhg.NetBSD.org/src/rev/9ddd46c5def2
branches: trunk
changeset: 796448:9ddd46c5def2
user: joerg <joerg%NetBSD.org@localhost>
date: Tue Jun 03 21:41:56 2014 +0000
description:
Convert the remaining uvmexp users to the sysctl as default source.
diffstat:
usr.bin/vmstat/Makefile | 4 ++--
usr.bin/vmstat/vmstat.c | 41 +++++++++++++++++++++++++++++++++--------
2 files changed, 35 insertions(+), 10 deletions(-)
diffs (115 lines):
diff -r 47e3966970b5 -r 9ddd46c5def2 usr.bin/vmstat/Makefile
--- a/usr.bin/vmstat/Makefile Tue Jun 03 21:31:54 2014 +0000
+++ b/usr.bin/vmstat/Makefile Tue Jun 03 21:41:56 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2014/06/03 21:31:54 joerg Exp $
+# $NetBSD: Makefile,v 1.32 2014/06/03 21:41:56 joerg Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
.include <bsd.own.mk>
@@ -14,6 +14,6 @@
BINMODE=2555
CWARNFLAGS.clang+= -Wno-format-extra-args
-COPTS.vmstat.c += -Wno-format-nonliteral -Wno-shadow
+COPTS.vmstat.c += -Wno-format-nonliteral
.include <bsd.prog.mk>
diff -r 47e3966970b5 -r 9ddd46c5def2 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Tue Jun 03 21:31:54 2014 +0000
+++ b/usr.bin/vmstat/vmstat.c Tue Jun 03 21:41:56 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.195 2014/06/03 21:31:54 joerg Exp $ */
+/* $NetBSD: vmstat.c,v 1.196 2014/06/03 21:41:56 joerg 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.195 2014/06/03 21:31:54 joerg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.196 2014/06/03 21:41:56 joerg Exp $");
#endif
#endif /* not lint */
@@ -250,7 +250,7 @@
uint64_t nsoft;
} cpucounter, ocpucounter;
-struct uvmexp uvmexp, ouvmexp;
+struct uvmexp_sysctl uvmexp, ouvmexp;
int ndrives;
int winlines = 20;
@@ -738,14 +738,22 @@
cpureadstats();
drvreadstats();
tkreadstats();
- kread(namelist, X_UVMEXP, &uvmexp, sizeof(uvmexp));
if (memf != NULL) {
+ struct uvmexp uvmexp_kernel;
/*
* XXX Can't do this if we're reading a crash
* XXX dump because they're lazily-calculated.
*/
warnx("Unable to get vmtotals from crash dump.");
(void)memset(&total, 0, sizeof(total));
+ kread(namelist, X_UVMEXP, &uvmexp_kernel, sizeof(uvmexp_kernel));
+#define COPY(field) uvmexp.field = uvmexp_kernel.field
+ COPY(pdreact);
+ COPY(pageins);
+ COPY(pgswapout);
+ COPY(pdfreed);
+ COPY(pdscans);
+#undef COPY
} else {
size = sizeof(total);
if (sysctl(vmmeter_mib, __arraycount(vmmeter_mib),
@@ -753,6 +761,10 @@
warn("Can't get vmtotals");
(void)memset(&total, 0, sizeof(total));
}
+ size = sizeof(uvmexp);
+ if (sysctl(uvmexp2_mib, __arraycount(uvmexp2_mib), &uvmexp,
+ &size, NULL, 0) == -1)
+ warn("sysctl vm.uvmexp2 failed");
}
cpucounters(&cpucounter);
ovflw = 0;
@@ -850,7 +862,6 @@
{
struct nchstats_sysctl nch_stats;
uint64_t nchtotal;
- struct uvmexp_sysctl uvmexp;
size_t ssize;
int active_kernel;
struct cpu_counter cc;
@@ -1081,10 +1092,24 @@
doforkst(void)
{
kread(namelist, X_UVMEXP, &uvmexp, sizeof(uvmexp));
+ if (memf != NULL) {
+ struct uvmexp uvmexp_kernel;
+ kread(namelist, X_UVMEXP, &uvmexp_kernel, sizeof(uvmexp_kernel));
+#define COPY(field) uvmexp.field = uvmexp_kernel.field
+ COPY(forks);
+ COPY(forks_ppwait);
+ COPY(forks_sharevm);
+#undef COPY
+ } else {
+ size_t size = sizeof(uvmexp);
+ if (sysctl(uvmexp2_mib, __arraycount(uvmexp2_mib), &uvmexp,
+ &size, NULL, 0) == -1)
+ warn("sysctl vm.uvmexp2 failed");
+ }
- (void)printf("%u forks total\n", uvmexp.forks);
- (void)printf("%u forks blocked parent\n", uvmexp.forks_ppwait);
- (void)printf("%u forks shared address space with parent\n",
+ (void)printf("%" PRIu64 " forks total\n", uvmexp.forks);
+ (void)printf("%" PRIu64 " forks blocked parent\n", uvmexp.forks_ppwait);
+ (void)printf("%" PRIu64 " forks shared address space with parent\n",
uvmexp.forks_sharevm);
}
Home |
Main Index |
Thread Index |
Old Index