# How much of 4GB RAM I should be able to see?

## wazow

I have compiled a kernel with himem support (4GB) and I believe I am running it on 4GB RAM machine (32 bit Xeon).  Nevertheless top says:

 *Quote:*   

> Mem:   3370212k total,   495228k used,  2874984k free,   103500k buffers
> 
> 

 

and

```

abacus root # cat /proc/meminfo 

MemTotal:      3370212 kB

MemFree:       2871528 kB

Buffers:        103536 kB

Cached:         255640 kB

SwapCached:          0 kB

Active:         262492 kB

Inactive:       118360 kB

HighTotal:     2490112 kB

HighFree:      2210304 kB

LowTotal:       880100 kB

LowFree:        661224 kB

SwapTotal:     3911816 kB

SwapFree:      3911816 kB

Dirty:            3464 kB

Writeback:           0 kB

Mapped:          29620 kB

Slab:           108600 kB

Committed_AS:    34464 kB

PageTables:        628 kB

VmallocTotal:   114680 kB

VmallocUsed:      2140 kB

VmallocChunk:   112376 kB

```

Is this expected or am I loosing (missing?) the big chunk of the last gig (something like 0.7GB)?

----------

## col

is that what  your bios says ?

----------

## wazow

 *col wrote:*   

> is that what  your bios says ?

 

Good question.  Sometimes one forgets the simplest thing.   I will check it as soon as I can reboot the machine.

----------

## piquadrat

I'll try my best explaining this with my limited english:

a 32bit system can only address 4GByte of RAM (2^32 bytes). But since the PCI bus needs some address space to, it blends a window in the 4GByte address space (512 MBytes AFAIK) which essentially means that your BIOS can't address all of your RAM. 

I'm not sure if there are workarounds for this problem for Xeons...

----------

## wazow

 *HermesConrad wrote:*   

> A 32bit system can only address 4GByte of RAM (2^32 bytes). But since the PCI bus needs some address space to, it blends a window in the 4GByte address space (512 MBytes AFAIK) which essentially means that your BIOS can't address all of your RAM. 

 

This cannot be true.  The standard kernel allows Highmem up to 64GB on x86 (I have recently investigated the issue).  This must be done by some indirect addressing, perhaps at some cost of slow access time.  Even 16bit machines running DOS were able to access beyond the limit of 20bit addresses.  It was just a little bit hacky to get it.  I believe the kernel can do it better, as long as a single process  does not need more than 4GB. 

I have not yet rebooted the machine, but this is what dmesg says for last reboot:

```
BIOS-provided physical RAM map:

 BIOS-e820: 0000000000000000 - 00000000000a0000 (usable)

 BIOS-e820: 0000000000100000 - 00000000cffc0000 (usable)

 BIOS-e820: 00000000cffc0000 - 00000000cffcfc00 (ACPI data)

 BIOS-e820: 00000000cffcfc00 - 00000000cffff000 (reserved)

 BIOS-e820: 00000000e0000000 - 00000000fec90000 (reserved)

 BIOS-e820: 00000000fed00000 - 00000000fed00400 (reserved)

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

 BIOS-e820: 00000000ffb00000 - 0000000100000000 (reserved)

 BIOS-e820: 0000000100000000 - 0000000130000000 (usable)

Warning only 4GB will be used.

Use a PAE enabled kernel.

3200MB HIGHMEM available.

896MB LOWMEM available.

```

Does not it look like it can see all the memory? So why top does not?   :Confused: 

----------

## col

I plugged 4G of ram in and only saw 3.8 in the bios and in the kernel...the amounts were the same.

----------

## jebroman

I've just installed a server with 4GB RAM. This is the output of meminfo:

system root # cat /proc/meminfo

MemTotal:      3960412 kB

MemFree:       1588560 kB

Buffers:        363996 kB

Cached:        1670564 kB

SwapCached:          0 kB

Active:        1170396 kB

Inactive:       995944 kB

HighTotal:     3080160 kB

HighFree:      1378304 kB

LowTotal:       880252 kB

LowFree:        210256 kB

SwapTotal:     3904552 kB

SwapFree:      3904552 kB

Dirty:              16 kB

Writeback:           0 kB

Mapped:         164808 kB

Slab:           190212 kB

Committed_AS:   246164 kB

PageTables:       1020 kB

VmallocTotal:   114680 kB

VmallocUsed:     14836 kB

VmallocChunk:    99788 kB

