Linux memory management 2 Memory nodes and memory partitions

Source: Internet
Author: User

Uma and NUMA:
Uma (uniform memory access), that is, consistent memory access. In this case, the cost of CPU access to any memory location is the same.
NUMA) (non-uniform memory access), that is, non-consistent memory access. In this case, the cost of CPU access to memory in different locations is different. In the case of multiple CPUs, each CPU has a local memory and a remote memory. The cost of accessing the local memory is lower than that of accessing the remote memory. It is very important to minimize the cost of CPU access to memory.

Linux supports multiple hardware architectures. Therefore, Linux must use a common method to describe the memory to facilitate memory management. For this reason, Linux has the concepts of Memory nodes, memory areas, and page boxes, which are also clear at a glance.
Memory nodes: these nodes are divided based on the CPU access cost. In multi-CPU environments, local memory and remote memory are different nodes. Even in a single CPU environment, the cost of accessing all the memory is the same, the Linux kernel still has the concept of Memory nodes, but only one memory node. The kernel uses struct pg_data_t to describe the memory partition.
Memory partition: Linux divides Memory nodes into different partitions. The kernel uses struct zone to describe the memory partition. Generally, a node is divided into DMA, normal, and high Memory areas.

Page box: Linux uses page-based memory management. pages are the basic unit of physical memory management. Each memory partition is composed of a large number of page boxes. The kernel uses the struct page to describe the page. The page box has many attributes that describe the status and purpose of the page box, for example, whether it is allocated.


Zone_mem_map in is an array of page boxes, which records the usage of all page boxes in a memory partition.


DMA memory zone: refers to the direct memory access partition, usually the starting 16 MB of physical memory. It is mainly used by some peripherals, And the peripherals and memory access data directly without the participation of the system CPU.
Normal memory zone: from 16 MB to MB memory zone.
Highmemory memory zone: Memory zone after 896m.

Why is the high-end memory boundary 896 MB? This is because the 32-bit Linux virtual memory space is 0-4g, 0-3G is used for the user State, and 3g-4G is used for the kernel state. This means that the kernel only has 1 GB of virtual address space. If the physical memory exceeds 1 GB, the kernel cannot be mapped. In Linux, the first 896 m of the kernel address space uses a fixed ing. The ing method is: Virtual Address-3G = physical address, which can only be mapped to the first m of the physical address. That is to say, the 3G to 3G + 896m part of the kernel virtual address space, the page table ing is fixed, and the system is established during initialization. The last 128 M of the virtual address space, that is, 3G + 896m to 4G, uses dynamic ing, that is, the physical address mapped to the page table is variable. During system operation, you can update the page table to map different physical addresses, including high-end physical memory.

This mainly solves two problems: first, it can map the kernel address space to the high-end physical memory; second, the 3G + 896m to 4G of the virtual address space, continuous virtual address space can be mapped to non-consecutive physical memory, as long as the page table is updated, which is the same as user-state virtual memory ing. This is very important when there are no consecutive idle physical addresses.

Backup memory zone:
When a memory differentiation page exists, if the memory area does not have a memory page that meets the conditions, it needs to be allocated from other memory areas or from other Memory nodes. Linux creates a list of backup memory areas for each memory area. When the current memory area does not meet the conditions, it is allocated from the backup memory area. For example, the system has four Memory nodes A, B, C, and D. Each memory node is divided into DMA, normal, and highmemory memory areas. For Node B, the memory partition allocation list may be B (highmemory), B (normal), B (DMA ),

A (highmemory), A (normal), A (DMA), C (highmemory), C (normal), C (DMA), D (highmemory), D (normal), D (DMA ).
When memory is allocated, it is allocated first from the local memory node and then from other Memory nodes. For a memory node, priority is allocated from highmemory, and then from normal or DMA

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.