Why Linux Kernel ZONE_NORMAL is limited to 896 MB?

前端 未结 2 623
小蘑菇
小蘑菇 2021-02-01 09:24

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

2条回答
  •  难免孤独
    2021-02-01 09:43

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

提交回复
热议问题