summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2006-01-31 18:24:57 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2006-01-31 18:24:57 +0000
commit2ccd51e7f849b0c386d724e69b3e44b67c18791f (patch)
tree4645dd5b494a9ea31fd6131842d1949a46ed84fb
parentf63b6800bfc29cdbb2c7e7f21bbbc98b45f5be1d (diff)
include uvm_km_pages_free into the pool accounting as it is the main consumer of it; feedback from millert@ and tedu@ ok
-rw-r--r--usr.bin/vmstat/vmstat.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index c4758c4a69f..ffeec835279 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.97 2005/09/28 00:54:05 pedro Exp $ */
+/* $OpenBSD: vmstat.c,v 1.98 2006/01/31 18:24:56 mickey Exp $ */
/*
* Copyright (c) 1980, 1986, 1991, 1993
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)vmstat.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.97 2005/09/28 00:54:05 pedro Exp $";
+static const char rcsid[] = "$OpenBSD: vmstat.c,v 1.98 2006/01/31 18:24:56 mickey Exp $";
#endif
#endif /* not lint */
@@ -92,7 +92,10 @@ struct nlist namelist[] = {
{ "_nselcoll" },
#define X_POOLHEAD 7 /* sysctl */
{ "_pool_head" },
-#define X_END 8
+};
+
+struct nlist namelist2[] = {
+ { "_uvm_km_pages_free" },
{ "" },
};
@@ -123,6 +126,7 @@ void dopool(void);
void dosum(void);
void dovmstat(u_int, int);
void kread(int, void *, size_t);
+int kreado(struct nlist *, void *, size_t);
void usage(void);
void dotimes(void);
void doforkst(void);
@@ -1025,7 +1029,7 @@ dopool_sysctl(void)
struct pool pool;
size_t size;
int mib[4];
- int npools, i;
+ int npools, i, kmfp;
mib[0] = CTL_KERN;
mib[1] = KERN_POOL;
@@ -1065,6 +1069,8 @@ dopool_sysctl(void)
inuse /= 1024;
total /= 1024;
+ if (!kreado(namelist2, &kmfp, sizeof(kmfp)))
+ total += kmfp * (getpagesize() / 1024);
printf("\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",
inuse, total, (double)(100 * inuse) / total);
}
@@ -1076,6 +1082,7 @@ dopool_kvm(void)
long total = 0, inuse = 0;
TAILQ_HEAD(,pool) pool_head;
struct pool pool, *pp = &pool;
+ int kmfp;
kread(X_POOLHEAD, &pool_head, sizeof(pool_head));
addr = (long)TAILQ_FIRST(&pool_head);
@@ -1108,6 +1115,8 @@ dopool_kvm(void)
inuse /= 1024;
total /= 1024;
+ if (!kreado(namelist2, &kmfp, sizeof(kmfp)))
+ total += kmfp * (getpagesize() / 1024);
printf("\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",
inuse, total, (double)(100 * inuse) / total);
}
@@ -1134,6 +1143,27 @@ kread(int nlx, void *addr, size_t size)
}
}
+/*
+ * kread reads something from the kernel, given its nlist index.
+ */
+int
+kreado(struct nlist *nl, void *addr, size_t size)
+{
+ char *sym;
+ int c;
+
+ if ((c = kvm_nlist(kd, nl)) != 0)
+ return (c);
+
+ if (nl->n_type == 0 || nl->n_value == 0)
+ return (-1);
+
+ if (kvm_read(kd, nl->n_value, addr, size) != size)
+ return (-1);
+
+ return (0);
+}
+
void
usage(void)
{