Subject: Re: vm size wrongly reported
To: Andrew Brown <firstname.lastname@example.org>
From: Robert Elz <kre@munnari.OZ.AU>
Date: 05/05/2003 06:09:55
Date: Sun, 4 May 2003 15:39:05 -0400
From: Andrew Brown <email@example.com>
| >if we add them all up yes but just using the size count from vm_map should
| >give the exact size of the virtual address space,
| so...it does, but that number is considerably larger than a given
| process's impact on the vm system, since a lot of that space is
I suspect you're confusing VM and real memory. I'm not sure which it
is you're wanting to count, but what's above makes no sense.
Take the simplest possible example. A process forks (not vfork, not that
it matters). The fork call has not yet actually returned in either process
(some higher priority process took away the CPU) but it has otherwise
finished - neither process has had a chance to touch a page. Each process
has identical process images (share every page).
The total VM consumed by those two processes is twice that consumed by
one of them (twice as much as was consumed before the fork). That all
of the pages are shared is irrelevant. To calculate VM allocations all
that should ever be done is to add the VM of every process in the system.
On the other hand, the real mem consumed is much harder to attribute to
processes, simply adding it will give vastly wrong numbers for the totals.
In the above example, one might allocate all of the real mem to one of the
two processes, and 0 to the other, or one might attempt to allocate it
"fairly" (attributing half of the allocated mem to each process) - calculating
the total is easy, ignore the processes, and count the allocated pages.
Distributing the total amongst the users in some rational way is hard
(because no two people will agree on what is rational, not because implementing
an agreed method needs to necessarily be difficult).