为什么Linux内核ZONE_NORMAL限制为896 MB? [英] Why Linux Kernel ZONE_NORMAL is limited to 896 MB?

查看:298
本文介绍了为什么Linux内核ZONE_NORMAL限制为896 MB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个新手问题.我正在做一些内核研究,对 ZONE_NORMAL的最大大小为896MB.我不明白为什么内核不能 将4G物理内存直接映射到内核空间.一些文件 提到了页面地图的大小限制.但是考虑4G内存 有2 ^ 20页,每个结构页"为4个字节,mem_map将 只能是4MB.那不应该是问题.希望你能给我一些 光.

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.

谢谢

推荐答案

当然,内核可以映射所有可用内存.

Of course, the kernel can map all available memory.

在Linux中,所有存储区中可用的内存归为节点".这些节点用于指示每个存储体有多少内存.每个节点中的内存分为区域".当前定义的区域是ZONE_DMAZONE_NORMALZONE_HIGHMEM.

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进行数据传输,并映射到较低的物理内存范围(最大16 MB).

ZONE_DMA is used by some devices for data transfer and is mapped in the lower physical memory range (up to 16 MB).

内存是内核在线性地址空间的上部区域中映射的.大多数操作只能在ZONE_NORMAL中进行;因此,这是性能最关键的区域. ZONE_NORMAL从16 MB增大到896 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.

为什么?

部分内存保留给内核数据结构使用,这些数据结构存储有关内存映射和页表的信息.这在x86上是128 MB.因此,内核可以访问的1 GB物理内存中(在典型配置中,为内核保留1 GB),保留128 MB.因此,这128 MB中的内核虚拟地址不会直接映射到物理内存.这样,ZONE_NORMAL最多保留896 MB.因此,即使一个人具有1 GB的物理RAM,实际上只有896 MB的空间可用于用户空间.

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.

为了更好地理解该主题,建议您阅读Linux设备驱动程序的第15章(

To better understand the subject, I suggest you have a look at Chapter 15 of Linux Device Drivers (pdf).

这篇关于为什么Linux内核ZONE_NORMAL限制为896 MB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