CVS commit: src/usr.bin/vmstat

2023-09-09 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Sep  9 20:13:54 UTC 2023

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
uidinfo is an SLIST.


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2023-09-09 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat Sep  9 20:13:54 UTC 2023

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
uidinfo is an SLIST.


To generate a diff of this commit:
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.257 src/usr.bin/vmstat/vmstat.c:1.258
--- src/usr.bin/vmstat/vmstat.c:1.257	Tue Aug  1 04:20:14 2023
+++ src/usr.bin/vmstat/vmstat.c	Sat Sep  9 20:13:54 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.257 2023/08/01 04:20:14 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.258 2023/09/09 20:13:54 ad Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.257 2023/08/01 04:20:14 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.258 2023/09/09 20:13:54 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -99,6 +99,7 @@ __RCSID("$NetBSD: vmstat.c,v 1.257 2023/
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1885,12 +1886,6 @@ enum hashtype {			/* from  
 	HASH_PSLIST
 };
 
-struct uidinfo {		/* XXX: no kernel header file */
-	LIST_ENTRY(uidinfo) ui_hash;
-	uid_t	ui_uid;
-	long	ui_proccnt;
-};
-
 struct kernel_hash {
 	const char *	description;	/* description */
 	int		hashsize;	/* nlist index for hash size */
@@ -1910,7 +1905,7 @@ struct kernel_hash {
 	}, {
 		"user info (uid -> used processes) hash",
 		X_UIHASH, X_UIHASHTBL,
-		HASH_LIST, offsetof(struct uidinfo, ui_hash),
+		HASH_SLIST, offsetof(struct uidinfo, ui_hash),
 	}, {
 		"vnode cache hash",
 		X_VCACHEHASH, X_VCACHETBL,



CVS commit: src/usr.bin/vmstat

2023-07-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Aug  1 04:20:14 UTC 2023

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For vmstat -mW, add a total KB consumed column and widen a couple of
other fields.


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.256 src/usr.bin/vmstat/vmstat.c:1.257
--- src/usr.bin/vmstat/vmstat.c:1.256	Sun Oct 23 23:30:31 2022
+++ src/usr.bin/vmstat/vmstat.c	Tue Aug  1 04:20:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.256 2022/10/23 23:30:31 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.257 2023/08/01 04:20:14 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.256 2022/10/23 23:30:31 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.257 2023/08/01 04:20:14 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1466,9 +1466,9 @@ dopool_sysctl(int verbose, int wide)
 
 	(void)printf("Memory resource pool statistics\n");
 	(void)printf(
-	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s\n",
+	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s%s\n",
 	wide ? 16 : 11, "Name",
-	wide ? 7 : 5, "Size",
+	wide ? 9 : 5, "Size",
 	wide ? 13 : 9, "Requests",
 	wide ? 8 : 5, "Fail",
 	wide ? 13 : 9, "Releases",
@@ -1477,13 +1477,14 @@ dopool_sysctl(int verbose, int wide)
 	wide ? 11 : 6, "Pgreq",
 	wide ? 11 : 6, "Pgrel",
 	wide ? 9 : 6, "Npage",
-	wide ? " PageSz" : "",
+	wide ? "   PageSz" : "",
 	wide ? 8 : 6, "Hiwat",
 	"Minpg",
 	wide ? 9 : 6, "Maxpg",
 	wide ? 8 : 5, "Idle",
 	wide ? "   Flags" : "",
-	wide ? "   Util" : "");
+	wide ? "   Util" : "",
+	wide ? "TotalKB" : "");
 
 	name_len = MIN((int)sizeof(pp->pr_wchan), wide ? 16 : 11);
 	for (i = 0; i < len; ++i) {
@@ -1497,7 +1498,7 @@ dopool_sysctl(int verbose, int wide)
 			pp->pr_maxpages);
 		ovflw = 0;
 		PRWORD(ovflw, "%-*s", name_len, 0, pp->pr_wchan);
-		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 5, 1, pp->pr_size);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 9 : 5, 1, pp->pr_size);
 		PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pp->pr_nget);
 		pool_totals.pt_nget += pp->pr_nget;
 		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pp->pr_nfail);
@@ -1517,7 +1518,7 @@ dopool_sysctl(int verbose, int wide)
 		PRWORD(ovflw, " %*" PRIu64, wide ? 9 : 6, 1, pp->pr_npages);
 		pool_totals.pt_npages += pp->pr_npages;
 		if (wide)
-			PRWORD(ovflw, " %*" PRIu64, 7, 1, pp->pr_pagesize);
+			PRWORD(ovflw, " %*" PRIu64, 9, 1, pp->pr_pagesize);
 		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pp->pr_hiwat);
 		PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_minpages);
 		PRWORD(ovflw, " %*s", wide ? 9 : 6, 1, maxp);
@@ -1540,17 +1541,19 @@ dopool_sysctl(int verbose, int wide)
 			total += this_total;
 		}
 		if (wide) {
-			if (this_total == 0)
+			if (this_total == 0) {
 (void)printf("   ---");
-			else
-(void)printf(" %5.1f%%",
-(100.0 * this_inuse) / this_total);
+			} else {
+(void)printf(" %5.1f%% %10" PRIu64,
+(100.0 * this_inuse) / this_total,
+this_total / KILO);
+			}
 		}
 		(void)printf("\n");
 	}
 	ovflw = 0;
 	PRWORD(ovflw, "%-*s", name_len, 0, "Totals");
-	PRWORD(ovflw, " %*s", wide ? 7 : 5, 1, "");
+	PRWORD(ovflw, " %*s", wide ? 9 : 5, 1, "");
 	PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pool_totals.pt_nget);
 	PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pool_totals.pt_nfail);
 	PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pool_totals.pt_nput);
@@ -1616,9 +1619,9 @@ dopool(int verbose, int wide)
 		if (first) {
 			(void)printf("Memory resource pool statistics\n");
 			(void)printf(
-			"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s\n",
+			"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s%s\n",
 			wide ? 16 : 11, "Name",
-			wide ? 7 : 5, "Size",
+			wide ? 9 : 5, "Size",
 			wide ? 13 : 9, "Requests",
 			wide ? 8 : 5, "Fail",
 			wide ? 13 : 9, "Releases",
@@ -1627,13 +1630,14 @@ dopool(int verbose, int wide)
 			wide ? 11 : 6, "Pgreq",
 			wide ? 11 : 6, "Pgrel",
 			wide ? 9 : 6, "Npage",
-			wide ? " PageSz" : "",
+			wide ? "   PageSz" : "",
 			wide ? 8 : 6, "Hiwat",
 			"Minpg",
 			wide ? 9 : 6, "Maxpg",
 			wide ? 8 : 5, "Idle",
 			wide ? "   Flags" : "",
-			wide ? "   Util" : "");
+			wide ? "   Util" : "",
+			wide ? "TotalKB" : "");
 			first = 0;
 		}
 		if (pp->pr_nget == 0 && !verbose)
@@ -1645,7 +1649,7 @@ dopool(int verbose, int wide)
 			pp->pr_maxpages);
 		ovflw = 0;
 		PRWORD(ovflw, "%-*s", wide ? 16 : 11, 0, name);
