High-performance server technology based on NUMA architecture (1)

Source: Internet
Author: User
Article Title: high-performance server technology based on NUMA architecture (1 ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
NUMA (Non-Uniform Memory Access Architecture) systems are widely used in the market. Many vendors have successfully launched NUMA-based servers. This article focuses on the NUMA Technology in Linux, it mainly includes: storage management, NUMA scheduling, and user-layer APIs, and performs basic NUMA tests on the SGI Altix 350 system, which is of reference value for the study of Linux NUMA technology.
  
   I. Introduction
With the increasing requirements of scientific computing and transaction processing on computer performance, SMP (symmetric multi-processor) systems are widely used and growing in scale. However, in traditional SMP systems, all processors share the system bus. Therefore, when the number of processors increases, the competition between the system bus becomes a bottleneck, therefore, the number of CPUs in the SMP system is generally dozens, and the scalability is greatly limited. NUMA effectively combines the programming capability of SMP system and the scalability of MPP (large-scale parallel processing) system to better solve the scalability problem of SMP system, it has become one of the mainstream architectures of high-performance servers. At present, famous foreign server manufacturers have successively launched high-performance Servers Based on NUMA architecture, such as HP Superdome, SGI's Altix 3000, IBM's x440, NEC's TX7, and AMD's Opteron. As Linux becomes more and more mature on the server platform, the support of the Linux kernel for the NUMA architecture is also improved, especially since 2.5, linux has carried out a lot of NUMA optimization work in terms of schedulers, storage management, and user-level APIs. At present, this work is still being improved, for example, the NUMA scheduler is added to 2.6.7-RC1 kernel. This article mainly discusses three aspects: storage management, scheduler and CpuMemSets.
  
   Ii. NUMA Storage Management
The NUMA system is composed of multiple nodes connected through a high-speed Interconnection Network. 1 is two nodes in the SGI Altix 3000 ccNUMA system.
    
   Figure 1 two nodes of the SGI Altix3000 System
The node of the NUMA system is usually composed of a group of CPUs (for example, SGI Altix 3000 is two Itanium2 CPUs) and local memory. Some nodes may also have I/O subsystems. Because each node has its own local memory, the entire system is physically distributed, the latency between accessing the local memory at each node and accessing the remote memory at other nodes is different. To reduce the impact of non-consistent memory access on the system, the hardware design should minimize the latency of Memory Access (such as Cache consistency design), and the operating system must be able to perceive the hardware topology and optimize the system access.
  
Currently, the physical topology of NUMA architecture servers supported by IA64 Linux is implemented through ACPI (Advanced Configuration and Power Interface. ACPI is a BIOS specification jointly developed by Compaq, Intel, Microsoft, Phoenix, and toshba. It defines a very wide range of configuration and power management. Currently, the specification version has grown to 2.0, version 3.0 is being developed and details can be obtained from the http://www.acpi.info website. ACPI specifications are also widely used in Xeon server systems in IA-32 architectures.
  
In Linux, the physical memory distribution Information of NUMA is obtained from the ACPI Table of firmware. The most important is the SRAT (System Resource Affinity Table) and SLIT (System Locality Information Table) tables, SRAT contains two structures:
  
Processor Local APIC/SAPIC Affinity Structure: records information about a CPU;
  
Memory Affinity Structure: records Memory information;
The SLIT table records the distance between nodes, which are recorded by the array node_distance [] in the system.
  
Linux uses the Node, Zone, and page structure to describe the physical memory, as shown in figure 2.
    
   Figure 2 Relationship between Node, Zone, and page in Linux
2.1 nodes
  
Linux uses a struct pg_data_t structure to describe the system memory. each node in the system is attached to a pgdat_list list. For the UMA architecture, there is only one static pg_data_t structure contig_page_data. NUMA system is very easy to expand. A node in NUMA system can correspond to a node in the Linux storage description. For details, see linux/mmzone. h.
  
Typedef struct pglist_data {
Zone_t node_zones [MAX_NR_ZONES];
Zonelist_t node_zonelists [GFP_ZONEMASK + 1];
Int nr_zones;
Struct page * node_mem_map;
Unsigned long * valid_addr_bitmap;
Struct bootmem_data * bdata;
Unsigned long node_start_paddr;
Unsigned long node_start_mapnr;
Unsigned long node_size;
Int node_id;
Struct pglist_data * node_next;
} Pg_data_t;
  
The main fields in the structure are described below.
    
All nodes in the system are maintained in the pgdat_list list and initialized in the init_bootmem_core function.
  
2.2 Zone
  
The memory of each node is divided into multiple blocks, called zones, which indicates a section of memory. A zone is described in struct_zone_t structure. zone types include ZONE_DMA, ZONE_NORMAL, and ZONE_HIGHMEM. ZONE_DMA is located in the low-end memory space for some old ISA devices. ZONE_NORMAL memory is directly mapped to the high-end part of the Linux Kernel linear address space. Many kernel operations can only be performed in ZONE_NORMAL. For example, in X86, the physical address of the zone is as follows:
    
The Zone is described in struct zone_t. It tracks the usage of the page box, idle areas, and locks. The specific descriptions are as follows:
  
Typedef struct zone_struct {
Spinlock_t lock;
Unsigned long free_pages;
Unsigned long pages_min, pages_low, pages_high;
Int need_balance;
Free_area_t free_area [MAX_ORDER];
Wait_queue_head_t * wait_table;
Unsigned long wait_table_size;
Unsigned long wait_table_shift;
Struct pglist_data * zone_pgdat;
Struct page * zone_mem_map;
Unsigned long zone_start_paddr;
Unsigned long zone_start_mapnr;
Char * name;
Unsigned long size;
} Zone_t;
  
The main fields in the structure are described below.
  
When the memory available in the system is small, kswapd will be awakened for page switching. If the memory pressure is high, the process will release the memory synchronously. As described above, each zone has three thresholds, namely pages_low, pages_min, and pages_high, to track the memory pressure of the zone. The number of pages_min page boxes is calculated by the memory initialization free_area_init_core function based on the ratio of the page boxes in the zone. The minimum value is 20 pages, and the maximum value is generally 255 pages. When pages_min is reached, the distributor synchronizes the kswapd operation. When the number of idle pages reaches pages_low, kswapd is awakened by the buddy distributor and the page is released. When pages_high is reached, kswapd will be awakened, and kswapd will not consider how to balance the zone until there is a pages_high idle page. Generally, the default value of pages_high is three times that of pages_min.
  
This hierarchical structure of Linux storage management can effectively map acpi srat and SLIT information with Node and Zone, in this way, the flat structure in traditional Linux cannot reflect the disadvantages of the NUMA architecture. When a task request allocates memory, Linux uses a local node allocation policy. First, it searches for idle pages in its own node. If not, it searches for idle pages in adjacent nodes; if not, go to the remote node to find the idle page, thus optimizing the memory access performance in the operating system.

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.