Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Linux Kernel ZONE_NORMAL is limited to 896 MB?

Tags:

linux

kernel

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

like image 980
user1063294 Avatar asked Nov 24 '11 05:11

user1063294


1 Answers

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).

like image 127
Michael Foukarakis Avatar answered Sep 23 '22 23:09

Michael Foukarakis