Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/vmstat - replace -h uvmhist with -u uvmhist, and -H ...



details:   https://anonhg.NetBSD.org/src/rev/f9f2fab80512
branches:  trunk
changeset: 518206:f9f2fab80512
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Nov 26 07:40:01 2001 +0000

description:
- replace -h uvmhist with -u uvmhist, and -H with -U, since uvm history stuff
  isn't generally enabled by default, and i wanted -h for something else.
- implement -h, which displays statistics for various kernel hash tables
- add deref_kptr(), which does the hard work of kvm_read() et al
- various minor cleanups

diffstat:

 usr.bin/vmstat/vmstat.1 |   44 ++-
 usr.bin/vmstat/vmstat.c |  482 ++++++++++++++++++++++++++++++-----------------
 2 files changed, 336 insertions(+), 190 deletions(-)

diffs (truncated from 898 to 300 lines):

diff -r e228450081f9 -r f9f2fab80512 usr.bin/vmstat/vmstat.1
--- a/usr.bin/vmstat/vmstat.1   Mon Nov 26 06:51:12 2001 +0000
+++ b/usr.bin/vmstat/vmstat.1   Mon Nov 26 07:40:01 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: vmstat.1,v 1.2 2001/05/19 00:36:15 ross Exp $
+.\"    $NetBSD: vmstat.1,v 1.3 2001/11/26 07:40:01 lukem Exp $
 .\"
 .\" Copyright (c) 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -64,7 +64,7 @@
 .\"
 .\"    @(#)vmstat.8    8.1 (Berkeley) 6/6/93
 .\"
-.Dd February 12, 1998
+.Dd November 26, 2001
 .Dt VMSTAT 8
 .Os
 .Sh NAME
@@ -72,12 +72,22 @@
 .Nd report virtual memory statistics
 .Sh SYNOPSIS
 .Nm
-.Op Fl Hefilmsv
+.Op Fl efhilmsUv
+.Bk -words
 .Op Fl M Ar core
+.Ek
+.Bk -words
 .Op Fl N Ar system
+.Ek
+.Bk -words
 .Op Fl c Ar count
-.Op Fl h Ar histname
+.Ek
+.Bk -words
+.Op Fl u Ar histname
+.Ek
+.Bk -words
 .Op Fl w Ar wait
+.Ek
 .Op Ar disks
 .Sh DESCRIPTION
 .Nm
@@ -85,9 +95,7 @@
 disk, trap and cpu activity.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
-.It Fl H
-Dump all UVM histories.
+.Bl -tag -width xxxhistname
 .It Fl M Ar core
 Extract values associated with the name list from the specified core
 instead of the default
@@ -108,8 +116,8 @@
 Report the values of system event counters.
 .It Fl f
 Report fork statistics.
-.It Fl h Ar histname
-Dump the specified UVM history.
+.It Fl h
+Report hash table statistics.
 .It Fl i
 Report the values of system interrupt counters.
 .It Fl l
@@ -121,6 +129,10 @@
 Display the contents of the
 .Dv uvmexp
 structure. This contains various paging event and memory status counters.
+.It Fl u Ar histname
+Dump the specified UVM history.
+.It Fl U
+Dump all UVM histories.
 .It Fl v
 Print more verbose information.  When used with the
 .Fl i
@@ -218,7 +230,9 @@
 .El
 .El
 .Sh EXAMPLES
-The command ``vmstat -w 5'' will print what the system is doing every five
+The command
+.Dq Li vmstat -w 5
+will print what the system is doing every five
 seconds; this is a good choice of printing interval since this is how often
 some of the statistics are sampled in the system.
 Others vary every second and running the output for a while will make it
@@ -239,7 +253,9 @@
 .Xr iostat 8 ,
 .Xr pstat 8
 .Pp
-The sections starting with ``Interpreting system activity'' in
+The sections starting with
+.Dq Interpreting system activity
+in
 .%T Installing and Operating 4.3BSD .
 .Sh BUGS
 The
@@ -249,9 +265,9 @@
 options are only available with the default output.
 .Pp
 The
-.Fl H ,
-.Fl h ,
+.Fl l ,
+.Fl u ,
 and
-.Fl l
+.Fl U
 options are useful only if the system was compiled with support for UVM
 history.
diff -r e228450081f9 -r f9f2fab80512 usr.bin/vmstat/vmstat.c
--- a/usr.bin/vmstat/vmstat.c   Mon Nov 26 06:51:12 2001 +0000
+++ b/usr.bin/vmstat/vmstat.c   Mon Nov 26 07:40:01 2001 +0000
@@ -1,12 +1,13 @@
-/* $NetBSD: vmstat.c,v 1.86 2001/11/21 00:40:56 enami Exp $ */
+/* $NetBSD: vmstat.c,v 1.87 2001/11/26 07:40:01 lukem Exp $ */
 
 /*-
- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
+ * This code is derived from software contributed to The NetBSD Foundation by:
+ *     - Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ *       NASA Ames Research Center.
+ *     - Simon Burge and Luke Mewburn of Wasabi Systems, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -80,46 +81,64 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c   8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.86 2001/11/21 00:40:56 enami Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.87 2001/11/26 07:40:01 lukem Exp $");
 #endif
 #endif /* not lint */
 
 #define        __POOL_EXPOSE
 
 #include <sys/param.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/user.h>
