A newbie question. I'm doing some kernel study and get confused on the 896MB size limit of ZONE_NORMAL. I don't understand why kernel cannot map 4G physical memory into kernel space directly. Some documents mentioned its size constraint of page map. But considering 4G memory has 2^20 pages and each "struct page" is 4 bytes, the mem_map would only be 4MB. That should not be the issue. Hope you could shed me some light.
Thanks
Of course, the kernel can map all available memory.
In Linux, the memory available from all banks is classified into "nodes". These nodes are used to indicate how much memory each bank has. Memory in each node is divided into "zones". The zones currently defined are ZONE_DMA
, ZONE_NORMAL
and ZONE_HIGHMEM
.
ZONE_DMA
is used by some devices for data transfer and is mapped in the lower physical memory range (up to 16 MB).
Memory in the ZONE_NORMAL
region is mapped by the kernel in the upper region of the linear address space. Most operations can only take place in ZONE_NORMAL
; so this is the most performance critical zone. ZONE_NORMAL
goes from 16 MB to 896 MB.
Why?
Part of memory is reserved for kernel data structures that store information about the memory map and page tables. This on x86 is 128 MB. Hence, of the 1 GB physical memory the kernel can access (on a typical configuration, 1GB is reserved for the kernel), 128MB is reserved. Hence the kernel virtual addresses in this 128 MB are not mapped to physical memory directly. This leaves a maximum of 896 MB for ZONE_NORMAL
. So, even if one has 1 GB of physical RAM, just 896 MB will be actually available for userspace.
To better understand the subject, I suggest you have a look at Chapter 15 of Linux Device Drivers (pdf).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With