Memory Management
  • Physical Address Space
  • On 32-bit x86 systems, the default kernel configuration splits the available 4GB address space into a 3GB virtual memory space for user processes and a 1GB space for the kernel, as shown in Figure 2.5. This imposes a 1GB limit on the amount of physical memory that the kernel can handle. In reality, the limit is 896MB because 128MB of the address space is occupied by kernel data structures.
  • Linux divides their virtual address space into two regions, devoting the larger to user space and the smaller to the kernel. In current 32-bit x86 computers, this commonly (although does not have to, as this is a configurable option) takes the form of a 3GB/1GB split of the 4GB address space, so kernel virtual addresses start at 0xC0000000 and go to 0xFFFFFFFF.
  • When in user mode, translations are only effective for the first region, thus protecting the kernel from user programs, but when in kernel mode, translations are effective for both regions, thus giving the kernel an easy way to refer to the buffers of processes—it just uses the process' own mappings.
  • However, if the kernel needs to refer to physical memory for which a userspace translation has not already been provided, it has only 1GB (for example) of virtual memory to use. On computers with a lot of physical memory, this can mean that there exists memory that the kernel cannot refer to directly—this is called high memory. When the kernel wishes to address high memory, it creates a mapping on the fly and destroys the mapping when done, which incurs a performance penalty.
  • Low memory continues to be mapped directly into the kernel's address space, and is thus always reachable via a kernel-space pointer. High memory, instead, has no direct kernel mapping. When the kernel needs to work with a page in high memory, it must explicitly set up a special page table to map it into the kernel's address space first.
  • The limitation on how much memory can be directly mapped with logical addresses remains, however. Only the lowest portion of memory (up to 1 or 2 GB, depending on the hardware and the kernel configuration) has logical addresses. the rest (high memory) does not.
  • Before accessing a specific high-memory page, the kernel must set up an explicit virtual mapping to make that page available in the kernel's address space. Thus, many kernel data structures must be placed in low memory; high memory tends to be reserved for user-space process pages.
min 内存物理地址起始
max_low 低端内存区物理地址末端
max_high 高端内存区物理地址末端
  • Virtual Address Space
  • Virtual/Logical Address Space in Kernel Space
  • Virtual Address Space in User Space
  • struct mbuf
  • LRU
    • Active list
    • Inactive list
  • Page Cache
    • Page Cache or Buffer Cache: Linux kernels up to version 2.2 had both a Page Cache (pages of memory mapped files) as well as a Buffer Cache (pages of physical devices). As of the 2.4 kernel, these two caches have been combined. Today, there is only one cache, the Page Cache.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License