32 位和 64 位内核上的 zone_NORMAL 和 ZONE_HIGHMEM
我试图使 Linux 内存管理更加清晰,以达到调优和性能的目的。
通过阅读 IBM 网站 我遇到了一些我不完全理解的事情。
在 IA-32 等 32 位架构上,Linux 内核只能直接寻址第一个 GB 的物理内存(考虑保留范围时为 896 MB)。高于所谓的
ZONE_NORMAL
的内存必须映射到较低的 1 GB。此映射对应用程序完全透明,但在ZONE_HIGHMEM
中分配内存页会导致性能轻微下降。
- 为什么896MB以上的内存必须映射到较低的1GB?
- 为什么在
ZONE_HIGHMEM
中分配内存页会对性能产生影响? - 那么
ZONE_HIGHMEM
的用途是什么? - 为什么能够识别高达 4GB 的内核 (
CONFIG_HIGHMEM=y
) 只能使用第一个 GB 字节?
提前致谢
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 when 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 inZONE_HIGHMEM
causes a small performance degradation.
- why the memory above 896 MB has to be mapped into the lower 1GB ?
- Why there is an impact on performances by allocating a memory page in
ZONE_HIGHMEM
? - what is the
ZONE_HIGHMEM
used for then ? - why a kernel that is able to recognize up to 4gb (
CONFIG_HIGHMEM=y
) can just use the first gigabyte ?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户进程陷入内核时,页表不会更改。这意味着一个线性地址空间必须能够覆盖用户进程可用的内存地址和内核可用的内存地址。
在允许4GB线性地址空间的IA-32上,通常前3GB线性地址空间分配给用户进程,最后1GB线性地址空间分配给内核。
内核必须使用其 1GB 地址范围才能寻址它需要的物理内存的任何部分。 896MB 以上的内存不“映射到低 1GB” - 发生的情况是,896MB 以下的物理内存在线性地址空间的内核部分中分配了一个永久线性地址,而高于该限制的内存必须在线性地址空间的剩余部分分配一个临时映射。
将
ZONE_HIGHMEM
页映射到用户空间进程时不会对性能产生影响 - 对于用户空间进程,所有物理内存页都是相等的。当内核需要访问 ZONE_HIGHMEM 中的非用户页面时,就会对性能产生影响 - 为此,它必须将其映射到线性地址空间(如果尚未映射)。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 inZONE_HIGHMEM
- to do so, it must map it into the linear address space if it is not already mapped.