Explain the management of large pages in Linux operating system

Source: Internet
Author: User
Keywords Operating system Linux Big page
Tags address aliyun file hardware hardware platform html http kernel

This article describes the implementation of large pages in the Linux operating system. From the memory layer, file system layer, LIBHUGETLBFS, and how users use the big page and so on in these aspects are analyzed and introduced. Let you better understand the big page in the kernel implementation mechanism as well as http://www.aliyun.com/zixun/aggregation/6579.html "" > user use method.

Large pages are primarily designed to provide an optimized way for users to use large amounts of memory. Through the support provided by the hardware platform, the operating system optimizes the memory operation and improves the efficiency of the system. This article first introduces the hardware platform to support the large page, and then analyze its implementation in the Linux kernel, and finally an example to understand how users use these large pages. As the price of hardware is getting lower, users need access to more memory, and the system has two ways to accommodate the increase in memory. One way to do this is to keep the page size unchanged and increase the number of page tables, and the other way is to increase the page size by keeping the page table level unchanged. The first method is prone to performance problems. The increase in Page table series and small pages increase the number of accesses to memory. The second method can reduce the number of memory accesses. Compared to small pages, the performance of the system is relatively high. This is why there are more and more ways to support large pages.

Large-page hardware support

This article takes the x86 architecture as an example to introduce the hardware platform's support for large pages. The table below shows the relationship between the size of the page and the length of the physical address. Some bits in the control register CR0, CR4 determine the size of the page. This form is from the Intel? IA and IA32 architectures Software Developer ' s Manual.

Paging Mode PG Flag CR0 PAE Flag CR4 LME ia32_effer Page Size Linear Address Physical address Width None 0 X X-32 bit 3 2 bit 1 0 0 4KB
4MB bit up to bit PAE 1 1 0 4KB
2MB bit up to bit ia-32e 1 1 2 4KB
2MB
1GB bit up to

Large page Overall structure

The main structure of the large page is the kernel code of the HUGETLB.C, memory.c,hugtlbpage.c and fs/hugetlbfs/inode.c, as well as the user space provided LIBHUGETLBFS. where HUGETLB.C, memory.c part of the memory management, HUGETLBPAGE.C is related to the specific architecture of the page table management, FS/HUGETLBFS/INODE.C is the file system layer, HUGETLBFS is a pseudo file system, There is not a single provided device file that provides a way to use and manage large pages. Finally, LIBHUGETLBFS provides users with the tools to manage large pages. The relationships in these sections are shown in the following illustration:

Figure 1. Large page Structure Chart


Figure 2. Timeline diagrams used for large pages

The sequence diagram above shows the process by which users are called from user space to kernel space when they use large pages.

Related Article

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.