Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Nov 2006 01:38:00 +0300
From:      Ruslan Ermilov <ru@freebsd.org>
To:        stable@freebsd.org
Subject:   Re: systat -vm output showing negative total virtual memory
Message-ID:  <20061116223800.GA85695@rambler-co.ru>
In-Reply-To: <20061116191037.GA1515@roadrunner.q.local>
References:  <7ad7ddd90611160255m553a471cy41f6c911bdc2a1bf@mail.gmail.com> <20061116150309.GD48412@rambler-co.ru> <20061116191037.GA1515@roadrunner.q.local>

next in thread | previous in thread | raw e-mail | index | archive | help

--GvXjxJ+pjyke8COw
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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:
>=20
> Thanks!, I applied your patch to RELENG_6
>=20
> 22K active VM and 1K shared? Seems pretty low to me...
>=20
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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[] =3D "@(#)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)
=20
 static void
 putint(n, l, lc, w)
-	int n, l, lc, w;
+	intmax_t n;
+	int l, lc, w;
 {
 	char b[128];
=20
@@ -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);
 }
=20
%%%


Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

--GvXjxJ+pjyke8COw
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (FreeBSD)

iD8DBQFFXOhIqRfpzJluFF4RAtBHAJsFdI/ctD226z4CiOSs+4saEy5I7QCbBMqb
V1Q2XU77i27P9y7IGGaLQiE=
=jNC2
-----END PGP SIGNATURE-----

--GvXjxJ+pjyke8COw--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061116223800.GA85695>