32 位和 64 位内核上的 zone_NORMAL 和 ZONE_HIGHMEM

发布于 2024-11-09 16:33:03 字数 599 浏览 0 评论 0原文

我试图使 Linux 内存管理更加清晰,以达到调优和性能的目的。

通过阅读 IBM 网站 我遇到了一些我不完全理解的事情。

在 IA-32 等 32 位架构上,Linux 内核只能直接寻址第一个 GB 的物理内存(考虑保留范围时为 896 MB)。高于所谓的 ZONE_NORMAL 的内存必须映射到较低的 1 GB。此映射对应用程序完全透明,但在 ZONE_HIGHMEM 中分配内存页会导致性能轻微下降。

  1. 为什么896MB以上的内存必须映射到较低的1GB?
  2. 为什么在 ZONE_HIGHMEM 中分配内存页会对性能产生影响?
  3. 那么 ZONE_HIGHMEM 的用途是什么?
  4. 为什么能够识别高达 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 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

儭儭莪哋寶赑 2024-11-16 16:33:03

当用户进程陷入内核时,页表不会更改。这意味着一个线性地址空间必须能够覆盖用户进程可用的内存地址和内核可用的内存地址。

在允许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 in ZONE_HIGHMEM - to do so, it must map it into the linear address space if it is not already mapped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文