# Missing Memory

## SuperMe

I have 8GB installed in my machine but /proc/meminfo and free only report 7GB? Am I reading them wrong or have I lost a GB somewhere?

```
$ cat /proc/meminfo

MemTotal:      7080360 kB

MemFree:       6536640 kB

Buffers:        156936 kB

Cached:         196940 kB

SwapCached:          0 kB

Active:         162668 kB

Inactive:       197812 kB

SwapTotal:     3903672 kB

SwapFree:      3903672 kB

Dirty:              60 kB

Writeback:           0 kB

AnonPages:        6608 kB

Mapped:           4368 kB

Slab:           168460 kB

SReclaimable:   161964 kB

SUnreclaim:       6496 kB

PageTables:       1424 kB

NFS_Unstable:        0 kB

Bounce:              0 kB

WritebackTmp:        0 kB

CommitLimit:   7443852 kB

Committed_AS:    19204 kB

VmallocTotal: 34359738367 kB

VmallocUsed:     51240 kB

VmallocChunk: 34359686275 kB

HugePages_Total:     0

HugePages_Free:      0

HugePages_Rsvd:      0

HugePages_Surp:      0

Hugepagesize:     2048 kB

DirectMap4k:      5056 kB

DirectMap2M:   7268352 kB

$ free -m

             total       used       free     shared    buffers     cached

Mem:          6914        530       6383          0        153        192

-/+ buffers/cache:        185       6729

Swap:         3812          0       3812

```

----------

## VinzC

I'd say your kernel sees a little more than 6 GB... Are you running Gentoo x86 or x86_64? Also post the results of cat /proc/cpuinfo. And does your computer BIOS notice the 8 GB? Any memory dedicated to your video card?

----------

## geraldine

Of course you can not use entirely 8GB memory, because the operating system you used requires hundred MB of memory.

----------

## VinzC

 *geraldine wrote:*   

> Of course you can not use entirely 8GB memory, because the operating system you used requires hundred MB of memory.

 

MemTotal always reflects the total amount of physical memory, even if it's not used entirely.

----------

## dmpogo

 *VinzC wrote:*   

>  *geraldine wrote:*   Of course you can not use entirely 8GB memory, because the operating system you used requires hundred MB of memory. 
> 
> MemTotal always reflects the total amount of physical memory, even if it's not used entirely.

 

At least on opterons there was always ~700 MB memory missing between 3rd and 4th GB when you install more that 4 Gb. Much discussed 'memory gap', which was not always recoverable (not sure about every platform)

Take my old server

Mem:  32829296k total

while 

32Gb = 33554432k

33554432k-32829296k=725136k=708M

----------

## VinzC

Gap is another thing. But are both of you using 32-bit kernels with PAE or 64-bit kernels?

----------

## dmpogo

 *VinzC wrote:*   

> Gap is another thing. But are both of you using 32-bit kernels with PAE or 64-bit kernels?

 

64-bit, of course

----------

## VinzC

Strangely enough there seems to be the same gap with Windows. Sorry, that's with 32-bit versions of Windows  :Embarassed:  .

EDIT: Maybe ask kernel developers... That's beyond my knowledge at least.

----------

## dmpogo

 *VinzC wrote:*   

> Strangely enough there seems to be the same gap with Windows. Sorry, that's with 32-bit versions of Windows  .
> 
> EDIT: Maybe ask kernel developers... That's beyond my knowledge at least.

 

Yep, I thought I was close to understanding when I was invesitgating it in 2005 when I got my opterons, but I never did understand it deeply and now forgot even what I knew  :Smile: 

My understanding was that it is a range in 'address space' where all hardware lives. It was put at the end of 32-bit addressible space, specifically not to interfere with physical RAM, which was in Megabytes,  not GB then.   But now with RAM reaching 4B we find that we can't address a part of it because those addresses are already used (not because hardware actually uses RAM). So the question of remapping arise.  64-but kernel could have all the hardware addresses far away again, but there is a question of BIOS which has to be able to address the hardware as well. 

Saying that, I think some BIOSes come with some option regarding remapping memory.

In my experience as well playing with 'memory model' in kernel setup (originally, on opterons, there was a choice of three) changed the size of the lost memory a bit.Last edited by dmpogo on Sun Jul 12, 2009 8:45 pm; edited 1 time in total

----------

## s4e8

Enable memory remap in BIOS, some motherboard will eat PCI bus overlayed memory (approx. 1G) without memory remap, but still report RAM over 4G.

Another possiblility is broken mtrr. You can verify it with

dmesg | grep e820

cat /proc/mtrr

----------

