Large-page memory allocation optimization method and device and medium

By avoiding data clearing operations when the virtual machine is started and delaying it until the virtual machine is shut down, the problem of data clearing is too long when the virtual machine is started, and the effect of shortening the system startup time is achieved.

CN120066679APending Publication Date: 2025-05-30ECARX (HUBEI) TECHCO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510131817.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-06
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

When a virtual machine uses large page memory map when starting, the data clearing operation takes a long time, resulting in the startup time of the vehicle computer system being too long.

Method used

When the virtual machine starts, the large page box is not cleared immediately, but the data clearing operation is performed when the virtual machine is shut down to avoid taking up startup time.

Benefits of technology

By setting the data clearing operation in the shutdown stage of the virtual machine, the overall startup time of the system is shortened and the startup speed of the vehicle machine system is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066679A_ABST
    Figure CN120066679A_ABST
Patent Text Reader

Abstract

The invention discloses a large-page memory allocation optimization method and device and a medium, and the large-page memory allocation optimization method comprises the steps: responding to a virtual machine starting instruction, mapping a virtual machine memory by using a large page, and obtaining a target large page; in response to the fact that the missing page exception is triggered, a target large page frame of the host machine is distributed to the target large page, and the mapping relation between the target large page and a virtual machine memory is obtained; and in response to a virtual machine closing instruction, executing a data clearing operation on the target large page frame, and releasing the mapping relationship. And the overall starting time consumption of the system (the host machine and the virtual machine) can be shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of large page memory allocation optimization, and particularly to a method, device, and medium for optimizing large page memory allocation. Background Art

[0002] Memory-intensive applications refer to application programs that require a large amount of memory resources to store data, intermediate results, or perform complex operations during operation, such as virtual machines or database applications. Memory-intensive applications usually need to process large-scale memory mappings. If small pages with a size of 4KB are used for memory mapping, it will increase the pressure on the TLB (Translation Lookaside Buffer) and the memory occupied by the page table itself will be larger. Therefore, for memory-intensive applications, large pages (HugePages) need to be used for memory mapping to improve the memory access speed. Among them, a large page is a memory management unit much larger than 4KB, and common large page sizes are 2MB, 1GB, etc.

[0003] However, there is a problem when virtual machines use large pages for memory mapping: For security reasons, when a certain large page is first accessed, the kernel will clear the data of the large page, and usually the data of the large page is cleared during large page allocation, but the clearing operation takes a long time. Most storage hardware takes more than 0.1s to clear a 1GB large page. Now, in-vehicle systems using virtual machines already have a demand for using more than 32G of memory. When a virtual machine using 32GB of memory starts up, it needs to map 32 1GB large pages, which will take more than 3.2s. And the startup time of the in-vehicle system is very precious, so there is a strong need to optimize this time-consuming.

[0004] In some cloud host scenarios, the time during the virtual machine startup process may be reduced by performing data clearing operations in advance. This method is to perform data clearing operations in advance before starting the virtual machine regardless of whether it is a large page or a small page, and then use these pre-cleared pages when starting the virtual machine. This method can only reduce the startup time of the virtual machine and cannot reduce the overall startup time of the system (for example, the startup process of an in-vehicle system using a virtual machine is: first start the host machine, and then start the virtual machine. This method only advances the time-consuming during the virtual machine startup process to before starting the virtual machine, that is, perform data clearing operations during the host machine startup process, which will inevitably lead to an extension of the host machine startup time. Therefore, the overall startup time of the in-vehicle system has not been shortened). Therefore, the problem has not been fundamentally solved.

[0005] In view of this, the present application is specifically proposed. Summary of the Invention

[0006] A brief summary of one or more aspects is given below to provide a basic understanding of these aspects. This summary is not an exhaustive overview of all conceived aspects, and is neither intended to identify the key or critical elements of all aspects nor to define the scope of any or all aspects. Its only purpose is to give some concepts of one or more aspects in a simplified form as a prelude to a more detailed description that will be given later.

