Martin Husemann | 3 Jun 2012 14:58
Picon

Unit confusion in kinfo_proc2

It seems there is confusion wether a vmpsace vm_map.size element is
measured in bytes or pages. The uvm code seems to treat it as bytes,
so I guess we should apply something like this patch?

Note the correct usage a few lines below the patched one...

Martin

Index: kern_proc.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_proc.c,v
retrieving revision 1.183
diff -u -1 -0 -r1.183 kern_proc.c
--- kern_proc.c	13 Apr 2012 15:32:15 -0000	1.183
+++ kern_proc.c	3 Jun 2012 12:54:41 -0000
 <at>  <at>  -2272,21 +2272,21  <at>  <at> 

 	ki->p_nlwps = p->p_nlwps;
 	ki->p_realflag = ki->p_flag;

 	if (p->p_stat != SIDL && !P_ZOMBIE(p) && !zombie) {
 		vm = p->p_vmspace;
 		ki->p_vm_rssize = vm_resident_count(vm);
 		ki->p_vm_tsize = vm->vm_tsize;
 		ki->p_vm_dsize = vm->vm_dsize;
 		ki->p_vm_ssize = vm->vm_ssize;
-		ki->p_vm_vsize = vm->vm_map.size;
+		ki->p_vm_vsize = atop(vm->vm_map.size);
 		/*
 		 * Since the stack is initially mapped mostly with
(Continue reading)

David Laight | 3 Jun 2012 19:08
Picon

Re: Unit confusion in kinfo_proc2

On Sun, Jun 03, 2012 at 02:58:15PM +0200, Martin Husemann wrote:
> It seems there is confusion wether a vmpsace vm_map.size element is
> measured in bytes or pages. The uvm code seems to treat it as bytes,
> so I guess we should apply something like this patch?

All the uses I found (building amd64 GENERIC with a renamed field)
showed the kernel expects it to be bytes.
p_vm_vsize is documented as being pages.

The entire source tree only contains 3 references of p_vm_vsize
(including the defn).
The other is:
./lib/libkvm/kvm_proc.c:     kp2p->p_vm_vsize = kp->kp_eproc.e_vm.vm_map.size;

I'm surprised 'ps' can't display it!

	David

--

-- 
David Laight: david <at> l8s.co.uk


Gmane