## VinzC

 *VinzC wrote:*   

> Strangely enough there seems to be the same gap with Windows. Sorry, that's with 32-bit versions of Windows  .
> 
> EDIT: Maybe ask kernel developers... That's beyond my knowledge at least.

 

 *dmpogo wrote:*   

> Yep, I thought I was close to understanding when I was invesitgating it in 2005 when I got my opterons, but I never did understand it deeply and now forgot even what I knew 
> 
> My understanding was that it is a range in 'address space' where all hardware lives. It was put at the end of 32-bit addressible space, specifically not to interfere with physical RAM, which was in Megabytes,  not GB then.   But now with RAM reaching 4B we find that we can't address a part of it because those addresses are already used (not because hardware actually uses RAM). So the question of remapping arise.  64-but kernel could have all the hardware addresses far away again, but there is a question of BIOS which has to be able to address the hardware as well. 
> 
> Saying that, I think some BIOSes come with some option regarding remapping memory.
> ...

 

 *s4e8 wrote:*   

> Enable memory remap in BIOS, some motherboard will eat PCI bus overlayed memory (approx. 1G) without memory remap, but still report RAM over 4G.
> 
> Another possiblility is broken mtrr. You can verify it with
> 
> dmesg | grep e820
> ...

 

I think I understand...

Far from willing to launch a troll but it reminds me the good old times of 8 then 16 bits architectures. I remember discussing and comparing Motorola processors (e.g. those found in Amiga computers) with Intel's. Conclusion was always the same for many reasons (Intel's model is crappy by design). Putting the BIOS at the end of the address space has the problem arise whether 8-, 16-, 32-, 64-, whatever- bitness of the address space. This kind of architecture forces things like remapping, which I find... a waste...

I might be not the only one who thinks that way.

----------

## SuperMe

Thanks for your helpful comments. I've just moved my gentoo box so it isn't plugged in at the moment. Next time I fire it up I'll see what I can find out.

----------

## snIP3r

hi all!

same here:

```

Memory: 5610904k/6815744k available (4675k kernel code, 1050184k absent, 154656k reserved, 2258k data, 632k init)

```

```

cat /proc/meminfo

MemTotal:        5611576 kB

MemFree:          173588 kB

Buffers:               0 kB

Cached:          4412512 kB

SwapCached:        29340 kB

Active:          2342176 kB

Inactive:        2749516 kB

Active(anon):     522368 kB

Inactive(anon):   157188 kB

Active(file):    1819808 kB

Inactive(file):  2592328 kB

Unevictable:           0 kB

Mlocked:               0 kB

SwapTotal:       3911816 kB

SwapFree:        3813236 kB

Dirty:               492 kB

Writeback:             0 kB

AnonPages:        651768 kB

Mapped:            24144 kB

Slab:             294928 kB

SReclaimable:     261428 kB

SUnreclaim:        33500 kB

PageTables:        10092 kB

NFS_Unstable:          0 kB

Bounce:                0 kB

WritebackTmp:          0 kB

CommitLimit:     6717604 kB

Committed_AS:    1159028 kB

VmallocTotal:   34359738367 kB

VmallocUsed:       92116 kB

VmallocChunk:   34359630867 kB

HugePages_Total:       0

HugePages_Free:        0

HugePages_Rsvd:        0

HugePages_Surp:        0

Hugepagesize:       2048 kB

DirectMap4k:        4992 kB

DirectMap2M:     5761024 kB

```

```

cat /proc/mtrr

reg00: base=0x000000000 (    0MB), size= 2048MB, count=1: write-back

reg01: base=0x080000000 ( 2048MB), size= 1024MB, count=1: write-back

reg02: base=0x0bff00000 ( 3071MB), size=    1MB, count=1: uncachable

reg03: base=0x100000000 ( 4096MB), size= 2048MB, count=1: write-back

reg04: base=0x180000000 ( 6144MB), size=  512MB, count=1: write-back

```

using 64bit gentoo. i think the missing ram is used by bios.

greets

snIP3r

----------

## VinzC

```
$ grep MemTotal /proc/meminfo

MemTotal:        4059396 kB
```

```
$ echo $((4*1024*1024-4059396))

134908
```

