Index | Thread | Search

From:
"Ted Unangst" <tedu@tedunangst.com>
Subject:
vmstat -m columns
To:
tech@openbsd.org
Date:
Mon, 19 May 2025 23:06:31 -0400

Download raw body.

Thread
vmstat -m output for malloc buckets has become unreadable.

Memory statistics by type                           Type  Kern
          Type InUse MemUse HighUse  Limit Requests Limit Size(s)
        devbuf  5076 17585K  18347K219874K     9164    0  16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288
           pcb    17    13K     13K219874K       17    0  16,32,1024
        rtable    58     2K      3K219874K      270    0  16,32,64,128,256

What do the words "Type  Kern" in the first header mean?
The first column is ragged, making it hard to read. Text should be left
aligned.
The limit column has exploded.

I think this is an improvement. I kept one space on the left, so it's 
easier to see when lines wrap.

Memory statistics by type
 Type          InUse MemUse HighUse    Limit Requests Limit Size(s)
 devbuf         5074 17557K  18347K  219874K     9210     0 16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288
 pcb              17    13K     13K  219874K       17     0 16,32,1024
 rtable           58     2K      3K  219874K      273     0 16,32,64,128,256

Index: vmstat.c
===================================================================
RCS file: /home/cvs/src/usr.bin/vmstat/vmstat.c,v
diff -u -p -r1.159 vmstat.c
--- vmstat.c	10 Mar 2025 19:52:57 -0000	1.159
+++ vmstat.c	20 May 2025 03:01:45 -0000
@@ -854,14 +854,13 @@ domem(void)
 		printf("\n");
 	}
 
+	(void)printf("\nMemory statistics by type\n");
 	(void)printf(
-	   "\nMemory statistics by type                           Type  Kern\n");
-	(void)printf(
-"          Type InUse MemUse HighUse  Limit Requests Limit Size(s)\n");
+" Type          InUse MemUse HighUse    Limit Requests Limit Size(s)\n");
 	for (i = 0, ks = &kmemstats[0]; i < M_LAST; i++, ks++) {
 		if (ks->ks_calls == 0)
 			continue;
-		(void)printf("%14s%6ld%6ldK%7ldK%6ldK%9ld%5u",
+		(void)printf(" %-13s%6ld%6ldK%7ldK%8ldK%9ld%6u",
 		    kmemnames[i] ? kmemnames[i] : "undefined",
 		    ks->ks_inuse, (ks->ks_memuse + 1023) / 1024,
 		    (ks->ks_maxused + 1023) / 1024,
@@ -872,7 +871,7 @@ domem(void)
 			if ((ks->ks_size & j) == 0)
 				continue;
 			if (first)
-				printf("  %d", j);
+				printf(" %d", j);
 			else
 				printf(",%d", j);
 			first = 0;