WO2024001644A1 - Method and apparatus for controlling transparent huge page, and storage medium - Google Patents

Method and apparatus for controlling transparent huge page, and storage medium Download PDF

Info

Publication number
WO2024001644A1
WO2024001644A1 PCT/CN2023/097197 CN2023097197W WO2024001644A1 WO 2024001644 A1 WO2024001644 A1 WO 2024001644A1 CN 2023097197 W CN2023097197 W CN 2023097197W WO 2024001644 A1 WO2024001644 A1 WO 2024001644A1
Authority
WO
WIPO (PCT)
Prior art keywords
transparent
page
pages
transparent huge
huge
Prior art date
Application number
PCT/CN2023/097197
Other languages
French (fr)
Chinese (zh)
Inventor
汪勇
杨洋
蒋学鑫
张文涯
徐鑫
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2024001644A1 publication Critical patent/WO2024001644A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Definitions

  • Embodiments of the present application relate to but are not limited to the field of memory management, and in particular, to a method of controlling transparent huge pages, a device thereof, and a storage medium.
  • the system generally uses huge pages in two ways.
  • One is that user-mode programs use the hugetlbfs library to reserve memory space for huge pages when the kernel starts, and at the same time explicitly complete mapping for huge pages in the code; the other is transparent giant pages.
  • Transparent Huge Page THP, which is transparent to the user, and the kernel automatically allocates huge pages to the application.
  • the host transparent huge page supports three modes: always mode means that transparent huge pages are used throughout the system, which may cause a lot of memory waste; madvise mode means that it can only be used in areas that support transparent huge pages by calling a dedicated (madvise interface) setting.
  • Transparent huge pages means that users need to modify the application code to use transparent huge pages, which has a high threshold and is not flexible enough; never mode means that transparent huge pages are not used, but system performance will be reduced.
  • Embodiments of the present application provide a method for controlling a transparent giant page, a device thereof, and a storage medium.
  • embodiments of the present application provide a method of controlling transparent huge pages.
  • the method of controlling transparent huge pages includes: setting transparent huge pages according to a transparent huge page mode based on container settings; and setting the transparent huge pages.
  • the performance change amount when the container uses the transparent huge page is obtained; and the transparent huge page mode is adjusted according to the performance change amount.
  • embodiments of the present application also provide a computer-readable storage medium that stores computer-executable instructions, and the computer-executable instructions are used to execute the above-mentioned method of controlling a transparent giant page.
  • Figure 1 is a flow chart of a method for controlling transparent huge pages provided by an embodiment of the present application
  • Figure 2 is a flow chart of a method for controlling transparent huge pages when triggering page faults to allocate physical memory provided by an embodiment of the present application;
  • Figure 3 is a flow chart of a method for controlling transparent huge pages in a virtual memory area that does not belong to a container provided by an embodiment of the present application;
  • Figure 4 is a flow chart of a method for controlling transparent huge pages after allocating physical memory to transparent huge pages according to an embodiment of the present application
  • Figure 5 is a flow chart of a method for merging ordinary pages into transparent giant pages according to an embodiment of the present application
  • Figure 6 is a flow chart of a calculation method for increasing physical memory when a container uses transparent huge pages according to an embodiment of the present application
  • Figure 8 is a flow chart of an example of controlling a transparent huge page provided by an embodiment of the present application.
  • Figure 9 is a flowchart of an example of calculating a performance change amount provided by an embodiment of the present application.
  • Embodiments of the present application provide a method, device, and storage medium for controlling transparent huge pages.
  • the transparent huge pages are set according to the transparent huge page mode set based on the container. In the process of setting the transparent huge pages, the time when the container uses the transparent huge page is obtained. The amount of performance change; adjust the transparent huge page mode according to the amount of performance change. Setting transparent huge pages according to the transparent huge page mode can reduce the number of page faults in the container and improve the performance of the container.
  • the transparent huge page mode also provides the container with a way to control the setting of transparent huge pages; in the process of setting transparent huge pages, Obtain the performance change when the container uses transparent huge pages.
  • Figure 1 is a flow chart of a method for controlling transparent huge pages provided by an embodiment of the present application.
  • the method for controlling transparent giant pages includes step S100, step S200, and step S300.
  • Step S100 Set the transparent huge page according to the transparent huge page mode set based on the container;
  • Step S200 In the process of setting up transparent huge pages, obtain the performance change amount when the container uses transparent huge pages;
  • Step S300 Adjust the transparent huge page mode according to the performance change amount.
  • setting transparent huge pages according to the transparent huge page mode can reduce the number of page failures in the container and improve the performance of the container.
  • the transparent huge page mode also provides the container with a way to control the setting of transparent huge pages; because transparent huge pages needs for use It takes up more memory, so the performance and memory required for different containers that use transparent huge pages or the same container that uses transparent huge pages at different times are different. Therefore, in the process of setting up transparent huge pages, use transparent The performance change amount of the container after the huge page is used to determine whether the container will still run in the current transparent huge page mode in the future, so that the container can choose the transparent huge page mode that meets its own needs to achieve the purpose of refined management.
  • transparent huge pages can improve performance by reducing page faults (one page fault allocates a large block of memory), can also reduce the cost of converting virtual addresses to physical addresses (reduce the number of conversions), and can even avoid address translation.
  • the processor must translate a virtual address, it must go through up to four levels of page tables, and the processor maintains a translation lookaside buffer (TLB) that caches the translation results.
  • TLB translation lookaside buffer
  • the capacity of the TLB is very small, usually 128 instruction translations and 32 data translations, which is very easy to fill up, so a large number of address translations must be performed.
  • Using transparent huge pages through the kernel address can reduce the pressure on tlb. Therefore, using transparent huge pages can increase performance, but it will allocate large blocks of memory and occupy more memory space.
  • the transparent huge page mode can control the use of transparent huge pages.
  • the transparent huge page mode can only be adjusted by modifying the program code, and it is configured globally, so the amount of change depends on the performance.
  • To adjust the transparent huge page mode solves the problem of the transparent huge page mode, allowing the container to manage the transparent huge page mode in a refined manner.
  • the transparent huge page mode includes one of the following: on mode, set to use transparent huge pages and allocate memory for transparent huge pages; off mode, set to use normal pages and allocate memory for normal pages; or select mode , set to set transparent huge pages for the preset target process and allocate memory for transparent huge pages.
  • the transparent huge page mode provides three modes for managing transparent huge pages. It can control whether to use transparent huge pages or specify the target process to use transparent huge pages. It also provides a way for the container to adjust the transparent huge page mode to achieve a balance between performance and memory. the basic mechanism.
  • the method of controlling a transparent giant page may also include, but is not limited to, step S400 and step S500.
  • Step S400 When a page fault is triggered and physical memory is allocated, determine whether the virtual memory area belongs to the container.
  • Step S500 If the virtual memory area belongs to the container, allocate physical memory for the transparent huge page according to the transparent huge page mode.
  • Determining whether the virtual memory area belongs to the container and then executing the current transparent huge page mode can avoid the current virtual memory area not belonging to the container and running the wrong transparent huge page mode, which will affect the performance.
  • the method of controlling a transparent giant page may also include but is not limited to step S600.
  • Step S600 If the virtual memory area does not belong to the container, allocate physical memory for the transparent huge page according to the host transparent huge page mode.
  • physical memory is allocated for transparent huge pages according to the host's transparent huge page mode.
  • physical memory is allocated according to the host's transparent huge page mode.
  • Transparent huge pages allocate memory and solve the problem of how to use transparent huge pages when the current virtual memory area does not belong to the container.
  • the method of controlling a transparent giant page may also include, but is not limited to, step S700 and step S800.
  • Step S700 Obtain the remaining memory amount of the container.
  • Step S800 If the remaining amount of memory is greater than the remaining amount threshold, merge ordinary pages to obtain transparent giant pages.
  • step S800 includes but is not limited to step S810 and step S820.
  • Step S810 Determine the transparent huge page mode of the container.
  • the container may not need to improve performance to avoid affecting the memory space of the container in its normal state.
  • the performance change includes at least one of the following: increased physical memory when the container uses transparent huge pages; or reduced number of page faults when the container uses transparent huge pages.
  • the performance change amount is a reference amount that measures the performance change of the container, and the container makes corresponding adjustments to the transparent huge page mode based on the reference amount.
  • the performance change amount when the performance change amount includes calculation of the increased physical memory when the container uses transparent huge pages, the performance change amount can be obtained according to step S311, step S312 and step S313.
  • Step S311 Initialize the increased physical memory when the container uses transparent huge pages to 0.
  • Step S312 Determine whether the container uses transparent huge pages.
  • Step S313 If the container uses transparent huge pages, obtain the physical memory increase when using transparent huge pages, and accumulate the physical memory increase to the increased physical memory when the container uses transparent huge pages.
  • To calculate the increased physical memory when the container uses transparent huge pages first initialize the increased physical memory when the container uses transparent huge pages to 0, and then determine whether the container uses transparent huge pages. This can reduce the amount of calculation and eliminates the need to obtain the data of each container. Physical memory to reduce the computational burden. Use transparent huge pages and then obtain the increase in physical memory using transparent huge pages. Accumulate the increase in physical memory to the increased physical memory when the container uses transparent huge pages. Calculate the cumulative increase in physical memory. It can visually reflect the total increased physical memory of the container in the current transparent huge page mode, and facilitate real-time monitoring of the memory usage of the container in the current transparent huge page mode.
  • the method of controlling a transparent huge page may also include but is not limited to step S314.
  • Step S314 If the transparent huge page mode is changed, clear the physical memory increased when the container uses transparent huge pages.
  • the increased physical memory when the container uses transparent huge pages will be recalculated, and the increased physical memory when using transparent huge pages will be remeasured.
  • the performance change amount when the performance change amount includes the reduced number of page misses when the container uses transparent huge pages, the performance change amount can be obtained according to steps S321 and S322.
  • Step S321 Initialize the number of page faults reduced when the container uses transparent huge pages to 0.
  • Step S322 If no page fault occurs in the container and the memory accessed for the first time belongs to a transparent huge page, increase the number of page faults reduced when the container uses transparent huge pages by 1 to obtain the number of page faults reduced when the container uses transparent huge pages.
  • To calculate the number of page faults reduced when the container uses transparent huge pages first initialize the number of page faults reduced when the container uses transparent huge pages to 0. If no page faults occur in the container and the memory accessed for the first time is a transparent huge page, set the container to use transparent huge pages. The number of page faults reduced when using transparent huge pages is increased by 1, which facilitates statistics on the total number of page faults reduced by the container using the current transparent huge page mode. It more intuitively reflects the effect of using transparent huge pages, and also facilitates real-time monitoring of the container in the current transparent huge page mode. The number of page faults in this case.
  • the method of controlling a transparent huge page may also include but is not limited to step S323.
  • Step S323 If the transparent huge page mode is changed, clear the reduced number of page faults when the container uses transparent huge pages.
  • the method of controlling transparent huge pages includes the following steps:
  • VMA belongs to the container and allocates physical memory for transparent huge pages according to the transparent huge page mode of the container.
  • the calculation of the performance change includes the following steps:
  • an embodiment of the present application also provides a device for controlling transparent huge pages.
  • the device for controlling transparent huge pages includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. The above-mentioned method of controlling transparent huge pages is implemented when the computer program is executed by the computer.
  • an embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium stores computer-executable instructions.
  • the computer-executable instructions are used to execute the above-mentioned method of controlling a transparent giant page, for example, Being executed by a processor in the embodiment of the apparatus for controlling a transparent huge page can cause the above processor to execute the method of controlling a transparent huge page in the above embodiment, for example, executing the method in Figure 1 and Figure 2 described above. method in and the method in Figure 3.
  • the non-transitory software programs and instructions required to implement the method of controlling transparent huge pages in the above embodiment are stored in the memory.
  • the method of controlling transparent huge pages in the above embodiment is executed. For example, execute the above The method in Figure 1, the method in Figure 2 and the method in Figure 3 are described.
  • Embodiments of the present application include: setting transparent huge pages according to the transparent huge page mode based on container settings; in the process of setting transparent huge pages, obtaining the performance change amount when the container uses transparent huge pages; adjusting the transparent huge page mode according to the performance change amount .
  • Setting transparent huge pages according to the transparent huge page mode can reduce the number of page faults in the container and improve the performance of the container.
  • the transparent huge page mode also provides the container with a way to control the setting of transparent huge pages; in the process of setting transparent huge pages, Get container to use transparent The amount of performance change when using huge pages. Since the use of transparent huge pages requires more memory, the performance and memory required for different containers using transparent huge pages or the same container using transparent huge pages at different times are different.
  • Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other storage cell technology, CD-ROM, Digital Versatile Disk (DVD) or other optical disk storage, magnetic cassettes, tapes, disk storage or other magnetic storage devices, or Any other medium that can be used to store the desired information and that can be accessed by a computer.
  • communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media .

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Image Generation (AREA)
  • Packaging For Recording Disks (AREA)

