On Thu, Nov 16, 2006 at 08:10:37PM +0100, Ulrich Spoerlein wrote:
> Ruslan Ermilov wrote:
> > sysctl(8) knows that t_vm is in bytes, but for the other stats
> > it thinks they are in pages.  "systat -vm" thinks they are all
> > in bytes.  Here's a fix:
> 
> Thanks!, I applied your patch to RELENG_6
> 
> 22K active VM and 1K shared? Seems pretty low to me...
> 
Actually, the values are also in pages.  Below is a new patch
to try.  The total amount of virtual memory reported is still
insane; I think some objects are included in the stats
mistakenly, but I'm not yet sure.

%%%
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /home/ncvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.67.2.7
diff -u -p -r1.67.2.7 sysctl.c
--- sbin/sysctl/sysctl.c        8 Sep 2006 09:45:35 -0000       1.67.2.7
+++ sbin/sysctl/sysctl.c        16 Nov 2006 22:23:35 -0000
@@ -395,8 +395,8 @@ S_vmtotal(int l2, void *p)
            "%hu Sleep: %hu)\n",
            v->t_rq, v->t_dw, v->t_pw, v->t_sl);
        printf(
-           "Virtual Memory:\t\t(Total: %luK, Active %lldK)\n",
-           (unsigned long)v->t_vm / 1024,
+           "Virtual Memory:\t\t(Total: %lldK, Active %lldK)\n",
+           (long long)v->t_vm * pageKilo,
            (long long)v->t_avm * pageKilo);
        printf("Real Memory:\t\t(Total: %lldK Active %lldK)\n",
            (long long)v->t_rm * pageKilo, (long long)v->t_arm * pageKilo);
Index: usr.bin/systat/vmstat.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.60.2.1
diff -u -p -r1.60.2.1 vmstat.c
--- usr.bin/systat/vmstat.c     21 Mar 2006 20:49:50 -0000      1.60.2.1
+++ usr.bin/systat/vmstat.c     16 Nov 2006 22:35:34 -0000
@@ -58,6 +58,7 @@ static const char sccsid[] = "@(#)vmstat
 #include <ctype.h>
 #include <err.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <langinfo.h>
 #include <nlist.h>
 #include <paths.h>
@@ -135,7 +136,7 @@ static void copyinfo(struct Info *, stru
 static float cputime(int);
 static void dinfo(int, int, struct statinfo *, struct statinfo *);
 static void getinfo(struct Info *);
-static void putint(int, int, int, int);
+static void putint(intmax_t, int, int, int);
 static void putfloat(double, int, int, int, int, int);
 static void putlongdouble(long double, int, int, int, int, int);
 static int ucount(void);
@@ -472,7 +473,7 @@ showkre()
        putfloat(avenrun[1], STATROW, STATCOL + 23, 6, 2, 0);
        putfloat(avenrun[2], STATROW, STATCOL + 29, 6, 2, 0);
        mvaddstr(STATROW, STATCOL + 53, buf);
-#define pgtokb(pg)     ((pg) * (s.v_page_size / 1024))
+#define pgtokb(pg)     ((intmax_t)(unsigned)(pg) * (s.v_page_size / 1024))
        putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 3, 8);
        putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 11, 8);
        putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 19, 9);
@@ -667,7 +668,8 @@ cputime(indx)
 
 static void
 putint(n, l, lc, w)
-       int n, l, lc, w;
+       intmax_t n;
+       int l, lc, w;
 {
        char b[128];
 
@@ -677,11 +679,11 @@ putint(n, l, lc, w)
                        addch(' ');
                return;
        }
-       snprintf(b, sizeof(b), "%*d", w, n);
+       snprintf(b, sizeof(b), "%*jd", w, n);
        if ((int)strlen(b) > w)
-               snprintf(b, sizeof(b), "%*dk", w - 1, n / 1000);
+               snprintf(b, sizeof(b), "%*jdk", w - 1, n / 1000);
        if ((int)strlen(b) > w)
-               snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000);
+               snprintf(b, sizeof(b), "%*jdM", w - 1, n / 1000000);
        addstr(b);
 }
 
%%%


Cheers,
-- 
Ruslan Ermilov
[EMAIL PROTECTED]
FreeBSD committer

Attachment: pgpgnPSqeKhlL.pgp
Description: PGP signature

Reply via email to