[0007] The present application provides a large page memory allocation optimization method, device and medium, which can shorten the overall system startup time.

[0008] In a first aspect, the present application provides a large page memory allocation optimization method, comprising the following steps:

[0009] In response to the virtual machine startup instruction, the virtual machine memory is mapped using huge pages to obtain a target huge page;

[0010] In response to a page fault exception being triggered, allocating a target huge page frame of the host machine to the target huge page, and obtaining a mapping relationship between the target huge page and the virtual machine memory;

[0011] In response to the virtual machine shutdown instruction, a data clearing operation is performed on the target large page frame, and the mapping relationship is released.

[0012] Further, in response to the page fault exception being triggered, allocating the target huge page frame of the host machine to the target huge page, and obtaining a mapping relationship between the target huge page and the virtual machine memory, includes:

[0013] In response to a page fault exception being triggered, when the time-consuming optimization function is turned on, a target huge page frame of the host machine is allocated to the target huge page, and a mapping relationship between the target huge page and the virtual machine memory is obtained;

[0014] In response to the virtual machine shutdown instruction, performing a data clearing operation on the target large page frame and releasing the mapping relationship include:

[0015] In response to a virtual machine shutdown instruction, when the time-consuming optimization function is enabled and the target large page attribute is a non-shared attribute, a data clearing operation is performed on the target large page frame, and the mapping relationship is released.

[0016] Furthermore, it also includes:

[0017] In response to a virtual machine shutdown instruction, when the time-consuming optimization function is enabled and the target large page attribute is a shared attribute, the mapping relationship is released.

[0018] Furthermore, it also includes:

[0019] In response to the virtual machine shutdown instruction, when the time-consuming optimization function is not enabled, the mapping relationship is released.

[0020] Furthermore, it also includes:

[0021] In response to a page fault exception being triggered, when the time-consuming optimization function is not enabled, if the target huge page attribute is a shared attribute, the target huge page frame of the host machine is allocated to the target huge page, and a mapping relationship between the target huge page and the virtual machine memory is obtained.

[0022] Furthermore, it also includes:

[0023] In response to a page fault exception being triggered, when the time-consuming optimization function is not enabled, when the target huge page frame of the host machine is allocated to the target huge page and a mapping relationship between the target huge page and the virtual machine memory is obtained, if the target huge page attribute is a non-shared attribute, a data clearing operation is performed on the target huge page frame.

[0024] Furthermore, it also includes:

[0025] In response to the virtual machine startup instruction, determining target configuration information;

[0026] Determine whether the time-consuming optimization function is enabled based on the target configuration information.

[0027] Furthermore, it also includes:

[0028] In response to the virtual machine shutdown instruction, determining target configuration information;

[0029] Determine whether the time-consuming optimization function is enabled based on the target configuration information.

[0030] In a second aspect, the present application also provides a large page memory allocation optimization device, comprising:

[0031] A first processing module is used to respond to a virtual machine startup instruction, use a huge page to map the virtual machine memory, and obtain a target huge page;

[0032] A second processing module is used for allocating a target huge page frame of the host machine to the target huge page in response to a page fault exception being triggered, and obtaining a mapping relationship between the target huge page and the virtual machine memory;

[0033] A third processing module, configured to execute a data clearing operation on the target huge page frame in response to a virtual machine shutdown instruction;

[0034] The release module is used to release the mapping relationship.

[0035] In a third aspect, the present application further provides an electronic device, the electronic device comprising:

[0036] One or more processors;

[0037] A storage device for storing one or more programs;

[0038] When the one or more programs are executed by the one or more processors, the one or more processors implement the large page memory allocation optimization method as described above.

[0039] In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the large page memory allocation optimization method as described above is implemented.

[0040] In the large page memory allocation optimization method disclosed in the present application, when allocating large page frames for the target large pages mapped to the virtual machine, the operation of clearing data from the large page frames is not performed to save time, thereby shortening the startup duration of the virtual machine. To ensure security, when the virtual machine shuts down, the operation of clearing data from the page frames of the large pages allocated to the virtual machine this time is performed, that is, the data clearing operation is set in the shutdown stage of the virtual machine, thereby avoiding occupying the startup time of the virtual machine or the startup time of the host machine, achieving the purpose of shortening the overall startup time of the system (host machine and virtual machine). BRIEF DESCRIPTION OF THE DRAWINGS

[0041] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0042] Figure 1 A flowchart showing a large page memory allocation optimization method provided by an embodiment of the present application;

[0043] Figure 2 An architecture diagram showing the relationship between a virtual machine and a host machine provided by an embodiment of the present application;

[0044] Figure 3 A flowchart showing another large page memory allocation optimization method provided by an embodiment of the present application;

[0045] Figure 4 A structural diagram showing a large page memory allocation optimization device provided by an embodiment of the present application;

[0046] Figure 5 A structural diagram showing an electronic device in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0047] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only for explaining the relevant invention and not for limiting the invention. In addition, it should be noted that for the sake of description, only the parts related to the invention are shown in the drawings.

[0048] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and embodiments.

[0049] Memory-intensive applications refer to application programs that require a large amount of memory resources to store data, intermediate results, or perform complex operations during operation, such as virtual machines or database applications. Therefore, memory-intensive applications usually need to process large-scale memory mappings. If small pages of 4KB in size are used for memory mapping, it will increase the pressure on the TLB (Translation Lookaside Buffer) and the memory occupied by the page table itself will be larger. The page table is a data structure used by the operating system to map virtual memory addresses to physical memory addresses. When using small pages for virtual memory mapping, due to the small size of the pages, more page table entries are required to manage the same-sized memory area. Suppose there is a 1GB memory area. If it is managed with 4KB pages, 1GB / 4KB = 262144 page table entries are required, while if 2MB-sized pages are used for management, 1GB / 2MB = 512 page table entries are required. Therefore, for memory-intensive applications, if small pages of 4KB in size are used for memory mapping, the memory occupied by the page table itself will be larger.

[0050] The reduction in the number of page table entries means that when the processor searches the page table to complete the memory address mapping, it can locate the corresponding physical memory address faster because the processor needs to traverse fewer page table entries. Therefore, the search speed is faster, achieving the purpose of improving the memory access speed. On the contrary, for memory-intensive applications, if small pages of 4KB in size are used for memory mapping, it will lead to a decrease in the memory access speed.

[0051] The TLB is a cache located between the processor and the main memory, used to store recently used page table entries. When the processor needs to access memory, it first searches for the corresponding page table entry in the TLB. If the corresponding page table entry is found, the virtual address to physical address conversion can be quickly completed. Since using large pages can reduce the number of page table entries, more valid page table ranges can be stored in the TLB, thereby improving the TLB hit rate, reducing the miss rate, and further accelerating the memory access speed. On the contrary, if small pages are used, the memory access speed will be reduced.

[0052] Therefore, for memory-intensive applications, huge pages (HugePages) need to be used for memory mapping to improve memory access speed. Among them, huge pages are memory management units much larger than 4KB, and common huge page sizes include 2MB, 1GB, etc.

[0053] Currently, there is a problem when virtual machines use huge pages for memory mapping: for security reasons, when a certain huge page is accessed for the first time, the kernel will clear the data of the huge page, and usually clears the data of the huge page during huge page allocation, but the clearing operation takes a long time. It takes more than 0.1s for most storage hardware to clear a 1GB huge page. Now, in-vehicle systems using virtual machines already have a requirement to use more than 32GB of memory. When a virtual machine with 32GB of memory starts up, it needs to map 32 1GB huge pages, which will take more than 3.2s. And the startup time of in-vehicle systems is very precious, so there is a strong need to optimize this time-consuming.

[0054] In some cloud host scenarios, the time during the virtual machine startup process may be reduced by performing the data clearing operation in advance. This method is to perform the data clearing operation in advance regardless of whether it is a huge page or a small page before starting the virtual machine, and then use these pages that have been cleared in advance when starting the virtual machine. This method can only reduce the startup time of the virtual machine and cannot reduce the overall startup time of the system (for example, the startup process of an in-vehicle system using a virtual machine is: first start the host machine, and then start the virtual machine. This method only advances the time-consuming during the virtual machine startup process to before starting the virtual machine, that is, performs the data clearing operation during the host machine startup process, which will inevitably lead to an extension of the host machine startup time. Therefore, the overall startup time of the in-vehicle system has not been shortened). Therefore, the problem has not been fundamentally solved.

[0055] In response to the above problems, this application proposes an optimization method for huge page memory allocation. Specifically, the data clearing operation is set in the shutdown stage of the virtual machine, so as to avoid occupying the startup time of the system (host machine and virtual machine), and achieve the purpose of shortening the system startup time.

[0056] Figure 1 The following is a schematic flow diagram of an optimization method for huge page memory allocation proposed in this application, as Figure 1 shown, the huge page memory allocation optimization method includes the following steps:

[0057] S110. In response to a virtual machine startup instruction, use huge pages to map the virtual machine memory to obtain target huge pages.

[0058] Among them, a virtual machine is a computer system with complete hardware system functions simulated by software. It runs on a physical computer (referred to as the host computer), and an operating system and various application programs can be installed and run in the virtual machine. The startup instruction of the virtual machine can be triggered through the shortcut on the host computer desktop.

[0059] Exemplarily, refer to Figure 2 The schematic architecture diagram of the relationship between a virtual machine and a host computer shown in the figure includes a host computer hardware system 210, a host computer software system 220, a virtual machine 230, and a virtualization technology core component 240. The virtualization technology core component 240 can specifically be a bare-metal virtual machine monitor Type-1 Hypervisor or a hosted virtual machine monitor Type-2 Hypervisor. Among them, Type-1 Hypervisor is directly installed on the hardware of the host computer, interacts with the computer hardware of the host computer, has no intermediate host operating system, and can directly access and control hardware resources. Type-2 Hypervisor is installed as an application program on the host computer operating system and depends on the host computer operating system to access and manage hardware resources. Figure 2 As an example, both the virtualization technology core components Type-1 Hypervisor and Type-2 Hypervisor are shown, but in actual applications, usually only one of them needs to be selected, that is, one of Type-1 Hypervisor and Type-2 Hypervisor is selected as the virtualization technology core component. The hardware of the host computer includes a CPU (Central Processing Unit, central processing unit), an MMU (Memory Management Unit, memory management unit), and memory. Among them, the MMU is a key hardware component for memory management in a computer system, mainly responsible for converting the virtual address used by a program into a physical address, so that the program can correctly access the data in physical memory.

[0060] The virtual address is divided into groups of a fixed length, called pages. A page frame is a basic unit in physical memory, and its size is the same as the page size in virtual memory. Physical memory is divided into multiple such page frames to facilitate the storage and management of virtual pages. The main role of a page frame is to serve as a container for storing virtual pages in physical memory. Each page frame has a unique physical address, and virtual pages are mapped to specific page frames through page table entries (PTEs). HugePages, also known as large pages, are used in memory management techniques to support page sizes larger than standard memory pages. In modern operating systems, memory is usually managed in units of 4KB pages. On the x86_64 architecture, the huge page sizes are 2MB and 1GB.

[0061] When the virtual machine starts, huge pages are used to map the virtual machine memory, which can also be said to use huge pages for virtual machine memory allocation. Specifically, huge pages (with sizes such as 2MB and 1GB) are allocated for the virtual machine memory. As mentioned above, "huge pages" belong to the category of virtual memory, and further physical memory allocation needs to be performed. Specifically, huge page frames (which belong to the category of physical memory) are allocated to the huge pages.

[0062] By allocating the physical memory of the host to the virtual machine for the virtual machine to use, the virtual machine can have performance comparable to that of the host.

[0063] Specifically, when the virtual machine starts, relevant memory (this relevant memory is the target huge page) will be mapped to the virtual machine as the virtual machine's memory. A page fault exception will be triggered during the mapping process. Specifically, in what circumstances the page fault exception is triggered is determined by the kernel design of the operating system, with the purpose of monitoring and servicing the user's memory operations. For example, a page fault exception is usually triggered when accessing a certain memory page for the first time, or when attempting to write data to a certain memory page without write permission.

[0064] S120. In response to the triggering of the page fault exception, allocate the target huge page frame of the host to the target huge page to obtain the mapping relationship between the target huge page and the virtual machine memory.

[0065] Among them, the target huge page belongs to the category of virtual memory. Therefore, through the execution of step S110, the virtual machine has not obtained physical memory yet. When a certain virtual memory page is accessed, a page fault exception will be triggered. After the page fault exception is triggered, the corresponding physical memory, that is, the huge page frame, will be further allocated. That is to say, when allocating the huge page frame, the operation of clearing the data in the huge page frame is not performed to save time, thereby shortening the startup duration of the virtual machine.

[0066] Optionally, in response to a page fault exception being triggered, allocating a target huge page frame of the host machine to the target huge page, and obtaining a mapping relationship between the target huge page and the virtual machine memory includes:

[0067] In response to a page fault exception being triggered, when the optimization time-consuming function is turned on, the target large page frame of the host machine is allocated to the target large page, and the mapping relationship between the target large page and the virtual machine memory is obtained. By separately setting the optimization time-consuming function switch, it is possible to flexibly control whether to turn on the optimization time-consuming function, thereby achieving compatibility with existing solutions. Among them, the optimization time-consuming function can be flexibly selected to be turned on or off according to demand. Exemplarily, the optimization time-consuming function can be turned on or off by setting the target configuration information. For example, when the target configuration information is 1, it indicates that the optimization time-consuming function is turned on; when the target configuration information is 0, it indicates that the optimization time-consuming function is not turned on.

[0068] To ensure security, each time the virtual machine is shut down, a data clearing operation is performed on the page frame of the large page currently allocated to the virtual machine. In other words, the data clearing operation is set during the shutdown phase of the virtual machine. This setting can save startup time and ensure data security.

[0069] Further, in some embodiments, in response to a page fault exception being triggered, when the time-consuming optimization function is not enabled, if the target huge page attribute is a shared attribute, the target huge page frame of the host machine is allocated to the target huge page, and a mapping relationship between the target huge page and the virtual machine memory is obtained. That is, when the huge page attribute allocated to the virtual machine is a shared attribute, the data clearing operation is not performed, and the data clearing operation is directly skipped, thereby saving time.

[0070] In some embodiments, in response to a page fault exception being triggered, when the optimization time consumption function is not enabled, when the target huge page frame of the host machine is assigned to the target huge page and a mapping relationship between the target huge page and the virtual machine memory is obtained, if the target huge page attribute is a non-shared attribute, a data clearing operation is performed on the target huge page frame. That is, when the optimization time consumption function is not enabled and the huge page attribute assigned to the virtual machine is a non-shared attribute, when the huge page frame is assigned, a data clearing operation is performed on the assigned huge page frame to prevent the historical data of the huge page frame from being read by a new process, causing data leakage, thereby ensuring data security.

[0071] S130. In response to a virtual machine shutdown instruction, perform a data clearing operation on the target large page frame, and release the mapping relationship.

[0072] Optionally, in response to the virtual machine shutdown instruction, a data clearing operation is performed for the target large page frame, and the mapping relationship is released, including: in response to the virtual machine shutdown instruction, when the optimization time-consuming function is turned on and the target large page attribute is a non-shared attribute, a data clearing operation is performed for the target large page frame, and the mapping relationship is released. That is, when the virtual machine is shut down, when the optimization time-consuming function is turned on and the target large page attribute is a non-shared attribute, a data clearing operation is performed for the target large page frame to ensure the security of the data in the large page frame. Wherein, if the target large page attribute is a non-shared attribute, it means that the data in the target large page frame cannot be shared. At this time, when the virtual machine is shut down, a data clearing operation needs to be performed to ensure data security. If the target large page attribute is a shared attribute, it means that the data in the target large page frame needs to be shared. At this time, when the virtual machine is shut down, the data clearing operation is not performed.

