Subject: bin/587: incorrect %MEM of ps
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Fumitoshi UKAI <ukai@vectra1.hplj.yhp.hp.com>
List: netbsd-bugs
Date: 11/24/1994 04:50:06
>Number:         587
>Category:       bin
>Synopsis:       incorrect %MEM of ps
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 24 04:50:05 1994
>Originator:     Fumitoshi UKAI
>Organization:
	"Hewlett-Packard Laboratories Japan, Inc."
>Release:        1.0
>Environment:
	machine		HP Vectra 66/XM
	os		NetBSD/i386 1.0
	target		i386
System: NetBSD vectra1.hplj.yhp.hp.com 1.0 NetBSD 1.0 (VECTRA) #0: Wed Nov 9 11:05:37 JST 1994 ukai@vectra1.hplj.yhp.hp.com:/usr/src/sys/arch/i386/compile/VECTRA i386


>Description:
	``ps aux'' tells the percentage of real memory about almost
	all processes is 0.0.
	This is because mempages, which is number of pages of
	phys. memory (in nlist.c) is not counted in pagesize but in
	bytes.
	
>How-To-Repeat:
	% ps aux

>Fix:
	apply this patch

--- /usr/src/bin/ps/nlist.c.orig	Thu Nov 24 21:28:18 1994
+++ /usr/src/bin/ps/nlist.c	Thu Nov 24 21:28:58 1994
@@ -46,6 +46,7 @@
 #include <nlist.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "ps.h"
 
@@ -109,6 +110,7 @@
 		eval = rval = 1;
 	}
 	mempages -= tmp;
+	mempages /= getpagesize();
 #else
 	if (kread(X_ECMX, mempages)) {
 		warnx("ecmx: %s", kvm_geterr(kd));


--
Fumitoshi UKAI,                                           ukai@hplj.hpl.hp.com
Hewlett-Packard Laboratories Japan, Inc.       Kawasaki-shi Kanagawa 213 JAPAN
>Audit-Trail:
>Unformatted: