Subject: bin/29213: sysstat(1) vmstat cannot display large memory values
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <njoly@pasteur.fr>
List: netbsd-bugs
Date: 02/03/2005 13:23:00
>Number:         29213
>Category:       bin
>Synopsis:       sysstat(1) vmstat cannot display large memory values
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 03 13:23:00 +0000 2005
>Originator:     Nicolas Joly
>Release:        NetBSD 2.99.15
>Organization:
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 2.99.15 NetBSD 2.99.15 (LANFEUST) #0: Tue Jan 25 18:26:25 CET 2005 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
On systems with memory + swap exceed 10GB, `sysstat vmstat' command is not
able to display correctly some memory values. The memory columns are currently
limited to 7 chars :

          memory totals (in kB)             3570 Interrupts               fksvm
         real   virtual    free              100 cpu0 softclock           pwait
Active  31652     31652 6962188                6 cpu0 softnet             relck
All    596140    596140 *******              100 cpu0 timer               rlkok

Bumping columns to 9 characters (8 numbers + 1 separator for easier reading)
gives a better result :

            memory totals (in kB)           4619 Interrupts               fksvm
           real  virtual     free            100 cpu0 softclock           pwait
Active    31652     3165  6962188                cpu0 softnet             relck
All      596140    59614 15351516            100 cpu0 timer               rlkok

>How-To-Repeat:
run `sysstat vmstat' on system with total mem+swap >10GB
>Fix:
Index: vmstat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.56
diff -u -r1.56 vmstat.c
--- vmstat.c	13 Jun 2004 08:56:21 -0000	1.56
+++ vmstat.c	3 Feb 2005 12:49:54 -0000
@@ -324,8 +324,8 @@
 
 	clear();
 	mvprintw(STATROW, STATCOL + 4, "users    Load");
-	mvprintw(MEMROW, MEMCOL,     "          memory totals (in kB)");
-	mvprintw(MEMROW + 1, MEMCOL, "         real   virtual    free");
+	mvprintw(MEMROW, MEMCOL,     "            memory totals (in kB)");
+	mvprintw(MEMROW + 1, MEMCOL, "           real  virtual     free");
 	mvprintw(MEMROW + 2, MEMCOL, "Active");
 	mvprintw(MEMROW + 3, MEMCOL, "All");
 
@@ -501,15 +501,15 @@
 	mvaddstr(STATROW, STATCOL + 53, buf);
 #define pgtokb(pg)	((pg) * (s.uvmexp.pagesize / 1024))
 
-	putint(pgtokb(s.uvmexp.active), MEMROW + 2, MEMCOL + 6, 7);
+	putint(pgtokb(s.uvmexp.active), MEMROW + 2, MEMCOL + 6, 9);
 	putint(pgtokb(s.uvmexp.active + s.uvmexp.swpginuse),	/* XXX */
-	    MEMROW + 2, MEMCOL + 16, 7);
-	putint(pgtokb(s.uvmexp.npages - s.uvmexp.free), MEMROW + 3, MEMCOL + 6, 7);
+	    MEMROW + 2, MEMCOL + 16, 9);
+	putint(pgtokb(s.uvmexp.npages - s.uvmexp.free), MEMROW + 3, MEMCOL + 6, 9);
 	putint(pgtokb(s.uvmexp.npages - s.uvmexp.free + s.uvmexp.swpginuse),
-	    MEMROW + 3, MEMCOL + 16, 7);
-	putint(pgtokb(s.uvmexp.free), MEMROW + 2, MEMCOL + 24, 7);
+	    MEMROW + 3, MEMCOL + 16, 9);
+	putint(pgtokb(s.uvmexp.free), MEMROW + 2, MEMCOL + 24, 9);
 	putint(pgtokb(s.uvmexp.free + s.uvmexp.swpages - s.uvmexp.swpginuse),
-	    MEMROW + 3, MEMCOL + 24, 7);
+	    MEMROW + 3, MEMCOL + 24, 9);
 	putint(total.t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3);
 	putint(total.t_dw, PROCSROW + 1, PROCSCOL + 6, 3);
 	putint(total.t_sl, PROCSROW + 1, PROCSCOL + 9, 3);