+#include <sys/mount.h>
+#include <sys/uio.h>
+
+#include <sys/buf.h>
+#include <sys/device.h>
 #include <sys/dkstat.h>
-#include <sys/buf.h>
+#include <sys/ioctl.h>
+#include <sys/malloc.h>
 #include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/ioctl.h>
+#include <sys/pool.h>
+#include <sys/proc.h>
 #include <sys/sched.h>
+#include <sys/socket.h>
 #include <sys/sysctl.h>
-#include <sys/device.h>
-#include <sys/pool.h>
+#include <sys/time.h>
+#include <sys/user.h>
 
 #include <uvm/uvm_extern.h>
 #include <uvm/uvm_stat.h>
 
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+#include <ufs/ufs/inode.h>
+
+#include <nfs/rpcv2.h>
+#include <nfs/nfsproto.h>
+#include <nfs/nfsnode.h>
+
+#include <ctype.h>
 #include <err.h>
+#include <errno.h>
 #include <fcntl.h>
-#include <time.h>
+#include <kvm.h>
+#include <limits.h>
 #include <nlist.h>
-#include <kvm.h>
-#include <errno.h>
-#include <unistd.h>
+#undef n_hash
+#include <paths.h>
 #include <signal.h>
 #include <stdio.h>
-#include <ctype.h>
+#include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
-#include <paths.h>
-#include <limits.h>
+#include <time.h>
+#include <unistd.h>
+
 #include "dkstats.h"
 
-struct nlist namelist[] = {
+struct nlist namelist[] =
+{
 #define        X_BOOTTIME      0
        { "_boottime" },
 #define        X_HZ            1
@@ -146,7 +165,36 @@
        { "_pool_head" },
 #define        X_UVMEXP        12
        { "_uvmexp" },
-#define        X_END           13
+#define        X_NFSNODE       13
+       { "_nfsnodehash" },
+#define        X_NFSNODETBL    14
+       { "_nfsnodehashtbl" },
+#define        X_IHASH         15
+       { "_ihash" },
+#define        X_IHASHTBL      16
+       { "_ihashtbl" },
+#define        X_BUFHASH       17
+       { "_bufhash" },
+#define        X_BUFHASHTBL    18
+       { "_bufhashtbl" },
+#define        X_PIDHASH       19
+       { "_pidhash" },
+#define        X_PIDHASHTBL    20
+       { "_pidhashtbl" },
+#define        X_PGRPHASH      21
+       { "_pgrphash" },
+#define        X_PGRPHASHTBL   22
+       { "_pgrphashtbl" },
+#define        X_UIHASH        23
+       { "_uihash" },
+#define        X_UIHASHTBL     24
+       { "_uihashtbl" },
+#define        X_IFADDRHASH    25
+       { "_in_ifaddrhash" },
+#define        X_IFADDRHASHTBL 26
+       { "_in_ifaddrhashtbl" },
+
+#define        X_END           27
 #if defined(pc532)
 #define        X_IVT           (X_END)
        { "_ivt" },
@@ -154,6 +202,7 @@
        { "" },
 };
 
+
 struct uvmexp uvmexp, ouvmexp;
 int    ndrives;
 
@@ -161,18 +210,21 @@
 
 kvm_t *kd;
 
-#define        FORKSTAT        0x01
-#define        INTRSTAT        0x02
-#define        MEMSTAT         0x04
-#define        SUMSTAT         0x08
-#define        EVCNTSTAT       0x10
-#define        VMSTAT          0x20
-#define        HISTLIST        0x40
-#define        HISTDUMP        0x80
+#define        FORKSTAT        1<<0
+#define        INTRSTAT        1<<1
+#define        MEMSTAT         1<<2
+#define        SUMSTAT         1<<3
+#define        EVCNTSTAT       1<<4
+#define        VMSTAT          1<<5
+#define        HISTLIST        1<<6
+#define        HISTDUMP        1<<7
+#define        HASHSTAT        1<<8
 
 void   cpustats(void);
+void   deref_kptr(const void *, void *, size_t, const char *);
 void   dkstats(void);
 void   doevcnt(int verbose);
+void   dohashstat(int verbose);
 void   dointr(int verbose);
 void   domem(void);
 void   dopool(void);
@@ -211,7 +263,7 @@
        (void)setegid(getgid());
        memf = nlistf = NULL;
        interval = reps = todo = verbose = 0;
-       while ((c = getopt(argc, argv, "c:efh:HilM:mN:svw:")) != -1) {
+       while ((c = getopt(argc, argv, "c:efhilM:mN:suUvw:")) != -1) {
                switch (c) {
                case 'c':
                        reps = atoi(optarg);



Home | Main Index | Thread Index | Old Index