Subject: Re: vm size wrongly reported
To: Andrew Brown <atatat@atatdot.net>
From: Lars Heidieker <lars@heidieker.de>
List: current-users
Date: 05/04/2003 18:12:46
Andrew Brown wrote:

> not entirely, since that (for example) includes all space added via
> mmap(2) (shared libraries, etc).  you almost certainly *don't* want to
> include shared libraries in the reported size since they're shared.
>

thats probably where the intuitions falls apart I would like to see such
mapping accounted,
as the field is called vmsize in top and ps etc.

>
> >Ok the vmsize would be quite big sometimes because of th stack space
> >reservation.
>
> the reservation isn't all counted.  the only thing counted here is
> space that's actually been faulted into use.
>
>     % pmap -D1
>     proc->p_vmspace 0xcf8349c4 = { vm_refcnt = 1, vm_shm = 0x0,
>         vm_rssize = 0, vm_swrss = 0, vm_tsize = 67, vm_dsize = 249,
>         vm_ssize = 26, vm_taddr = 0x8048000, vm_daddr = 0x808b000,
>         vm_maxsaddr = 0xbdc00000, vm_minsaddr = 0xbfc00000 }
>     ...
>     BDC00000  30720K                     [ stack ]
>     BFA00000   1920K read/write/exec     [ stack ]
>     BFBE0000     64K read/write/exec     [ stack ]
>     BFBF0000     64K read/write/exec     [ stack ]
>
> vm_ssize says i've used 26 pages out of the two megabyte reservation
> for stack space.  again, if you used the size field from the vm_map,
> you'd be counting all of that reservation, plus the empty space from
> the top of the soft limit to the top of the hard limit (an additional
> 30 megabytes).  and the shared libraries.  etc.
>

True, its the 30megs that should not be reported but I don't see any
trouble with the 2megs from the soft limit,
thats what happens in a lot of other systems FreeBSD, Solaris...
This is the point where the problem is.
Its the fact that memory mapped with mmap on /dev/null device or with
MAP_ANON flag does not
increase the reported vmsize and that is strange.

>
> perhaps what you want is something more intelligent that can walk
> through the map, entry by entry, and count only:
>
>     * the text segment
>     * the data segment
>     * stack segments that are backed by an amap (and only the number
>       of used pages there)
>     * any other entries backed by anon space up to the size of the
>       allocation (or the number of pages?)
>
> how do you want to count a one megabyte mapping of which i've only
> used one page?
>

Just count them as they use up the virtual space, it would then make sense
to have reported
how much of the virtual space is shared.

>
> >And anyway whats up with merging the struct vmspace with struct vm_map?
>
> processes need a vmspace.  the kernel only needs a vm_map.
>
> --
> |-----< "CODE WARRIOR" >-----|
> codewarrior@daemon.org             * "ah!  i see you have the internet
> twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
> werdna@squooshy.com       * "information is power -- share the wealth."

--
Mystische Erklärungen.
Die mystischen Erklärungen gelten für tief;
die Wahrheit ist, daß sie noch nicht einmal oberflächlich sind.
                --Friedrich Nietzsche