More RAM than MemTotal

More RAM than MemTotal

Oleg Goldshmidt pub at goldshmidt.org
Wed Mar 28 20:21:29 IST 2012


Hi Orna, Baruch,

On Wed, Mar 28, 2012 at 2:46 PM, Baruch Siach <baruch at tkos.co.il> wrote:

> Do 'dmesg |grep Memory:' on your machine. Here is the output of mine:
>
> Memory: 3967520k/5240832k available (3402k kernel code, 1137484k absent,
> 135828k reserved, 3330k data, 568k init)
>
> The sum of 'absent' and 'reserved' should account for most of the missing
> RAM.
>

It should, actually, account for all of the "missing" (note quotation
marks!) kilobytes. The other pieces *are* available to the OS (and are used
as indicated).

Note that these two components do not count the same thing. The "reserved"
one is actually physical RAM that is reserved by the BIOS (typically for
the various I/O stuff, including PCI, as Nadav mentioned; IIRC - not
checked - the "reserve" boot parameter is related). The details are in
"dmesg | grep BIOS" or similar. The "absent" part is *not* physical memory
- these are holes in the virtual address space.

There are enough quirks and dark corners to confuse anyone here. The
crucial observation is that neither "dmesg | grep Memory" nor "grep
MemTotal /proc/meminfo" show you the physical memory (or memory allocated
to a VM). They show you *available* memory. Here are some numerological
details from my laptop.

$ dmesg | grep Memory
[    0.000000] Memory: 3956448k/5242880k available (5873k kernel code,
1123116k absent, 163316k reserved, 5785k data, 960k init)

I work out that 5242880k=5G, which I know to be wrong because I only have
4G of RAM. I seem to be "missing" 5242880k-3956448k=1286432k, which is
exactly 1123116k+163316k - see above.

Now, there is another little mystery: why does my computer say

$ egrep MemTotal /proc/meminfo
MemTotal:        3976120 kB

rather than 3956448k that is reported as available by dmesg? Recall that
neither represents physical memory (that would be 4194304k). Actually,
dmesg reports whatever is available at that stage in the boot process.
MemTotal shows RAM available for use at the time you looked. After the boot
finishes some of the memory used during boot is freed and becomes available
(hint: look at the 960k reported as "init"), so typically you'll see a
somewhat larger number in MemTotal (as is the case above).

I figure that 4194304k-3976120k-163316k=54868k are still reserved in one
way or another. My guess is that the missing memory (about 1.3%) is struct
page.

Hope that helps.

-- 
Oleg Goldshmidt | pub at goldshmidt.org <oleg at goldshmidt.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20120328/e63b8b64/attachment-0001.html>


More information about the Linux-il mailing list