Source-Changes-HG archive

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

[src/netbsd-1-6]: src/usr.bin/vmstat Pull up revision 1.101 (requested by som...



details:   https://anonhg.NetBSD.org/src/rev/1b6113333e37
branches:  netbsd-1-6
changeset: 528305:1b6113333e37
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Jun 30 05:47:55 2002 +0000

description:
Pull up revision 1.101 (requested by sommerfeld in ticket #406):
Since the KERN_CP_TIME sysctl reports total clock ticks across all
cpus and hz is measured in ticks per cpu, divide tick count by ncpu to
determine elapsed time since last sample.
Fixes I/O rate deflation observed on multiprocessors.

diffstat:

 usr.bin/vmstat/vmstat.c |  35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diffs (121 lines):

diff -r 83b81181a19b -r 1b6113333e37 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Sun Jun 30 05:47:44 2002 +0000
+++ b/usr.bin/vmstat/vmstat.c   Sun Jun 30 05:47:55 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.100 2002/03/13 11:02:11 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.100.2.1 2002/06/30 05:47:55 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.100 2002/03/13 11:02:11 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.100.2.1 2002/06/30 05:47:55 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -465,8 +465,8 @@
                                dohashstat(verbose, todo, hashname);
                                putchar('\n');
                        }
-               
-                       if (reps >= 0 && --reps <=0) 
+
+                       if (reps >= 0 && --reps <=0)
                                break;
                        sleep(interval);
                }
@@ -776,18 +776,13 @@
 void
 dkstats(void)
 {
-       int dn, state;
+       int dn;
        double etime;
 
        /* Calculate disk stat deltas. */
        dkswap();
-       etime = 0;
-       for (state = 0; state < CPUSTATES; ++state) {
-               etime += cur.cp_time[state];
-       }
-       if (etime == 0)
-               etime = 1;
-       etime /= hz;
+       etime = cur.cp_etime;
+
        for (dn = 0; dn < dk_ndrive; ++dn) {
                if (!dk_select[dn])
                        continue;
@@ -1204,7 +1199,7 @@
        int             hashsize;       /* nlist index for hash size */
        int             hashtbl;        /* nlist index for hash table */
        enum hashtype   type;           /* type of hash table */
-       size_t          offset;         /* offset of {LIST,TAILQ}_NEXT */ 
+       size_t          offset;         /* offset of {LIST,TAILQ}_NEXT */
 } khashes[] =
 {
        {
@@ -1250,7 +1245,7 @@
 
 void
 dohashstat(int verbose, int todo, const char *hashname)
-{ 
+{
        LIST_HEAD(, generic)    *hashtbl_list;
        TAILQ_HEAD(, generic)   *hashtbl_tailq;
        struct kernel_hash      *curhash;
@@ -1265,7 +1260,7 @@
        if (todo & HASHLIST) {
                printf("Supported hashes:\n");
                for (curhash = khashes; curhash->description; curhash++) {
-                       if (hashnl[curhash->hashsize].n_value == 0 || 
+                       if (hashnl[curhash->hashsize].n_value == 0 ||
                            hashnl[curhash->hashtbl].n_value == 0)
                                continue;
                        printf("\t%-16s%s\n",
@@ -1279,7 +1274,7 @@
                for (curhash = khashes; curhash->description; curhash++) {
                        if (strcmp(hashnl[curhash->hashsize].n_name + 1,
                            hashname) == 0 &&
-                           hashnl[curhash->hashsize].n_value != 0 && 
+                           hashnl[curhash->hashsize].n_value != 0 &&
                            hashnl[curhash->hashtbl].n_value != 0)
                                break;
                }
@@ -1297,7 +1292,7 @@
            "chain");
 
        for (curhash = khashes; curhash->description; curhash++) {
-               if (hashnl[curhash->hashsize].n_value == 0 || 
+               if (hashnl[curhash->hashsize].n_value == 0 ||
                    hashnl[curhash->hashtbl].n_value == 0)
                        continue;
                if (hashname != NULL &&
@@ -1316,13 +1311,13 @@
                        printf("%s %lu, %s %p, offset %ld, elemsize %llu\n",
                            hashnl[curhash->hashsize].n_name + 1, hashsize,
                            hashnl[curhash->hashtbl].n_name + 1, hashaddr,
-                           (long)curhash->offset, 
+                           (long)curhash->offset,
                            (unsigned long long)elemsize);
                thissize = hashsize * elemsize;
                if (thissize > hashbufsize) {
                        hashbufsize = thissize;
                        if ((hashbuf = realloc(hashbuf, hashbufsize)) == NULL)
-                               errx(1, "malloc hashbuf %llu", 
+                               errx(1, "malloc hashbuf %llu",
                                    (unsigned long long)hashbufsize);
                }
                deref_kptr(hashaddr, hashbuf, thissize,
@@ -1383,7 +1378,7 @@
 }
 
 /*
- * Dereference the kernel pointer `kptr' and fill in the local copy 
+ * Dereference the kernel pointer `kptr' and fill in the local copy
  * pointed to by `ptr'.  The storage space must be pre-allocated,
  * and the size of the copy passed in `len'.
  */



Home | Main Index | Thread Index | Old Index