I'm using kernel 2.6.9 and as you can see I'm able to use all of the 4 GB of RAM. The Linux kernel can address 64GB RAM on a 32 bitIintel plattform using Intel PAE. As far as I know a single process can never be address more than  4GB on a 32-bit system. Because of the 3:1 memory split that the Linux kernel uses I think a single process can never be bigger than 3GB. (1GB revserved for kernel-stuff)

When I first installed my 4GB system I first actived the 64GB option in kernel. This caused some serious problemes though....I couldn't do anything without getting Segmentation Faults.  Perhaps this occcured because of the Intel PAE (Physical Address Extension) which in essence allows the 32 Intel CPU to address more than 4GB of RAM.

I'm not sure why the seg faults occured, perhaps the hardware (HP DL 580) needs to activate Intel PAE?? Anyone seen anything similar?

Anyway..you should be able to use all of your 4GB of RAM.

/johan

----------

## wazow

Are you guys giving any options to your kernels? What options?

(I now know that BIOS says 4GB)

----------

## jebroman

Nope, no extra options to kernel....(during boot i persume?)

When compling the kernel i set:

CONFIG_HIGHMEM4G=y

That's it. No other magic to make it see the full 4GB of RAM

/j

----------

## wazow

jebroman, what kernel sources are you using?  Can  you also post the top of dmesg output corresponding to the one I posted above?

(yes, I meant boot options, too bad that you do not use them  :Wink: 

 I have to search for another fix then)

----------

## jebroman

I use gentoo-dev sources (kernel 2.6.9-gentoo-r1). Dmesg doesn't give any information about memory.....sorry

----------

## wazow

This puzzles me still a bit.  I have recompiled the kernel (actually current hardened kernel -r10) with 64GB support and everything seems to be fine.  The system sees the entire 4GB RAM.   Anybody got a clue why this happens? According to kernel help (and common sense) it should be sufficient to turn on the 4GB option...

(I have also tested gentoo-dev-sources and it seems to present exactly the same puzzles).

----------

## semen

hi,

I had the same problem. 

Only 1 GB memory was available instead of 2 GB.

After changing the value:

CONFIG_HIGHMEM4G=y

and recompiling the kernel 2.6.10-gentoo-r4

and reboot

everthing becomes fine.

dmesg  | grep mem

Memory: 2074872k/2097024k available (2617k kernel code, 21344k reserved, 884k data, 200k init, 1179520k highmem)

highmem bounce pool size: 64 pages

Total HugeTLB memory allocated, 0

Freeing unused kernel memory: 200k freed

 :Wink: 

----------

## zeek

 *wazow wrote:*   

> I have not yet rebooted the machine, but this is what dmesg says for last reboot:
> 
> ```
> 
> Use a PAE enabled kernel.
> ...

 

Did you make a PAE enabled kernel?  (Note that'll add a ~20% performance hit)

----------

## drescherjm

I believe this is exactly what the 64GB option does (it enables PAE). You can not have a full 4GB of memory with 32 bit addressing because of the pci slots take over some of the upper addresses.

----------

## semen

The help of kernel make menuconfig says...

CONFIG_NOHIGHMEM:                                                   

Linux can use up to 64 Gigabytes of physical memory on x86 systems.     However, the address space of 32-bit x86 processors is only 4

Gigabytes large. That means that, if you have a large amount of         │

physical memory, not all of it can be "permanently mapped" by the       │

kernel. The physical memory that's not permanently mapped is called      "high memory".                                                       

If you are compiling a kernel which will never run on a machine with    │

more than 1 Gigabyte total physical RAM, answer "off" here (default     │

choice and suitable for most users). This will result in a "3GB/1GB"    │

split: 3GB are mapped so that each process sees a 3GB virtual memory    space and the remaining part of the 4GB virtual memory space is used    

by the kernel to permanently map as much physical memory as              possible.     

If the machine has between 1 and 4 Gigabytes physical RAM, then         │

answer "4GB" here.                                                      │

If more than 4 Gigabytes is used then answer "64GB" here. This          │

selection turns Intel PAE (Physical Address Extension) mode on.         │

PAE implements 3-level paging on IA32 processors. PAE is fully          │

supported by Linux, PAE mode is implemented on all recent Intel         │

processors (Pentium Pro and better). NOTE: If you say "64GB" here,      │

then the kernel will not boot on CPUs that don't support PAE!           │

The actual amount of total physical memory will either be               │

auto detected or can be forced by using a kernel command line option    such as "mem=256M". (Try "man bootparam" or see the documentation of your boot loader (lilo or loadlin) about how to pass options to the     │  │ kernel at boot time.)      

If unsure, say "off".   

so long

----------

