summaryrefslogtreecommitdiffstats
path: root/usr.bin/vmstat
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>1999-02-13 09:59:24 +0000
committerdillon <dillon@FreeBSD.org>1999-02-13 09:59:24 +0000
commit1ff9917e475c4eb1d9231e33318af8f554eaa59c (patch)
treef279eb6bead26e7f5d6a139e4a2711f39374daf0 /usr.bin/vmstat
parentb1eb7d827258f86dee0a24964971083ce0c036c5 (diff)
downloadFreeBSD-src-1ff9917e475c4eb1d9231e33318af8f554eaa59c.zip
FreeBSD-src-1ff9917e475c4eb1d9231e33318af8f554eaa59c.tar.gz
Add -z option to vmstat to dump data from the zone allocator
Diffstat (limited to 'usr.bin/vmstat')
-rw-r--r--usr.bin/vmstat/vmstat.86
-rw-r--r--usr.bin/vmstat/vmstat.c83
2 files changed, 77 insertions, 12 deletions
diff --git a/usr.bin/vmstat/vmstat.8 b/usr.bin/vmstat/vmstat.8
index 7b58608..20492ac 100644
--- a/usr.bin/vmstat/vmstat.8
+++ b/usr.bin/vmstat/vmstat.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)vmstat.8 8.1 (Berkeley) 6/6/93
-.\" $Id: vmstat.8,v 1.10 1998/09/15 08:16:43 gibbs Exp $
+.\" $Id: vmstat.8,v 1.11 1999/02/10 00:46:26 ken Exp $
.\"
.Dd June 6, 1996
.Dt VMSTAT 8
@@ -41,7 +41,7 @@
.Sh SYNOPSIS
.Nm vmstat
.\" .Op Fl fimst
-.Op Fl ims
+.Op Fl imzs
.Op Fl c Ar count
.Op Fl M Ar core
.Op Fl N Ar system
@@ -88,6 +88,8 @@ instead of the default
.It Fl m
Report on the usage of kernel dynamic memory listed first by size of
allocation and then by type of usage.
+.It Fl z
+Report on memory used by the kernel zone allocator, by zone.
.It Fl n
Change the maximum number of disks to display from the default of 2.
.It Fl p
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index d2b77b5..3dcd44c 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)vmstat.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
- "$Id: vmstat.c,v 1.29 1998/10/28 06:41:24 jdp Exp $";
+ "$Id: vmstat.c,v 1.31 1999/02/10 00:46:27 ken Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -60,6 +60,7 @@ static const char rcsid[] =
#include <sys/vmmeter.h>
#include <vm/vm_param.h>
+#include <vm/vm_zone.h>
#include <ctype.h>
#include <err.h>
@@ -101,20 +102,22 @@ struct nlist namelist[] = {
{ "_kmemstatistics" },
#define X_KMEMBUCKETS 11
{ "_bucket" },
+#define X_ZLIST 12
+ { "_zlist" },
#ifdef notyet
-#define X_DEFICIT 12
+#define X_DEFICIT 13
{ "_deficit" },
-#define X_FORKSTAT 13
+#define X_FORKSTAT 14
{ "_forkstat" },
-#define X_REC 14
+#define X_REC 15
{ "_rectime" },
-#define X_PGIN 15
+#define X_PGIN 16
{ "_pgintime" },
-#define X_XSTATS 16
+#define X_XSTATS 17
{ "_xstats" },
-#define X_END 17
+#define X_END 18
#else
-#define X_END 14
+#define X_END 13
#endif
#if defined(hp300) || defined(luna68k)
#define X_HPDINIT (X_END)
@@ -166,8 +169,9 @@ kvm_t *kd;
#define SUMSTAT 0x08
#define TIMESTAT 0x10
#define VMSTAT 0x20
+#define ZMEMSTAT 0x40
-void cpustats(), dointr(), domem(), dosum();
+void cpustats(), dointr(), domem(), dozmem(), dosum();
void dovmstat(), kread(), usage();
#ifdef notyet
void dotimes(), doforkst();
@@ -190,7 +194,7 @@ main(argc, argv)
memf = nlistf = NULL;
interval = reps = todo = 0;
maxshowdevs = 2;
- while ((c = getopt(argc, argv, "c:fiM:mN:n:p:stw:")) != -1) {
+ while ((c = getopt(argc, argv, "c:fiM:mzN:n:p:stw:")) != -1) {
switch (c) {
case 'c':
reps = atoi(optarg);
@@ -211,6 +215,9 @@ main(argc, argv)
case 'm':
todo |= MEMSTAT;
break;
+ case 'z':
+ todo |= ZMEMSTAT;
+ break;
case 'N':
nlistf = optarg;
break;
@@ -316,6 +323,8 @@ main(argc, argv)
#endif
if (todo & MEMSTAT)
domem();
+ if (todo & ZMEMSTAT)
+ dozmem();
if (todo & SUMSTAT)
dosum();
#ifdef notyet
@@ -896,6 +905,60 @@ domem()
(totuse + 1023) / 1024, (totfree + 1023) / 1024, totreq);
}
+void
+dozmem()
+{
+ vm_zone_t zonep;
+ int nmax = 512;
+ int zused_bytes = 0;
+ int ztotal_bytes = 0;
+
+ printf(
+ "\n"
+ "%-16s%-8s%-8s%-8s\n",
+ "ZONE",
+ "used",
+ "total",
+ "mem-use"
+ );
+
+ kread(X_ZLIST, &zonep, sizeof(zonep));
+ while (zonep != NULL && nmax) {
+ struct vm_zone zone;
+ char buf[32];
+ int n;
+
+ if (kvm_read(kd, (u_long)zonep, &zone, sizeof(zone)) != sizeof(zone))
+ break;
+ n = kvm_read(kd, (u_long)zone.zname, buf, sizeof(buf) - 1);
+ if (n < 0)
+ n = 0;
+ buf[n] = 0;
+
+ printf(
+ "%-15.15s %-7d %-7d %4d/%dK\n",
+ buf,
+ zone.ztotal - zone.zfreecnt,
+ zone.ztotal,
+ (zone.ztotal - zone.zfreecnt) * zone.zsize / 1024,
+ zone.ztotal * zone.zsize / 1024
+ );
+ zused_bytes += (zone.ztotal - zone.zfreecnt) * zone.zsize;
+ ztotal_bytes += zone.ztotal * zone.zsize;
+ --nmax;
+ zonep = zone.znext;
+ }
+ printf(
+ "------------------------------------------\n"
+ "%-15.15s %-7s %-7s %4d/%dK\n\n",
+ "TOTAL",
+ "",
+ "",
+ zused_bytes / 1024,
+ ztotal_bytes / 1024
+ );
+}
+
/*
* kread reads something from the kernel, given its nlist index.
*/
OpenPOWER on IntegriCloud