Real and availible RAM
tlambert2 at mindspring.com
Mon May 5 21:09:55 PDT 2003
Eric Anderson wrote:
> > If you look at the way x86 architecture is designed (and somebody else can
> > feel free to correct me if I'm wrong), but system memory is often used in
> > the caching/shadowing of BIOS. This is where a lot of system memory often
> > goes before the OS is loaded - also, as Rob said, the kernel itself will
> > take up memory before the rest of the OS is booted.
> I believe that the BIOS steals the ram prior to the OS booting, so that
> the box does not show that as part of the total ram.. Like:
Since the BIOS is where FreeBSD obtains the "real memory" number,
this is pretty unlikely; the BIOS would just lie to FreeBSD about
the number, and be done with it.
Also, the 6M is the FreeBSD kernel, page tables, and some misc
stuff. You'll note that the "real memory" number is smaller
than the expected number for the amount of physical RAM: it
already contains the lies by the BIOS.
Basically, FreeBSD does not retroactively repair the accounting
of the VM system to account for memory consumed before it was up
and running -- e.g. it uses pages, and it (in fact) loses pages as
well (for example the pages used for the 4K page tables for the
kernel prior to the switch over to 4M pages, if you switch to 4M
pages, are never returned to the VM system, among many others).
The "real" vs. "avail" are a courtesy, between what FreeBSD was
told by the BIOS, vs. what is known to the FreeBSD VM. I really
suggest anyone who thinks any differently read and understand the
code in /sys/i386/i386/machdep.c; specificfically, getmemsize(),
where "basemem", "extmem", and Maxmem are calculated, and in the
code that gets run in cpu_startup() that prints out the "avail"
from ptoa(cnt.v_free_count) -- the VM system's idea of the size
of memory available to the kernel.
More information about the freebsd-performance