Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/vmstat Use CPU statistics from uvmexp when possible.
details: https://anonhg.NetBSD.org/src/rev/acedff763860
branches: trunk
changeset: 329689:acedff763860
user: joerg <joerg%NetBSD.org@localhost>
date: Tue Jun 03 21:56:03 2014 +0000
description:
Use CPU statistics from uvmexp when possible.
diffstat:
usr.bin/vmstat/vmstat.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diffs (72 lines):
diff -r 750ef5b11be7 -r acedff763860 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c Tue Jun 03 21:45:41 2014 +0000
+++ b/usr.bin/vmstat/vmstat.c Tue Jun 03 21:56:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.197 2014/06/03 21:45:41 joerg Exp $ */
+/* $NetBSD: vmstat.c,v 1.198 2014/06/03 21:56:03 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.197 2014/06/03 21:45:41 joerg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.198 2014/06/03 21:56:03 joerg Exp $");
#endif
#endif /* not lint */
@@ -142,8 +142,6 @@
# include <sys/cpu.h>
#endif
-struct cpu_info **cpu_infos;
-
/*
* General namelist
*/
@@ -740,8 +738,6 @@
hz = clockinfo.hz;
}
- kread(namelist, X_CPU_INFOS, &cpu_infos, sizeof(cpu_infos));
-
for (hdrcnt = 1;;) {
if (!--hdrcnt)
printhdr();
@@ -989,7 +985,6 @@
(void)printf("%9" PRIu64 " swap pages in use\n", uvmexp.swpginuse);
(void)printf("%9" PRIu64 " swap allocations\n", uvmexp.nswget);
- kread(namelist, X_CPU_INFOS, &cpu_infos, sizeof(cpu_infos));
cpucounters(&cc);
(void)printf("%9" PRIu64 " total faults taken\n", cc.nfault);
@@ -1149,7 +1144,26 @@
void
cpucounters(struct cpu_counter *cc)
{
- struct cpu_info **slot = cpu_infos;
+ static struct cpu_info **cpu_infos;
+ static int initialised;
+ struct cpu_info **slot;
+
+ if (memf == NULL) {
+ cc->nintr = uvmexp.intrs;
+ cc->nsyscall = uvmexp.syscalls;
+ cc->nswtch = uvmexp.swtch;
+ cc->nfault = uvmexp.faults;
+ cc->ntrap = uvmexp.traps;
+ cc->nsoft = uvmexp.softs;
+ return;
+ }
+
+ if (!initialised) {
+ kread(namelist, X_CPU_INFOS, &cpu_infos, sizeof(cpu_infos));
+ initialised = 1;
+ }
+
+ slot = cpu_infos;
memset(cc, 0, sizeof(*cc));
Home |
Main Index |
Thread Index |
Old Index