I have 4GB on my 64-bit Gentoo laptop (Dell Studio XPS) and the difference is a little more than 128MB. I think my video card uses 128MB from system memory. There is still a ~3MB gap... BIOS shadow (it's about 4MB too)? Shadow at all? (I have no such information from the BIOS unfortunately.)

----------

## s4e8

Your 128M margin is normal, It's used by kernel internals: code, data, reserved, bootmem(hashtable). The memtotal is the total memory available to dynamic memory allocator.

The most accurate usable memory is int15 E820 interface, here is my examaple: 

```

gentoo$ dmesg | grep e820

 BIOS-e820: 0000000000000000 - 0000000000098000 (usable)

 BIOS-e820: 0000000000098000 - 00000000000a0000 (reserved)

 BIOS-e820: 00000000000e4000 - 0000000000100000 (reserved)

 BIOS-e820: 0000000000100000 - 00000000bff90000 (usable)

 BIOS-e820: 00000000bff90000 - 00000000bff9e000 (ACPI data)

 BIOS-e820: 00000000bff9e000 - 00000000bffe0000 (ACPI NVS)

 BIOS-e820: 00000000bffe0000 - 00000000c0000000 (reserved)

 BIOS-e820: 00000000fee00000 - 00000000fee01000 (reserved)

 BIOS-e820: 00000000ffb00000 - 0000000100000000 (reserved)

 BIOS-e820: 0000000100000000 - 0000000240000000 (usable)

e820 update range: 0000000000000000 - 0000000000010000 (usable) ==> (reserved)

e820 update range: 00000000c0000000 - 0000000100000000 (usable) ==> (reserved)

gentoo$ cat /proc/mtrr 

reg00: base=0x0c0000000 ( 3072MB), size= 1024MB, count=1: uncachable

reg01: base=0x000000000 (    0MB), size= 8192MB, count=1: write-back

reg02: base=0x200000000 ( 8192MB), size= 1024MB, count=1: write-back

```

My gentoo has 8G RAM, 3G below 32bit(4G), 5G above 4G. MTRR mark first 8G, and 8G+1G is writable-back(RAM), exclude 3G+1G(pci bus) as uncachable. The total usable RAM is 8G: 0G+3G, 4G+4G, 8G+1G.  The E820 show same memory mapping: 0-98000(602k) is DOS legacy, 1G-0xbff90000 is first 3G(low 32bit, exclude some ACPI and SMM), 4G+5G(high).

----------

## VinzC

Thanks, I never paid attention to what that meant. Here's what is shown on my laptop;

```
reg00: base=0x000000000 (    0MB), size= 2048MB, count=1: write-back

reg01: base=0x080000000 ( 2048MB), size= 1024MB, count=1: write-back

reg02: base=0x100000000 ( 4096MB), size= 1024MB, count=1: write-back

reg03: base=0x0ffe00000 ( 4094MB), size=    2MB, count=1: write-protect

reg04: base=0x0d0000000 ( 3328MB), size=  256MB, count=1: write-combining
```

```
 BIOS-e820: 0000000000000000 - 000000000009c400 (usable)

 BIOS-e820: 000000000009c400 - 00000000000a0000 (reserved)

 BIOS-e820: 00000000000d2000 - 00000000000d4000 (reserved)

 BIOS-e820: 00000000000e0000 - 0000000000100000 (reserved)

 BIOS-e820: 0000000000100000 - 00000000bf8a1000 (usable)

 BIOS-e820: 00000000bf8a1000 - 00000000bf8a7000 (reserved)

 BIOS-e820: 00000000bf8a7000 - 00000000bf9bb000 (usable)

 BIOS-e820: 00000000bf9bb000 - 00000000bfa0f000 (reserved)

 BIOS-e820: 00000000bfa0f000 - 00000000bfb08000 (usable)

 BIOS-e820: 00000000bfb08000 - 00000000bfd0f000 (reserved)

 BIOS-e820: 00000000bfd0f000 - 00000000bfd18000 (usable)

 BIOS-e820: 00000000bfd18000 - 00000000bfd1f000 (reserved)

 BIOS-e820: 00000000bfd1f000 - 00000000bfd63000 (usable)

 BIOS-e820: 00000000bfd63000 - 00000000bfd9f000 (ACPI NVS)

 BIOS-e820: 00000000bfd9f000 - 00000000bfde4000 (usable)

 BIOS-e820: 00000000bfde4000 - 00000000bfdff000 (ACPI data)

 BIOS-e820: 00000000bfdff000 - 00000000bfe00000 (usable)

 BIOS-e820: 0000000100000000 - 0000000140000000 (usable)
```

Makes it clearer. I haven't made the computation but I guess the sum of all these (usable) items gives what's indicated by MemTotal, right?

----------

## snIP3r

 *VinzC wrote:*   

> Makes it clearer. I haven't made the computation but I guess the sum of all these (usable) items gives what's indicated by MemTotal, right?

 

i assume thats right.

greets

snIP3r

----------

## s4e8

Don't assume anything, the truth is the fact.

----------

