如何在Linux内核管理超过1GB的物理内存少? [英] How does the linux kernel manage less than 1GB physical memory?

查看:362
本文介绍了如何在Linux内核管理超过1GB的物理内存少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我学习linux内核内部和在阅读理解Linux内核,相当多的内存相关的问题,让我吃惊。其中之一是,Linux内核如何处理内存映射如果只有512 MB安装我的系统上的物理内存的说。

I'm learning the linux kernel internals and while reading "Understanding Linux Kernel", quite a few memory related questions struck me. One of them is, how the Linux kernel handles the memory mapping if the physical memory of say only 512 MB is installed on my system.

当我读到,内核的地图 0(或16)MB-896MB 的物理内存为0xC0000000的线性地址,可直接解决这个问题。因此,在上述情况下,我只有512 MB:

As I read, kernel maps 0(or 16) MB-896MB physical RAM into 0xC0000000 linear address and can directly address it. So, in the above described case where I only have 512 MB:


  • 如何可以在内核地图仅512 MB 896 MB?在所述的方案中,核心设定让每一个进程的页表映射虚拟地址从0xC0000000的到0xFFFFFFFF(1GB)直接到物理地址从00000000到0x3FFFFFFF(1GB)。但是,当我只有512 MB的物理内存,我怎么能映射,虚拟地址从0xC0000000-0xFFFFFFFF物理0x00000000-0x3FFFFFFF?关键是我有只0x00000000-0x20000000一个物理范围。

  • How can the kernel map 896 MB from only 512 MB ? In the scheme described, the kernel set things up so that every process's page tables mapped virtual addresses from 0xC0000000 to 0xFFFFFFFF (1GB) directly to physical addresses from 0x00000000 to 0x3FFFFFFF (1GB). But when I have only 512 MB physical RAM, how can I map, virtual addresses from 0xC0000000-0xFFFFFFFF to physical 0x00000000-0x3FFFFFFF ? Point is I have a physical range of only 0x00000000-0x20000000.

有关这种情况下,用户模式进程是什么?

What about user mode processes in this situation?

每一篇文章只能解释的情况下,当你安装4 GB的内存和内核的1 GB映射到内核空间和用户进程使用的内存的剩余量。

Every article explains only the situation, when you've installed 4 GB of memory and the kernel maps the 1 GB into kernel space and user processes uses the remaining amount of RAM.

我想AP preciate在提高我的理解任何帮助。

I would appreciate any help in improving my understanding.

谢谢..!

推荐答案

并非所有虚拟(线性)地址必须映射到任何东西。如果code访问映射的页面,该页面故障上升。

Not all virtual (linear) addresses must be mapped to anything. If the code accesses unmapped page, the page fault is risen.

的物理页可以同时映射到多个虚拟地址。

The physical page can be mapped to several virtual addresses simultaneously.

在4 GB的虚拟内存有2部分:为0x0 ... 0xbfffffff - 是进程虚拟内存和0xc00000000的.. 0xffffffff的是内核虚拟内存

In the 4 GB virtual memory there are 2 sections: 0x0... 0xbfffffff - is process virtual memory and 0xc0000000 .. 0xffffffff is a kernel virtual memory.


  • 如何可以在内核地图仅512 MB 896 MB?

它映射到896 MB。所以,如果你只有512,将只有512 MB映射。

It maps up to 896 MB. So, if you have only 512, there will be only 512 MB mapped.

如果你的物理内存是00000000到0x20000000,它会被映射为内核直接访问虚拟地址0xC0000000的到0xE0000000(线性映射)。

If your physical memory is in 0x00000000 to 0x20000000, it will be mapped for direct kernel access to virtual addresses 0xC0000000 to 0xE0000000 (linear mapping).


  • 有关在这种情况下,用户模式进程是什么?

有关用户进程的内存物理学会被映射(不是按顺序而是随机页面到页面的映射),以虚拟地址为0x0 .... 0xC0000000的。该映射将是从0..896MB页面的第二映射。该页面将免费页列出服用。

Phys memory for user processes will be mapped (not sequentially but rather random page-to-page mapping) to virtual addresses 0x0 .... 0xc0000000. This mapping will be the second mapping for pages from 0..896MB. The pages will be taken from free page lists.


    在Phys RAM
  • 在哪里用户模式进程?

无处不在。


  • 每篇文章都只能解释的情况下,当你的安装4 GB内存的和

  • Every article explains only the situation, when you've installed 4 GB of memory and the

没有。每一篇文章解释了虚拟地址空间的4 Gb如何被映射。虚拟内存的大小始终是4 GB(对于32位机不带内存的扩展名如PAE / PSE /等用于x86)

No. Every article explains how 4 Gb of virtual address space is mapped. The size of virtual memory is always 4 GB (for 32-bit machine without memory extensions like PAE/PSE/etc for x86)

作为 8.1.3规定。内存区 Linux内核开发由罗伯特·爱(我用的第三版),有物理内存的几个区域:

As stated in 8.1.3. Memory Zones of the book Linux Kernel Development by Robert Love (I use third edition), there are several zones of physical memory:


  • ZONE_DMA - 包含16 MB以下
  • 内存页面帧
  • ZONE_NORMAL - 包含在以上16 MB和下方896 MB的内存页面帧

  • ZONE_HIGHMEM - 包含在以上896 MB
  • 的内存页面帧
  • ZONE_DMA - Contains page frames of memory below 16 MB
  • ZONE_NORMAL - Contains page frames of memory at and above 16 MB and below 896 MB
  • ZONE_HIGHMEM - Contains page frames of memory at and above 896 MB

所以,如果你有512 MB,你将ZONE_HIGHMEM是空的,并且ZONE_NORMAL将有496 MB的映射物理内存。

So, if you have 512 MB, your ZONE_HIGHMEM will be empty, and ZONE_NORMAL will have 496 MB of physical memory mapped.

此外,看一看,以 2.5.5.2。最终内核页表时,RAM的大小是本书的不足896 MB 部分。这是有关的情况下,当你有超过896 MB的内存更少。

Also, take a look to 2.5.5.2. Final kernel Page Table when RAM size is less than 896 MB section of the book. It is about case, when you have less memory than 896 MB.

此外,对于ARM有虚拟内存布局的一些介绍:的http:/ /www.mjmwired.net/kernel/Documentation/arm/memory.txt

Also, for ARM there is some description of virtual memory layout: http://www.mjmwired.net/kernel/Documentation/arm/memory.txt

行63 PAGE_OFFSET high_memory-1 是内存的直接映射的部分。

The line 63 PAGE_OFFSET high_memory-1 is the direct mapped part of memory

这篇关于如何在Linux内核管理超过1GB的物理内存少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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