Abstract

Provided in the present application are a method and apparatus for controlling a transparent huge page, and a storage medium. The method comprises: according to a transparent huge page mode which is configured on the basis of a container, configuring a transparent huge page (S100); during a process of configuring the transparent huge page, acquiring a performance change amount when the container uses the transparent huge page (S200); and according to the performance change amount, adjusting the transparent huge page mode (S300).

Description

控制透明巨页的方法及其装置、存储介质Method and device and storage medium for controlling transparent huge page
相关申请的交叉引用Cross-references to related applications
本申请基于申请号为202210736636.7、申请日为2022年06月27日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is filed based on a Chinese patent application with application number 202210736636.7 and a filing date of June 27, 2022, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby incorporated by reference into this application.
技术领域Technical field
本申请实施例涉及但不限于内存管理领域,尤其涉及一种控制透明巨页的方法及其装置、存储介质。Embodiments of the present application relate to but are not limited to the field of memory management, and in particular, to a method of controlling transparent huge pages, a device thereof, and a storage medium.
背景技术Background technique
系统使用巨页一般通过两种方式,一种是用户态程序使用hugetlbfs库,在内核启动时为巨页预留内存空间,同时在代码中明确地为巨页完成映射;另一种是透明巨页(Transparent Huge Page,THP),即对用户透明,内核自动为应用分配巨页。The system generally uses huge pages in two ways. One is that user-mode programs use the hugetlbfs library to reserve memory space for huge pages when the kernel starts, and at the same time explicitly complete mapping for huge pages in the code; the other is transparent giant pages. Transparent Huge Page (THP), which is transparent to the user, and the kernel automatically allocates huge pages to the application.
目前主机透明巨页支持3种模式:always模式表示在整个系统范围内使用透明巨页,可能造成大量的内存浪费;madvise模式表示在调用专用(madvise接口)设置支持透明巨页的区域才可使用透明巨页,意味着用户需要修改应用程序的代码才能使用透明巨页,门槛高且不够灵活;never模式表示不使用透明巨页,但系统性能会有所下降。Currently, the host transparent huge page supports three modes: always mode means that transparent huge pages are used throughout the system, which may cause a lot of memory waste; madvise mode means that it can only be used in areas that support transparent huge pages by calling a dedicated (madvise interface) setting. Transparent huge pages means that users need to modify the application code to use transparent huge pages, which has a high threshold and is not flexible enough; never mode means that transparent huge pages are not used, but system performance will be reduced.
使用巨页可以减少缺页异常(Page Fault)发生次数,提升访问性能,但是导致分配到的物理页面比实际需要的内存多,造成内存浪费。透明巨页以空间换取性能。越来越多的应用容器化,在容器为单位的管理设备上,比如一些5G基站,想要对某个容器的透明巨页使用做优化,需要手动修改容器内的应用程序源代码。内存紧缺的低端设备通常不使用透明巨页技术,但是如果低端设备中容器对内存消耗不多且需要较高性能时,则这类容器可以使用透明巨页。目前透明巨页的几种模式都是针对主机全局进行配置的,而各容器对性能需求不一样,使用全局透明巨页模式,无法满足所有容器的需求。目前缺少针对容器的精细化管理的透明巨页机制。Using huge pages can reduce the number of page fault exceptions (Page Fault) and improve access performance, but it will cause more physical pages to be allocated than the actual memory required, resulting in memory waste. Transparent huge pages trade space for performance. More and more applications are being containerized. On container-based management equipment, such as some 5G base stations, if you want to optimize the use of transparent huge pages in a certain container, you need to manually modify the application source code in the container. Low-end devices with tight memory usually do not use transparent huge pages technology, but if the containers in low-end devices do not consume much memory and require high performance, such containers can use transparent huge pages. Currently, several modes of transparent huge pages are configured globally for the host, and each container has different performance requirements. Using the global transparent huge page mode cannot meet the needs of all containers. Currently, there is a lack of transparent huge page mechanism for refined management of containers.
发明内容Contents of the invention
本申请实施例提供了控制透明巨页的方法及其装置、存储介质。Embodiments of the present application provide a method for controlling a transparent giant page, a device thereof, and a storage medium.
第一方面,本申请实施例提供了一种控制透明巨页的方法,所述控制透明巨页的方法包括:根据基于容器设置的透明巨页模式设置透明巨页;在设置所述透明巨页的过程中,获取所述容器使用所述透明巨页时的性能改变量;根据所述性能改变量调整所述透明巨页模式。In a first aspect, embodiments of the present application provide a method of controlling transparent huge pages. The method of controlling transparent huge pages includes: setting transparent huge pages according to a transparent huge page mode based on container settings; and setting the transparent huge pages. In the process, the performance change amount when the container uses the transparent huge page is obtained; and the transparent huge page mode is adjusted according to the performance change amount.
第二方面,本申请实施例还提供了一种控制透明巨页的装置,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上述的控制透明巨页的方法。In a second aspect, embodiments of the present application also provide a device for controlling transparent huge pages, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor executes the computer program. The program implements the above-mentioned method of controlling transparent huge pages.
第三方面,本申请实施例还提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行如上述的控制透明巨页的方法。 In a third aspect, embodiments of the present application also provide a computer-readable storage medium that stores computer-executable instructions, and the computer-executable instructions are used to execute the above-mentioned method of controlling a transparent giant page.
附图说明Description of drawings
图1是本申请一个实施例提供的控制透明巨页的方法的流程图;Figure 1 is a flow chart of a method for controlling transparent huge pages provided by an embodiment of the present application;
图2是本申请一个实施例提供的触发缺页分配物理内存时的控制透明巨页的方法的流程图;Figure 2 is a flow chart of a method for controlling transparent huge pages when triggering page faults to allocate physical memory provided by an embodiment of the present application;
图3是本申请一个实施例提供的虚拟内存区不属于容器的控制透明巨页的方法的流程图;Figure 3 is a flow chart of a method for controlling transparent huge pages in a virtual memory area that does not belong to a container provided by an embodiment of the present application;
图4是本申请一个实施例提供的为透明巨页分配完物理内存后的控制透明巨页的方法的流程图;Figure 4 is a flow chart of a method for controlling transparent huge pages after allocating physical memory to transparent huge pages according to an embodiment of the present application;
图5是本申请一个实施例提供的将普通页合并为透明巨页的方法的流程图;Figure 5 is a flow chart of a method for merging ordinary pages into transparent giant pages according to an embodiment of the present application;
图6是本申请一个实施例提供的容器使用透明巨页时增大的物理内存的计算方法的流程图;Figure 6 is a flow chart of a calculation method for increasing physical memory when a container uses transparent huge pages according to an embodiment of the present application;
图7是本申请一个实施例提供的容器使用透明巨页时减少的缺页次数的计算方法的流程图;Figure 7 is a flowchart of a calculation method for reducing the number of page faults when a container uses transparent huge pages according to an embodiment of the present application;
图8是本申请一个实施例提供的控制透明巨页的示例的流程图;Figure 8 is a flow chart of an example of controlling a transparent huge page provided by an embodiment of the present application;
图9是本申请一个实施例提供的计算性能改变量的示例的流程图。Figure 9 is a flowchart of an example of calculating a performance change amount provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application and are not used to limit the present application.
需要说明的是,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于流程图中的顺序执行所示出或描述的步骤。说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that although a logical sequence is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that in the flowchart. The terms "first", "second", etc. in the description, claims, and above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific sequence or sequence.
本申请实施例提供了一种控制透明巨页的方法、装置及存储介质,根据基于容器设置的透明巨页模式设置透明巨页;在设置透明巨页的过程中,获取容器使用透明巨页时的性能改变量;根据性能改变量调整透明巨页模式。根据透明巨页模式设置透明巨页,能够减少容器的缺页次数,提高容器的性能,而透明巨页模式也为容器提供了控制设置透明巨页的方式;在设置透明巨页的过程中,获取容器使用透明巨页时的性能改变量,由于透明巨页的使用需要占用更多的内存,因此对于使用透明巨页的不同容器或者不同时段使用透明巨页的同一容器所需要的性能和内存是不同的,通过获取使用透明巨页后的容器的性能改变量,根据该性能改变量来确定容器后续是否仍按当前透明巨页模式运行,使得容器能够选择满足自身需求的透明巨页模式,达到精细化管理的目的。Embodiments of the present application provide a method, device, and storage medium for controlling transparent huge pages. The transparent huge pages are set according to the transparent huge page mode set based on the container. In the process of setting the transparent huge pages, the time when the container uses the transparent huge page is obtained. The amount of performance change; adjust the transparent huge page mode according to the amount of performance change. Setting transparent huge pages according to the transparent huge page mode can reduce the number of page faults in the container and improve the performance of the container. The transparent huge page mode also provides the container with a way to control the setting of transparent huge pages; in the process of setting transparent huge pages, Obtain the performance change when the container uses transparent huge pages. Since the use of transparent huge pages requires more memory, the performance and memory required for different containers using transparent huge pages or the same container using transparent huge pages at different times. is different. By obtaining the performance change of the container after using transparent huge pages, and based on the performance change, it is determined whether the container will still run in the current transparent huge page mode, so that the container can choose the transparent huge page mode that meets its own needs. Achieve the purpose of refined management.
如图1所示,图1是本申请一个实施例提供的控制透明巨页的方法流程图。As shown in Figure 1, Figure 1 is a flow chart of a method for controlling transparent huge pages provided by an embodiment of the present application.
如图1所示,该控制透明巨页的方法包括步骤S100、步骤S200、步骤S300,As shown in Figure 1, the method for controlling transparent giant pages includes step S100, step S200, and step S300.
步骤S100:根据基于容器设置的透明巨页模式设置透明巨页;Step S100: Set the transparent huge page according to the transparent huge page mode set based on the container;
步骤S200:在设置透明巨页的过程中,获取容器使用透明巨页时的性能改变量;Step S200: In the process of setting up transparent huge pages, obtain the performance change amount when the container uses transparent huge pages;
步骤S300:根据性能改变量调整透明巨页模式。Step S300: Adjust the transparent huge page mode according to the performance change amount.
本实施例中,根据透明巨页模式设置透明巨页,能够减少容器的缺页次数,提高容器的性能,而透明巨页模式也为容器提供了控制设置透明巨页的方式;由于透明巨页的使用需要 占用更多的内存,因此对于使用透明巨页的不同容器或者不同时段使用透明巨页的同一容器所需要的性能和内存是不同的,所以,在设置透明巨页的过程中,通过获取使用透明巨页后的容器的性能改变量,根据该性能改变量来确定容器后续是否仍按当前透明巨页模式运行,使得容器能够选择满足自身需求的透明巨页模式,达到精细化管理的目的。In this embodiment, setting transparent huge pages according to the transparent huge page mode can reduce the number of page failures in the container and improve the performance of the container. The transparent huge page mode also provides the container with a way to control the setting of transparent huge pages; because transparent huge pages needs for use It takes up more memory, so the performance and memory required for different containers that use transparent huge pages or the same container that uses transparent huge pages at different times are different. Therefore, in the process of setting up transparent huge pages, use transparent The performance change amount of the container after the huge page is used to determine whether the container will still run in the current transparent huge page mode in the future, so that the container can choose the transparent huge page mode that meets its own needs to achieve the purpose of refined management.
可理解的是,透明巨页可以通过减少缺页提升性能(一次缺页分配大块的内存),还可以通过减少虚拟地址到物理地址的转换成本(减少转化次数),甚至可以避免地址转换。如果处理器必须转换一个虚拟地址,它必须通过多达四层页表,处理器保持一翻译后备缓冲器(TLB)的缓存的转换结果。TLB的容量很小,一般是128条指令转换、32条数据转换,非常容易被填满,从而必须进行大量的地址转换。通过内核地址使用透明巨页,可以减少tlb的压力,因此使用透明巨页能够增加性能,但是会分配大块的内存,占用更多的内存空间。针对透明巨页有对应的透明巨页模式,透明巨页模式能控制使用透明巨页,但是目前只能通过修改程序代码才能调整透明巨页模式,并且进行的是全局配置,因此根据性能改变量来调整透明巨页模式解决了透明巨页模式的问题,使容器能对透明巨页模式进行精细化地管理。It is understandable that transparent huge pages can improve performance by reducing page faults (one page fault allocates a large block of memory), can also reduce the cost of converting virtual addresses to physical addresses (reduce the number of conversions), and can even avoid address translation. If the processor must translate a virtual address, it must go through up to four levels of page tables, and the processor maintains a translation lookaside buffer (TLB) that caches the translation results. The capacity of the TLB is very small, usually 128 instruction translations and 32 data translations, which is very easy to fill up, so a large number of address translations must be performed. Using transparent huge pages through the kernel address can reduce the pressure on tlb. Therefore, using transparent huge pages can increase performance, but it will allocate large blocks of memory and occupy more memory space. There is a corresponding transparent huge page mode for transparent huge pages. The transparent huge page mode can control the use of transparent huge pages. However, currently the transparent huge page mode can only be adjusted by modifying the program code, and it is configured globally, so the amount of change depends on the performance. To adjust the transparent huge page mode solves the problem of the transparent huge page mode, allowing the container to manage the transparent huge page mode in a refined manner.
在一些实施例中,透明巨页模式包括如下之一:开启模式,设置为使用透明巨页并为透明巨页分配内存;关闭模式,设置为使用普通页并为普通页分配内存;或选择模式,设置为为预设的目标进程设置透明巨页并为透明巨页分配内存。In some embodiments, the transparent huge page mode includes one of the following: on mode, set to use transparent huge pages and allocate memory for transparent huge pages; off mode, set to use normal pages and allocate memory for normal pages; or select mode , set to set transparent huge pages for the preset target process and allocate memory for transparent huge pages.
透明巨页模式提供了管理透明巨页的三种模式,能够满足是否使用透明巨页或指定目标进程使用透明巨页的控制,也为容器调整透明巨页模式达到性能和内存之间的平衡提供了基础机制。The transparent huge page mode provides three modes for managing transparent huge pages. It can control whether to use transparent huge pages or specify the target process to use transparent huge pages. It also provides a way for the container to adjust the transparent huge page mode to achieve a balance between performance and memory. the basic mechanism.
在一些实施例中,如图2所示,在执行步骤S300之后,该控制透明巨页的方法还可以包括但不限于有步骤S400和步骤S500。In some embodiments, as shown in FIG. 2 , after step S300 is executed, the method of controlling a transparent giant page may also include, but is not limited to, step S400 and step S500.
步骤S400:当触发缺页分配物理内存,判断虚拟内存区是否属于容器。Step S400: When a page fault is triggered and physical memory is allocated, determine whether the virtual memory area belongs to the container.
步骤S500:若虚拟内存区属于容器,根据透明巨页模式为透明巨页分配物理内存。Step S500: If the virtual memory area belongs to the container, allocate physical memory for the transparent huge page according to the transparent huge page mode.
判断虚拟内存区是否属于容器,再执行当前透明巨页模式,能够避免当前虚拟内存区不属于容器,运行错误的透明巨页模式导致性能受到影响。Determining whether the virtual memory area belongs to the container and then executing the current transparent huge page mode can avoid the current virtual memory area not belonging to the container and running the wrong transparent huge page mode, which will affect the performance.
在一些实施例中,如图3所示,在执行步骤S500之后,该控制透明巨页的方法还可以包括但不限于有步骤S600。In some embodiments, as shown in FIG. 3 , after performing step S500, the method of controlling a transparent giant page may also include but is not limited to step S600.
步骤S600:若虚拟内存区不属于容器,根据主机透明巨页模式为透明巨页分配物理内存。当虚拟内存区不属于容器时,按照主机透明巨页模式为透明巨页分配物理内存,当虚拟内存区不属于容器且仍有透明巨页需要分配物理内存时,按照主机的透明巨页模式为透明巨页分配内存,解决了当前虚拟内存区不属于容器时如何使用透明巨页的问题。Step S600: If the virtual memory area does not belong to the container, allocate physical memory for the transparent huge page according to the host transparent huge page mode. When the virtual memory area does not belong to the container, physical memory is allocated for transparent huge pages according to the host's transparent huge page mode. When the virtual memory area does not belong to the container and there are still transparent huge pages that need to be allocated physical memory, physical memory is allocated according to the host's transparent huge page mode. Transparent huge pages allocate memory and solve the problem of how to use transparent huge pages when the current virtual memory area does not belong to the container.
在一些实施例中,如图4所示,在执行步骤S600之后,该控制透明巨页的方法还可以包括但不限于有步骤S700和步骤S800。In some embodiments, as shown in FIG. 4 , after step S600 is performed, the method of controlling a transparent giant page may also include, but is not limited to, step S700 and step S800.
步骤S700:获取容器的内存剩余量。Step S700: Obtain the remaining memory amount of the container.
步骤S800:若内存剩余量大于剩余量阈值,将普通页合并得到透明巨页。Step S800: If the remaining amount of memory is greater than the remaining amount threshold, merge ordinary pages to obtain transparent giant pages.
当按照透明巨页模式为透明巨页分配物理内存时,容器的内存空间在不断缩小,如果完成全部分配任务,容器内存被检测到仍有剩余量,将该容器内的普通页合并得到透明巨页,能够提高容器内存空间的利用率,并且在内存空间允许的前提下将普通页转化为透明巨页,能够提高容器的性能,减少容器的缺页次数。 When allocating physical memory for transparent huge pages according to the transparent huge page mode, the memory space of the container is constantly shrinking. If all allocation tasks are completed, it is detected that the container memory is still remaining, and the ordinary pages in the container are merged to obtain a transparent giant page. Pages can improve the utilization of the container's memory space, and convert ordinary pages into transparent huge pages if the memory space allows, which can improve the performance of the container and reduce the number of page faults in the container.
在一些实施例中,如图5所示,对步骤S800进行说明,步骤S800包括但不限于有步骤S810和步骤S820。In some embodiments, as shown in Figure 5, step S800 is described. Step S800 includes but is not limited to step S810 and step S820.
步骤S810:确定容器的透明巨页模式。Step S810: Determine the transparent huge page mode of the container.
步骤S820:若透明巨页模式为开启模式或选择模式,并且在选择模式中使用透明巨页的进程为预设的目标进程,将普通巨页合并得到透明巨页。Step S820: If the transparent huge page mode is the on mode or the selection mode, and the process using the transparent huge page in the selection mode is the default target process, merge the ordinary huge pages to obtain the transparent huge page.
将普通页合并得到透明巨页,需要进行前提条件的验证,验证该容器的透明巨页模式不是关闭模式,该容器可能不需要提升性能,避免影响容器正常状态下的内存空间。To merge ordinary pages to obtain transparent huge pages, you need to verify the prerequisites and verify that the transparent huge page mode of the container is not a closed mode. The container may not need to improve performance to avoid affecting the memory space of the container in its normal state.
在一些实施例中,性能改变量包括如下至少之一:容器使用透明巨页时增大的物理内存;或容器使用透明巨页时减少的缺页次数。In some embodiments, the performance change includes at least one of the following: increased physical memory when the container uses transparent huge pages; or reduced number of page faults when the container uses transparent huge pages.
在一些实施例中,性能改变量是度量容器性能改变的参考量,容器根据参考量做出相应的透明巨页模式的调整。In some embodiments, the performance change amount is a reference amount that measures the performance change of the container, and the container makes corresponding adjustments to the transparent huge page mode based on the reference amount.
在一些实施例中,如图6所示,当性能改变量包括容器使用透明巨页时增大的物理内存的计算,性能改变量可以根据步骤S311、步骤S312和步骤S313得到。In some embodiments, as shown in Figure 6, when the performance change amount includes calculation of the increased physical memory when the container uses transparent huge pages, the performance change amount can be obtained according to step S311, step S312 and step S313.
步骤S311:将容器使用透明巨页时增大的物理内存初始化为0。Step S311: Initialize the increased physical memory when the container uses transparent huge pages to 0.
步骤S312:判断容器是否使用透明巨页。Step S312: Determine whether the container uses transparent huge pages.
步骤S313:若容器使用透明巨页,获取使用透明巨页时的物理内存增加量,将物理内存增加量累计至容器使用透明巨页时增大的物理内存。Step S313: If the container uses transparent huge pages, obtain the physical memory increase when using transparent huge pages, and accumulate the physical memory increase to the increased physical memory when the container uses transparent huge pages.
容器使用透明巨页时增大的物理内存的计算,先将容器使用透明巨页时增大的物理内存初始化为0,判断容器是否使用透明巨页,能够减少计算量,不必获取每个容器的物理内存,减轻计算负担,使用了透明巨页再获取使用透明巨页的物理内存增加量,将物理内存增加量累计至容器使用透明巨页时增大的物理内存,计算累积增大的物理内存能够直观体现容器在当前透明巨页模式下总共增大的物理内存,便于实时监测容器在当前透明巨页模式下的内存占用情况。To calculate the increased physical memory when the container uses transparent huge pages, first initialize the increased physical memory when the container uses transparent huge pages to 0, and then determine whether the container uses transparent huge pages. This can reduce the amount of calculation and eliminates the need to obtain the data of each container. Physical memory to reduce the computational burden. Use transparent huge pages and then obtain the increase in physical memory using transparent huge pages. Accumulate the increase in physical memory to the increased physical memory when the container uses transparent huge pages. Calculate the cumulative increase in physical memory. It can visually reflect the total increased physical memory of the container in the current transparent huge page mode, and facilitate real-time monitoring of the memory usage of the container in the current transparent huge page mode.
在一些实施例中,在执行步骤S313之后,该控制透明巨页的方法还可以包括但不限于有步骤S314。In some embodiments, after performing step S313, the method of controlling a transparent huge page may also include but is not limited to step S314.
步骤S314:若透明巨页模式改变,清除容器使用透明巨页时增大的物理内存。Step S314: If the transparent huge page mode is changed, clear the physical memory increased when the container uses transparent huge pages.
透明巨页模式改变后,将重新计算容器使用透明巨页时增大的物理内存,重新度量使用透明巨页时增大的物理内存。After the transparent huge page mode is changed, the increased physical memory when the container uses transparent huge pages will be recalculated, and the increased physical memory when using transparent huge pages will be remeasured.
在一些实施例中,如图7所示,当性能改变量包括容器使用透明巨页时减少的缺页次数,性能改变量可以根据步骤S321和步骤S322得到。In some embodiments, as shown in Figure 7, when the performance change amount includes the reduced number of page misses when the container uses transparent huge pages, the performance change amount can be obtained according to steps S321 and S322.
步骤S321:将容器使用透明巨页时减少的缺页次数初始化为0。Step S321: Initialize the number of page faults reduced when the container uses transparent huge pages to 0.
步骤S322:若容器没有发生缺页且首次访问的内存属于透明巨页,将容器使用透明巨页时减少的缺页次数增加1,得到容器使用透明巨页时减少的缺页次数。Step S322: If no page fault occurs in the container and the memory accessed for the first time belongs to a transparent huge page, increase the number of page faults reduced when the container uses transparent huge pages by 1 to obtain the number of page faults reduced when the container uses transparent huge pages.
容器使用透明巨页时减少的缺页次数的计算,先将容器使用透明巨页时减少的缺页次数初始化为0,若容器没有发生缺页且首次访问的内存属于透明巨页,将容器使用透明巨页时减少的缺页次数增加1,方便统计容器使用当前透明巨页模式所减少的缺页总次数,更加直观体现使用透明巨页的效果,也便于实时监测容器在当前透明巨页模式情况下的缺页次数。To calculate the number of page faults reduced when the container uses transparent huge pages, first initialize the number of page faults reduced when the container uses transparent huge pages to 0. If no page faults occur in the container and the memory accessed for the first time is a transparent huge page, set the container to use transparent huge pages. The number of page faults reduced when using transparent huge pages is increased by 1, which facilitates statistics on the total number of page faults reduced by the container using the current transparent huge page mode. It more intuitively reflects the effect of using transparent huge pages, and also facilitates real-time monitoring of the container in the current transparent huge page mode. The number of page faults in this case.
在一些实施例中,在执行步骤S322之后,该控制透明巨页的方法还可以包括但不限于有步骤S323。 In some embodiments, after performing step S322, the method of controlling a transparent huge page may also include but is not limited to step S323.
步骤S323:若透明巨页模式改变,清除容器使用透明巨页时减少的缺页次数。Step S323: If the transparent huge page mode is changed, clear the reduced number of page faults when the container uses transparent huge pages.
透明巨页模式改变后,将重新计算容器使用透明巨页时减少的缺页次数,重新度量使用透明巨页时增大的物理内存。After the transparent huge page mode is changed, the number of page faults reduced when the container uses transparent huge pages will be recalculated, and the increased physical memory when using transparent huge pages will be re-measured.
如图8所示,为了更加清楚的说明本申请实施例提供的控制透明巨页的方法的处理流程,下面以示例进行说明。As shown in FIG. 8 , in order to more clearly explain the processing flow of the method for controlling transparent huge pages provided by the embodiment of the present application, an example will be used to illustrate below.
该控制透明巨页的方法包括以下步骤:The method of controlling transparent huge pages includes the following steps:
启动容器,设置该容器的透明巨页模式。系统运行中,用户可根据容器使用透明巨页的性能改变量,重新选择该容器的透明巨页模式。透明巨页模式包括以下之一:开启模式,设置为使用透明巨页并为透明巨页分配内存;关闭模式,设置为使用普通页并为普通页分配内存;或选择模式,设置为为预设的目标进程设置透明巨页并为透明巨页分配内存。Start the container and set the container's transparent huge page mode. While the system is running, the user can reselect the transparent huge page mode of the container based on the performance change of the container using transparent huge pages. Transparent huge page modes include one of the following: On mode, set to use transparent huge pages and allocate memory for transparent huge pages; Off mode, set to use normal pages and allocate memory for normal pages; or Select mode, set to Default The target process sets up transparent huge pages and allocates memory for transparent huge pages.
触发缺页分配物理内存时,判断VMA(虚拟内存区)是否属于容器;VMA不属于容器,按照主机透明巨页模式为透明巨页分配物理内存。When a page fault is triggered to allocate physical memory, it is judged whether the VMA (virtual memory area) belongs to the container; the VMA does not belong to the container, and physical memory is allocated for transparent huge pages according to the host transparent huge page mode.
VMA属于容器,按照容器的透明巨页模式为透明巨页分配物理内存。VMA belongs to the container and allocates physical memory for transparent huge pages according to the transparent huge page mode of the container.
获取容器的内存剩余量,若内存剩余量大于剩余量阈值,将普通页合并得到透明巨页。Get the remaining memory of the container. If the remaining memory is greater than the remaining threshold, ordinary pages will be merged to obtain transparent giant pages.
其中,如图9所示,为了更加清楚的说明性能改变量的计算,下面以示例进行说明,该性能改变量的计算包括以下步骤:As shown in Figure 9, in order to explain the calculation of the performance change more clearly, the following is an example. The calculation of the performance change includes the following steps:
启动容器,设置容器透明巨页模式为开启模式或者选择模式;Start the container and set the container's transparent huge page mode to open mode or select mode;
初始化容器的AMT(容器使用透明巨页时增大的物理内存)和RFT(容器使用透明巨页时减少的缺页次数)为0,运行过程中修改容器的透明巨页模式,会清除AMT和RFT记录;Initialize the container's AMT (increased physical memory when the container uses transparent huge pages) and RFT (reduced page faults when the container uses transparent huge pages) to 0. Modifying the container's transparent huge page mode during operation will clear AMT and RFT records;
当容器触发缺页分配物理内存时,根据容器设置的透明巨页模式判断是否分配透明巨页;When a container triggers a page fault to allocate physical memory, it determines whether to allocate transparent huge pages based on the transparent huge page mode set by the container;
若分配透明巨页,获取使用透明巨页时的物理内存增加量,将物理内存增加量累计至容器使用透明巨页时增大的物理内存;If transparent huge pages are allocated, obtain the physical memory increase when using transparent huge pages, and accumulate the physical memory increase to the increased physical memory when the container uses transparent huge pages;
若容器没有发生缺页且首次访问的内存属于透明巨页,将容器使用透明巨页时减少的缺页次数增加1,得到容器使用透明巨页时减少的缺页次数。If no page faults occur in the container and the memory accessed for the first time is a transparent huge page, increase the number of page faults reduced when the container uses transparent huge pages by 1 to obtain the number of page faults reduced when the container uses transparent huge pages.
另外,本申请的一个实施例还提供了一种控制透明巨页的装置,该控制透明巨页的装置包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现如上述的控制透明巨页的方法。In addition, an embodiment of the present application also provides a device for controlling transparent huge pages. The device for controlling transparent huge pages includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. The above-mentioned method of controlling transparent huge pages is implemented when the computer program is executed by the computer.
另外,本申请的一个实施例还提供了一种计算机可读存储介质,计算机可读存储介质存储有计算机可执行指令,计算机可执行指令用于执行如上述的控制透明巨页的方法,例如,被上述控制透明巨页的装置的实施例中的一个处理器执行,可使得上述处理器执行上述实施例中的控制透明巨页的方法,例如,执行以上描述的图1中的方法、图2中的方法和图3中的方法。In addition, an embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. The computer-executable instructions are used to execute the above-mentioned method of controlling a transparent giant page, for example, Being executed by a processor in the embodiment of the apparatus for controlling a transparent huge page can cause the above processor to execute the method of controlling a transparent huge page in the above embodiment, for example, executing the method in Figure 1 and Figure 2 described above. method in and the method in Figure 3.
实现上述实施例的控制透明巨页的方法所需的非暂态软件程序以及指令存储在存储器中,当被处理器执行时,执行上述实施例中的控制透明巨页的方法,例如,执行以上描述的图1中的方法、图2中的方法和图3中的方法。The non-transitory software programs and instructions required to implement the method of controlling transparent huge pages in the above embodiment are stored in the memory. When executed by the processor, the method of controlling transparent huge pages in the above embodiment is executed. For example, execute the above The method in Figure 1, the method in Figure 2 and the method in Figure 3 are described.
本申请实施例包括:根据基于容器设置的透明巨页模式设置透明巨页;在设置透明巨页的过程中,获取容器使用透明巨页时的性能改变量;根据性能改变量调整透明巨页模式。根据透明巨页模式设置透明巨页,能够减少容器的缺页次数,提高容器的性能,而透明巨页模式也为容器提供了控制设置透明巨页的方式;在设置透明巨页的过程中,获取容器使用透明 巨页时的性能改变量,由于透明巨页的使用需要占用更多的内存,因此对于使用透明巨页的不同容器或者不同时段使用透明巨页的同一容器所需要的性能和内存是不同的,通过获取使用透明巨页后的容器的性能改变量,根据该性能改变量来确定容器在后续是否仍按当前透明巨页模式运行,使得容器能够选择满足自身需求的透明巨页模式,达到精细化管理的目的。Embodiments of the present application include: setting transparent huge pages according to the transparent huge page mode based on container settings; in the process of setting transparent huge pages, obtaining the performance change amount when the container uses transparent huge pages; adjusting the transparent huge page mode according to the performance change amount . Setting transparent huge pages according to the transparent huge page mode can reduce the number of page faults in the container and improve the performance of the container. The transparent huge page mode also provides the container with a way to control the setting of transparent huge pages; in the process of setting transparent huge pages, Get container to use transparent The amount of performance change when using huge pages. Since the use of transparent huge pages requires more memory, the performance and memory required for different containers using transparent huge pages or the same container using transparent huge pages at different times are different. By obtaining the performance change amount of the container after using transparent huge pages, and based on the performance change amount, it is determined whether the container will still run in the current transparent huge page mode in the future, so that the container can choose the transparent huge page mode that meets its own needs to achieve refinement. management purposes.
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统可以被实施为软件、固件、硬件及其适当的组合。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于RAM、ROM、EEPROM、闪存或其他存储单元技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。 Those of ordinary skill in the art can understand that all or some steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit . Such software may be distributed on computer-readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. removable, removable and non-removable media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other storage cell technology, CD-ROM, Digital Versatile Disk (DVD) or other optical disk storage, magnetic cassettes, tapes, disk storage or other magnetic storage devices, or Any other medium that can be used to store the desired information and that can be accessed by a computer. Additionally, it is known to those of ordinary skill in the art that communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media .

