Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
vmstat -s "active pages" / "inactive pages" output
Hi,
it appears that between netbsd-3 and netbsd-4 we lost the "active
pages" and "inactive pages" output in "vmstat -s" output. The
attached patch restores that part of the output when run on the
active kernel (since sysctl() can't be used on a crash dump).
Any objection to committing this?
Regards,
- Håvard
Index: vmstat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/vmstat/vmstat.c,v
retrieving revision 1.153
diff -u -p -r1.153 vmstat.c
--- vmstat.c 17 Oct 2006 15:13:08 -0000 1.153
+++ vmstat.c 18 Aug 2008 09:49:16 -0000
@@ -783,6 +783,22 @@ dosum(void)
{
struct nchstats nchstats;
u_long nchtotal;
+ int mib[2];
+ struct uvmexp_sysctl uvmexp2;
+ size_t ssize;
+ int active_kernel;
+
+ ssize = sizeof(uvmexp2);
+ memset(&uvmexp2, 0, ssize);
+ active_kernel = (nlistf == NULL && memf == NULL);
+ if (active_kernel) {
+ /* only on active kernel */
+ mib[0] = CTL_VM;
+ mib[1] = VM_UVMEXP2;
+ if (sysctl(mib, 2, &uvmexp2, &ssize, NULL, 0) < 0)
+ fprintf(stderr, "%s: sysctl vm.uvmexp2 failed: %s\n",
+ getprogname(), strerror(errno));
+ }
kread(namelist, X_UVMEXP, &uvmexp, sizeof(uvmexp));
@@ -793,6 +809,10 @@ dosum(void)
(void)printf("%9u pages managed\n", uvmexp.npages);
(void)printf("%9u pages free\n", uvmexp.free);
+ if (active_kernel) {
+ (void)printf("%9" PRIu64 " pages active\n", uvmexp2.active);
+ (void)printf("%9" PRIu64 " pages inactive\n", uvmexp2.inactive);
+ }
(void)printf("%9u pages paging\n", uvmexp.paging);
(void)printf("%9u pages wired\n", uvmexp.wired);
(void)printf("%9u zero pages\n", uvmexp.zeropages);
Home |
Main Index |
Thread Index |
Old Index