开发者

zone_NORMAL and ZONE_HIGHMEM on 32 and 64 bit kernels

开发者 https://www.devze.com 2023-03-08 12:34 出处:网络
I trying to to make the linux memory management a little bit more clear for tuning and performances purposes.

I trying to to make the linux memory management a little bit more clear for tuning and performances purposes.

By reading this very interesting redbook "Linux Performance and Tuning Guidelines" found on the IBM website I came across something I don't fully understand.

On 32-bit architectures such as the IA-32, the Linux kernel can directly address only the first gigabyte of physical memory (896 MB w开发者_如何学Pythonhen considering the reserved range). Memory above the so-called ZONE_NORMAL must be mapped into the lower 1 GB. This mapping is completely transparent to applications, but allocating a memory page in ZONE_HIGHMEM causes a small performance degradation.

  1. why the memory above 896 MB has to be mapped into the lower 1GB ?
  2. Why there is an impact on performances by allocating a memory page in ZONE_HIGHMEM ?
  3. what is the ZONE_HIGHMEM used for then ?
  4. why a kernel that is able to recognize up to 4gb ( CONFIG_HIGHMEM=y ) can just use the first gigabyte ?

Thanks in advance


When a user process traps in to the kernel, the page tables are not changed. This means that one linear address space must be able to cover both the memory addresses available to the user process, and the memory addresses available to the kernel.

On IA-32, which allows a 4GB linear address space, usually the first 3GB of the linear address space are allocated to the user process, and the last 1GB of the linear address space is allocated to the kernel.

The kernel must use its 1GB range of addresses to be able to address any part of physical memory it needs to. Memory above 896MB is not "mapped into the low 1GB" - what happens is that physical memory below 896MB is assigned a permanent linear address in the kernel's part of the linear address space, whereas as memory above that limit must be assigned a temporary mapping in the remaining part of the linear address space.

There is no impact on performance when mapping a ZONE_HIGHMEM page into a userspace process - for a userspace process, all physical memory pages are equal. The impact on performance exists when the kernel needs to access a non-user page in ZONE_HIGHMEM - to do so, it must map it into the linear address space if it is not already mapped.

0

精彩评论

暂无评论...
验证码 换一张
取 消