Claims (13)

  1. 一种控制透明巨页的方法,包括:A method to control transparent huge pages, including:
    根据基于容器设置的透明巨页模式设置透明巨页;Set transparent huge pages according to the transparent huge page mode set based on the container;
    在设置所述透明巨页的过程中,获取所述容器使用所述透明巨页时的性能改变量;In the process of setting the transparent huge page, obtain the performance change amount when the container uses the transparent huge page;
    根据所述性能改变量调整所述透明巨页模式。The transparent huge page mode is adjusted according to the performance change amount.
  2. 根据权利要求1所述的控制透明巨页的方法,其中,所述透明巨页模式包括如下之一:The method of controlling transparent huge pages according to claim 1, wherein the transparent huge page mode includes one of the following:
    开启模式,设置为使用所述透明巨页并为所述透明巨页分配内存;Enable mode, set to use the transparent huge page and allocate memory for the transparent huge page;
    关闭模式,设置为使用普通页并为所述普通页分配内存;或Off mode, set to use normal pages and allocate memory for said normal pages; or
    选择模式,设置为为预设的目标进程设置所述透明巨页并为所述透明巨页分配内存。Select a mode to set the transparent huge page for a preset target process and allocate memory for the transparent huge page.
  3. 根据权利要求1所述的控制透明巨页的方法,还包括:The method for controlling transparent giant pages according to claim 1, further comprising:
    当触发缺页分配物理内存,判断虚拟内存区是否属于所述容器;When a page fault is triggered to allocate physical memory, determine whether the virtual memory area belongs to the container;
    若所述虚拟内存区属于所述容器,根据所述透明巨页模式为所述透明巨页分配所述物理内存。If the virtual memory area belongs to the container, allocate the physical memory to the transparent huge page according to the transparent huge page mode.
  4. 根据权利要求3所述的控制透明巨页的方法,还包括:The method for controlling transparent giant pages according to claim 3, further comprising:
    若所述虚拟内存区不属于所述容器,根据主机透明巨页模式为所述透明巨页分配所述物理内存。If the virtual memory area does not belong to the container, the physical memory is allocated to the transparent huge page according to the host transparent huge page mode.
  5. 根据权利要求3所述的控制透明巨页的方法,其中,所述根据所述透明巨页模式为所述透明巨页分配所述物理内存后,所述控制透明巨页的方法还包括:The method of controlling transparent huge pages according to claim 3, wherein after allocating the physical memory to the transparent huge page according to the transparent huge page mode, the method of controlling transparent huge pages further includes:
    获取所述容器的内存剩余量;Get the remaining memory of the container;
    若所述内存剩余量大于剩余量阈值,将普通页合并得到透明巨页。If the remaining amount of memory is greater than the remaining amount threshold, ordinary pages are merged to obtain transparent huge pages.
  6. 根据权利要求5所述的控制透明巨页的方法,其中,所述将普通页合并得到透明巨页,包括:The method of controlling transparent huge pages according to claim 5, wherein said merging ordinary pages to obtain transparent huge pages includes:
    确定所述容器的透明巨页模式;Determine the transparent huge page mode of the container;
    若所述透明巨页模式为所述开启模式或所述选择模式,并且在所述选择模式中使用所述透明巨页的进程为预设的目标进程,将所述普通巨页合并得到所述透明巨页。If the transparent huge page mode is the open mode or the selection mode, and the process using the transparent huge page in the selection mode is a preset target process, the ordinary huge pages are merged to obtain the Transparent giant page.
  7. 根据权利要求2所述的控制透明巨页的方法,其中,所述性能改变量包括如下至少之一:The method for controlling transparent huge pages according to claim 2, wherein the performance change amount includes at least one of the following:
    所述容器使用所述透明巨页时增大的物理内存;或The physical memory increased when the container uses the transparent huge page; or
    所述容器使用所述透明巨页时减少的缺页次数。The number of page faults reduced when the container uses the transparent huge page.
  8. 根据权利要求7所述的控制透明巨页的方法,其中,当所述性能改变量包括所述容器使用所述透明巨页时增大的物理内存的计算,性能改变量可以根据以下步骤得到:The method of controlling transparent huge pages according to claim 7, wherein when the performance change amount includes calculation of the increased physical memory when the container uses the transparent huge page, the performance change amount can be obtained according to the following steps:
    将所述容器使用所述透明巨页时增大的物理内存初始化为0;Initialize the increased physical memory when the container uses the transparent huge page to 0;
    判断所述容器是否使用所述透明巨页;Determine whether the container uses the transparent huge page;
    若所述容器使用所述透明巨页,获取使用所述透明巨页时的物理内存增加量,将所述物理内存增加量累计至所述容器使用所述透明巨页时增大的物理内存。If the container uses the transparent huge page, obtain the physical memory increase when the transparent huge page is used, and accumulate the physical memory increase to the physical memory increase when the container uses the transparent huge page.
  9. 根据权利要求8所述的控制透明巨页的方法,还包括:The method for controlling transparent giant pages according to claim 8, further comprising:
    若所述透明巨页模式改变,清除所述容器使用所述透明巨页时增大的物理内存。If the transparent huge page mode is changed, clear the physical memory that is increased when the container uses the transparent huge page.
  10. 根据权利要求7所述的控制透明巨页的方法,其中,当所述性能改变量包括所述容 器使用所述透明巨页时减少的缺页次数,所述性能改变量可以根据以下步骤得到:The method for controlling transparent huge pages according to claim 7, wherein when the performance change amount includes the content The number of page faults reduced when the server uses the transparent huge page, and the performance change amount can be obtained according to the following steps:
    将所述容器使用所述透明巨页时减少的缺页次数初始化为0;Initialize the number of page faults reduced when the container uses the transparent huge page to 0;
    若所述容器没有发生缺页且首次访问的内存属于透明巨页,将所述容器使用所述透明巨页时减少的缺页次数增加1,得到所述容器使用所述透明巨页时减少的缺页次数。If no page fault occurs in the container and the memory accessed for the first time belongs to a transparent huge page, increase the number of page faults reduced when the container uses the transparent huge page by 1 to obtain the reduced number of page faults when the container uses the transparent huge page. Number of missing pages.
  11. 根据权利要求10所述的控制透明巨页的方法,其中,若所述透明巨页模式改变,清除所述容器使用所述透明巨页时减少的缺页次数。The method of controlling a transparent huge page according to claim 10, wherein if the transparent huge page mode is changed, the number of page faults reduced when the container uses the transparent huge page is cleared.
  12. 一种控制透明巨页的装置,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如权利要求1至11任一项所述的控制透明巨页的方法。A device for controlling transparent giant pages, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any one of claims 1 to 11 The method of controlling transparent huge pages as described in item 1.
  13. 一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1至11任一项所述的控制透明巨页的方法。 A computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the method of controlling a transparent giant page according to any one of claims 1 to 11.