[0073] In some implementations, in response to a virtual machine shutdown instruction, when the time-consuming optimization function is enabled and the target large page attribute is a shared attribute, the data clearing operation for the target large page frame is skipped, and the mapping relationship is directly released.

[0074] In some implementations, in response to a virtual machine shutdown instruction, when the time-consuming optimization function is not enabled, the data clearing operation for the target huge page frame is skipped, and the mapping relationship is directly released. That is, when the time-consuming optimization function is not enabled, the data clearing operation is not performed when the virtual machine is shut down.

[0075] The time-consuming optimization function can be flexibly selected to be turned on or off according to demand. Exemplarily, the time-consuming optimization function can be turned on or off by setting the target configuration information. For example, when the target configuration information is 1, it indicates that the time-consuming optimization function is turned on; when the target configuration information is 0, it indicates that the time-consuming optimization function is not turned on. Exemplarily, in response to a virtual machine startup instruction, the target configuration information is determined; based on the target configuration information, it is determined whether the time-consuming optimization function is turned on. In response to a virtual machine shutdown instruction, the target configuration information is determined; based on the target configuration information, it is determined whether the time-consuming optimization function is turned on.

[0076] Based on the above embodiments, Figure 3 The flowchart of a large page memory allocation optimization method shown in FIG. 1 specifically includes the following steps:

[0077] S1. The host machine starts using the modified LINUX kernel.

[0078] Specifically, the modified LINUX kernel supports configuration to clear the huge page memory when releasing the huge page (rather than only clearing the huge page memory when allocating the huge page).

[0079] S2. Trigger the virtual machine startup instruction.

[0080] Specifically, the virtual machine is started in the host machine.

[0081] S3, use large pages to map virtual machine memory.

[0082] Specifically, when the virtual machine is started, a corresponding number of large pages of the host machine are mapped to the virtual machine memory.

[0083] S4, judging whether to enable the time-consuming optimization function, if the time-consuming optimization function is enabled, jumping to step S6, otherwise jumping to step S5.

[0084] Specifically, this embodiment can configure and select whether to enable the time-consuming optimization function. When the time-consuming optimization function is enabled, when a large page frame is allocated due to a page fault exception, the memory of the corresponding large page frame is not cleared.

[0085] S5. When a page fault exception is triggered, a large page frame is allocated and the memory of the corresponding large page frame is cleared.

[0086] S6. When a page fault exception is triggered, a large page frame is allocated.

[0087] S7. The virtual machine is started and runs based on virtual memory.

[0088] S8. Trigger the virtual machine shutdown instruction.

[0089] Specifically, after the virtual machine shutdown instruction is triggered, the host machine kernel memory management module will be triggered to execute the unmapping process.

[0090] S9, determine whether to enable the time-consuming optimization function. If the time-consuming optimization function is enabled, jump to step S10; otherwise, jump to step S12.

[0091] S10. Determine whether the huge page is a shared huge page. If so, execute S12; otherwise, execute S11.

[0092] Specifically, when the shared attribute is set for the huge page mapped by the virtual machine, the allocated huge page memory is not cleared, and the operation of releasing the huge page mapping relationship is directly performed; otherwise, the allocated huge page memory is cleared first, and then the operation of releasing the huge page mapping relationship is performed.

[0093] S11. Clear the allocated large page memory.

[0094] S12. Release the large page mapping relationship.

[0095] Figure 4 is a structural diagram of a large page memory allocation optimization device provided in an embodiment of the present application, such as Figure 4As shown in the figure, the device includes: a first processing module 410, a second processing module 420, a third processing module 430, and a release module 440.

