diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-11-19 18:35:17 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-11-19 18:35:17 +0000 |
commit | 0ae08084bdeee734850317c2723d814a0ac8bad1 (patch) | |
tree | e0033192617f7d77a5ca4c81a628b41162f9587a | |
parent | 7d02c14675c111c2f4359f11c604d837f3538ab4 (diff) |
Make KERN_CPTIME return an avarage number of ticks across all CPUs
tedu agreed with an idea, tested by Luis Useche and me; ok deraadt
-rw-r--r-- | lib/libc/gen/sysctl.3 | 7 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 5 | ||||
-rw-r--r-- | usr.bin/systat/vmstat.c | 13 | ||||
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 10 |
4 files changed, 10 insertions, 25 deletions
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index 9097587c8a9..8a9bf0428de 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sysctl.3,v 1.200 2010/10/11 08:26:40 claudio Exp $ +.\" $OpenBSD: sysctl.3,v 1.201 2010/11/19 18:35:16 mikeb Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: October 11 2010 $ +.Dd $Mdocdate: November 19 2010 $ .Dt SYSCTL 3 .Os .Sh NAME @@ -511,8 +511,7 @@ The console device. An array of longs of size .Li CPUSTATES is returned, containing statistics about the number of ticks spent by -the system among all processors in interrupt processing, -user processes +the system in interrupt processing, user processes .Po .Xr nice 1 or normal diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7ebac0128e6..0ebcf20cbeb 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.194 2010/11/02 09:36:09 dlg Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.195 2010/11/19 18:35:16 mikeb Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -469,6 +469,9 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, cp_time[i] += ci->ci_schedstate.spc_cp_time[i]; } + for (i = 0; i < CPUSTATES; i++) + cp_time[i] /= ncpus; + return (sysctl_rdstruct(oldp, oldlenp, newp, &cp_time, sizeof(cp_time))); } diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index 47ed8641f75..a7025edab5c 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.72 2009/10/27 23:59:44 deraadt Exp $ */ +/* $OpenBSD: vmstat.c,v 1.73 2010/11/19 18:35:16 mikeb Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -159,8 +159,6 @@ field_view views_vm[] = { {NULL, NULL, 0, NULL} }; -int ncpu = 1; - int initvmstat(void) { @@ -168,13 +166,7 @@ initvmstat(void) int mib[4], i; size_t size; - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - size = sizeof(ncpu); - if (sysctl(mib, 2, &ncpu, &size, NULL, 0) < 0) - return (-1); - - hertz = stathz ? stathz : hz; + hertz = stathz; if (!dkinit(1)) return(0); @@ -343,7 +335,6 @@ showkre(void) } failcnt = 0; etime /= hertz; - etime /= ncpu; inttotal = 0; for (i = 0; i < nintr; i++) { if (s.intrcnt[i] == 0) diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index beb62411da4..5d4951b4998 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -1,5 +1,5 @@ /* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */ -/* $OpenBSD: vmstat.c,v 1.117 2010/08/01 02:51:03 chl Exp $ */ +/* $OpenBSD: vmstat.c,v 1.118 2010/11/19 18:35:16 mikeb Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -128,8 +128,6 @@ extern char *__progname; int verbose = 0; int zflag = 0; -int ncpu; - int main(int argc, char *argv[]) { @@ -211,11 +209,6 @@ main(int argc, char *argv[]) } } - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - size = sizeof(ncpu); - (void) sysctl(mib, 2, &ncpu, &size, NULL, 0); - if (todo & VMSTAT) { struct winsize winsize; @@ -649,7 +642,6 @@ dkstats(void) if (etime == 0) etime = 1; etime /= hz; - etime /= ncpu; for (dn = 0; dn < dk_ndrive; ++dn) { if (!dk_select[dn]) continue; |