PCT/CN2023/097197 2022-06-27 2023-05-30 Method and apparatus for controlling transparent huge page, and storage medium WO2024001644A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210736636.7A CN117331643A (en) 2022-06-27 2022-06-27 Method for controlling transparent macro page, device and storage medium thereof
CN202210736636.7 2022-06-27

Publications (1)

Publication Number Publication Date
WO2024001644A1 true WO2024001644A1 (en) 2024-01-04

Family

ID=89288954

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/097197 WO2024001644A1 (en) 2022-06-27 2023-05-30 Method and apparatus for controlling transparent huge page, and storage medium

Country Status (2)

Country Link
CN (1) CN117331643A (en)
WO (1) WO2024001644A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008692A (en) * 2019-03-22 2019-07-12 联想(北京)有限公司 A kind of information processing method, device and storage medium
CN112596913A (en) * 2020-12-29 2021-04-02 海光信息技术股份有限公司 Method and device for improving performance of transparent large page of memory, user equipment and storage medium
CN113687873A (en) * 2021-07-30 2021-11-23 济南浪潮数据技术有限公司 Large-page memory configuration method, system and related device in cloud service page table
US20210374071A1 (en) * 2020-06-01 2021-12-02 The Texas A&M University System Methods, systems, and computer readable media for performing page fault handling
CN114020416A (en) * 2021-11-16 2022-02-08 湖南麒麟信安科技股份有限公司 Large-page memory dynamic management method and device and computer equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008692A (en) * 2019-03-22 2019-07-12 联想(北京)有限公司 A kind of information processing method, device and storage medium
US20210374071A1 (en) * 2020-06-01 2021-12-02 The Texas A&M University System Methods, systems, and computer readable media for performing page fault handling
CN112596913A (en) * 2020-12-29 2021-04-02 海光信息技术股份有限公司 Method and device for improving performance of transparent large page of memory, user equipment and storage medium
CN113687873A (en) * 2021-07-30 2021-11-23 济南浪潮数据技术有限公司 Large-page memory configuration method, system and related device in cloud service page table
CN114020416A (en) * 2021-11-16 2022-02-08 湖南麒麟信安科技股份有限公司 Large-page memory dynamic management method and device and computer equipment