[0096] Among them, the first processing module 410 is used to, in response to a virtual machine startup instruction, map the virtual machine memory using large pages to obtain target large pages; the second processing module 420 is used to, in response to a page fault exception being triggered, allocate the target large page frame of the host machine to the target large page to obtain the mapping relationship between the target large page and the virtual machine memory; the third processing module 430 is used to, in response to a virtual machine shutdown instruction, perform a data clearing operation on the target large page frame; the release module 440 is used to release the mapping relationship.

[0097] Furthermore, the second processing module 420 is used to, in response to a page fault exception being triggered, and when the optimization time-consuming function is enabled, allocate the target large page frame of the host machine to the target large page to obtain the mapping relationship between the target large page and the virtual machine memory.

[0098] The third processing module 430 is used to, in response to a virtual machine shutdown instruction, and when the optimization time-consuming function is enabled and the target large page attribute is a non-shared attribute, perform a data clearing operation on the target large page frame and release the mapping relationship.

[0099] Furthermore, the release module 440 is further used to: in response to a virtual machine shutdown instruction, and when the optimization time-consuming function is enabled and the target large page attribute is a shared attribute, release the mapping relationship.

[0100] Furthermore, it further includes: the release module 440 is further used to: in response to a virtual machine shutdown instruction, and when the optimization time-consuming function is not enabled, release the mapping relationship.

[0101] Furthermore, the second processing module 420 is further used to: in response to a page fault exception being triggered, and when the optimization time-consuming function is not enabled, if the target large page attribute is a shared attribute, allocate the target large page frame of the host machine to the target large page to obtain the mapping relationship between the target large page and the virtual machine memory.

[0102] Furthermore, the third processing module 430 is further used to: in response to a page fault exception being triggered, and when the optimization time-consuming function is not enabled, when allocating the target large page frame of the host machine to the target large page to obtain the mapping relationship between the target large page and the virtual machine memory, if the target large page attribute is a non-shared attribute, perform a data clearing operation on the target large page frame.

[0103] Further, it further includes a determination module, configured to determine target configuration information in response to a virtual machine startup instruction; determine whether the optimization time-consuming function is enabled based on the target configuration information; and, in response to a virtual machine shutdown instruction, determine target configuration information; determine whether the optimization time-consuming function is enabled based on the target configuration information.

[0104] In the large page memory allocation optimization device disclosed in the embodiments of the present application, when the optimization time-consuming function is enabled, when allocating large page frames for the target large pages mapped to the virtual machine, the operation of clearing data from the large page frames is not performed to save time, thereby shortening the startup duration of the virtual machine. To ensure security, when the virtual machine shuts down, the operation of clearing data from the page frames of the large pages with non-shared attributes allocated to the virtual machine for the current time is performed, that is, the data clearing operation is set in the shutdown stage of the virtual machine, thereby avoiding occupying the startup time of the virtual machine or the startup time of the host machine, achieving the purpose of shortening the overall startup time of the system (host machine and virtual machine).

[0105] The large page memory allocation optimization device provided in the embodiments of the present disclosure can execute the steps in the large page memory allocation optimization method provided in the method embodiments of the present disclosure, and has the same execution steps and beneficial effects, which will not be elaborated here.

[0106] Figure 5 It is a schematic structural diagram of an electronic device in the embodiments of the present disclosure. Specifically refer to Figure 5 hereinafter, which shows a schematic structural diagram of the electronic device 500 suitable for implementing the embodiments of the present disclosure. Figure 5 The electronic device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.

[0107] As Figure 5 shown, the electronic device 500 may include a processing device (such as a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) or the program loaded from the storage device 508 into the random access memory (RAM) to implement the method of the embodiments as described in the present disclosure. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through the bus 504. The I / O interface 505 is also connected to the bus 504. The input device 506, the output device 507, the storage device 508, and the communication device 509 are all connected to the I / O interface 505.