-		PRWORD(ovflw, " 

CVS commit: src/usr.bin/vmstat

2023-07-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Aug  1 04:20:14 UTC 2023

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For vmstat -mW, add a total KB consumed column and widen a couple of
other fields.


To generate a diff of this commit:
cvs rdiff -u -r1.256 -r1.257 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-10-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 23 23:30:31 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Remove extraneous "d" in a printf format string in UVM history dump
(leftover int format specifier from conversion to FMTd32?).


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.255 src/usr.bin/vmstat/vmstat.c:1.256
--- src/usr.bin/vmstat/vmstat.c:1.255	Sat Jul 16 10:36:19 2022
+++ src/usr.bin/vmstat/vmstat.c	Sun Oct 23 23:30:31 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.256 2022/10/23 23:30:31 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.256 2022/10/23 23:30:31 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -2299,7 +2299,7 @@ hist_dodump(struct kern_history *histp)
 			bintime2timeval(>bt, );
 			(void)printf("%06ld.%06ld ", (long int)tv.tv_sec,
 			(long int)tv.tv_usec);
-			(void)printf("%s#%" PRId32 "@%" PRId32 "d: ",
+			(void)printf("%s#%" PRId32 "@%" PRId32 ": ",
 			fn, e->call, e->cpunum);
 			(void)printf(fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
 			(void)putchar('\n');



CVS commit: src/usr.bin/vmstat

2022-10-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Oct 23 23:30:31 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Remove extraneous "d" in a printf format string in UVM history dump
(leftover int format specifier from conversion to FMTd32?).


To generate a diff of this commit:
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-07-16 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Jul 16 10:36:19 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
When operating on core files or /dev/mem when using the -M option,
use 64-bit math to calculate pool sizes.  Fixes overflow errors for
pools larger than 4GB and gives the correct output with "vmstat -m"
for in use, total allocation and utilisation numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.254 src/usr.bin/vmstat/vmstat.c:1.255
--- src/usr.bin/vmstat/vmstat.c:1.254	Sat Jul 16 09:32:27 2022
+++ src/usr.bin/vmstat/vmstat.c	Sat Jul 16 10:36:19 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.254 2022/07/16 09:32:27 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.254 2022/07/16 09:32:27 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.255 2022/07/16 10:36:19 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1578,7 +1578,7 @@ dopool(int verbose, int wide)
 {
 	int first, ovflw;
 	void *addr;
-	long total, inuse, this_total, this_inuse;
+	uint64_t total, inuse, this_total, this_inuse;
 	struct {
 		uint64_t pt_nget;
 		uint64_t pt_nfail;
@@ -1674,8 +1674,8 @@ dopool(int verbose, int wide)
 			PRWORD(ovflw, " 0x%0*x", 6, 1,
 			pp->pr_flags | pp->pr_roflags);
 
-		this_inuse = pp->pr_nout * pp->pr_size;
-		this_total = pp->pr_npages * pa.pa_pagesz;
+		this_inuse = (uint64_t)pp->pr_nout * pp->pr_size;
+		this_total = (uint64_t)pp->pr_npages * pa.pa_pagesz;
 		if (pp->pr_roflags & PR_RECURSIVE) {
 			/*
 			 * Don't count in-use memory, since it's part
@@ -1714,7 +1714,8 @@ dopool(int verbose, int wide)
 	inuse /= KILO;
 	total /= KILO;
 	(void)printf(
-	"\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",
+	"\nIn use %" PRIu64 "K, "
+	"total allocated %" PRIu64 "K; utilization %.1f%%\n",
 	inuse, total, (100.0 * inuse) / total);
 }
 



CVS commit: src/usr.bin/vmstat

2022-07-16 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Jul 16 10:36:19 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
When operating on core files or /dev/mem when using the -M option,
use 64-bit math to calculate pool sizes.  Fixes overflow errors for
pools larger than 4GB and gives the correct output with "vmstat -m"
for in use, total allocation and utilisation numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-07-16 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Jul 16 09:32:27 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Move the call to getnlist() to after we check if kvm_openfiles(3) succeeded.
Avoids a coredump when called with "vmstat -M /dev/mem".


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.253 src/usr.bin/vmstat/vmstat.c:1.254
--- src/usr.bin/vmstat/vmstat.c:1.253	Thu May 19 13:57:03 2022
+++ src/usr.bin/vmstat/vmstat.c	Sat Jul 16 09:32:27 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.253 2022/05/19 13:57:03 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.254 2022/07/16 09:32:27 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.253 2022/05/19 13:57:03 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.254 2022/07/16 09:32:27 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -422,12 +422,14 @@ main(int argc, char *argv[])
 		kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
 	} else {
 		kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
-		getnlist(todo);
 	}
 
 	if (kd == NULL)
 		errx(EXIT_FAILURE, "%s", errbuf);
 
+	if (memf != NULL)
+		getnlist(todo);	/* Only need this if a core is specified. */
+
 	if (todo & VMSTAT) {
 		struct winsize winsize;
 



CVS commit: src/usr.bin/vmstat

2022-07-16 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Jul 16 09:32:27 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Move the call to getnlist() to after we check if kvm_openfiles(3) succeeded.
Avoids a coredump when called with "vmstat -M /dev/mem".


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-05-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 19 13:57:03 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Bump some column widths for "vmstat -mW".


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.252 src/usr.bin/vmstat/vmstat.c:1.253
--- src/usr.bin/vmstat/vmstat.c:1.252	Sun Feb 27 19:00:46 2022
+++ src/usr.bin/vmstat/vmstat.c	Thu May 19 13:57:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.252 2022/02/27 19:00:46 rillig Exp $ */
+/* $NetBSD: vmstat.c,v 1.253 2022/05/19 13:57:03 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.252 2022/02/27 19:00:46 rillig Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.253 2022/05/19 13:57:03 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1464,22 +1464,22 @@ dopool_sysctl(int verbose, int wide)
 
 	(void)printf("Memory resource pool statistics\n");
 	(void)printf(
-	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%5s%s%s\n",
+	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s\n",
 	wide ? 16 : 11, "Name",
 	wide ? 7 : 5, "Size",
-	wide ? 12 : 9, "Requests",
+	wide ? 13 : 9, "Requests",
 	wide ? 8 : 5, "Fail",
-	wide ? 12 : 9, "Releases",
+	wide ? 13 : 9, "Releases",
 	wide ? "InUse" : "",
 	wide ? "Avail" : "",
 	wide ? 11 : 6, "Pgreq",
 	wide ? 11 : 6, "Pgrel",
-	wide ? 8 : 6, "Npage",
+	wide ? 9 : 6, "Npage",
 	wide ? " PageSz" : "",
-	wide ? 7 : 6, "Hiwat",
+	wide ? 8 : 6, "Hiwat",
 	"Minpg",
-	wide ? 7 : 6, "Maxpg",
-	"Idle",
+	wide ? 9 : 6, "Maxpg",
+	wide ? 8 : 5, "Idle",
 	wide ? "   Flags" : "",
 	wide ? "   Util" : "");
 
@@ -1496,11 +1496,11 @@ dopool_sysctl(int verbose, int wide)
 		ovflw = 0;
 		PRWORD(ovflw, "%-*s", name_len, 0, pp->pr_wchan);
 		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 5, 1, pp->pr_size);
-		PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pp->pr_nget);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pp->pr_nget);
 		pool_totals.pt_nget += pp->pr_nget;
 		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pp->pr_nfail);
 		pool_totals.pt_nfail += pp->pr_nfail;
-		PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pp->pr_nput);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pp->pr_nput);
 		pool_totals.pt_nput += pp->pr_nput;
 		if (wide) {
 			PRWORD(ovflw, " %*" PRIu64, 9, 1, pp->pr_nout);
@@ -1512,14 +1512,14 @@ dopool_sysctl(int verbose, int wide)
 		pool_totals.pt_npagealloc += pp->pr_npagealloc;
 		PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pp->pr_npagefree);
 		pool_totals.pt_npagefree += pp->pr_npagefree;
-		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pp->pr_npages);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 9 : 6, 1, pp->pr_npages);
 		pool_totals.pt_npages += pp->pr_npages;
 		if (wide)
 			PRWORD(ovflw, " %*" PRIu64, 7, 1, pp->pr_pagesize);
-		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 6, 1, pp->pr_hiwat);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pp->pr_hiwat);
 		PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_minpages);
-		PRWORD(ovflw, " %*s", wide ? 7 : 6, 1, maxp);
-		PRWORD(ovflw, " %*" PRIu64, 5, 1, pp->pr_nidle);
+		PRWORD(ovflw, " %*s", wide ? 9 : 6, 1, maxp);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pp->pr_nidle);
 		if (wide)
 			PRWORD(ovflw, " 0x%0*" PRIx64, 6, 1,
 			pp->pr_flags);
@@ -1549,16 +1549,16 @@ dopool_sysctl(int verbose, int wide)
 	ovflw = 0;
 	PRWORD(ovflw, "%-*s", name_len, 0, "Totals");
 	PRWORD(ovflw, " %*s", wide ? 7 : 5, 1, "");
-	PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pool_totals.pt_nget);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pool_totals.pt_nget);
 	PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pool_totals.pt_nfail);
-	PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pool_totals.pt_nput);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 13 : 9, 1, pool_totals.pt_nput);
 	if (wide) {
 		PRWORD(ovflw, " %*" PRIu64, 9, 1, pool_totals.pt_nout);
 		PRWORD(ovflw, " %*" PRIu64, 9, 1, pool_totals.pt_nitems);
 	}
 	PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pool_totals.pt_npagealloc);
 	PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pool_totals.pt_npagefree);
-	PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pool_totals.pt_npages);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 9 : 6, 1, pool_totals.pt_npages);
 	(void)printf("\n");
 
 	inuse /= KILO;
@@ -1614,22 +1614,22 @@ dopool(int verbose, int wide)
 		if (first) {
 			(void)printf("Memory resource pool statistics\n");
 			(void)printf(
-			"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%5s%s%s\n",
+			"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%*s%s%s\n",
 			wide ? 16 : 11, 

CVS commit: src/usr.bin/vmstat

2022-05-19 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 19 13:57:03 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Bump some column widths for "vmstat -mW".


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



re: CVS commit: src/usr.bin/vmstat

2022-02-28 Thread matthew green
"Roland Illig" writes:
> Module Name:  src
> Committed By: rillig
> Date: Sun Feb 27 19:00:46 UTC 2022
>
> Modified Files:
>   src/usr.bin/vmstat: vmstat.c
>
> Log Message:
> vmstat: unexport file-scope variable numdisks
>
> There is no need to make this variable externally visible.  There are
> several more variables in this file that could be unexported, leave
> these for someone who knows whether vmstat.c is used by other parts of
> the tree as well.
>
> No functional change, OK mrg.

thanks!


CVS commit: src/usr.bin/vmstat

2022-02-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 19:00:46 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
vmstat: unexport file-scope variable numdisks

There is no need to make this variable externally visible.  There are
several more variables in this file that could be unexported, leave
these for someone who knows whether vmstat.c is used by other parts of
the tree as well.

No functional change, OK mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.251 src/usr.bin/vmstat/vmstat.c:1.252
--- src/usr.bin/vmstat/vmstat.c:1.251	Wed Feb  9 07:51:45 2022
+++ src/usr.bin/vmstat/vmstat.c	Sun Feb 27 19:00:46 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.251 2022/02/09 07:51:45 wiz Exp $ */
+/* $NetBSD: vmstat.c,v 1.252 2022/02/27 19:00:46 rillig Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.251 2022/02/09 07:51:45 wiz Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.252 2022/02/27 19:00:46 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -329,7 +329,7 @@ static const int vmmeter_mib[] = { CTL_V
 static const int uvmexp2_mib[] = { CTL_VM, VM_UVMEXP2 };
 static const int boottime_mib[] = { CTL_KERN, KERN_BOOTTIME };
 
-int numdisks = 2;
+static int numdisks = 2;
 
 int
 main(int argc, char *argv[])



CVS commit: src/usr.bin/vmstat

2022-02-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb 27 19:00:46 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
vmstat: unexport file-scope variable numdisks

There is no need to make this variable externally visible.  There are
several more variables in this file that could be unexported, leave
these for someone who knows whether vmstat.c is used by other parts of
the tree as well.

No functional change, OK mrg.


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



re: CVS commit: src/usr.bin/vmstat

2022-02-27 Thread matthew green
Roland Illig writes:
> Am 09.02.2022 um 08:34 schrieb matthew green:
> > Module Name:src
> > Committed By:   mrg
> > Date:   Wed Feb  9 07:34:18 UTC 2022
> >
> > Modified Files:
> > src/usr.bin/vmstat: vmstat.c
> >
> > Log Message:
> > allow the number of disks displayed in the default output
> > to be controlled.
> >
> >
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.249 -r1.250 src/usr.bin/vmstat/vmstat.c
>
> Did you omit the "static" from the variable definition on purpose?  As a
> general rule, I prefer to keep the scope of each variable as narrow as
> possible.

good idea.  feel free to fix, i usually do this :-)


Re: CVS commit: src/usr.bin/vmstat

2022-02-26 Thread Roland Illig

Am 09.02.2022 um 08:34 schrieb matthew green:

Module Name:src
Committed By:   mrg
Date:   Wed Feb  9 07:34:18 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
allow the number of disks displayed in the default output
to be controlled.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/vmstat/vmstat.c


Did you omit the "static" from the variable definition on purpose?  As a
general rule, I prefer to keep the scope of each variable as narrow as
possible.

Roland


CVS commit: src/usr.bin/vmstat

2022-02-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb  9 07:51:45 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Fix typo in usage.


To generate a diff of this commit:
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-02-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb  9 07:51:45 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Fix typo in usage.


To generate a diff of this commit:
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.250 src/usr.bin/vmstat/vmstat.c:1.251
--- src/usr.bin/vmstat/vmstat.c:1.250	Wed Feb  9 07:34:18 2022
+++ src/usr.bin/vmstat/vmstat.c	Wed Feb  9 07:51:45 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.250 2022/02/09 07:34:18 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.251 2022/02/09 07:51:45 wiz Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.250 2022/02/09 07:34:18 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.251 2022/02/09 07:51:45 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -2442,7 +2442,7 @@ usage(void)
 
 	(void)fprintf(stderr,
 	"usage: %s [-CefHiLlmstUvW] [-c count] [-h hashname]\n"
-	"\t\t[-M core] [-N system] [-d diskcount] [-u histname]\n"
+	"\t\t[-M core] [-N system] [-n diskcount] [-u histname]\n"
 	"[-w wait] [disks]\n",
 	getprogname());
 	exit(1);



CVS commit: src/usr.bin/vmstat

2022-02-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb  9 07:34:18 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
allow the number of disks displayed in the default output
to be controlled.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.249 src/usr.bin/vmstat/vmstat.c:1.250
--- src/usr.bin/vmstat/vmstat.c:1.249	Tue Feb  1 09:18:07 2022
+++ src/usr.bin/vmstat/vmstat.c	Wed Feb  9 07:34:18 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.250 2022/02/09 07:34:18 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.250 2022/02/09 07:34:18 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -329,6 +329,8 @@ static const int vmmeter_mib[] = { CTL_V
 static const int uvmexp2_mib[] = { CTL_VM, VM_UVMEXP2 };
 static const int boottime_mib[] = { CTL_KERN, KERN_BOOTTIME };
 
+int numdisks = 2;
+
 int
 main(int argc, char *argv[])
 {
@@ -343,7 +345,7 @@ main(int argc, char *argv[])
 	reps = todo = verbose = wide = 0;
 	interval.tv_sec = 0;
 	interval.tv_nsec = 0;
-	while ((c = getopt(argc, argv, "Cc:efh:HilLM:mN:stu:UvWw:")) != -1) {
+	while ((c = getopt(argc, argv, "Cc:efh:HilLM:mN:n:stu:UvWw:")) != -1) {
 		switch (c) {
 		case 'c':
 			reps = atoi(optarg);
@@ -381,6 +383,9 @@ main(int argc, char *argv[])
 		case 'N':
 			nlistf = optarg;
 			break;
+		case 'n':
+			numdisks = atoi(optarg);
+			break;
 		case 's':
 			todo |= SUMSTAT;
 			break;
@@ -595,10 +600,10 @@ choosedrives(char **argv)
 	/*
 	 * Pick the most active drives.  Must read the stats once before
 	 * sorting so that there is current IO data, before selecting
-	 * just the first two drives.
+	 * just the first 'numdisks' (default 2) drives.
 	 */
 	drvreadstats();
-	for (i = 0; i < ndrive && ndrives < 2; i++) {
+	for (i = 0; i < ndrive && ndrives < numdisks; i++) {
 		uint64_t high_bytes = 0, bytes;
 
 		k = ndrive;
@@ -2436,7 +2441,9 @@ usage(void)
 {
 
 	(void)fprintf(stderr,
-	"usage: %s [-CefHiLlmstUvW] [-c count] [-h hashname] [-M core] [-N system]\n"
-	"\t\t[-u histname] [-w wait] [disks]\n", getprogname());
+	"usage: %s [-CefHiLlmstUvW] [-c count] [-h hashname]\n"
+	"\t\t[-M core] [-N system] [-d diskcount] [-u histname]\n"
+	"[-w wait] [disks]\n",
+	getprogname());
 	exit(1);
 }



CVS commit: src/usr.bin/vmstat

2022-02-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb  9 07:34:18 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
allow the number of disks displayed in the default output
to be controlled.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-02-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb  9 07:34:08 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
allow the number of disks displayed in the default output
to be controlled.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.1
diff -u src/usr.bin/vmstat/vmstat.1:1.25 src/usr.bin/vmstat/vmstat.1:1.26
--- src/usr.bin/vmstat/vmstat.1:1.25	Mon Dec 13 08:19:12 2021
+++ src/usr.bin/vmstat/vmstat.1	Wed Feb  9 07:34:08 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmstat.1,v 1.25 2021/12/13 08:19:12 simonb Exp $
+.\"	$NetBSD: vmstat.1,v 1.26 2022/02/09 07:34:08 mrg Exp $
 .\"
 .\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\"
 .\"	@(#)vmstat.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd December 13, 2021
+.Dd February 1, 2022
 .Dt VMSTAT 1
 .Os
 .Sh NAME
@@ -66,6 +66,7 @@
 .Op Fl h Ar hashname
 .Op Fl M Ar core
 .Op Fl N Ar system
+.Op Fl n Ar diskcount
 .Op Fl u Ar histname
 .Op Fl w Ar wait
 .Op Ar disks
@@ -123,6 +124,10 @@ Report on the list of the kernel memory 
 .It Fl N Ar system
 Extract the name list from the specified system instead of the default
 .Pa /netbsd .
+.It Fl n Ar diskcount
+Display up to
+.Ar diskcount
+disks in the standard output, instead of the default 2.
 .It Fl s
 Display the contents of the
 .Dv uvmexp
@@ -300,7 +305,8 @@ apparent which are recomputed every seco
 .Xr kernhist 9
 .Sh BUGS
 The
-.Fl c
+.Fl c ,
+.Fl n ,
 and
 .Fl w
 options are only available with the default output.



CVS commit: src/usr.bin/vmstat

2022-02-08 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb  9 07:34:08 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
allow the number of disks displayed in the default output
to be controlled.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2022-02-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  1 09:18:07 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
when picking which 2 disks to show in the 'vmstat' default output
and they haven't been specified on the command line, pick the two
devices that have had the largest read+write IO bytes count.


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.248 src/usr.bin/vmstat/vmstat.c:1.249
--- src/usr.bin/vmstat/vmstat.c:1.248	Sat Nov 27 22:16:42 2021
+++ src/usr.bin/vmstat/vmstat.c	Tue Feb  1 09:18:07 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.248 2021/11/27 22:16:42 rillig Exp $ */
+/* $NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.248 2021/11/27 22:16:42 rillig Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.249 2022/02/01 09:18:07 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -569,7 +569,7 @@ getnlist(int todo)
 char **
 choosedrives(char **argv)
 {
-	size_t i;
+	size_t i, j, k;
 
 	/*
 	 * Choose drives to be displayed.  Priority goes to (in order) drives
@@ -591,11 +591,30 @@ choosedrives(char **argv)
 			break;
 		}
 	}
+
+	/*
+	 * Pick the most active drives.  Must read the stats once before
+	 * sorting so that there is current IO data, before selecting
+	 * just the first two drives.
+	 */
+	drvreadstats();
 	for (i = 0; i < ndrive && ndrives < 2; i++) {
-		if (drv_select[i])
-			continue;
-		drv_select[i] = 1;
-		++ndrives;
+		uint64_t high_bytes = 0, bytes;
+
+		k = ndrive;
+		for (j = 0; j < ndrive; j++) {
+			if (drv_select[j])
+continue;
+			bytes = cur.rbytes[j] + cur.wbytes[j];
+			if (bytes > high_bytes) {
+high_bytes = bytes;
+k = j;
+			}
+		}
+		if (k != ndrive) {
+			drv_select[k] = 1;
+			++ndrives;
+		}
 	}
 
 	return (argv);



CVS commit: src/usr.bin/vmstat

2022-02-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  1 09:18:07 UTC 2022

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
when picking which 2 disks to show in the 'vmstat' default output
and they haven't been specified on the command line, pick the two
devices that have had the largest read+write IO bytes count.


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2021-12-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Dec 13 08:19:12 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Update -m description to reflect reality.  Kernel dynamic memory tracking
was removed long ago; only pool usage is reported.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.1
diff -u src/usr.bin/vmstat/vmstat.1:1.24 src/usr.bin/vmstat/vmstat.1:1.25
--- src/usr.bin/vmstat/vmstat.1:1.24	Tue Dec 25 03:38:59 2018
+++ src/usr.bin/vmstat/vmstat.1	Mon Dec 13 08:19:12 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmstat.1,v 1.24 2018/12/25 03:38:59 sevan Exp $
+.\"	$NetBSD: vmstat.1,v 1.25 2021/12/13 08:19:12 simonb Exp $
 .\"
 .\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\"
 .\"	@(#)vmstat.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd December 25, 2018
+.Dd December 13, 2021
 .Dt VMSTAT 1
 .Os
 .Sh NAME
@@ -119,9 +119,7 @@ Extract values associated with the name 
 instead of the default
 .Pa /dev/mem .
 .It Fl m
-Report on the usage of kernel dynamic memory listed first by size of
-allocation and then by type of usage,
-followed by a list of the kernel memory pools and their usage.
+Report on the list of the kernel memory pools and their usage.
 .It Fl N Ar system
 Extract the name list from the specified system instead of the default
 .Pa /netbsd .



CVS commit: src/usr.bin/vmstat

2021-12-13 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Dec 13 08:19:12 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Update -m description to reflect reality.  Kernel dynamic memory tracking
was removed long ago; only pool usage is reported.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2021-04-02 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri Apr  2 06:28:55 UTC 2021

Modified Files:
src/usr.bin/vmstat: Makefile vmstat.c

Log Message:
Drop setgid kmem, simplify nlist setup.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/vmstat/Makefile
cvs rdiff -u -r1.245 -r1.246 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/Makefile
diff -u src/usr.bin/vmstat/Makefile:1.34 src/usr.bin/vmstat/Makefile:1.35
--- src/usr.bin/vmstat/Makefile:1.34	Thu Dec 29 23:42:39 2016
+++ src/usr.bin/vmstat/Makefile	Fri Apr  2 06:28:55 2021
@@ -1,8 +1,7 @@
-#	$NetBSD: Makefile,v 1.34 2016/12/29 23:42:39 mrg Exp $
+#	$NetBSD: Makefile,v 1.35 2021/04/02 06:28:55 simonb Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 .include 
-USE_FORT?= yes	# setgid
 PROG=	vmstat
 
 CPPFLAGS+=-D_KMEMUSER -I${NETBSDSRCDIR}/sys
@@ -10,8 +9,6 @@ SRCS=	drvstats.c vmstat.c
 MAN=	vmstat.1
 DPADD=	${LIBKVM}
 LDADD=	-lkvm
-BINGRP=	kmem
-BINMODE=2555
 
 CWARNFLAGS.clang+=	-Wno-format-extra-args
 COPTS.vmstat.c += -Wno-format-nonliteral
@@ -19,6 +16,4 @@ COPTS.vmstat.c += -Wno-format-nonliteral
 # sparc64 is broken!
 COPTS.vmstat.c += -Wno-error=stack-protector
 
-.include "../../compat/exec.mk"
-
 .include 

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.245 src/usr.bin/vmstat/vmstat.c:1.246
--- src/usr.bin/vmstat/vmstat.c:1.245	Thu Apr  1 06:23:14 2021
+++ src/usr.bin/vmstat/vmstat.c	Fri Apr  2 06:28:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.245 2021/04/01 06:23:14 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.246 2021/04/02 06:28:55 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.245 2021/04/01 06:23:14 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.246 2021/04/02 06:28:55 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -328,7 +328,6 @@ static const int clockrate_mib[] = { CTL
 static const int vmmeter_mib[] = { CTL_VM, VM_METER };
 static const int uvmexp2_mib[] = { CTL_VM, VM_UVMEXP2 };
 static const int boottime_mib[] = { CTL_KERN, KERN_BOOTTIME };
-static char kvm_errbuf[_POSIX2_LINE_MAX];
 
 int
 main(int argc, char *argv[])
@@ -336,11 +335,10 @@ main(int argc, char *argv[])
 	int c, todo, verbose, wide;
 	struct timespec interval;
 	int reps;
-	gid_t egid = getegid();
 	const char *histname, *hashname;
+	char errbuf[_POSIX2_LINE_MAX];
 
 	histname = hashname = NULL;
-	(void)setegid(getgid());
 	memf = nlistf = NULL;
 	reps = todo = verbose = wide = 0;
 	interval.tv_sec = 0;
@@ -415,35 +413,21 @@ main(int argc, char *argv[])
 	if (todo == 0)
 		todo = VMSTAT;
 
-	/*
-	 * Discard setgid privileges.  If not the running kernel, we toss
-	 * them away totally so that bad guys can't print interesting stuff
-	 * from kernel memory, otherwise switch back to kmem for the
-	 * duration of the kvm_openfiles() call.
-	 */
-	if (nlistf != NULL || memf != NULL)
-		(void)setgid(getgid());
-	else
-		(void)setegid(egid);
-
-	kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, kvm_errbuf);
-	if (kd == NULL) {
-		if (nlistf != NULL || memf != NULL) {
-			errx(1, "kvm_openfiles: %s", kvm_errbuf);
-		}
+	if (memf == NULL) {
+		kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
+	} else {
+		kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
+		getnlist(todo);
 	}
 
-	if (nlistf == NULL && memf == NULL)
-		(void)setgid(getgid());
-
+	if (kd == NULL)
+		errx(EXIT_FAILURE, "%s", errbuf);
 
 	if (todo & VMSTAT) {
 		struct winsize winsize;
 
 		(void)drvinit(0);/* Initialize disk stats, no disks selected. */
 
-		(void)setgid(getgid()); /* don't need privs anymore */
-
 		argv = choosedrives(argv);	/* Select disks. */
 		winsize.ws_row = 0;
 		(void)ioctl(STDOUT_FILENO, TIOCGWINSZ, );
@@ -466,8 +450,6 @@ main(int argc, char *argv[])
 	} else if (reps)
 		interval.tv_sec = 1;
 
-
-	getnlist(todo);
 	/*
 	 * Statistics dumping is incompatible with the default
 	 * VMSTAT/dovmstat() output. So perform the interval/reps handling
@@ -539,36 +521,30 @@ main(int argc, char *argv[])
 void
 getnlist(int todo)
 {
-	static int namelist_done = 0;
 	static int done = 0;
 	int c;
 	size_t i;
 
-	if (kd == NULL)
-		errx(1, "kvm_openfiles: %s", kvm_errbuf);
-
-	if (!namelist_done) {
-		namelist_done = 1;
-		if ((c = kvm_nlist(kd, namelist)) != 0) {
-			int doexit = 0;
-			if (c == -1)
-errx(1, "kvm_nlist: %s %s",
-"namelist", kvm_geterr(kd));
-			for (i = 0; i < __arraycount(namelist)-1; i++)
-if (namelist[i].n_type == 0) {
-	if (doexit++ == 0)
-		(void)fprintf(stderr,
-		"%s: undefined symbols:",
-		getprogname());
-	(void)fprintf(stderr, " %s",
-	namelist[i].n_name);
-}
-			if (doexit) {
-

CVS commit: src/usr.bin/vmstat

2021-04-02 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri Apr  2 06:28:55 UTC 2021

Modified Files:
src/usr.bin/vmstat: Makefile vmstat.c

Log Message:
Drop setgid kmem, simplify nlist setup.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/vmstat/Makefile
cvs rdiff -u -r1.245 -r1.246 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:23:15 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use kernel sysctl hashstat collection instead of kmem grovelling
directly.  Also GC a few old hash nlist entries that no longer exist.


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.244 src/usr.bin/vmstat/vmstat.c:1.245
--- src/usr.bin/vmstat/vmstat.c:1.244	Thu Apr  1 05:33:50 2021
+++ src/usr.bin/vmstat/vmstat.c	Thu Apr  1 06:23:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.245 2021/04/01 06:23:14 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.245 2021/04/01 06:23:14 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -113,6 +113,7 @@ __RCSID("$NetBSD: vmstat.c,v 1.244 2021/
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -207,31 +208,23 @@ struct nlist intrnl[] =
  */
 struct nlist hashnl[] =
 {
-#define	X_NFSNODE	0
-	{ .n_name = "_nfsnodehash" },
-#define	X_NFSNODETBL	1
-	{ .n_name = "_nfsnodehashtbl" },
-#define	X_IHASH		2
-	{ .n_name = "_ihash" },
-#define	X_IHASHTBL	3
-	{ .n_name = "_ihashtbl" },
-#define	X_BUFHASH	4
+#define	X_BUFHASH	0
 	{ .n_name = "_bufhash" },
-#define	X_BUFHASHTBL	5
+#define	X_BUFHASHTBL	1
 	{ .n_name = "_bufhashtbl" },
-#define	X_UIHASH	6
+#define	X_UIHASH	2
 	{ .n_name = "_uihash" },
-#define	X_UIHASHTBL	7
+#define	X_UIHASHTBL	3
 	{ .n_name = "_uihashtbl" },
-#define	X_IFADDRHASH	8
+#define	X_IFADDRHASH	4
 	{ .n_name = "_in_ifaddrhash" },
-#define	X_IFADDRHASHTBL	9
+#define	X_IFADDRHASHTBL	5
 	{ .n_name = "_in_ifaddrhashtbl" },
-#define	X_VCACHEHASH	10
+#define	X_VCACHEHASH	6
 	{ .n_name = "_vcache_hashmask" },
-#define	X_VCACHETBL	11
+#define	X_VCACHETBL	7
 	{ .n_name = "_vcache_hashtab" },
-#define X_HASHNL_SIZE	12	/* must be last */
+#define X_HASHNL_SIZE	8	/* must be last */
 	{ .n_name = NULL },
 };
 
@@ -300,6 +293,7 @@ void	deref_kptr(const void *, void *, si
 void	drvstats(int *);
 void	doevcnt(int verbose, int type);
 void	dohashstat(int, int, const char *);
+void	dohashstat_sysctl(int, int, const char *);
 void	dointr(int verbose);
 void	dopool(int, int);
 void	dopoolcache(int);
@@ -1925,6 +1919,9 @@ dohashstat(int verbose, int todo, const 
 	u_long	hashsize, i;
 	int	used, items, chain, maxchain;
 
+	if (memf == NULL)
+		return dohashstat_sysctl(verbose, todo, hashname);
+
 	hashbuf = NULL;
 	hashbufsize = 0;
 
@@ -2057,6 +2054,75 @@ dohashstat(int verbose, int todo, const 
 	}
 }
 
+void
+dohashstat_sysctl(int verbose, int todo, const char *hashname)
+{
+	struct hashstat_sysctl hash, *data, *hs;
+	int mib[3];
+	int error;
+	size_t i, len, miblen;
+
+
+	miblen = __arraycount(mib);
+	error = sysctlnametomib("kern.hashstat", mib, );
+	if (error)
+		err(EXIT_FAILURE, "nametomib kern.hashstat failed");
+	assert(miblen < 3);
+
+	if (todo & HASHLIST) {
+		mib[miblen] = CTL_DESCRIBE;
+		miblen++;
+	};
+
+	if (hashname) {
+		mib[miblen] = CTL_QUERY;
+		miblen++;
+		memset(, 0, sizeof(hash));
+		strlcpy(hash.hash_name, hashname, sizeof(hash.hash_name));
+		len = sizeof(hash);
+		error = sysctl(mib, miblen, , , , len);
+		if (error == ENOENT) {
+			err(1, "hash '%s' not found", hashname);
+			return;
+		} else if (error) {
+			err(1, "sysctl kern.hashstat query failed");
+			return;
+		}
+
+		data = 
+		len = 1;
+	} else {
+		data = asysctl(mib, miblen, );
+		if (data == NULL)
+			err(1, "failed to read kern.hashstat");
+		len /= sizeof(*data);
+	}
+
+	if (todo & HASHLIST) {
+		printf("Supported hashes:\n");
+		for (i = 0, hs = data; i < len; i++, hs++) {
+			printf("\t%-16s%s\n", hs->hash_name, hs->hash_desc);
+		}
+	} else {
+		printf("%-16s %8s %8s %8s %8s %8s %8s\n"
+		"%-16s %8s %8s %8s %8s %8s %8s\n",
+		"", "total", "used", "util", "num", "average", "maximum",
+		"hash table", "buckets", "buckets", "%", "items", "chain",
+		"chain");
+		for (i = 0, hs = data; i < len; i++, hs++) {
+			printf("%-16s %8"PRId64" %8"PRId64" %8.2f %8"PRId64
+			" %8.2f %8"PRId64"\n",
+			hs->hash_name, hs->hash_size, hs->hash_used,
+			hs->hash_used * 100.0 / hs->hash_size, hs->hash_items,
+			hs->hash_used ? (double)hs->hash_items / hs->hash_used : 0.0,
+			hs->hash_maxchain);
+		}
+	}
+
+	if (!hashname && (data != NULL))
+		free(data);
+}
+
 /*
  * kreadc like kread but returns 1 if successful, 0 otherwise
  */
@@ -2254,7 +2320,7 @@ hist_traverse_sysctl(int todo, const cha
  			warnx("kernel history 

CVS commit: src/usr.bin/vmstat

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:23:15 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use kernel sysctl hashstat collection instead of kmem grovelling
directly.  Also GC a few old hash nlist entries that no longer exist.


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2021-03-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 05:33:51 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Now that ports that use legacy intrcnt interrupt accounting have event
counters to show that data, for the live kernel case just show INTR
events for "vmstat -i".


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.243 src/usr.bin/vmstat/vmstat.c:1.244
--- src/usr.bin/vmstat/vmstat.c:1.243	Wed Mar  3 08:25:16 2021
+++ src/usr.bin/vmstat/vmstat.c	Thu Apr  1 05:33:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.243 2021/03/03 08:25:16 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.243 2021/03/03 08:25:16 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1259,6 +1259,11 @@ dointr(int verbose)
 	int nintr, inamlen;
 	char *intrname, *ointrname;
 
+	if (memf == NULL) {
+		doevcnt(verbose, EVCNT_TYPE_INTR);
+		return;
+	}
+
 	inttotal = 0;
 	uptime = getuptime();
 	nintr = intrnl[X_EINTRCNT].n_value - intrnl[X_INTRCNT].n_value;



CVS commit: src/usr.bin/vmstat

2021-03-31 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 05:33:51 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Now that ports that use legacy intrcnt interrupt accounting have event
counters to show that data, for the live kernel case just show INTR
events for "vmstat -i".


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2021-03-03 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed Mar  3 08:25:16 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For vmstat -h/-H, calculate the hash element size correctly instead of
assuming that everything that isn't a list is a tailq.  Fixes random
reads from kmem that either fail or return incorrect data for the vcache
hash table.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.242 src/usr.bin/vmstat/vmstat.c:1.243
--- src/usr.bin/vmstat/vmstat.c:1.242	Sun Jun 14 21:41:42 2020
+++ src/usr.bin/vmstat/vmstat.c	Wed Mar  3 08:25:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.242 2020/06/14 21:41:42 ad Exp $ */
+/* $NetBSD: vmstat.c,v 1.243 2021/03/03 08:25:16 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.242 2020/06/14 21:41:42 ad Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.243 2021/03/03 08:25:16 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1964,8 +1964,20 @@ dohashstat(int verbose, int todo, const 
 		if (hashname != NULL &&
 		strcmp(hashnl[curhash->hashsize].n_name + 1, hashname))
 			continue;
-		elemsize = curhash->type == HASH_LIST ?
-		sizeof(*hashtbl_list) : sizeof(*hashtbl_tailq);
+		switch (curhash->type) {
+		case HASH_LIST:
+			elemsize = sizeof(*hashtbl_list);
+			break;
+		case HASH_SLIST:
+			elemsize = sizeof(*hashtbl_slist);
+			break;
+		case HASH_TAILQ:
+			elemsize = sizeof(*hashtbl_tailq);
+			break;
+		default:
+			/* shouldn't get here */
+			continue;
+		}
 		deref_kptr((void *)hashnl[curhash->hashsize].n_value,
 		, sizeof(hashsize),
 		hashnl[curhash->hashsize].n_name);



CVS commit: src/usr.bin/vmstat

2021-03-03 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Wed Mar  3 08:25:16 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For vmstat -h/-H, calculate the hash element size correctly instead of
assuming that everything that isn't a list is a tailq.  Fixes random
reads from kmem that either fail or return incorrect data for the vcache
hash table.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-03-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Mar 23 18:44:18 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
ncs_collisions is gone.


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.238 src/usr.bin/vmstat/vmstat.c:1.239
--- src/usr.bin/vmstat/vmstat.c:1.238	Sun Mar 22 18:32:42 2020
+++ src/usr.bin/vmstat/vmstat.c	Mon Mar 23 18:44:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.238 2020/03/22 18:32:42 ad Exp $ */
+/* $NetBSD: vmstat.c,v 1.239 2020/03/23 18:44:17 ad Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.238 2020/03/22 18:32:42 ad Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.239 2020/03/23 18:44:17 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -1124,7 +1124,6 @@ dosum(void)
 	(void)printf("%9" PRIu64 " 2passes\n", nch_stats.ncs_2passes);
 	(void)printf("%9" PRIu64 " reverse hits\n", nch_stats.ncs_revhits);
 	(void)printf("%9" PRIu64 " reverse miss\n", nch_stats.ncs_revmiss);
-	(void)printf("%9" PRIu64 " hash collisions\n", nch_stats.ncs_collisions);
 	(void)printf("%9" PRIu64 " access denied\n", nch_stats.ncs_denied);
 	(void)printf(
 	"%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n",



CVS commit: src/usr.bin/vmstat

2020-03-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Mar 23 18:44:18 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
ncs_collisions is gone.


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-03-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Mar 22 14:39:29 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
- nchash is gone.
- Report new namecache stats.


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-03-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Mar 22 14:39:29 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
- nchash is gone.
- Report new namecache stats.


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.236 src/usr.bin/vmstat/vmstat.c:1.237
--- src/usr.bin/vmstat/vmstat.c:1.236	Sat Jan 25 05:43:32 2020
+++ src/usr.bin/vmstat/vmstat.c	Sun Mar 22 14:39:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.236 2020/01/25 05:43:32 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.237 2020/03/22 14:39:28 ad Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.236 2020/01/25 05:43:32 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.237 2020/03/22 14:39:28 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -227,15 +227,11 @@ struct nlist hashnl[] =
 	{ .n_name = "_in_ifaddrhash" },
 #define	X_IFADDRHASHTBL	9
 	{ .n_name = "_in_ifaddrhashtbl" },
-#define	X_NCHASH	10
-	{ .n_name = "_nchash" },
-#define	X_NCHASHTBL	11
-	{ .n_name = "_nchashtbl" },
-#define	X_NCVCACHEHASH	12
+#define	X_VCACHEHASH	10
 	{ .n_name = "_vcache_hashmask" },
-#define	X_NCVCACHETBL	13
+#define	X_VCACHETBL	11
 	{ .n_name = "_vcache_hashtab" },
-#define X_HASHNL_SIZE	14	/* must be last */
+#define X_HASHNL_SIZE	12	/* must be last */
 	{ .n_name = NULL },
 };
 
@@ -1124,6 +1120,8 @@ dosum(void)
 	(void)printf("%9" PRIu64 " 2passes\n", nch_stats.ncs_2passes);
 	(void)printf("%9" PRIu64 " reverse hits\n", nch_stats.ncs_revhits);
 	(void)printf("%9" PRIu64 " reverse miss\n", nch_stats.ncs_revmiss);
+	(void)printf("%9" PRIu64 " hash collisions\n", nch_stats.ncs_collisions);
+	(void)printf("%9" PRIu64 " access denied\n", nch_stats.ncs_denied);
 	(void)printf(
 	"%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n",
 	"", PCT(nch_stats.ncs_goodhits, nchtotal),
@@ -1898,16 +1896,12 @@ struct kernel_hash {
 		X_IFADDRHASH, X_IFADDRHASHTBL,
 		HASH_LIST, offsetof(struct in_ifaddr, ia_hash),
 	}, {
-		"name cache hash",
-		X_NCHASH, X_NCHASHTBL,
-		HASH_LIST, offsetof(struct namecache, nc_hash),
-	}, {
 		"user info (uid -> used processes) hash",
 		X_UIHASH, X_UIHASHTBL,
 		HASH_LIST, offsetof(struct uidinfo, ui_hash),
 	}, {
 		"vnode cache hash",
-		X_NCVCACHEHASH, X_NCVCACHETBL,
+		X_VCACHEHASH, X_VCACHETBL,
 		HASH_SLIST, offsetof(struct vnode_impl, vi_hash),
 	}, {
 		NULL, -1, -1, 0, 0,



CVS commit: src/usr.bin/vmstat

2020-01-24 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Jan 25 05:43:32 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Fix alignment of Flags column for vmstat -mW.


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.235 src/usr.bin/vmstat/vmstat.c:1.236
--- src/usr.bin/vmstat/vmstat.c:1.235	Wed Jan 15 17:56:46 2020
+++ src/usr.bin/vmstat/vmstat.c	Sat Jan 25 05:43:32 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.235 2020/01/15 17:56:46 ad Exp $ */
+/* $NetBSD: vmstat.c,v 1.236 2020/01/25 05:43:32 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.235 2020/01/15 17:56:46 ad Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.236 2020/01/25 05:43:32 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1492,7 +1492,7 @@ dopool_sysctl(int verbose, int wide)
 	"Minpg",
 	wide ? 7 : 6, "Maxpg",
 	"Idle",
-	wide ? "  Flags" : "",
+	wide ? "   Flags" : "",
 	wide ? "   Util" : "");
 
 	name_len = MIN((int)sizeof(pp->pr_wchan), wide ? 16 : 11);
@@ -1533,7 +1533,7 @@ dopool_sysctl(int verbose, int wide)
 		PRWORD(ovflw, " %*s", wide ? 7 : 6, 1, maxp);
 		PRWORD(ovflw, " %*" PRIu64, 5, 1, pp->pr_nidle);
 		if (wide)
-			PRWORD(ovflw, " 0x%0*" PRIx64, 5, 1,
+			PRWORD(ovflw, " 0x%0*" PRIx64, 6, 1,
 			pp->pr_flags);
 
 		this_inuse = pp->pr_nout * pp->pr_size;
@@ -1640,7 +1640,7 @@ dopool(int verbose, int wide)
 			"Minpg",
 			wide ? 7 : 6, "Maxpg",
 			"Idle",
-			wide ? "  Flags" : "",
+			wide ? "   Flags" : "",
 			wide ? "   Util" : "");
 			first = 0;
 		}
@@ -1679,7 +1679,7 @@ dopool(int verbose, int wide)
 		PRWORD(ovflw, " %*s", wide ? 7 : 6, 1, maxp);
 		PRWORD(ovflw, " %*lu", 5, 1, pp->pr_nidle);
 		if (wide)
-			PRWORD(ovflw, " 0x%0*x", 5, 1,
+			PRWORD(ovflw, " 0x%0*x", 6, 1,
 			pp->pr_flags | pp->pr_roflags);
 
 		this_inuse = pp->pr_nout * pp->pr_size;



CVS commit: src/usr.bin/vmstat

2020-01-24 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Jan 25 05:43:32 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Fix alignment of Flags column for vmstat -mW.


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 17:56:46 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
vmstat -s: report new stats:

0 per-cpu stats one synced
 7246 per-cpu stats all synced
 4092 anon pages possibly dirty
 8881 anon pages dirty
0 anon pages clean
   68 file pages possibly dirty
0 file pages dirty
  2367889 file pages clean


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-01-15 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan 15 17:56:46 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
vmstat -s: report new stats:

0 per-cpu stats one synced
 7246 per-cpu stats all synced
 4092 anon pages possibly dirty
 8881 anon pages dirty
0 anon pages clean
   68 file pages possibly dirty
0 file pages dirty
  2367889 file pages clean


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.234 src/usr.bin/vmstat/vmstat.c:1.235
--- src/usr.bin/vmstat/vmstat.c:1.234	Wed Jan  8 11:58:02 2020
+++ src/usr.bin/vmstat/vmstat.c	Wed Jan 15 17:56:46 2020
@@ -1,7 +1,8 @@
-/* $NetBSD: vmstat.c,v 1.234 2020/01/08 11:58:02 ad Exp $ */
+/* $NetBSD: vmstat.c,v 1.235 2020/01/15 17:56:46 ad Exp $ */
 
 /*-
- * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
+ * The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation by:
@@ -70,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.234 2020/01/08 11:58:02 ad Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.235 2020/01/15 17:56:46 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -1089,6 +1090,14 @@ dosum(void)
 	(void)printf("%9" PRIu64 " pages found busy by daemon\n", uvmexp.pdbusy);
 	(void)printf("%9" PRIu64 " total pending pageouts\n", uvmexp.pdpending);
 	(void)printf("%9" PRIu64 " pages deactivated\n", uvmexp.pddeact);
+	(void)printf("%9" PRIu64 " per-cpu stats one synced\n", uvmexp.countsyncone);
+	(void)printf("%9" PRIu64 " per-cpu stats all synced\n", uvmexp.countsyncall);
+	(void)printf("%9" PRIu64 " anon pages possibly dirty\n", uvmexp.anonunknown);
+	(void)printf("%9" PRIu64 " anon pages dirty\n", uvmexp.anondirty);
+	(void)printf("%9" PRIu64 " anon pages clean\n", uvmexp.anonclean);
+	(void)printf("%9" PRIu64 " file pages possibly dirty\n", uvmexp.fileunknown);
+	(void)printf("%9" PRIu64 " file pages dirty\n", uvmexp.filedirty);
+	(void)printf("%9" PRIu64 " file pages clean\n", uvmexp.fileclean);
 
 	if (active_kernel) {
 		ssize = sizeof(nch_stats);



CVS commit: src/usr.bin/vmstat

2020-01-08 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan  8 11:58:02 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Show reverse misses too.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-01-08 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Wed Jan  8 11:58:02 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Show reverse misses too.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.233 src/usr.bin/vmstat/vmstat.c:1.234
--- src/usr.bin/vmstat/vmstat.c:1.233	Mon Jan  6 11:24:30 2020
+++ src/usr.bin/vmstat/vmstat.c	Wed Jan  8 11:58:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.233 2020/01/06 11:24:30 ad Exp $ */
+/* $NetBSD: vmstat.c,v 1.234 2020/01/08 11:58:02 ad Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.233 2020/01/06 11:24:30 ad Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.234 2020/01/08 11:58:02 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -1114,6 +1114,7 @@ dosum(void)
 	(void)printf("%9" PRIu64 " pass2 hits\n", nch_stats.ncs_pass2);
 	(void)printf("%9" PRIu64 " 2passes\n", nch_stats.ncs_2passes);
 	(void)printf("%9" PRIu64 " reverse hits\n", nch_stats.ncs_revhits);
+	(void)printf("%9" PRIu64 " reverse miss\n", nch_stats.ncs_revmiss);
 	(void)printf(
 	"%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n",
 	"", PCT(nch_stats.ncs_goodhits, nchtotal),



CVS commit: src/usr.bin/vmstat

2020-01-06 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jan  6 11:24:30 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
- Report namecache reverse hits with vmstat -s.
- ncvhashtbl is no more.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.232 src/usr.bin/vmstat/vmstat.c:1.233
--- src/usr.bin/vmstat/vmstat.c:1.232	Sat Jan  4 03:09:55 2020
+++ src/usr.bin/vmstat/vmstat.c	Mon Jan  6 11:24:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.232 2020/01/04 03:09:55 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.233 2020/01/06 11:24:30 ad Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.232 2020/01/04 03:09:55 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.233 2020/01/06 11:24:30 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -230,15 +230,11 @@ struct nlist hashnl[] =
 	{ .n_name = "_nchash" },
 #define	X_NCHASHTBL	11
 	{ .n_name = "_nchashtbl" },
-#define	X_NCVHASH	12
-	{ .n_name = "_ncvhash" },
-#define	X_NCVHASHTBL	13
-	{ .n_name = "_ncvhashtbl" },
-#define	X_NCVCACHEHASH	14
+#define	X_NCVCACHEHASH	12
 	{ .n_name = "_vcache_hashmask" },
-#define	X_NCVCACHETBL	15
+#define	X_NCVCACHETBL	13
 	{ .n_name = "_vcache_hashtab" },
-#define X_HASHNL_SIZE	16	/* must be last */
+#define X_HASHNL_SIZE	14	/* must be last */
 	{ .n_name = NULL },
 };
 
@@ -1117,6 +1113,7 @@ dosum(void)
 	(void)printf("%9" PRIu64 " too long\n", nch_stats.ncs_long);
 	(void)printf("%9" PRIu64 " pass2 hits\n", nch_stats.ncs_pass2);
 	(void)printf("%9" PRIu64 " 2passes\n", nch_stats.ncs_2passes);
+	(void)printf("%9" PRIu64 " reverse hits\n", nch_stats.ncs_revhits);
 	(void)printf(
 	"%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n",
 	"", PCT(nch_stats.ncs_goodhits, nchtotal),
@@ -1895,10 +1892,6 @@ struct kernel_hash {
 		X_NCHASH, X_NCHASHTBL,
 		HASH_LIST, offsetof(struct namecache, nc_hash),
 	}, {
-		"name cache directory hash",
-		X_NCVHASH, X_NCVHASHTBL,
-		HASH_LIST, offsetof(struct namecache, nc_vhash),
-	}, {
 		"user info (uid -> used processes) hash",
 		X_UIHASH, X_UIHASHTBL,
 		HASH_LIST, offsetof(struct uidinfo, ui_hash),



CVS commit: src/usr.bin/vmstat

2020-01-06 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Jan  6 11:24:30 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
- Report namecache reverse hits with vmstat -s.
- ncvhashtbl is no more.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-01-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jan  4 03:09:55 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
move the time nlist fetches into their own namelist and only
fetch them when necessary.  allow for fallback uses of older
time sources if others are not present.

this stops vmstat from exiting if it can't get the addresses
of these time values it often doesn't need (eg, running kernels
use the sysctl method), which has cropped up recently wit the
removal of boottime variable.

a slighly modified version of this patch (modified to handle
the old boottime variable over the new one) works against a
netbsd-9 vmstat in -current too.

XXX: pullup


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.231 src/usr.bin/vmstat/vmstat.c:1.232
--- src/usr.bin/vmstat/vmstat.c:1.231	Fri Jan  3 19:13:54 2020
+++ src/usr.bin/vmstat/vmstat.c	Sat Jan  4 03:09:55 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $ */
+/* $NetBSD: vmstat.c,v 1.232 2020/01/04 03:09:55 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.232 2020/01/04 03:09:55 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -150,27 +150,36 @@ struct cpu_info {
  */
 struct nlist namelist[] =
 {
-#define	X_TIMEBASEBIN	0
-	{ .n_name = "_timebasebin" },
-#define	X_HZ		1
+#define	X_HZ		0
 	{ .n_name = "_hz" },
-#define	X_STATHZ	2
+#define	X_STATHZ	1
 	{ .n_name = "_stathz" },
-#define	X_NCHSTATS	3
+#define	X_NCHSTATS	2
 	{ .n_name = "_nchstats" },
-#define	X_ALLEVENTS	4
+#define	X_ALLEVENTS	3
 	{ .n_name = "_allevents" },
-#define	X_POOLHEAD	5
+#define	X_POOLHEAD	4
 	{ .n_name = "_pool_head" },
-#define	X_UVMEXP	6
+#define	X_UVMEXP	5
 	{ .n_name = "_uvmexp" },
-#define	X_TIME_SECOND	7
+#define X_CPU_INFOS	6
+	{ .n_name = "_cpu_infos" },
+#define	X_NL_SIZE	7
+	{ .n_name = NULL },
+};
+
+/*
+ * Namelist for time data.
+ */
+struct nlist timenl[] =
+{
+#define	X_TIMEBASEBIN	0
+	{ .n_name = "_timebasebin" },
+#define	X_TIME_SECOND	1
 	{ .n_name = "_time_second" },
-#define X_TIME		8
+#define X_TIME		2
 	{ .n_name = "_time" },
-#define X_CPU_INFOS	9
-	{ .n_name = "_cpu_infos" },
-#define	X_NL_SIZE	10
+#define	X_TIMENL_SIZE	3
 	{ .n_name = NULL },
 };
 
@@ -559,9 +568,7 @@ getnlist(int todo)
 errx(1, "kvm_nlist: %s %s",
 "namelist", kvm_geterr(kd));
 			for (i = 0; i < __arraycount(namelist)-1; i++)
-if (namelist[i].n_type == 0 &&
-i != X_TIME_SECOND &&
-i != X_TIME) {
+if (namelist[i].n_type == 0) {
 	if (doexit++ == 0)
 		(void)fprintf(stderr,
 		"%s: undefined symbols:",
@@ -575,6 +582,11 @@ getnlist(int todo)
 			}
 		}
 	}
+	if ((todo & (VMSTAT|INTRSTAT)) && !(done & (VMSTAT))) {
+		done |= VMSTAT;
+		if ((c = kvm_nlist(kd, timenl)) == -1 || c == X_TIMENL_SIZE)
+			errx(1, "kvm_nlist: %s %s", "timenl", kvm_geterr(kd));
+	}
 	if ((todo & (SUMSTAT|INTRSTAT)) && !(done & (SUMSTAT|INTRSTAT))) {
 		done |= SUMSTAT|INTRSTAT;
 		(void) kvm_nlist(kd, intrnl);
@@ -645,11 +657,10 @@ getuptime(void)
 		if (boottime.tv_sec == 0) {
 			struct bintime bt;
 
-			kread(namelist, X_TIMEBASEBIN, ,
-			sizeof(bt));
+			kread(timenl, X_TIMEBASEBIN, , sizeof(bt));
 			bintime2timespec(, );
 		}
-		if (kreadc(namelist, X_TIME_SECOND, , sizeof(nowsec))) {
+		if (kreadc(timenl, X_TIME_SECOND, , sizeof(nowsec))) {
 			/*
 			 * XXX this assignment dance can be removed once
 			 * timeval tv_sec is SUS mandated time_t
@@ -657,7 +668,7 @@ getuptime(void)
 			now.tv_sec = nowsec;
 			now.tv_nsec = 0;
 		} else {
-			kread(namelist, X_TIME, , sizeof(now));
+			kread(timenl, X_TIME, , sizeof(now));
 		}
 	}
 	uptime = now.tv_sec - boottime.tv_sec;



CVS commit: src/usr.bin/vmstat

2020-01-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Jan  4 03:09:55 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
move the time nlist fetches into their own namelist and only
fetch them when necessary.  allow for fallback uses of older
time sources if others are not present.

this stops vmstat from exiting if it can't get the addresses
of these time values it often doesn't need (eg, running kernels
use the sysctl method), which has cropped up recently wit the
removal of boottime variable.

a slighly modified version of this patch (modified to handle
the old boottime variable over the new one) works against a
netbsd-9 vmstat in -current too.

XXX: pullup


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-01-03 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jan  3 19:13:54 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
boottime in the kernel is no more.  Instead, read timebasebin and convert
from bintime to timespec.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2020-01-03 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jan  3 19:13:54 UTC 2020

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
boottime in the kernel is no more.  Instead, read timebasebin and convert
from bintime to timespec.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.230 src/usr.bin/vmstat/vmstat.c:1.231
--- src/usr.bin/vmstat/vmstat.c:1.230	Fri Dec 27 09:45:27 2019
+++ src/usr.bin/vmstat/vmstat.c	Fri Jan  3 19:13:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.230 2019/12/27 09:45:27 msaitoh Exp $ */
+/* $NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.230 2019/12/27 09:45:27 msaitoh Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.231 2020/01/03 19:13:54 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -150,8 +150,8 @@ struct cpu_info {
  */
 struct nlist namelist[] =
 {
-#define	X_BOOTTIME	0
-	{ .n_name = "_boottime" },
+#define	X_TIMEBASEBIN	0
+	{ .n_name = "_timebasebin" },
 #define	X_HZ		1
 	{ .n_name = "_hz" },
 #define	X_STATHZ	2
@@ -642,9 +642,13 @@ getuptime(void)
 		}
 		clock_gettime(CLOCK_REALTIME, );
 	} else {
-		if (boottime.tv_sec == 0)
-			kread(namelist, X_BOOTTIME, ,
-			sizeof(boottime));
+		if (boottime.tv_sec == 0) {
+			struct bintime bt;
+
+			kread(namelist, X_TIMEBASEBIN, ,
+			sizeof(bt));
+			bintime2timespec(, );
+		}
 		if (kreadc(namelist, X_TIME_SECOND, , sizeof(nowsec))) {
 			/*
 			 * XXX this assignment dance can be removed once



CVS commit: src/usr.bin/vmstat

2019-12-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Dec 22 17:27:54 UTC 2019

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Have vmstat -H report on vcache_hashtab.


To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.229 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2019-12-22 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sun Dec 22 17:27:54 UTC 2019

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Have vmstat -H report on vcache_hashtab.


To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.229 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.228 src/usr.bin/vmstat/vmstat.c:1.229
--- src/usr.bin/vmstat/vmstat.c:1.228	Fri Sep 13 13:56:05 2019
+++ src/usr.bin/vmstat/vmstat.c	Sun Dec 22 17:27:53 2019
@@ -1,7 +1,7 @@
-/* $NetBSD: vmstat.c,v 1.228 2019/09/13 13:56:05 christos Exp $ */
+/* $NetBSD: vmstat.c,v 1.229 2019/12/22 17:27:53 ad Exp $ */
 
 /*-
- * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2001, 2007, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation by:
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.228 2019/09/13 13:56:05 christos Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.229 2019/12/22 17:27:53 ad Exp $");
 #endif
 #endif /* not lint */
 
@@ -96,6 +96,8 @@ __RCSID("$NetBSD: vmstat.c,v 1.228 2019/
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -223,7 +225,11 @@ struct nlist hashnl[] =
 	{ .n_name = "_ncvhash" },
 #define	X_NCVHASHTBL	13
 	{ .n_name = "_ncvhashtbl" },
-#define X_HASHNL_SIZE	14	/* must be last */
+#define	X_NCVCACHEHASH	14
+	{ .n_name = "_vcache_hashmask" },
+#define	X_NCVCACHETBL	15
+	{ .n_name = "_vcache_hashtab" },
+#define X_HASHNL_SIZE	16	/* must be last */
 	{ .n_name = NULL },
 };
 
@@ -1842,7 +1848,9 @@ dopoolcache(int verbose)
 
 enum hashtype {			/* from  */
 	HASH_LIST,
-	HASH_TAILQ
+	HASH_SLIST,
+	HASH_TAILQ,
+	HASH_PSLIST
 };
 
 struct uidinfo {		/* XXX: no kernel header file */
@@ -1880,6 +1888,10 @@ struct kernel_hash {
 		X_UIHASH, X_UIHASHTBL,
 		HASH_LIST, offsetof(struct uidinfo, ui_hash),
 	}, {
+		"vnode cache hash",
+		X_NCVCACHEHASH, X_NCVCACHETBL,
+		HASH_SLIST, offsetof(struct vnode_impl, vi_hash),
+	}, {
 		NULL, -1, -1, 0, 0,
 	}
 };
@@ -1888,6 +1900,7 @@ void
 dohashstat(int verbose, int todo, const char *hashname)
 {
 	LIST_HEAD(, generic)	*hashtbl_list;
+	SLIST_HEAD(, generic)	*hashtbl_slist;
 	TAILQ_HEAD(, generic)	*hashtbl_tailq;
 	struct kernel_hash	*curhash;
 	void	*hashaddr, *hashbuf, *nhashbuf, *nextaddr;
@@ -1969,14 +1982,22 @@ dohashstat(int verbose, int todo, const 
 		items = maxchain = 0;
 		if (curhash->type == HASH_LIST) {
 			hashtbl_list = hashbuf;
+			hashtbl_slist = NULL;
+			hashtbl_tailq = NULL;
+		} else if (curhash->type == HASH_SLIST) {
+			hashtbl_list = NULL;
+			hashtbl_slist = hashbuf;
 			hashtbl_tailq = NULL;
 		} else {
 			hashtbl_list = NULL;
+			hashtbl_slist = NULL;
 			hashtbl_tailq = hashbuf;
 		}
 		for (i = 0; i < hashsize; i++) {
 			if (curhash->type == HASH_LIST)
 nextaddr = LIST_FIRST(_list[i]);
+			else if (curhash->type == HASH_SLIST)
+nextaddr = SLIST_FIRST(_slist[i]);
 			else
 nextaddr = TAILQ_FIRST(_tailq[i]);
 			if (nextaddr == NULL)



CVS commit: src/usr.bin/vmstat

2019-05-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May  9 08:01:07 UTC 2019

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
when dumping a kernhist history replace "%s" with "%p" so that the
kernhist in kernel can be a little more usable without making the
userland dumping code crash.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2019-05-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu May  9 08:01:07 UTC 2019

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
when dumping a kernhist history replace "%s" with "%p" so that the
kernhist in kernel can be a little more usable without making the
userland dumping code crash.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.226 src/usr.bin/vmstat/vmstat.c:1.227
--- src/usr.bin/vmstat/vmstat.c:1.226	Tue Apr 30 23:29:18 2019
+++ src/usr.bin/vmstat/vmstat.c	Thu May  9 08:01:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.226 2019/04/30 23:29:18 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.227 2019/05/09 08:01:07 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.226 2019/04/30 23:29:18 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.227 2019/05/09 08:01:07 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -2148,15 +2148,13 @@ hist_dodump(struct kern_history *histp)
 		e = [i];
 		if (e->fmt != NULL) {
 			if (fmt == NULL || e->fmtlen > fmtlen) {
-if (fmt != NULL)
-	free(fmt);
+free(fmt);
 fmtlen = e->fmtlen;
 if ((fmt = malloc(fmtlen + 1)) == NULL)
 	err(1, "malloc printf format");
 			}
 			if (fn == NULL || e->fnlen > fnlen) {
-if (fn != NULL)
-	free(fn);
+free(fn);
 fnlen = e->fnlen;
 if ((fn = malloc(fnlen + 1)) == NULL)
 	err(1, "malloc function name");
@@ -2164,6 +2162,10 @@ hist_dodump(struct kern_history *histp)
 
 			deref_kptr(e->fmt, fmt, fmtlen, "printf format");
 			fmt[fmtlen] = '\0';
+			for (unsigned z = 0; z < fmtlen - 1; z++) {
+if (fmt[z] == '%' && fmt[z+1] == 's')
+	fmt[z+1] = 'p';
+			}
 
 			deref_kptr(e->fn, fn, fnlen, "function name");
 			fn[fnlen] = '\0';
@@ -2180,10 +2182,8 @@ hist_dodump(struct kern_history *histp)
 	} while (i != histp->f);
 
 	free(histents);
-	if (fmt != NULL)
-		free(fmt);
-	if (fn != NULL)
-		free(fn);
+	free(fmt);
+	free(fn);
 }
 
 void
@@ -2293,6 +2293,11 @@ hist_dodump_sysctl(int mib[], unsigned i
 		e = >sh_events[i];
 		if (e->she_fmtoffset != 0) {
 			fmt = [e->she_fmtoffset];
+			size_t fmtlen = strlen(fmt);
+			for (unsigned z = 0; z < fmtlen - 1; z++) {
+if (fmt[z] == '%' && fmt[z+1] == 's')
+	fmt[z+1] = 'p';
+			}
 			fn = [e->she_funcoffset];
 			bintime2timeval(>she_bintime, );
 			(void)printf("%06ld.%06ld %s#%"PRIu32"@%"PRIu32": ",



CVS commit: src/usr.bin/vmstat

2019-04-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr 30 23:29:18 UTC 2019

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use PRWORD for printing -m/-mW totals so fields don't run in to each other.

While here, update field widths for 'vmstat -mW' for modern machines.


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.225 src/usr.bin/vmstat/vmstat.c:1.226
--- src/usr.bin/vmstat/vmstat.c:1.225	Thu Dec 13 01:58:04 2018
+++ src/usr.bin/vmstat/vmstat.c	Tue Apr 30 23:29:18 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.225 2018/12/13 01:58:04 sevan Exp $ */
+/* $NetBSD: vmstat.c,v 1.226 2019/04/30 23:29:18 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.225 2018/12/13 01:58:04 sevan Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.226 2019/04/30 23:29:18 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -1435,7 +1435,7 @@ dopool_sysctl(int verbose, int wide)
 	size_t i, len;
 	int name_len, ovflw;
 	struct pool_sysctl *pp, *data;
-	char in_use[8], avail[8], maxp[32];
+	char maxp[32];
 
 	data = asysctlbyname("kern.pool", );
 	if (data == NULL)
@@ -1447,23 +1447,23 @@ dopool_sysctl(int verbose, int wide)
 
 	(void)printf("Memory resource pool statistics\n");
 	(void)printf(
-	"%-*s%*s%*s%5s%*s%s%s%*s%*s%6s%s%6s%6s%6s%5s%s%s\n",
+	"%-*s%*s%*s%*s%*s%s%s%*s%*s%*s%s%*s%6s%*s%5s%s%s\n",
 	wide ? 16 : 11, "Name",
-	wide ? 6 : 5, "Size",
+	wide ? 7 : 5, "Size",
 	wide ? 12 : 9, "Requests",
-	"Fail",
+	wide ? 8 : 5, "Fail",
 	wide ? 12 : 9, "Releases",
-	wide ? "  InUse" : "",
-	wide ? " Avail" : "",
-	wide ? 7 : 6, "Pgreq",
-	wide ? 7 : 6, "Pgrel",
-	"Npage",
+	wide ? "InUse" : "",
+	wide ? "Avail" : "",
+	wide ? 11 : 6, "Pgreq",
+	wide ? 11 : 6, "Pgrel",
+	wide ? 8 : 6, "Npage",
 	wide ? " PageSz" : "",
-	"Hiwat",
+	wide ? 7 : 6, "Hiwat",
 	"Minpg",
-	"Maxpg",
+	wide ? 7 : 6, "Maxpg",
 	"Idle",
-	wide ? " Flags" : "",
+	wide ? "  Flags" : "",
 	wide ? "   Util" : "");
 
 	name_len = MIN((int)sizeof(pp->pr_wchan), wide ? 16 : 11);
@@ -1478,35 +1478,33 @@ dopool_sysctl(int verbose, int wide)
 			pp->pr_maxpages);
 		ovflw = 0;
 		PRWORD(ovflw, "%-*s", name_len, 0, pp->pr_wchan);
-		PRWORD(ovflw, " %*" PRIu64, wide ? 6 : 5, 1, pp->pr_size);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 5, 1, pp->pr_size);
 		PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pp->pr_nget);
 		pool_totals.pt_nget += pp->pr_nget;
-		PRWORD(ovflw, " %*" PRIu64, 5, 1, pp->pr_nfail);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pp->pr_nfail);
 		pool_totals.pt_nfail += pp->pr_nfail;
 		PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pp->pr_nput);
 		pool_totals.pt_nput += pp->pr_nput;
 		if (wide) {
-			PRWORD(ovflw, " %*" PRIu64, 7, 1, pp->pr_nout);
+			PRWORD(ovflw, " %*" PRIu64, 9, 1, pp->pr_nout);
 			pool_totals.pt_nout += pp->pr_nout;
-		}
-		if (wide) {
-			PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_nitems);
+			PRWORD(ovflw, " %*" PRIu64, 9, 1, pp->pr_nitems);
 			pool_totals.pt_nitems += pp->pr_nitems;
 		}
-		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 6, 1, pp->pr_npagealloc);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pp->pr_npagealloc);
 		pool_totals.pt_npagealloc += pp->pr_npagealloc;
-		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 6, 1, pp->pr_npagefree);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 11 : 6, 1, pp->pr_npagefree);
 		pool_totals.pt_npagefree += pp->pr_npagefree;
-		PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_npages);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 6, 1, pp->pr_npages);
 		pool_totals.pt_npages += pp->pr_npages;
 		if (wide)
 			PRWORD(ovflw, " %*" PRIu64, 7, 1, pp->pr_pagesize);
-		PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_hiwat);
+		PRWORD(ovflw, " %*" PRIu64, wide ? 7 : 6, 1, pp->pr_hiwat);
 		PRWORD(ovflw, " %*" PRIu64, 6, 1, pp->pr_minpages);
-		PRWORD(ovflw, " %*s", 6, 1, maxp);
+		PRWORD(ovflw, " %*s", wide ? 7 : 6, 1, maxp);
 		PRWORD(ovflw, " %*" PRIu64, 5, 1, pp->pr_nidle);
 		if (wide)
-			PRWORD(ovflw, " 0x%0*" PRIx64, 4, 1,
+			PRWORD(ovflw, " 0x%0*" PRIx64, 5, 1,
 			pp->pr_flags);
 
 		this_inuse = pp->pr_nout * pp->pr_size;
@@ -1531,25 +1529,20 @@ dopool_sysctl(int verbose, int wide)
 		}
 		(void)printf("\n");
 	}
+	ovflw = 0;
+	PRWORD(ovflw, "%-*s", name_len, 0, "Totals");
+	PRWORD(ovflw, " %*s", wide ? 7 : 5, 1, "");
+	PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, pool_totals.pt_nget);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 8 : 5, 1, pool_totals.pt_nfail);
+	PRWORD(ovflw, " %*" PRIu64, wide ? 12 : 9, 1, 

CVS commit: src/usr.bin/vmstat

2019-04-30 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr 30 23:29:18 UTC 2019

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use PRWORD for printing -m/-mW totals so fields don't run in to each other.

While here, update field widths for 'vmstat -mW' for modern machines.


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2018-12-24 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Tue Dec 25 03:38:59 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Remove reference to Installing and Operating 4.3BSD paper, at present it's not
possible to find a paper titled as such with sections starting with
"Interpreting system activity".
There is a "Monitoring System Performance" section present from the 4.1BSD
Installing and Operating paper up to and including the 4.4BSD paper. The advice
in this section has not aged very well.
>From "Installing and Operating 4.3BSD-tahoe UNIX on the VAX":
"Cumulatively on one of our large machines we average about 60-100
context switches and interrupts per second and about 70-120 system calls
per second"


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.1
diff -u src/usr.bin/vmstat/vmstat.1:1.23 src/usr.bin/vmstat/vmstat.1:1.24
--- src/usr.bin/vmstat/vmstat.1:1.23	Thu Dec 13 01:29:10 2018
+++ src/usr.bin/vmstat/vmstat.1	Tue Dec 25 03:38:59 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmstat.1,v 1.23 2018/12/13 01:29:10 sevan Exp $
+.\"	$NetBSD: vmstat.1,v 1.24 2018/12/25 03:38:59 sevan Exp $
 .\"
 .\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\"
 .\"	@(#)vmstat.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd December 13, 2018
+.Dd December 25, 2018
 .Dt VMSTAT 1
 .Os
 .Sh NAME
@@ -300,11 +300,6 @@ apparent which are recomputed every seco
 .Xr iostat 8 ,
 .Xr pstat 8 ,
 .Xr kernhist 9
-.Pp
-The sections starting with
-.Dq Interpreting system activity
-in
-.%T Installing and Operating 4.3BSD .
 .Sh BUGS
 The
 .Fl c



CVS commit: src/usr.bin/vmstat

2018-12-24 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Tue Dec 25 03:38:59 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Remove reference to Installing and Operating 4.3BSD paper, at present it's not
possible to find a paper titled as such with sections starting with
"Interpreting system activity".
There is a "Monitoring System Performance" section present from the 4.1BSD
Installing and Operating paper up to and including the 4.4BSD paper. The advice
in this section has not aged very well.
>From "Installing and Operating 4.3BSD-tahoe UNIX on the VAX":
"Cumulatively on one of our large machines we average about 60-100
context switches and interrupts per second and about 70-120 system calls
per second"


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.bin/vmstat

2018-12-13 Thread Sevan Janiyan
On 13/12/2018 04:00, Simon Burge wrote:
> While a bit wordier, I think that accurately describes the behaviour.
> LGTM.

Thanks. I had one other thought which I haven't investigated yet but did
we change behaviour intentionally? My committed change complements the
description of -c
"Repeat the display count times.  The first display is for the time
since a reboot and each subsequent report is for the time period since
the last display.  If no wait interval is specified, the default is 1
second."

The other thing was that prior to my commit, I was testing things on an
i7 and there the run queue doesn't change. When you followed up post
commit, I checked on a uniprocessor system & there the run queue does
register.
I want to explore that too and document further (heads up) aside from
this scenario with the first line.


Sevan


Re: CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Simon Burge
Hi Sevan,

Sevan Janiyan wrote:

> How about this?
>
> Index: usr.bin/vmstat/vmstat.1
> ===
> RCS file: /cvsroot/src/usr.bin/vmstat/vmstat.1,v
> retrieving revision 1.23
> diff -u -p -r1.23 vmstat.1
> --- usr.bin/vmstat/vmstat.1 13 Dec 2018 01:29:10 -  1.23
> +++ usr.bin/vmstat/vmstat.1 13 Dec 2018 02:50:00 -
> @@ -76,9 +76,17 @@ disk, trap, and CPU activity.
>  If
>  .Nm
>  is invoked without any options, it displays the summary of statistics since
> -boot and exits.
> +boot for all fields except memory and process statistic then exits.
> +The memory and process fields are live samples taken at the time
> +.Nm
> +was invoked in this implementation.
>  This is also referred to as the first line of
>  .Nm .
> +The
> +.Fl N ,
> +.Fl v ,
> +.Fl W
> +options adhere to this behaviour.
>  .Pp
>  The options are as follows:
>  .Bl -tag -width xxxhistname

While a bit wordier, I think that accurately describes the behaviour.
LGTM.

Cheers,
Simon.


Re: CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Sevan Janiyan
How about this?

Index: usr.bin/vmstat/vmstat.1
===
RCS file: /cvsroot/src/usr.bin/vmstat/vmstat.1,v
retrieving revision 1.23
diff -u -p -r1.23 vmstat.1
--- usr.bin/vmstat/vmstat.1 13 Dec 2018 01:29:10 -  1.23
+++ usr.bin/vmstat/vmstat.1 13 Dec 2018 02:50:00 -
@@ -76,9 +76,17 @@ disk, trap, and CPU activity.
 If
 .Nm
 is invoked without any options, it displays the summary of statistics since
-boot and exits.
+boot for all fields except memory and process statistic then exits.
+The memory and process fields are live samples taken at the time
+.Nm
+was invoked in this implementation.
 This is also referred to as the first line of
 .Nm .
+The
+.Fl N ,
+.Fl v ,
+.Fl W
+options adhere to this behaviour.
 .Pp
 The options are as follows:
 .Bl -tag -width xxxhistname



Re: CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Sevan Janiyan
Hi Simon,

On 13/12/2018 02:14, Simon Burge wrote:
>   +If
>   +.Nm
>   +is invoked without any options, it displays the summary of statistics since
>   +boot and exits.
> 
> That's not true for the process and memory info though, right?  For
> those two these are their current state, not a summary since boot.  Also
> technically a few options don't change this behaviour either (at least
> -M -N -v and -W?).
> 
> Not sure how we should document all this and be correct at the same
> time. :)

Yes you are right. When you invoke it over and over, free memory
changes. then the run queue if you specify an option.
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502920  18484  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502920  18484  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502920  18488  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502920  18484  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502924  18480  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502924  18480  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 1 0   502920  18488  229   0   0056 18   21 7949  62  2  1 97
play$ vmstat -c 3
 procsmemory  page   disk faults  cpu
 r b  avmfre  flt  re  pi   po   fr   sr l0   in   sy  cs us sy id
 2 0   502920  18484  229   0   0056 18   21 7949  62  2  1 97
 0 0   502920  184840   0   0000  07   62  23  0 0 100
 0 0   502924  184841   0   0000  07   58  26  0 0 100


Re: CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Simon Burge
Hi Sevan,

"Sevan Janiyan" wrote:

> Module Name:  src
> Committed By: sevan
> Date: Thu Dec 13 01:29:11 UTC 2018
>
> Modified Files:
>
>   src/usr.bin/vmstat: vmstat.1
>
> Log Message:
>
> Describe what happens when you run vmstat witout any options aka the first 
> line
> of vmstat.

  +If
  +.Nm
  +is invoked without any options, it displays the summary of statistics since
  +boot and exits.

That's not true for the process and memory info though, right?  For
those two these are their current state, not a summary since boot.  Also
technically a few options don't change this behaviour either (at least
-M -N -v and -W?).

Not sure how we should document all this and be correct at the same
time. :)

Cheers,
Simon.


CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Dec 13 01:58:04 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
typo


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.224 src/usr.bin/vmstat/vmstat.c:1.225
--- src/usr.bin/vmstat/vmstat.c:1.224	Mon Dec  4 03:05:57 2017
+++ src/usr.bin/vmstat/vmstat.c	Thu Dec 13 01:58:04 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.224 2017/12/04 03:05:57 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.225 2018/12/13 01:58:04 sevan Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.224 2017/12/04 03:05:57 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.225 2018/12/13 01:58:04 sevan Exp $");
 #endif
 #endif /* not lint */
 
@@ -1439,7 +1439,7 @@ dopool_sysctl(int verbose, int wide)
 
 	data = asysctlbyname("kern.pool", );
 	if (data == NULL)
-		err(1, "failed to reead kern.pool");
+		err(1, "failed to read kern.pool");
 
 	memset(_totals, 0, sizeof pool_totals);
 	total = inuse = 0;
@@ -1725,7 +1725,7 @@ dopoolcache_sysctl(int verbose)
 
 	data = asysctlbyname("kern.pool", );
 	if (data == NULL)
-		err(1, "failed to reead kern.pool");
+		err(1, "failed to read kern.pool");
 	len /= sizeof(*data);
 
 	for (i = 0; i < len; ++i) {



CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Dec 13 01:58:04 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
typo


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Dec 13 01:29:11 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Describe what happens when you run vmstat witout any options aka the first line
of vmstat.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2018-12-12 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Dec 13 01:29:11 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Describe what happens when you run vmstat witout any options aka the first line
of vmstat.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.1
diff -u src/usr.bin/vmstat/vmstat.1:1.22 src/usr.bin/vmstat/vmstat.1:1.23
--- src/usr.bin/vmstat/vmstat.1:1.22	Wed Dec  5 23:42:23 2018
+++ src/usr.bin/vmstat/vmstat.1	Thu Dec 13 01:29:10 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmstat.1,v 1.22 2018/12/05 23:42:23 sevan Exp $
+.\"	$NetBSD: vmstat.1,v 1.23 2018/12/13 01:29:10 sevan Exp $
 .\"
 .\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\"
 .\"	@(#)vmstat.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd December 5, 2018
+.Dd December 13, 2018
 .Dt VMSTAT 1
 .Os
 .Sh NAME
@@ -73,6 +73,12 @@
 .Nm
 reports certain kernel statistics kept about process, virtual memory,
 disk, trap, and CPU activity.
+If
+.Nm
+is invoked without any options, it displays the summary of statistics since
+boot and exits.
+This is also referred to as the first line of
+.Nm .
 .Pp
 The options are as follows:
 .Bl -tag -width xxxhistname



CVS commit: src/usr.bin/vmstat

2018-12-05 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed Dec  5 23:42:23 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Document vmstat -w -1 is accepted.
via FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2018-12-05 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed Dec  5 23:42:23 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Document vmstat -w -1 is accepted.
via FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.1
diff -u src/usr.bin/vmstat/vmstat.1:1.21 src/usr.bin/vmstat/vmstat.1:1.22
--- src/usr.bin/vmstat/vmstat.1:1.21	Wed Dec  5 10:35:14 2018
+++ src/usr.bin/vmstat/vmstat.1	Wed Dec  5 23:42:23 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmstat.1,v 1.21 2018/12/05 10:35:14 sevan Exp $
+.\"	$NetBSD: vmstat.1,v 1.22 2018/12/05 23:42:23 sevan Exp $
 .\"
 .\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -186,6 +186,11 @@ seconds between each display.
 If no repeat
 .Ar count
 is specified, the default is infinity.
+The
+.Nm
+command will accept and honor a negative number of
+.Ar wait
+seconds.
 .El
 .Pp
 By default,



CVS commit: src/usr.bin/vmstat

2018-12-05 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed Dec  5 10:35:14 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Suggest kernhist(9) which is required for vmstat -u and -U
Drop Pp before Bl while here.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.1
diff -u src/usr.bin/vmstat/vmstat.1:1.20 src/usr.bin/vmstat/vmstat.1:1.21
--- src/usr.bin/vmstat/vmstat.1:1.20	Wed Oct 21 22:18:37 2009
+++ src/usr.bin/vmstat/vmstat.1	Wed Dec  5 10:35:14 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: vmstat.1,v 1.20 2009/10/21 22:18:37 wiz Exp $
+.\"	$NetBSD: vmstat.1,v 1.21 2018/12/05 10:35:14 sevan Exp $
 .\"
 .\" Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -53,7 +53,7 @@
 .\"
 .\"	@(#)vmstat.8	8.1 (Berkeley) 6/6/93
 .\"
-.Dd October 22, 2009
+.Dd December 5, 2018
 .Dt VMSTAT 1
 .Os
 .Sh NAME
@@ -191,7 +191,6 @@ is specified, the default is infinity.
 By default,
 .Nm
 displays the following information:
-.Pp
 .Bl -tag -width memory
 .It procs
 Information about the numbers of processes in various states.
@@ -288,7 +287,8 @@ apparent which are recomputed every seco
 .Xr ps 1 ,
 .Xr systat 1 ,
 .Xr iostat 8 ,
-.Xr pstat 8
+.Xr pstat 8 ,
+.Xr kernhist 9
 .Pp
 The sections starting with
 .Dq Interpreting system activity



CVS commit: src/usr.bin/vmstat

2018-12-05 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Wed Dec  5 10:35:14 UTC 2018

Modified Files:
src/usr.bin/vmstat: vmstat.1

Log Message:
Suggest kernhist(9) which is required for vmstat -u and -U
Drop Pp before Bl while here.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/vmstat/vmstat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-12-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Dec  4 03:05:57 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
deref the right address to get the pool_allocator.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.223 src/usr.bin/vmstat/vmstat.c:1.224
--- src/usr.bin/vmstat/vmstat.c:1.223	Sun Dec  3 21:10:01 2017
+++ src/usr.bin/vmstat/vmstat.c	Mon Dec  4 03:05:57 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.223 2017/12/03 21:10:01 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.224 2017/12/04 03:05:57 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.223 2017/12/03 21:10:01 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.224 2017/12/04 03:05:57 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -968,8 +968,8 @@ dosum(void)
 		uvmexp.poolpages = 0;
 		for (; addr != NULL; addr = TAILQ_NEXT(pp, pr_poollist)) {
 			deref_kptr(addr, pp, sizeof(*pp), "pool chain trashed");
-			deref_kptr(addr, , sizeof(pa),
-   "pool_allocator trashed");
+			deref_kptr(pp->pr_alloc, , sizeof(pa),
+			"pool allocator trashed");
 			bytes = pp->pr_npages * pa.pa_pagesz;
 			if ((pp->pr_roflags & PR_RECURSIVE) != 0)
 bytes -= (pp->pr_nout * pp->pr_size);



CVS commit: src/usr.bin/vmstat

2017-12-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Dec  4 03:05:57 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
deref the right address to get the pool_allocator.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-12-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Dec  3 21:10:01 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
remove now wrong comment.  minor KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.222 src/usr.bin/vmstat/vmstat.c:1.223
--- src/usr.bin/vmstat/vmstat.c:1.222	Sun Dec  3 21:09:01 2017
+++ src/usr.bin/vmstat/vmstat.c	Sun Dec  3 21:10:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.222 2017/12/03 21:09:01 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.223 2017/12/03 21:10:01 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.222 2017/12/03 21:09:01 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.223 2017/12/03 21:10:01 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -968,8 +968,8 @@ dosum(void)
 		uvmexp.poolpages = 0;
 		for (; addr != NULL; addr = TAILQ_NEXT(pp, pr_poollist)) {
 			deref_kptr(addr, pp, sizeof(*pp), "pool chain trashed");
-			deref_kptr(addr, , sizeof(pa), "pool_allocator trashed");
-			 // XXX deref pr_alloc first
+			deref_kptr(addr, , sizeof(pa),
+   "pool_allocator trashed");
 			bytes = pp->pr_npages * pa.pa_pagesz;
 			if ((pp->pr_roflags & PR_RECURSIVE) != 0)
 bytes -= (pp->pr_nout * pp->pr_size);



CVS commit: src/usr.bin/vmstat

2017-12-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Dec  3 21:10:01 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
remove now wrong comment.  minor KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-12-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Dec  3 21:09:01 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
fix the kvm version of counting pool pages for vmstat -s.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.221 src/usr.bin/vmstat/vmstat.c:1.222
--- src/usr.bin/vmstat/vmstat.c:1.221	Sat Dec  2 08:15:43 2017
+++ src/usr.bin/vmstat/vmstat.c	Sun Dec  3 21:09:01 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.221 2017/12/02 08:15:43 mrg Exp $ */
+/* $NetBSD: vmstat.c,v 1.222 2017/12/03 21:09:01 mrg Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.221 2017/12/02 08:15:43 mrg Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.222 2017/12/03 21:09:01 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -893,8 +893,10 @@ dosum(void)
 	} else {
 		struct uvmexp uvmexp_kernel;
 		struct pool pool, *pp = 
+		struct pool_allocator pa;
 		TAILQ_HEAD(,pool) pool_head;
 		void *addr;
+		uint64_t bytes;
 
 		kread(namelist, X_UVMEXP, _kernel, sizeof(uvmexp_kernel));
 #define COPY(field) uvmexp.field = uvmexp_kernel.field
@@ -963,13 +965,15 @@ dosum(void)
 #undef COPY
 		kread(namelist, X_POOLHEAD, _head, sizeof(pool_head));
 		addr = TAILQ_FIRST(_head);
+		uvmexp.poolpages = 0;
 		for (; addr != NULL; addr = TAILQ_NEXT(pp, pr_poollist)) {
 			deref_kptr(addr, pp, sizeof(*pp), "pool chain trashed");
-			/*
-			 * XXXMRG
-			if ((pp->pr_roflags & PR_RECURSIVE) == 0)
-			 */
-uvmexp.poolpages += pp->pr_npages;
+			deref_kptr(addr, , sizeof(pa), "pool_allocator trashed");
+			 // XXX deref pr_alloc first
+			bytes = pp->pr_npages * pa.pa_pagesz;
+			if ((pp->pr_roflags & PR_RECURSIVE) != 0)
+bytes -= (pp->pr_nout * pp->pr_size);
+			uvmexp.poolpages += bytes / uvmexp.pagesize;
 		}
 	}
 



CVS commit: src/usr.bin/vmstat

2017-12-03 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Dec  3 21:09:01 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
fix the kvm version of counting pool pages for vmstat -s.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-09-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  6 06:05:23 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Don't print "nan" when there is no disk activity.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.217 src/usr.bin/vmstat/vmstat.c:1.218
--- src/usr.bin/vmstat/vmstat.c:1.217	Tue Jul  4 21:19:33 2017
+++ src/usr.bin/vmstat/vmstat.c	Wed Sep  6 06:05:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.217 2017/07/04 21:19:33 mlelstv Exp $ */
+/* $NetBSD: vmstat.c,v 1.218 2017/09/06 06:05:23 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.217 2017/07/04 21:19:33 mlelstv Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.218 2017/09/06 06:05:23 mlelstv Exp $");
 #endif
 #endif /* not lint */
 
@@ -1123,8 +1123,11 @@ drvstats(int *ovflwp)
 
 	for (dn = 0; dn < ndrive; ++dn) {
 		/* elapsed time for disk stats */
-		dtime = (double)cur.timestamp[dn].tv_sec +
-			((double)cur.timestamp[dn].tv_usec / (double)100);
+		dtime = cur.cp_etime;
+		if (cur.timestamp[dn].tv_sec || cur.timestamp[dn].tv_usec) {
+			dtime = (double)cur.timestamp[dn].tv_sec +
+((double)cur.timestamp[dn].tv_usec / (double)100);
+		}
 
 		if (!drv_select[dn])
 	 		continue;



CVS commit: src/usr.bin/vmstat

2017-09-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Wed Sep  6 06:05:23 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Don't print "nan" when there is no disk activity.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-04 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Jan  5 07:53:20 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
"vmstat -ie[v]" auto fit to minimum columns

Reviewed by msaitoh@


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-04 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Jan  5 07:53:20 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
"vmstat -ie[v]" auto fit to minimum columns

Reviewed by msaitoh@


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.215 src/usr.bin/vmstat/vmstat.c:1.216
--- src/usr.bin/vmstat/vmstat.c:1.215	Thu Jan  5 03:42:27 2017
+++ src/usr.bin/vmstat/vmstat.c	Thu Jan  5 07:53:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.215 2017/01/05 03:42:27 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.216 2017/01/05 07:53:20 ryo Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.215 2017/01/05 03:42:27 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.216 2017/01/05 07:53:20 ryo Exp $");
 #endif
 #endif /* not lint */
 
@@ -1216,10 +1216,11 @@ dointr(int verbose)
 
 	inttotal = 0;
 	uptime = getuptime();
-	(void)printf("%-34s %16s %8s\n", "interrupt", "total", "rate");
 	nintr = intrnl[X_EINTRCNT].n_value - intrnl[X_INTRCNT].n_value;
 	inamlen = intrnl[X_EINTRNAMES].n_value - intrnl[X_INTRNAMES].n_value;
 	if (nintr != 0 && inamlen != 0) {
+		(void)printf("%-34s %16s %8s\n", "interrupt", "total", "rate");
+
 		ointrcnt = intrcnt = malloc((size_t)nintr);
 		ointrname = intrname = malloc((size_t)inamlen);
 		if (intrcnt == NULL || intrname == NULL)
@@ -1250,19 +1251,17 @@ doevcnt(int verbose, int type)
 	uint64_t counttotal, uptime;
 	struct evcntlist allevents;
 	struct evcnt evcnt, *evptr;
+	size_t evlen_max, total_max, rate_max;
 	char evgroup[EVCNT_STRING_MAX], evname[EVCNT_STRING_MAX];
 
 	counttotal = 0;
 	uptime = getuptime();
-	if (type == EVCNT_TYPE_ANY)
-		(void)printf("%-34s %16s %8s %s\n", "event", "total", "rate",
-		"type");
 
 	if (memf == NULL) do {
 		const int mib[4] = { CTL_KERN, KERN_EVCNT, type,
 		verbose ? KERN_EVCNT_COUNT_ANY : KERN_EVCNT_COUNT_NONZERO };
-		size_t buflen = 0;
-		void *buf = NULL;
+		size_t buflen0, buflen = 0;
+		void *buf0, *buf = NULL;
 		const struct evcnt_sysctl *evs, *last_evs;
 		for (;;) {
 			size_t newlen;
@@ -1285,33 +1284,80 @@ doevcnt(int verbose, int type)
 free(buf);
 			buflen = newlen;
 		}
-		evs = buf;
+		buflen0 = buflen;
+		evs = buf0 = buf;
+		last_evs = (void *)((char *)buf + buflen);
+		buflen /= sizeof(uint64_t);
+		/* calc columns */
+		evlen_max = 0;
+		total_max = sizeof("total") - 1;
+		rate_max = sizeof("rate") - 1;
+		while (evs < last_evs
+		&& buflen >= sizeof(*evs)/sizeof(uint64_t)
+		&& buflen >= evs->ev_len) {
+			char cbuf[64];
+			size_t len;
+			len = strlen(evs->ev_strings + evs->ev_grouplen + 1);
+			len += evs->ev_grouplen + 1;
+			if (evlen_max < len)
+evlen_max= len;
+			len = snprintf(cbuf, sizeof(cbuf), "%"PRIu64,
+			evs->ev_count);
+			if (total_max < len)
+total_max = len;
+			len = snprintf(cbuf, sizeof(cbuf), "%"PRIu64,
+			evs->ev_count / uptime);
+			if (rate_max < len)
+rate_max = len;
+			buflen -= evs->ev_len;
+			evs = (const void *)
+			((const uint64_t *)evs + evs->ev_len);
+		}
+
+		(void)printf(type == EVCNT_TYPE_ANY ?
+		"%-*s  %*s %*s %s\n" :
+		"%-*s  %*s %*s\n",
+		(int)evlen_max, "interrupt",
+		(int)total_max, "total",
+		(int)rate_max, "rate",
+		"type");
+
+		buflen = buflen0;
+		evs = buf0;
 		last_evs = (void *)((char *)buf + buflen);
 		buflen /= sizeof(uint64_t);
 		while (evs < last_evs
 		&& buflen >= sizeof(*evs)/sizeof(uint64_t)
 		&& buflen >= evs->ev_len) {
 			(void)printf(type == EVCNT_TYPE_ANY ?
-			"%s %s%*s %16"PRIu64" %8"PRIu64" %s\n" :
-			"%s %s%*s %16"PRIu64" %8"PRIu64"\n",
+			"%s %s%*s  %*"PRIu64" %*"PRIu64" %s\n" :
+			"%s %s%*s  %*"PRIu64" %*"PRIu64"\n",
 			evs->ev_strings,
 			evs->ev_strings + evs->ev_grouplen + 1,
-			34 - (evs->ev_grouplen + 1 + evs->ev_namelen), "",
-			evs->ev_count,
-			evs->ev_count / uptime,
+			(int)evlen_max - (evs->ev_grouplen + 1
+			+ evs->ev_namelen), "",
+			(int)total_max, evs->ev_count,
+			(int)rate_max, evs->ev_count / uptime,
 			(evs->ev_type < __arraycount(evtypes) ?
-evtypes[evs->ev_type] : "?"));
+			evtypes[evs->ev_type] : "?"));
 			buflen -= evs->ev_len;
 			counttotal += evs->ev_count;
-			evs = (const void *)((const uint64_t *)evs + evs->ev_len);
+			evs = (const void *)
+			((const uint64_t *)evs + evs->ev_len);
 		}
 		free(buf);
 		if (type != EVCNT_TYPE_ANY)
-			(void)printf("%-34s %16"PRIu64" %8"PRIu64"\n",
-			"Total", counttotal, counttotal / uptime);
+			(void)printf("%-*s  %*"PRIu64" %*"PRIu64"\n",
+			

CVS commit: src/usr.bin/vmstat

2017-01-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jan  5 03:42:27 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Adapt to use of bintime(9) for kernel history timestamps (7.99.55).


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-04 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jan  5 03:42:27 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Adapt to use of bintime(9) for kernel history timestamps (7.99.55).


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.214 src/usr.bin/vmstat/vmstat.c:1.215
--- src/usr.bin/vmstat/vmstat.c:1.214	Wed Jan  4 01:29:18 2017
+++ src/usr.bin/vmstat/vmstat.c	Thu Jan  5 03:42:27 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.214 2017/01/04 01:29:18 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.215 2017/01/05 03:42:27 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.214 2017/01/04 01:29:18 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.215 2017/01/05 03:42:27 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -2069,6 +2069,7 @@ void
 hist_dodump(struct kern_history *histp)
 {
 	struct kern_history_ent *histents, *e;
+	struct timeval tv;
 	size_t histsize;
 	char *fmt = NULL, *fn = NULL;
 	size_t fmtlen = 0, fnlen = 0;
@@ -2110,8 +2111,9 @@ hist_dodump(struct kern_history *histp)
 			deref_kptr(e->fn, fn, fnlen, "function name");
 			fn[fnlen] = '\0';
 
-			(void)printf("%06ld.%06ld ", (long int)e->tv.tv_sec,
-			(long int)e->tv.tv_usec);
+			bintime2timeval(>bt, );
+			(void)printf("%06ld.%06ld ", (long int)tv.tv_sec,
+			(long int)tv.tv_usec);
 			(void)printf("%s#%ld@%d: ", fn, e->call, e->cpunum);
 			(void)printf(fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
 			(void)putchar('\n');
@@ -2198,6 +2200,7 @@ hist_traverse_sysctl(int todo, const cha
 hist_dodump_sysctl(int mib[], unsigned int miblen)
  {
 	struct sysctl_history *hist;
+	struct timeval tv;
 	struct sysctl_history_event *e;
  	size_t histsize;
 	char *strp;
@@ -2231,9 +2234,9 @@ hist_dodump_sysctl(int mib[], unsigned i
 		if (e->she_fmtoffset != 0) {
 			fmt = [e->she_fmtoffset];
 			fn = [e->she_funcoffset];
+			bintime2timeval(>she_bintime, );
 			(void)printf("%06ld.%06ld %s#%"PRIu64"@%"PRIu32": ",
-			(long int)e->she_time_sec,
-			(long int)e->she_time_usec,
+			(long int)tv.tv_sec, (long int)tv.tv_usec,
 			fn, e->she_callnumber, e->she_cpunum);
 			(void)printf(fmt, e->she_values[0], e->she_values[1],
 			 e->she_values[2], e->she_values[3]);



CVS commit: src/usr.bin/vmstat

2017-01-03 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Jan  4 01:29:18 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Fix error handling confusion between error and errno


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.213 src/usr.bin/vmstat/vmstat.c:1.214
--- src/usr.bin/vmstat/vmstat.c:1.213	Wed Jan  4 01:06:26 2017
+++ src/usr.bin/vmstat/vmstat.c	Wed Jan  4 01:29:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.213 2017/01/04 01:06:26 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.214 2017/01/04 01:29:18 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.213 2017/01/04 01:06:26 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.214 2017/01/04 01:29:18 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -2138,13 +2138,12 @@ hist_traverse_sysctl(int todo, const cha
 	/* retrieve names of available histories */
 	miblen = __arraycount(mib);
 	error = sysctlnametomib("kern.hist", mib, );
-	if (error == ENOENT) {
- 		warnx("kernel history is not compiled into the kernel.");
- 		return;
- 	}
 	if (error != 0) {
-		err(1, "nametomib failed");
-		return;
+		if (errno == ENOENT) {
+ 			warnx("kernel history is not compiled into the kernel.");
+			return;
+		} else
+			err(EXIT_FAILURE, "nametomib failed");
 	}
  
 	/* get the list of nodenames below kern.hist */



CVS commit: src/usr.bin/vmstat

2017-01-03 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Jan  4 01:29:18 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Fix error handling confusion between error and errno


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-03 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Jan  4 01:06:26 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Adapt to new version of the sysctl export structure


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.212 src/usr.bin/vmstat/vmstat.c:1.213
--- src/usr.bin/vmstat/vmstat.c:1.212	Mon Jan  2 09:24:54 2017
+++ src/usr.bin/vmstat/vmstat.c	Wed Jan  4 01:06:26 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.212 2017/01/02 09:24:54 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.213 2017/01/04 01:06:26 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.212 2017/01/02 09:24:54 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.213 2017/01/04 01:06:26 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -2232,11 +2232,10 @@ hist_dodump_sysctl(int mib[], unsigned i
 		if (e->she_fmtoffset != 0) {
 			fmt = [e->she_fmtoffset];
 			fn = [e->she_funcoffset];
-			(void)printf("%06ld.%06ld ",
-			(long int)e->she_tspec.tv_sec,
-			(long int)(e->she_tspec.tv_nsec / 1000));
-			(void)printf("%s#%"PRIu64"@%"PRIu32": ", fn,
-			e->she_callnumber, e->she_cpunum);
+			(void)printf("%06ld.%06ld %s#%"PRIu64"@%"PRIu32": ",
+			(long int)e->she_time_sec,
+			(long int)e->she_time_usec,
+			fn, e->she_callnumber, e->she_cpunum);
 			(void)printf(fmt, e->she_values[0], e->she_values[1],
 			 e->she_values[2], e->she_values[3]);
  			(void)putchar('\n');



CVS commit: src/usr.bin/vmstat

2017-01-03 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Jan  4 01:06:26 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Adapt to new version of the sysctl export structure


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 09:24:55 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use appropriate PRI* format specifiers for fixed-bit-size numbers

Should fix i386 build.


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.211 src/usr.bin/vmstat/vmstat.c:1.212
--- src/usr.bin/vmstat/vmstat.c:1.211	Mon Jan  2 02:08:05 2017
+++ src/usr.bin/vmstat/vmstat.c	Mon Jan  2 09:24:54 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.211 2017/01/02 02:08:05 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.212 2017/01/02 09:24:54 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.211 2017/01/02 02:08:05 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.212 2017/01/02 09:24:54 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -2235,8 +2235,8 @@ hist_dodump_sysctl(int mib[], unsigned i
 			(void)printf("%06ld.%06ld ",
 			(long int)e->she_tspec.tv_sec,
 			(long int)(e->she_tspec.tv_nsec / 1000));
-			(void)printf("%s#%ld@%d: ", fn, e->she_callnumber,
-			e->she_cpunum);
+			(void)printf("%s#%"PRIu64"@%"PRIu32": ", fn,
+			e->she_callnumber, e->she_cpunum);
 			(void)printf(fmt, e->she_values[0], e->she_values[1],
 			 e->she_values[2], e->she_values[3]);
  			(void)putchar('\n');



CVS commit: src/usr.bin/vmstat

2017-01-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 09:24:55 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use appropriate PRI* format specifiers for fixed-bit-size numbers

Should fix i386 build.


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 02:08:05 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For kvm-based kernhist code, print size of history table and "next free"
pointer, same as we do for sysctl-based code.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.210 src/usr.bin/vmstat/vmstat.c:1.211
--- src/usr.bin/vmstat/vmstat.c:1.210	Mon Jan  2 01:48:56 2017
+++ src/usr.bin/vmstat/vmstat.c	Mon Jan  2 02:08:05 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.210 2017/01/02 01:48:56 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.211 2017/01/02 02:08:05 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.210 2017/01/02 01:48:56 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.211 2017/01/02 02:08:05 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -2081,6 +2081,9 @@ hist_dodump(struct kern_history *histp)
 
 	(void)memset(histents, 0, histsize);
 
+	(void)printf("%"PRIu32" entries, next is %"PRIu32"\n",
+	histp->n, histp->f);
+
 	deref_kptr(histp->e, histents, histsize, "history entries");
 	i = histp->f;
 	do {



CVS commit: src/usr.bin/vmstat

2017-01-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 02:08:05 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For kvm-based kernhist code, print size of history table and "next free"
pointer, same as we do for sysctl-based code.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 01:48:56 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Restore the kvm-grovelling code for use on crash files (where sysctl(3)
is not available).  Otherwise, this would always report on the current
running kernel regardless of the use of -M option.


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.209 src/usr.bin/vmstat/vmstat.c:1.210
--- src/usr.bin/vmstat/vmstat.c:1.209	Mon Jan  2 01:02:19 2017
+++ src/usr.bin/vmstat/vmstat.c	Mon Jan  2 01:48:56 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.209 2017/01/02 01:02:19 pgoyette Exp $ */
+/* $NetBSD: vmstat.c,v 1.210 2017/01/02 01:48:56 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.209 2017/01/02 01:02:19 pgoyette Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.210 2017/01/02 01:48:56 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -309,7 +309,9 @@ __dead static void	usage(void);
 void	doforkst(void);
 
 void	hist_traverse(int, const char *);
-void	hist_dodump(int[], unsigned int);
+void	hist_dodump(struct kern_history *);
+void	hist_traverse_sysctl(int, const char *);
+void	hist_dodump_sysctl(int[], unsigned int);
 
 char	**choosedrives(char **);
 
@@ -475,7 +477,10 @@ main(int argc, char *argv[])
 (HISTLIST|HISTDUMP))
 	errx(1, "you may list or dump,"
 	" but not both!");
-hist_traverse(todo, histname);
+if (memf != NULL)
+	hist_traverse(todo, histname);
+else
+	hist_traverse_sysctl(todo, histname);
 (void)putchar('\n');
 			}
 			if (todo & FORKSTAT) {
@@ -2000,6 +2005,127 @@ deref_kptr(const void *kptr, void *ptr, 
 void
 hist_traverse(int todo, const char *histname)
 {
+	struct kern_history_head histhead;
+	struct kern_history hist, *histkva;
+	char *name = NULL;
+	size_t namelen = 0;
+
+	if (histnl[0].n_value == 0) {
+		warnx("kernel history is not compiled into the kernel.");
+		return;
+	}
+
+	deref_kptr((void *)histnl[X_KERN_HISTORIES].n_value, ,
+	sizeof(histhead), histnl[X_KERN_HISTORIES].n_name);
+
+	if (histhead.lh_first == NULL) {
+		warnx("No active kernel history logs.");
+		return;
+	}
+
+	if (todo & HISTLIST)
+		(void)printf("Active kernel histories:");
+
+	for (histkva = LIST_FIRST(); histkva != NULL;
+	histkva = LIST_NEXT(, list)) {
+		deref_kptr(histkva, , sizeof(hist), "histkva");
+		if (name == NULL || hist.namelen > namelen) {
+			if (name != NULL)
+free(name);
+			namelen = hist.namelen;
+			if ((name = malloc(namelen + 1)) == NULL)
+err(1, "malloc history name");
+		}
+
+		deref_kptr(hist.name, name, namelen, "history name");
+		name[namelen] = '\0';
+		if (todo & HISTLIST)
+			(void)printf(" %s", name);
+		else {
+			/*
+			 * If we're dumping all histories, do it, else
+			 * check to see if this is the one we want.
+			 */
+			if (histname == NULL || strcmp(histname, name) == 0) {
+if (histname == NULL)
+	(void)printf(
+	"\nkernel history `%s':\n", name);
+hist_dodump();
+			}
+		}
+	}
+
+	if (todo & HISTLIST)
+		(void)putchar('\n');
+
+	if (name != NULL)
+		free(name);
+}
+
+/*
+ * Actually dump the history buffer at the specified KVA.
+ */
+void
+hist_dodump(struct kern_history *histp)
+{
+	struct kern_history_ent *histents, *e;
+	size_t histsize;
+	char *fmt = NULL, *fn = NULL;
+	size_t fmtlen = 0, fnlen = 0;
+	unsigned i;
+
+	histsize = sizeof(struct kern_history_ent) * histp->n;
+
+	if ((histents = malloc(histsize)) == NULL)
+		err(1, "malloc history entries");
+
+	(void)memset(histents, 0, histsize);
+
+	deref_kptr(histp->e, histents, histsize, "history entries");
+	i = histp->f;
+	do {
+		e = [i];
+		if (e->fmt != NULL) {
+			if (fmt == NULL || e->fmtlen > fmtlen) {
+if (fmt != NULL)
+	free(fmt);
+fmtlen = e->fmtlen;
+if ((fmt = malloc(fmtlen + 1)) == NULL)
+	err(1, "malloc printf format");
+			}
+			if (fn == NULL || e->fnlen > fnlen) {
+if (fn != NULL)
+	free(fn);
+fnlen = e->fnlen;
+if ((fn = malloc(fnlen + 1)) == NULL)
+	err(1, "malloc function name");
+			}
+
+			deref_kptr(e->fmt, fmt, fmtlen, "printf format");
+			fmt[fmtlen] = '\0';
+
+			deref_kptr(e->fn, fn, fnlen, "function name");
+			fn[fnlen] = '\0';
+
+			(void)printf("%06ld.%06ld ", (long int)e->tv.tv_sec,
+			(long int)e->tv.tv_usec);
+			(void)printf("%s#%ld@%d: ", fn, e->call, e->cpunum);
+			(void)printf(fmt, e->v[0], e->v[1], e->v[2], e->v[3]);
+			(void)putchar('\n');
+		}
+		i = (i + 1) % histp->n;
+	} while (i != histp->f);
+
+	free(histents);
+	if (fmt != NULL)
+		

CVS commit: src/usr.bin/vmstat

2017-01-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 01:48:56 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Restore the kvm-grovelling code for use on crash files (where sysctl(3)
is not available).  Otherwise, this would always report on the current
running kernel regardless of the use of -M option.


To generate a diff of this commit:
cvs rdiff -u -r1.209 -r1.210 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2017-01-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 01:02:19 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For kernel history display, replace the kvm grovelling with the newly
available sysctl access to the history data.

XXX vmstat still uses kvm for several other displays


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.208 src/usr.bin/vmstat/vmstat.c:1.209
--- src/usr.bin/vmstat/vmstat.c:1.208	Tue Oct  4 17:36:21 2016
+++ src/usr.bin/vmstat/vmstat.c	Mon Jan  2 01:02:19 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.208 2016/10/04 17:36:21 christos Exp $ */
+/* $NetBSD: vmstat.c,v 1.209 2017/01/02 01:02:19 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.208 2016/10/04 17:36:21 christos Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.209 2017/01/02 01:02:19 pgoyette Exp $");
 #endif
 #endif /* not lint */
 
@@ -309,7 +309,7 @@ __dead static void	usage(void);
 void	doforkst(void);
 
 void	hist_traverse(int, const char *);
-void	hist_dodump(struct kern_history *);
+void	hist_dodump(int[], unsigned int);
 
 char	**choosedrives(char **);
 
@@ -2000,122 +2000,122 @@ deref_kptr(const void *kptr, void *ptr, 
 void
 hist_traverse(int todo, const char *histname)
 {
-	struct kern_history_head histhead;
-	struct kern_history hist, *histkva;
-	char *name = NULL;
-	size_t namelen = 0;
-
-	if (histnl[0].n_value == 0) {
+	int error;
+	int mib[4];
+	unsigned int i;
+	size_t len, miblen;
+	struct sysctlnode query, histnode[32];
+
+	/* retrieve names of available histories */
+	miblen = __arraycount(mib);
+	error = sysctlnametomib("kern.hist", mib, );
+	if (error == ENOENT) {
 		warnx("kernel history is not compiled into the kernel.");
 		return;
 	}
+	if (error != 0) {
+		err(1, "nametomib failed");
+		return;
+	}
 
-	deref_kptr((void *)histnl[X_KERN_HISTORIES].n_value, ,
-	sizeof(histhead), histnl[X_KERN_HISTORIES].n_name);
-
-	if (histhead.lh_first == NULL) {
+	/* get the list of nodenames below kern.hist */
+	mib[2] = CTL_QUERY;
+	memset(, 0, sizeof(query));
+	query.sysctl_flags = SYSCTL_VERSION;
+	len = sizeof(histnode);
+	error = sysctl(mib, 3, [0], , , sizeof(query));
+	if (error != 0) {
+		err(1, "query failed");
+		return;
+	}
+	if (len == 0) {
 		warnx("No active kernel history logs.");
 		return;
 	}
 
+	len = len / sizeof(histnode[0]);	/* get # of entries returned */
+
 	if (todo & HISTLIST)
 		(void)printf("Active kernel histories:");
 
-	for (histkva = LIST_FIRST(); histkva != NULL;
-	histkva = LIST_NEXT(, list)) {
-		deref_kptr(histkva, , sizeof(hist), "histkva");
-		if (name == NULL || hist.namelen > namelen) {
-			if (name != NULL)
-free(name);
-			namelen = hist.namelen;
-			if ((name = malloc(namelen + 1)) == NULL)
-err(1, "malloc history name");
-		}
-
-		deref_kptr(hist.name, name, namelen, "history name");
-		name[namelen] = '\0';
+	for (i = 0; i < len; i++) {
 		if (todo & HISTLIST)
-			(void)printf(" %s", name);
+			(void)printf(" %s", histnode[i].sysctl_name);
 		else {
 			/*
 			 * If we're dumping all histories, do it, else
 			 * check to see if this is the one we want.
 			 */
-			if (histname == NULL || strcmp(histname, name) == 0) {
+			if (histname == NULL ||
+			strcmp(histname, histnode[i].sysctl_name) == 0) {
 if (histname == NULL)
 	(void)printf(
-	"\nkernel history `%s':\n", name);
-hist_dodump();
+	"\nkernel history `%s':\n",
+	histnode[i].sysctl_name);
+mib[2] = histnode[i].sysctl_num;
+mib[3] = CTL_EOL;
+hist_dodump(mib, 4);
 			}
 		}
 	}
 
 	if (todo & HISTLIST)
 		(void)putchar('\n');
-
-	if (name != NULL)
-		free(name);
 }
 
 /*
  * Actually dump the history buffer at the specified KVA.
  */
 void
-hist_dodump(struct kern_history *histp)
+hist_dodump(int mib[], unsigned int miblen)
 {
-	struct kern_history_ent *histents, *e;
+	struct sysctl_history *hist;
+	struct sysctl_history_event *e;
 	size_t histsize;
-	char *fmt = NULL, *fn = NULL;
-	size_t fmtlen = 0, fnlen = 0;
+	char *strp;
 	unsigned i;
+	char *fmt = NULL, *fn = NULL;
 
-	histsize = sizeof(struct kern_history_ent) * histp->n;
-
-	if ((histents = malloc(histsize)) == NULL)
-		err(1, "malloc history entries");
-
-	(void)memset(histents, 0, histsize);
-
-	deref_kptr(histp->e, histents, histsize, "history entries");
-	i = histp->f;
+	hist = NULL;
+	histsize = 0;
 	do {
-		e = [i];
-		if (e->fmt != NULL) {
-			if (fmt == NULL || e->fmtlen > fmtlen) {
-if (fmt != NULL)
-	free(fmt);
-fmtlen = e->fmtlen;
-if ((fmt = malloc(fmtlen + 1)) == NULL)
-	

CVS commit: src/usr.bin/vmstat

2017-01-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Jan  2 01:02:19 UTC 2017

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
For kernel history display, replace the kvm grovelling with the newly
available sysctl access to the history data.

XXX vmstat still uses kvm for several other displays


To generate a diff of this commit:
cvs rdiff -u -r1.208 -r1.209 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2016-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  4 17:36:21 UTC 2016

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
No point in using float here; makes evbmips64 need __truncdfsf2, and that
causes static linking issues because of softfloat.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/vmstat

2016-10-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Oct  4 17:36:21 UTC 2016

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
No point in using float here; makes evbmips64 need __truncdfsf2, and that
causes static linking issues because of softfloat.


To generate a diff of this commit:
cvs rdiff -u -r1.207 -r1.208 src/usr.bin/vmstat/vmstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.207 src/usr.bin/vmstat/vmstat.c:1.208
--- src/usr.bin/vmstat/vmstat.c:1.207	Sun Sep  4 20:40:30 2016
+++ src/usr.bin/vmstat/vmstat.c	Tue Oct  4 13:36:21 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.207 2016/09/05 00:40:30 sevan Exp $ */
+/* $NetBSD: vmstat.c,v 1.208 2016/10/04 17:36:21 christos Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.207 2016/09/05 00:40:30 sevan Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.208 2016/10/04 17:36:21 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -1643,7 +1643,7 @@ dopoolcache_sysctl(int verbose)
 	bool first = true;
 	int ovflw;
 	uint64_t tot;
-	float p;
+	double p;
 
 	data = asysctlbyname("kern.pool", );
 	if (data == NULL)



Re: CVS commit: src/usr.bin/vmstat

2016-03-07 Thread Martin Husemann
On Sun, Mar 06, 2016 at 01:01:28PM -0500, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Sun Mar  6 18:01:28 UTC 2016
> 
> Modified Files:
>   src/usr.bin/vmstat: Makefile
> 
> Log Message:
> Work around gcc on sparc64 bug

This warning should in general be made non-fatal, as it only tells us something
about the compiler backend, not the code being compiled.

Martin


CVS commit: src/usr.bin/vmstat

2016-03-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  6 18:01:28 UTC 2016

Modified Files:
src/usr.bin/vmstat: Makefile

Log Message:
Work around gcc on sparc64 bug


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/vmstat/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   >