Also Published As

Publication number Publication date
CN117331643A (en) 2024-01-02

Similar Documents

Publication Publication Date Title
US10761876B2 (en) Faster access of virtual machine memory backed by a host computing device's virtual memory
US10552337B2 (en) Memory management and device
US20200364821A1 (en) Unified memory systems and methods
US8788739B2 (en) Hypervisor-based management of local and remote virtual memory pages
JP6616433B2 (en) Storage system, storage management device, storage, hybrid storage device, and storage management method
JP6982468B2 (en) Memory system and control method
US7299337B2 (en) Enhanced shadow page table algorithms
US9098417B2 (en) Partitioning caches for sub-entities in computing devices
US20200117368A1 (en) Method for achieving data copying in ftl of solid state drive, system and solid state drive
JP6785204B2 (en) Memory system and control method
CN104583979A (en) Techniques for dynamic physical memory partitioning
US8458434B2 (en) Unified virtual contiguous memory manager
CN112988387A (en) Memory page management method and computing device
CN110019083B (en) Storage method and device of distributed file system, electronic equipment and storage medium
WO2024001644A1 (en) Method and apparatus for controlling transparent huge page, and storage medium
US7395400B2 (en) Adaptive address space operating system
EP3291103A1 (en) System and method for creating a snapshot of a subset of a database
US20210048958A1 (en) Concept for Controlling a Memory Performance in a Computer System
US10613989B2 (en) Fast address translation for virtual machines
CN112860381B (en) Virtual machine memory capacity expansion method and system based on Shenwei processor
KR20190069134A (en) Apparatus and method for file sharing between applications
US10649809B2 (en) Fork-aware smart pointers
JP3859063B2 (en) Configuration information access control method for virtual machines
JP2022019787A (en) Memory system and control method
CN115390876A (en) Virtual machine QEMU program hot upgrading method, device and equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23829829

Country of ref document: EP

Kind code of ref document: A1