[0108] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product that includes a computer program carried on a non-transitory computer-readable medium, the computer program including program code for performing the methods shown in the flowcharts, thereby implementing the large page memory allocation optimization method as described above. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-described functions defined in the methods of the embodiments of the present disclosure are performed.

[0109] It should be noted that the above computer-readable medium in the present disclosure may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0110] The above computer-readable medium may be included in the above electronic device; or may exist separately without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device performs the method steps in the present application.

[0111] Optionally, when one or more of the above programs are executed by the electronic device, the electronic device may also perform the other steps described in the above embodiments.

[0112] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0113] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, a technical solution formed by mutually replacing the above features with technical features having similar functions (but not limited to) disclosed in the present disclosure.

[0114] Specific examples are used herein to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. The above is only the preferred implementation manner of the present application. It should be noted that due to the limited nature of written expression and the objectively infinite specific structures, for those of ordinary skill in the art, without departing from the principle of the present application, several improvements, refinements, or changes can be made, or the above technical features can be combined in an appropriate manner; these improvements, refinements, changes, or combinations, or directly applying the inventive concept and technical solution to other occasions without improvement, should all be regarded as the protection scope of the present application.

Claims

1. A large page memory allocation optimization method, characterized in that: include: In response to the virtual machine startup instruction, the virtual machine memory is mapped using huge pages to obtain a target huge page; In response to a page fault exception being triggered, allocating a target huge page frame of the host machine to the target huge page, and obtaining a mapping relationship between the target huge page and the virtual machine memory; In response to the virtual machine shutdown instruction, a data clearing operation is performed on the target large page frame, and the mapping relationship is released.

2. The large page memory allocation optimization method according to claim 1, characterized in that: In response to a page fault exception being triggered, allocating a target huge page frame of the host machine to the target huge page, and obtaining a mapping relationship between the target huge page and the virtual machine memory, including: In response to a page fault exception being triggered, when the time-consuming optimization function is turned on, a target huge page frame of the host machine is allocated to the target huge page, and a mapping relationship between the target huge page and the virtual machine memory is obtained; In response to the virtual machine shutdown instruction, performing a data clearing operation on the target large page frame and releasing the mapping relationship include: In response to a virtual machine shutdown instruction, when the time-consuming optimization function is enabled and the target large page attribute is a non-shared attribute, a data clearing operation is performed on the target large page frame, and the mapping relationship is released.

3. The large page memory allocation optimization method according to claim 1, characterized in that: Also includes: In response to a virtual machine shutdown instruction, when the time-consuming optimization function is enabled and the target large page attribute is a shared attribute, the mapping relationship is released.

4. The large page memory allocation optimization method according to claim 1, characterized in that: Also includes: In response to the virtual machine shutdown instruction, when the time-consuming optimization function is not enabled, the mapping relationship is released.

5. The large page memory allocation optimization method according to claim 1, characterized in that: Also includes: In response to a page fault exception being triggered, when the time-consuming optimization function is not enabled, if the target huge page attribute is a shared attribute, the target huge page frame of the host machine is allocated to the target huge page, and a mapping relationship between the target huge page and the virtual machine memory is obtained.

6. The large page memory allocation optimization method according to claim 1, characterized in that: Also includes: In response to a page fault exception being triggered, when the time-consuming optimization function is not enabled, when the target huge page frame of the host machine is allocated to the target huge page and a mapping relationship between the target huge page and the virtual machine memory is obtained, if the target huge page attribute is a non-shared attribute, a data clearing operation is performed on the target huge page frame.

7. The large page memory allocation optimization method according to claim 1, characterized in that: Also includes: In response to the virtual machine startup instruction, determining target configuration information; Determine whether the time-consuming optimization function is enabled based on the target configuration information.

8. The large page memory allocation optimization method according to claim 1, characterized in that: Also includes: In response to the virtual machine shutdown instruction, determining target configuration information; Determine whether the time-consuming optimization function is enabled based on the target configuration information.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the large page memory allocation optimization method as described in any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the large page memory allocation optimization method as described in any one of claims 1 to 8 is implemented.