Virtual machine memory management method and computing device

By obtaining the memory page information of the virtual machine and the host, and determining and releasing the memory pages that meet the conditions, the memory release failure caused by inconsistent memory page sizes of the virtual machine and the host is solved, and memory reuse and memory utilization are achieved.

CN116107690BActive Publication Date: 2025-04-18XFUSION DIGITAL TECH CO LTD

Patent Information

Application Number
CN202211607011.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-13
Publication Date
2025-04-18
Estimated Expiration
2042-12-13

AI Technical Summary

Technical Problem

When a virtual machine releases memory resources, the memory release fails due to the inconsistent memory page size of the host and virtual machine, resulting in a waste of memory resources.

Method used

By obtaining the memory page information of the virtual machine and the host, determining the target free memory page that meets the release conditions, and coordinating between the virtual machine and the host, the memory page size matching is achieved to successfully release memory resources.

Benefits of technology

It realizes memory reuse managed by virtual machine, solves the memory release failure caused by inconsistent memory page sizes of virtual machines and hosts, and improves memory usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116107690B_ABST
    Figure CN116107690B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a virtual machine memory management method and computing device, which belongs to the field of virtualization technology. It supports the on-demand release of virtual machine-managed memory in different page table scenarios, and realizes the scenario of virtualized memory reuse. The method includes: obtaining first information of the memory page managed by the host machine corresponding to the virtual machine; obtaining second information of the memory page of the virtual machine; based on the first information and the second information, determining the target free memory page from the free memory page of the virtual machine, the target free memory page of the virtual machine is the free memory page that meets the release condition; the release condition includes: the starting address of the target free memory page in the virtual machine is the same as the starting address of the memory page managed by the host machine, and the total memory size of the continuous free memory pages of the target free memory page starting from the starting address is equal to the page size of the memory page managed by the host machine; releasing the target free memory page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of virtualization technology, and in particular to a virtual machine memory management method and a computing device. Background Art

[0002] As server virtualization technology continues to mature, a virtualization manager (VMM) can be introduced between the server's hardware and operating system to abstractly simulate the physical entity resources in the server and combine them into multiple virtual machines (VMs) that can be installed with different operating systems.

[0003] Currently, virtual machines can apply for needed memory resources while processing business. However, due to the peaks and troughs in the business processed by the virtual machines and the inaccurate estimation of memory resources by users, the amount of memory resources applied for is higher than the amount of memory resources actually used, resulting in the phenomenon that the memory resources applied for by the virtual machines are "occupied but not used". Therefore, the "memory bubble" technology can be used to enable the virtual machine to obtain idle memory resources and release the memory resources.

[0004] In the above-mentioned related technologies, if the virtual machine is to successfully release the free memory resources after acquiring the free memory resources, it is necessary to ensure that the properties of the memory resources corresponding to the operating systems installed in the virtual machine and the host machine are the same, which leads to limitations in the release of memory resources by the virtual machine. Summary of the invention

[0005] The embodiments of the present application provide a virtual machine memory management method and a computing device, which can support on-demand release of virtual machine managed memory in different page table scenarios, thereby realizing memory reuse of virtual machine management.

[0006] In a first aspect, an embodiment of the present application provides a virtual machine memory management method, the method comprising: obtaining first information of a memory page managed by a host machine corresponding to the virtual machine; the first information includes the size of the memory page managed by the host machine and the starting address of the memory page managed by the host machine; obtaining second information of the memory page of the virtual machine; the second information includes the status information of the memory page of the virtual machine and the starting address of the memory page managed by the virtual machine; based on the first information and the second information, determining a target free memory page from the free memory pages of the virtual machine, the free memory page is a memory page whose status information is an idle state, and the target free memory page of the virtual machine is a free memory page that meets a release condition; wherein the release condition comprises: the starting address of the target free memory page in the virtual machine is the same as the starting address of the memory page managed by the host machine, and the total memory size of the continuous free memory pages of the target free memory page starting from the starting address is equal to the page size of the memory page managed by the host machine; releasing the target free memory page.

[0007] It can be understood that first information of the host-managed memory page corresponding to the virtual machine is obtained, the first information includes the size of the host-managed memory page and the starting address of the host-managed memory page, and second information of the virtual machine's memory page is obtained, the second information includes the status information of the virtual machine's memory page and the starting address of the virtual machine's memory page, and a free memory page with a continuous address and a total memory size equal to the host-managed memory page size is obtained as the target free memory page, and the target free memory page is released. Since the memory page size of the host-managed memory page can be obtained, the total memory size can be equal to the memory page size of the host-managed memory page, and multiple consecutive virtual machine-managed memory pages can be released to the host together, so that the host can manage memory release according to its own memory page size. This solves the problem of failure of releasing the virtual machine-managed memory to the host due to the inconsistency between the memory page size of the virtual machine-managed memory and the memory page size of the host-managed memory, and realizes memory reuse of virtual machine management.

[0008] In a possible implementation manner, obtaining first information of a memory page managed by a host machine corresponding to the virtual machine includes: obtaining first information of a memory page managed by the host machine in a configuration space of a virtual machine manager VMM.

[0009] It is understandable that the first information of the memory page managed by the host machine can be obtained from the configuration space of the VMM, so that the virtual machine can obtain the first information and determine the target free memory page according to the first information.

[0010] In a possible implementation, the method further includes: obtaining a memory release instruction of the virtual machine; wherein the memory release instruction is used to instruct the release of a memory page in the virtual machine; and in response to the memory release instruction, setting the state of the memory page of the virtual machine corresponding to the memory release instruction to an idle state.

[0011] It can be understood that, for the memory pages managed by the virtual machine, when each memory page needs to be released to the host machine, the virtual machine can send a memory release instruction for the memory page. After receiving the memory release instruction, the memory page information of the virtual machine and the memory page information of the host machine corresponding to the virtual machine can be obtained, so that when each memory page needs to be released, the state information of the memory page can be set to the idle state, thereby determining the memory page as an idle memory page, which is convenient for subsequent judgment whether the idle memory page meets the release conditions, and is conducive to the release of memory managed by the virtual machine.

[0012] In one possible implementation, based on the first information and the second information, a target free memory page is determined from the free memory pages of the virtual machine, including: in response to a memory release instruction, determining whether the size of a memory page with a continuous free mark bit in the virtual machine is equal to the size of a memory page managed by a host machine; if the size of the memory page with a continuous free mark bit is equal to the size of the memory page managed by the host machine, determining whether the starting address of the first free memory page in the memory page with a continuous free mark bit in the virtual machine is the same as the starting address of the memory page managed by the host machine; if the starting address of the first free memory page in the memory page with a continuous free mark bit in the virtual machine is the same as the starting address of the memory page managed by the host machine, determining that the memory page with the continuous free mark bit is the target free memory page that meets the release condition.

[0013] It can be understood that the memory page processing the idle state can be recorded as an idle mark bit. After responding to the memory release instruction, it can be determined whether the size of the memory page with continuous mark bits is equal to the size of the memory page managed by the host machine. If they are determined to be equal, it can be determined whether the starting address of the first idle memory page in the memory page with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine. If they are the same, it can be determined that the memory page with continuous free mark bits is the target idle memory page that meets the release condition. This solves the problem of failure of releasing the memory managed by the virtual machine to the host machine due to the inconsistency between the memory page size of the virtual machine managed memory and the memory page size of the host managed memory, and realizes memory reuse of virtual machine management.

[0014] In one possible implementation, determining whether the size of a memory page with continuous free mark bits in a virtual machine is equal to the size of a memory page managed by a host machine includes: determining whether the number of memory pages with continuous free mark bits in the virtual machine is the same as the number of first free memory pages, wherein the number of first free memory pages is the ratio of the size of a memory page managed by the host machine to the size of a memory page managed by the virtual machine; if the number of memory pages with continuous free mark bits in the virtual machine is the same as the number of first free memory pages, determining that the size of the memory pages with continuous free mark bits in the virtual machine is equal to the size of the memory pages managed by the host machine.

[0015] It can be understood that, by determining the number of the first free memory pages by the size of the memory page in the first information and the size of the memory page in the second information, when the number of memory pages with continuous free marks in the virtual machine is the same as the number of the first free memory pages, the size of the memory pages with continuous free marks can be made the same as the size of the memory pages managed by the host machine, thereby not affecting the process of releasing the memory managed by the virtual machine to the host machine due to the inconsistency between the memory page size of the virtual machine managed memory and the memory page size of the host machine managed memory.

[0016] In a possible implementation, the memory page information of the virtual machine includes each memory page managed by the virtual machine and tag information corresponding to each memory page, where the tag information corresponding to the memory page is used to indicate whether the memory page is a free memory page.

[0017] It can be understood that obtaining the memory page information of the virtual machine can also be obtaining each memory page of the virtual machine and their corresponding tag information. The tag information can indicate whether the corresponding memory page is a free memory page, which is convenient for subsequent judgment of whether the free memory page meets the release conditions, and is conducive to the release of memory managed by the virtual machine.

[0018] In a possible implementation, when the marking information of the memory page managed by the virtual machine indicates that the memory page is a free memory page, the permission of the memory page managed by the virtual machine to be used by the virtual machine is modified to not support the use of the virtual machine.

[0019] It can be understood that, when it is determined that the virtual machine memory page is a free memory page, the server can modify the usage permissions of the free memory page and modify the usage permissions of the free memory page to be unusable by the virtual machine, thereby achieving the effect of isolating the memory page of the virtual machine and avoiding the problem of the free memory page being released from the idle state due to the virtual machine calling the free memory page when the free memory page does not meet the release conditions, so that the virtual machine can accurately release the free memory to the host machine.

[0020] In a possible implementation, the state information of the memory page of the virtual machine is stored in a first data structure, wherein the first data structure includes any one of a bitmap, a hash table, and a linked list.

[0021] It can be understood that the status information of the memory page in the second information of the virtual machine can be recorded in the virtual machine or the host machine in the first data structure. By using a data structure including any one of a bitmap, a hash table, and a linked list to record the memory page information of the virtual machine, the efficiency of determining the target free memory pages that meet the release conditions can be improved.

[0022] In a possible implementation, target free memory pages that meet the release conditions are obtained from the free memory pages of the virtual machine, including: obtaining a first quantity; the first quantity is the ratio of the memory page size of the memory page managed by the host machine to the memory page size of the memory page managed by the virtual machine; if it is determined that the mark information corresponding to each of the first number of consecutive memory pages in the first data structure indicates that the memory page is a free memory page, the first number of consecutive memory pages are determined as target free memory pages.

[0023] It can be understood that if the memory page information of the virtual machine is recorded in the first data structure, the first number of consecutive free memory pages required to meet the release condition can be determined based on the ratio of the memory page size of the memory page managed by the host machine to the memory page size of the memory page managed by the virtual machine. When it is determined that the mark information corresponding to the first number of consecutive memory pages recorded in the first data structure indicates that the memory page is a free memory page, the first number of consecutive memory pages can be determined as target free memory pages, thereby improving the efficiency of determining the target free memory pages.

[0024] In a possible implementation, the first data structure is a bitmap; based on the first information and the second information, the target free memory page is determined from the free memory pages of the virtual machine, including: if the number of consecutive memory pages in the bitmap is the same as the number of first free memory pages, the consecutive free memory pages are determined as the target free memory pages; wherein the number of first free memory pages is the ratio of the size of memory pages managed by the host machine to the size of memory pages managed by the virtual machine.

[0025] It can be understood that by comparing the number of consecutive memory pages in the bitmap with the number of the first free memory pages, the consecutive memory pages are determined as the target free memory pages, thereby achieving the process of avoiding the failure of releasing the memory managed by the virtual machine to the host machine due to the inconsistency between the memory page size of the virtual machine management memory and the memory page size of the host machine management memory when the first data structure is a bitmap.

[0026] In one possible implementation, after determining the target free memory page from the free memory pages of the virtual machine based on the first information and the second information, the method also includes: sending information of the target free memory page to the virtual machine manager VMM; calling the virtual machine manager VMM to determine whether the target free memory page meets the release condition; releasing the target free memory page, including: if the target free memory page meets the release condition, releasing the target free memory page.

[0027] It is understandable that after the virtual machine sends the target free memory page information to the VMM, it determines whether the target free memory page meets the release condition, and releases the target free memory page through the VMM, thereby realizing memory reuse of virtual machine management.

[0028] In a possible implementation, in response to the memory release instruction, the usage permission of the memory page of the virtual machine corresponding to the memory release instruction is modified to be unavailable.

[0029] It is understandable that in response to the memory release instruction, the usage permission of the virtual machine's memory page corresponding to the memory release instruction can be modified to unavailable, thereby preventing the memory page to be released indicated by the memory release instruction from being occupied by the virtual machine again, resulting in memory release failure.

[0030] In a possible implementation, obtaining the memory page information of the virtual machine includes: calling a Balloon simulation device to obtain the memory page information of the virtual machine from the virtual machine.

[0031] It is understandable that a Balloon simulation device can be simulated in the server. By calling the Balloon simulation device, the memory page information of the virtual machine can be obtained from the virtual machine. Combined with the bubble memory technology, the process of releasing the memory managed by the virtual machine to the host machine according to the memory information of the virtual machine can be realized.

[0032] In a possible implementation, the first information of the memory page of the host machine is stored in a peripheral component interconnect standard PCI configuration space; the PCI configuration space is a configuration space of a Balloon simulation device simulated by the host machine.

[0033] It is understandable that, since the simulated Balloon simulation device can be a PCI device, the Balloon simulation device has a PCI configuration space, and the first information of the host's memory page can be stored in the PCI configuration space so that the server can obtain and determine the release condition.

[0034] In a possible implementation manner, the method is applied to a virtualization manager VMM of a host machine, or to a virtual machine VM.

[0035] It is understandable that the method can be applied to a virtualization manager VMM of a host machine, or can also be applied to a virtual machine VM, which expands the implementation mode of the method.

[0036] In a second aspect, an embodiment of the present application provides a memory management device for a virtual machine, and the memory management device for a virtual machine is used to execute any one of the memory management methods for a virtual machine provided in the first aspect above.

[0037] In a possible implementation, the present application may divide the memory management device for the virtual machine into functional modules according to the method provided in the first aspect above. For example, each functional module may be divided corresponding to each function, or two or more functions may be inherited in one processing module. Exemplarily, the present application may divide the virtual machine memory management device into an acquisition module and a processing module, etc. according to the function. The description of the possible technical solutions and beneficial effects executed by each of the functional modules divided above can refer to the technical solutions provided in the first aspect above or its corresponding possible implementation, which will not be repeated here.

[0038] In a third aspect, an embodiment of the present application provides a host machine, the host machine comprising at least one virtual machine, a processor and a memory, the processor being coupled to the memory; the memory being used to store computer instructions, the computer instructions being loaded and executed by the processor so that the host machine implements the virtual machine memory management method as described in the above aspects.

[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which at least one computer program instruction is stored, and the computer program instruction is loaded and executed by a processor to implement the virtual machine memory management method as described in the above aspects.

[0040] In a fifth aspect, an embodiment of the present application provides a computer program product, the computer program product including computer instructions, the computer instructions stored in a computer-readable storage medium. A processor of a computing device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computing device executes the virtual machine memory management method provided in various optional implementations of the first aspect above.

[0041] For the specific description of the second to fifth aspects and their various implementations in the present application, reference may be made to the detailed description in the first aspect and its various implementations; and for the beneficial effects of the second to fifth aspects and their various implementations, reference may be made to the beneficial effects analysis in the first aspect and its various implementations, which will not be repeated here.

[0042] These and other aspects of the present application will become more apparent from the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 is a schematic diagram of a server according to an exemplary embodiment;

[0044] Figure 2 yes Figure 1 A schematic diagram of a virtual machine memory release logic structure involved in the illustrated embodiment;

[0045] Figure 3 It is a flowchart of a memory management method of a virtual machine according to an exemplary embodiment;

[0046] Figure 4 is a flow chart of a memory management method for a virtual machine according to an exemplary embodiment;

[0047] Figure 5 yes Figure 4 A schematic diagram of a Balloon driver loading process involved in the illustrated embodiment;

[0048] Figure 6 yes Figure 4 A schematic diagram of a virtual machine memory release process involved in the illustrated embodiment;

[0049] Figure 7 is a structural diagram of a memory management device for a virtual machine provided by an exemplary embodiment of the present application;

[0050] Figure 8 It is a schematic diagram of the structure of a server provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0051] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0052] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0053] Server virtualization is the introduction of a virtualization manager (VMM) between the hardware and the operating system. It can abstract, convert and simulate physical entity resources (CPU, memory, disk space, network adapter, etc.) and combine them into multiple virtual machines (VMs) that can install different operating systems. By virtualizing a single server and running multiple virtual machines on the virtualization platform, a large number of physical host resources can be cut into multiple small, flexible and controllable virtual machines that are indistinguishable from the physical host. It can even over-allocate physical host resources (such as CPU, memory and other resource reuse capabilities) and dynamically allocate and recycle resources, thereby greatly improving the utilization of the server and reducing operating and management costs. Although virtualization technology has achieved the cutting and simulation of physical host resources, and achieved small-granular allocation of host resources to improve resource utilization, the actual situation is that due to the peaks and troughs of the business inside the virtual machine, the memory resources inside the virtual machine are occupied but not used, which leads to the problem of virtual machine memory waste. In order to solve the problem of virtual machine memory waste, the "memory bubble" technology can be used.

[0054] Among them, the "memory bubble" technology can be simulated by the VMM side Balloon device, relying on the Balloon driver installed in the virtual machine, the use of memory inside the virtual machine can be detected, and the Balloon driver can release the virtual machine's free memory to the host side through two methods. Other VMs or applications on the host side can use this memory, thereby achieving the purpose of improving memory utilization. One method is that through the Balloon inflate / deflate method, the Balloon driver applies for free memory inside the virtual machine, and then notifies the back end through the Balloon device to release the memory applied by the Balloon driver to the host side, thereby realizing the return of the virtual machine's free memory to the host. In this process, the free memory seen inside the virtual machine is all used; the Balloon driver releases the memory inside the virtual machine, and then returns the virtual machine's memory through the memory virtualization of the VMM. At this time, the released memory visible to the memory management unit inside the virtual machine becomes the content before the Balloon is inflated.

[0055] Since the method of releasing free memory to the host in this method is to apply for free memory through the Balloon driver and then release it to the host. Another method is still to use the Balloon driver, but the function is enhanced. This function is called free page report (FPR). FPR can be processed in the memory management of the virtual machine operating system to release memory. When the virtual machine operating system releases memory, it will first isolate the memory and then notify the backend VMM through the Balloon driver. After the VMM releases the memory on the physical machine side, it will notify the Balloon driver inside the virtual machine, and the Balloon driver will release the isolated memory again.

[0056] Since the above methods for releasing the memory managed by the virtual machine do not limit the page size to 4K, 2M, or 64K, and since the minimum page unit of the memory page is 4K, by default, the memory release can only be successfully achieved when the page size of the memory page managed by the host is the minimum page unit of 4K. Usually, for processing performance considerations, the page size of the memory page managed by the host will choose a large page, such as 2M. Therefore, the page size of the memory page managed by the virtual machine is inconsistent with the page size of the memory page managed by the host. When the memory page size of the virtual machine is smaller than the memory page size of the host, the memory managed by the virtual machine cannot be released normally.

[0057] The embodiment of the present application can add a new function (Capability) to indicate the page size and page alignment information of the memory page managed by the host by extending the Balloon device configuration (i.e., PCI configuration space). At the same time, the page organization process is placed on the VM side, and the page statistics are organized through bitmap (or other organization methods, such as linked lists). When a complete host page is formed, the release process is performed according to the existing process, or based on the original process, the page processing is placed on the VMM side, and the VMM side organizes the page release situation through bitmap (or other organization methods, such as linked lists). When a memory page (group) that meets the release conditions is formed, the memory page (group) is released, and the unreleased page situation is notified to the virtual machine side.

[0058] The method provided in the embodiments of the present application is described in detail below in conjunction with the accompanying drawings.

[0059] Please refer to Figure 1 , Figure 1 1 is a schematic diagram of a server involved in an embodiment of the present application, wherein the server 10 includes multiple hardware, and a virtualization manager 102 (Virtual Machine Monitor, VMM) and at least one virtual machine (Virtual Machine, VM) 101 running on the hardware of the server 10, the host of at least one virtual machine is the server 10, and the hardware of the server 10 includes a processor, a memory, and an input and output device. At least one virtual machine 101 is started by VMM102.

[0060] In order to solve the problem that VM 101 cannot perceive the size of the memory page used by the host machine to actually manage the memory and the alignment information used for memory alignment, and thus cannot effectively release the free memory in VM 101. The embodiment of the present application can add the first information of the host machine's memory page in the original PCI configuration space, and the first information of the host machine's memory page may include the size and alignment information of the memory page managed by the host machine, wherein the alignment information may be the starting address and / or the ending address of the memory page. At the same time, memory tags and reference units are added to the virtual machine to record the release and use of memory pages on the VM side, so that it can be determined whether the free memory pages constitute the target free memory pages that can be released on the host side.

[0061] Among them, the virtual machine 101 may have an independent operating system (OS), and the operating system of the virtual machine may be different from the operating system of the host machine, and the operating system of the virtual machine 101 includes a memory management module for managing the virtualized memory (or memory) configured for the virtual machine 101. In order to realize the release of the virtualized memory to the host machine, a balloon driver may be set in the operating system of the virtual machine 101. Since the usage of the virtualized memory inside the operating system of the virtual machine 101 is dynamically changing, the balloon driver may notify the VMM 102 of the specific information of the release of the virtualized memory inside the virtual machine 101 through the balloon device corresponding to the balloon driver in the VMM 102. The balloon device of the VMM 102 may release the memory released inside the virtual machine to the memory of the host machine with the help of the memory management module of the host machine kernel, thereby avoiding the problem of memory resource waste caused by this part of the memory not being used in the VM 101 and not being used by other applications on the host machine or the VMM 102.

[0062] In a possible implementation, the virtual machine 101 can obtain the second information of the memory page of the virtual machine and the first information of the memory page of the host machine corresponding to the virtual machine, wherein the host machine corresponding to the virtual machine is the host machine running the virtual machine, determine the size of the free memory page in the virtual machine and the size of the memory page of the memory page managed by the host machine, and the virtual machine 101 determines the free memory page with the same starting address and / or ending address, continuous address and total memory size equal to the size of the memory page managed by the host machine as the target free memory page, and notifies the VMM to release the target free memory page. Alternatively, the VMM can obtain the second information of the memory page of the virtual machine and the memory page information of the host machine corresponding to the virtual machine, determine the size of the free memory page in the virtual machine and the memory page of the memory page managed by the host machine, and the VMM determines the free memory page with the same starting address and / or ending address, continuous address and total memory size equal to the page size of the memory page managed by the host machine as the target free memory page, and releases the target free memory page.

[0063] For example, Figure 1 The virtual machine 101 and the VMM 102 may include multiple functional modules that implement the method described in this application. Figure 2 For example, Figure 2 Schematic diagram of a virtual machine memory release logic structure involved in the embodiment of the present application. Figure 2As shown, a Balloon simulation device is provided in VMM 102, and the Balloon simulation device can be a simulated standard Peripheral Component Interconnect (PCI) device, so the Balloon simulation device has a configuration space inside, or there is a configuration space corresponding to the Balloon simulation device in VMM102. The Balloon simulation device can be used to release the free memory in the virtual machine 101 to the host side. The virtual machine 101 has a Balloon driver corresponding to the Balloon simulation device inside, and the Balloon driver is used to discover and enable the Balloon simulation device. The operating system 103 of the host machine can run on the hardware in the server, such as a processor.

[0064] The Balloon driver may be a standard PCI driver, which has an information notification mechanism, and implements communication between VMM 102 and VM 101 through an interrupt processing unit, and the notification unit implements communication between VM 101 and VMM 102 by writing the Bar space of the configuration space. At the same time, the Balloon driver and the Balloon simulation device also have a data processing mechanism, and the data processing unit is used to process data.

[0065] The following is based on Figure 1 and Figure 2 The architecture diagram shown introduces the method provided by this application. Figure 3 A flow chart of a virtual machine memory management method provided by an exemplary embodiment of the present application is shown. The virtual machine memory management method is applied to the virtual machine side, and the virtual machine memory management method includes the following steps:

[0066] S201, obtaining first information of a memory page managed by a host machine corresponding to the virtual machine and second information of a memory page of the virtual machine.

[0067] In an embodiment of the present application, the first information of the memory page managed by the host corresponding to the virtual machine can be used to indicate the size of the memory page managed by the host and information used for page alignment. The second information of the memory page of the virtual machine includes free memory pages that can indicate the memory page managed by the virtual machine itself. The virtual machine can obtain the second information of its own memory page from the inside of the virtual machine. For example, the second information of the memory page can be stored in the first data structure. Figure 2 In the tag and reference unit in the virtual machine, the virtual machine can Figure 2 The second information of the memory page is obtained from the tag and reference unit in the memory.

[0068] The first information of the host machine's memory page can be used to indicate the size of the memory page managed by the host machine. The virtual machine can obtain the first information of the host machine from the host machine corresponding to the virtual machine. For example, the host machine's memory page information is stored in the PCI configuration space of the VMM, and the virtual machine can obtain the first information of the host machine's memory page from the PCI configuration space of the VMM.

[0069] It should be understood that the free memory pages involved in the embodiments of the present application may refer to memory pages that are configured for a virtual machine but are not used by a program in the virtual machine or are released to the virtual machine after being used by a program in the virtual machine.

[0070] S202: Based on the first information and the second information, obtain a target free memory page that meets a release condition from free memory pages of the virtual machine.

[0071] In an embodiment of the present application, the virtual machine can obtain the target free memory page that meets the release condition from the free memory pages managed by itself based on the second information of the virtual machine's own memory page and the first information of the corresponding host machine's memory page obtained.

[0072] Among them, the release conditions may include: the starting address of the target free memory page in the virtual machine is the same as the starting address of the memory page managed by the host machine, and the total memory size of the continuous free memory pages starting from the starting address of the target free memory page is equal to the page size of the memory page managed by the host machine.

[0073] Exemplarily, when determining whether the page sizes are equal, the virtual machine can obtain each free memory page in its own managed memory pages, and based on the obtained page size of the memory pages managed by the host machine, start from the memory address of the first free memory page, and sequentially search according to the memory addresses for a memory size composed of consecutive free memory pages equal to the page size of the memory pages managed by the host machine, and use each free memory page that meets the release condition as the target free memory page.

[0074] In a possible implementation, the virtual machine may determine, according to the memory address, whether the memory size composed of continuous free memory pages is equal to the page size of the memory pages managed by the host machine.

[0075] S203, releasing the target free memory page.

[0076] In the embodiment of the present application, after determining the target free memory page, the virtual machine may first notify the VMM, and the VMM releases the target free memory page to the host machine corresponding to the virtual machine.

[0077] Exemplarily, the virtual machine can notify the Balloon simulation device of the memory page information that needs to be released by writing the memory page information that needs to be released to the PCI configuration space of the Balloon simulation device in the VMM. The memory page information that needs to be released can be used to indicate the memory address that needs to be released, that is, the memory address of the target free memory page determined in S202, so that the VMM releases the free memory pages in the virtual machine based on the memory page information that needs to be released.

[0078] In a possible implementation, the VMM of the host machine can directly release the free memory pages in the virtual machine based on the information of the memory page to be released, for example, by directly calling the memory interface of the host machine to release the memory.

[0079] In another possible implementation, in order to ensure the accuracy of the release, the VMM of the host machine can re-judge whether the target free memory page meets the release condition after determining the information of the memory page to be released, that is, if the size of the memory page with continuous free mark bits is equal to the size of the memory page managed by the host machine, determine whether the starting address of the first free memory page in the memory page with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine; if the starting address of the first free memory page in the memory page with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine, determine that the memory page with continuous free mark bits is the target free memory page that meets the release condition; if it is determined that the release condition is still met, the VMM can call the host machine's memory interface to release the memory.

[0080] based on Figure 3 The method shown obtains second information of a memory page of a virtual machine to determine free memory pages in the memory page managed by the virtual machine and the starting address of each free memory page, obtains first information of a memory page of a host machine corresponding to the virtual machine, determines the size of the memory page managed by the host machine and the starting address of each memory page, and the virtual machine obtains free memory pages with the same starting address and continuous addresses and a total memory size equal to the size of the memory page managed by the host machine as target free memory pages based on the determined free memory pages in the memory page managed by the virtual machine and the size of the memory page of the host machine, and releases the target free memory page to the host machine. Since the virtual machine can obtain the memory page size of the memory page managed by the host machine, the virtual machine can release a total memory size equal to the size of the memory page managed by the host machine and a plurality of consecutive memory pages managed by the virtual machine to the host machine, so that the host machine can manage memory release according to its own memory page size, thereby solving the problem of failure of releasing the memory managed by the virtual machine to the host machine due to inconsistency between the memory page size of the memory managed by the virtual machine and the memory page size of the memory managed by the host machine, and realizing memory reuse managed by the virtual machine.

[0081] Above Figure 3 The method described in the present application is introduced by taking VM as the execution subject as an example. Alternatively, the method described in the present application can also be executed by VMM. The method described in the present application is introduced by taking VMM as the execution subject as an example.

[0082] Figure 4 A flow chart of a memory management method for a virtual machine provided by an exemplary embodiment of the present application is shown. The memory management method for a virtual machine is applied to the VMM side, and the memory management method for a virtual machine includes the following steps:

[0083] S301, obtaining first information of a memory page of a host machine corresponding to a virtual machine and second information of a memory page of the virtual machine.

[0084] In an embodiment of the present application, the VMM can obtain first information of the host machine's own memory pages, and the first information of the host machine's own memory pages can indicate the size of the memory pages managed by the host machine itself and the starting address of each memory page, and the VMM can obtain second information of the virtual machine's memory pages from the virtual machine, and the second information of the virtual machine's memory pages can be used to indicate the size of the memory pages of the free memory pages in the memory pages managed by the virtual machine and the starting address of each free memory page.

[0085] That is, the second information of the memory page of the virtual machine can be used to indicate the free memory page in the memory page managed by the virtual machine; the first information of the memory page of the host machine can be used to indicate the size and starting address of the memory page managed by the host machine.

[0086] The start address may be a physical address of the start position of the memory page.

[0087] In a possible implementation, when the virtual machine detects that it has free memory pages, it notifies the VMM of the memory information corresponding to the free memory pages, and the VMM can count the free memory pages sent by the virtual machine.

[0088] S302: Based on the first information and the second information, obtain a target free memory page that meets a release condition from free memory pages of the virtual machine.

[0089] In an embodiment of the present application, the VMM can obtain the target free memory page that meets the release condition from the statistical free memory pages managed by the virtual machine based on the first information of the host machine's own memory page and the obtained second information of the virtual machine's memory page.

[0090] Among them, the release conditions may include: the starting address of the target free memory page in the virtual machine is the same as the starting address of the memory page managed by the host machine, and the total memory size of the continuous free memory pages starting from the starting address of the target free memory page is equal to the page size of the memory page managed by the host machine.

[0091] In one possible implementation, whenever the virtual machine detects its own free memory pages and sends the second information of the free memory pages to the VMM, the VMM can determine whether there is a target free memory page that meets the release condition in each free memory page based on the second information obtained this time and the second information of the free memory pages obtained historically.

[0092] That is to say, the VMM can receive the second information of each free memory page in the memory page managed by the virtual machine sent by the virtual machine, and according to the page size of the memory page managed by the host machine and the starting address of the memory page, search for the memory size composed of consecutive free memory pages with the same starting address equal to the page size of the memory page managed by the host machine, and use each free memory page that meets the release condition as the target free memory page.

[0093] In a possible implementation, the VMM can determine the memory address of each free memory page based on the second information of each free memory page obtained, determine whether the free memory pages are continuous according to the memory address, and determine whether the memory size composed of the continuous free memory pages is equal to the size of the memory pages managed by the host machine according to the memory address.

[0094] S303: Release the target free memory page to the host machine.

[0095] In the embodiment of the present application, after determining the target free memory page, the VMM may release the target free memory page to the host machine corresponding to the virtual machine.

[0096] In a possible implementation, after determining the target free memory page, the VMM may send memory information corresponding to the target free memory page to the virtual machine, and the virtual machine may determine the actually released memory page according to the received memory information corresponding to the target free memory page.

[0097] In a possible implementation, after the VMM of the host machine determines the information of the memory page that needs to be released, the VMM can directly call the memory interface of the host machine to release the memory.

[0098] In addition, the memory management method of the virtual machine can also be executed by the VMM of the host machine corresponding to the virtual machine and the virtual machine interactively. The memory management method of the virtual machine specifically includes the following steps:

[0099] S401, the VM obtains first information of a memory page of the host machine from the VMM.

[0100] In the embodiment of the present application, if the free memory pages of the VM are counted on the VM side, it is necessary to obtain the first information of the memory pages of the host machine from the VMM after the VM is started.

[0101] In a possible implementation, when the VMM is preparing to simulate the Balloon simulation device, the VMM can obtain the memory page information of the host machine and write the memory page information of the host machine into the configuration space of the Balloon simulation device. When the VM is started and the Balloon driver is loaded, the VM can read the first information of the host machine's memory page in the configuration space of the Balloon simulation device in the VMM.

[0102] The method for counting the free memory pages of the VM on the VM side may be to record the first information of the memory pages of the free memory pages of the VM in the form of a first data structure.

[0103] For example, the first data structure may include any one of a bitmap, a hash table, and a linked list.

[0104] That is to say, if the first data structure is a bitmap, the VM can create a bitmap according to the first information of the host's memory page after obtaining the first information of the host's memory page. The number of bits in the bitmap can be determined by the ratio of the size of the memory page managed by the host to the size of the memory page managed by the virtual machine. Each corresponding position in the bitmap corresponds to a memory page managed by the virtual machine, wherein the corresponding position marked as 1 can indicate that the memory page corresponding to the position is a free memory page, and the corresponding position marked as 0 can indicate that the memory page corresponding to the position is a memory page in normal use.

[0105] In one possible implementation, the first information of the host machine's memory page includes the page size of the memory page managed by the host machine, and may also include page alignment information of the memory page managed by the host machine. The page alignment information can indicate the starting position of the memory address of each memory page managed by the host machine, which is used to determine the corresponding position of each free memory in the virtual machine in the bitmap.

[0106] For example, Figure 5 1 is a schematic diagram of a Balloon driver loading process involved in an embodiment of the present application. Figure 5As shown, a Balloon simulation device is simulated in the VMM (S11); the VMM obtains the page size of the memory page managed by the host and the page alignment information of the memory page managed by the host (S12); the relevant values ​​of the obtained page size of the memory page managed by the host and the page alignment information of the memory page managed by the host are set to the PCI configuration space of the Balloon simulation device (S13); on the other side, if the virtual machine is started and the Balloon driver is loaded (S14); the virtual machine can read the PCI configuration space through the Balloon driver to obtain the page size of the memory page managed by the host and the page alignment information of the memory page managed by the host, and then initialize the bitmap according to the obtained page size of the memory page managed by the host and the page alignment information of the memory page managed by the host (S15);

[0107] Among them, in the process of VMM simulating the Balloon simulation device, the host machine's memory page information can be placed in the PCI configuration space by adding fields. After the VM is started, the Balloon driver inside the virtual machine can identify and obtain these newly added fields and read the host machine's memory page information.

[0108] S402, the VM receives a memory release instruction.

[0109] In an embodiment of the present application, a memory management module in a virtual machine may receive a memory release instruction, and the memory release instruction may be used to instruct the release of a free memory page of the virtual machine.

[0110] In a possible implementation, when releasing memory, the application software may send a memory release instruction to the virtual machine, and a memory management module in the virtual machine may receive the memory release instruction.

[0111] When each memory page managed by the virtual machine needs to be released, the memory management module can obtain a memory release instruction for instructing the release of the memory page.

[0112] In another possible implementation, if statistics of free memory pages managed by the virtual machine are collected on the VMM side, the VMM may receive a memory release instruction from the virtual machine, and the memory release instruction may include memory page information of the free memory page.

[0113] S403: In response to the memory release instruction, the VM obtains second information of the memory page.

[0114] In an embodiment of the present application, if the free memory pages managed by the virtual machine are counted on the VM side, the VM can obtain the free memory pages managed by the virtual machine according to the memory release instruction.

[0115] The first information of the host machine's memory page is stored in a peripheral component interconnect standard PCI configuration space; the PCI configuration space is a configuration space of a Balloon simulation device simulated by the host machine, and can be set in the Balloon simulation device or in the VMM.

[0116] In one possible implementation, the second information of the virtual machine's memory page may include each memory page managed by the virtual machine and mark information corresponding to each memory page. The mark information corresponding to the memory page is used to indicate whether the memory page is a free memory page. The mark information corresponding to the memory page in the idle state may be a free mark bit.

[0117] Specifically, according to the memory release instruction, the VM can obtain the free memory page indicated by the memory release instruction. Each memory page managed by the virtual machine can be recorded in the VM. Each time a memory release instruction is received, marking information can be added to the corresponding memory page to mark the memory page indicated by the memory release instruction as a free memory page. Each time a free memory page record is added, it can be detected whether each free memory page of the current record meets the release condition.

[0118] In a possible implementation, when the marking information of the memory page managed by the virtual machine indicates that the memory page is a free memory page, the permission of the memory page managed by the virtual machine to be used by the virtual machine is modified to not support the use of the virtual machine.

[0119] That is to say, after receiving the memory release instruction, the VM can isolate the memory page corresponding to the memory release instruction to prevent the memory page from being applied for again during the processing.

[0120] Exemplarily, if the VM records the memory page managed by the virtual machine in the form of a first data structure, and the first data structure is implemented as a bitmap, the position in the bitmap corresponding to the memory page indicated by the memory release instruction can be marked as 1.

[0121] In a possible implementation, the VMM may call the Balloon simulation device to obtain the second information of the memory page of the virtual machine from the virtual machine.

[0122] That is, if the free memory pages managed by the virtual machine are counted on the VMM side, the VMM can obtain the second information of the memory pages of the virtual machine from the virtual machine by calling the Balloon simulation device.

[0123] S404: Based on the first information and the second information, the VM obtains a target free memory page that meets the release condition from the free memory pages.

[0124] In an embodiment of the present application, the VM obtains a memory page with the same starting address and continuous address and a total memory size equal to the size of the memory page managed by the host machine from the free memory page of the virtual machine as the target free memory page.

[0125] In one possible implementation, the VM obtains a first quantity; the first quantity is the ratio of the size of the memory page managed by the host machine to the size of the memory page managed by the virtual machine; if it is determined that the mark information corresponding to each of the first number of consecutive memory pages in the first data structure indicates that the memory page is a free memory page, the first number of consecutive memory pages are determined as target free memory pages.

[0126] That is, if the memory page size of the memory page managed by the host is 64K and the memory page size of the memory page managed by the virtual machine is 4K, the release condition may be that 16 consecutive free memory pages managed by the virtual machine can be determined as the target free memory pages.

[0127] Exemplarily, if the VM records the memory pages managed by the virtual machine in the form of a first data structure, and the first data structure is implemented as a bitmap, the position in the bitmap corresponding to the memory page indicated by the memory release instruction can be marked as 1, the memory page size of the memory page managed by the host is 64K, and the memory page size of the memory page managed by the virtual machine is 4K, then the virtual machine can check whether there are 16 consecutive positions marked as 1 in the bitmap, if so, determine whether the starting address of the first memory page is the same as one of the starting addresses of each memory page managed by the host, if there are memory pages with the same starting address, then the free memory pages corresponding to each position can be determined as the target free memory page; or, if there are 16 consecutive positions marked as 1, determine whether the end address of the last memory page is the same as one of the end addresses of each memory page managed by the host, if there are memory pages with the same end address, then the free memory pages corresponding to each position can be determined as the target free memory page.

[0128] S405, the VM releases the target free memory page to the host machine.

[0129] In an embodiment of the present application, after determining the target free memory page, the VM may release the target free memory page to the host machine corresponding to the virtual machine.

[0130] In a possible implementation, after determining the target free memory page, the VM may send the memory page information of the target free memory page to the VMM of the host machine. After determining the memory page information to be released, the VMM may directly call the memory interface of the host machine to release the memory.

[0131] For example, Figure 6Schematic diagram of a virtual machine memory release process involved in an embodiment of the present application. Figure 6 As shown, after receiving the memory release instruction, the memory management module in the VM controls the VM to prepare to release the memory page corresponding to the memory release instruction (S21). The memory management module can send a notification of releasing the memory page to the Balloon driver (S22). The Balloon driver starts a thread for releasing the page processing (S23). In the thread for releasing the page processing, after receiving the notification for releasing the memory page, the memory page can be isolated (S24), and then the memory-related information of the memory page is recorded, such as the memory address of the memory page (S25). Then, according to the memory-related information of the memory page, the corresponding position of the memory page in the bitmap is determined, and the corresponding position is marked as 1 (S26). The VM determines whether there is a continuous position in the bitmap that meets the release condition, and the page size of the memory page corresponding to the memory page is the page size of the memory page managed by the host (S27). If it is determined that there is a target free memory page, the Balloon driver can be used to notify the Ball in the VMM. oon simulation device (S28), wherein the method of notifying the Balloon simulation device in the VMM may be to write the memory page information of the target free memory page in the PCI configuration space of the Balloon simulation device through the Balloon driver, and then, the Balloon simulation device obtains the memory page information of the target free memory page in its own memory space (S29), and the VMM may again determine whether the target free memory page meets the release condition according to the memory address of the target free memory page (including the end address and / or the start address) and the size of the memory page of the host machine, that is, determine whether the memory size of the target free memory page is the same as the size of the memory page of the host machine, and / or, whether the start address of the target free memory page is the same as the start address of the memory page of the host machine (S30), if it is determined that the release condition is met, the target free memory page may be released to the physical memory of the host machine (S31), wherein the memory page released to the host machine may be applied for use by other virtual machines or application software.

[0132] The embodiments of the present application can support the host to apply for and release virtualized memory on demand in different page table scenarios, and can achieve full-scenario support for the memory reuse characteristics of virtualization scenarios, which can improve the density of virtual machines on a single host, thereby improving memory utilization and reducing capital.

[0133] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the method. It is understandable that, in order to realize the above functions, the memory management device for the virtual machine includes at least one of the hardware structure and software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0134] The embodiment of the present application can divide the memory management device for the virtual machine into functional units according to the above method example. For example, each functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0135] For example, Figure 7 A schematic diagram of the structure of a virtual machine memory management device 400 provided by an exemplary embodiment of the present application is shown. The virtual machine memory management device 400 may be in a server, and the virtual machine memory management device 400 includes:

[0136] The acquisition module 410 is used to acquire first information of a memory page managed by a host machine corresponding to the virtual machine; the first information includes the size of the memory page managed by the host machine and the starting address of the memory page managed by the host machine;

[0137] The acquisition module 410 is further used to acquire second information of the memory page of the virtual machine; the second information includes the state information of the memory page of the virtual machine and the starting address of the memory page managed by the virtual machine;

[0138] The processing module 420 is used to determine a target free memory page from the free memory pages of the virtual machine based on the first information and the second information, wherein the free memory page is a memory page whose status information is an idle state, and the target free memory page of the virtual machine is the free memory page that meets a release condition; wherein the release condition includes: a starting address of the target free memory page in the virtual machine is the same as a starting address of a memory page managed by the host machine, and a total memory size of the continuous free memory pages of the target free memory page starting from the starting address is equal to a page size of the memory page managed by the host machine;

[0139] The processing module 420 is further used to release the target free memory page;

[0140] For example, combined with Figure 3 , the acquisition module 410 can be used to perform the following steps: Figure 3 As shown in S201, the processing module 420 can be used to perform the following steps: Figure 3 S202 and S203 shown.

[0141] In a possible implementation, the acquisition module 410 includes:

[0142] The acquisition submodule is used to acquire the first information of the memory page managed by the host machine in the configuration space of the virtual machine manager VMM.

[0143] In a possible implementation manner, the device further includes:

[0144] An instruction receiving module, used for obtaining a memory release instruction of the virtual machine; wherein the memory release instruction is used for instructing to release a memory page in the virtual machine;

[0145] The state setting module is used to set the state information of the memory page of the virtual machine corresponding to the memory release instruction to the idle state in response to the memory release instruction.

[0146] In a possible implementation, the processing module 420 is used to, in response to the memory release instruction, determine whether the size of the memory page with continuous free mark bits in the virtual machine is equal to the size of the memory page managed by the host machine;

[0147] If the size of the memory page with continuous free mark bits is equal to the size of the memory page managed by the host machine, determine whether the starting address of the first free memory page in the memory page with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine;

[0148] If the starting address of the first free memory page in the memory pages with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine, the memory page with continuous free mark bits is determined to be the target free memory page that meets the release condition.

[0149] In a possible implementation, determining whether the size of the memory page with continuous free marking bits in the virtual machine is equal to the size of the memory page managed by the host machine includes:

[0150] Determine whether the number of memory pages having continuous free mark bits in the virtual machine is the same as the number of first free memory pages, wherein the number of first free memory pages is a ratio of the size of memory pages managed by the host machine to the size of memory pages managed by the virtual machine;

[0151] If the number of memory pages with continuous free marking bits in the virtual machine is the same as the number of the first free memory pages, it is determined that the size of the memory pages with continuous free marking bits in the virtual machine is equal to the size of the memory pages managed by the host machine.

[0152] In a possible implementation, the state information of the memory page of the virtual machine is stored in a first data structure, wherein the first data structure includes any one of a bitmap, a hash table, and a linked list.

[0153] In a possible implementation manner, the first data structure is a bitmap;

[0154] The processing module 420 includes:

[0155] A target determination submodule is used to determine that if the number of consecutive memory pages in the bitmap is the same as the number of first free memory pages, the consecutive memory pages are the target free memory pages; wherein the number of the first free memory pages is the ratio of the size of the memory pages managed by the host machine to the size of the memory pages managed by the virtual machine.

[0156] In a possible implementation manner, the device further includes:

[0157] An information sending module, used for sending information of the target free memory page to a virtual machine manager VMM;

[0158] A judgment module, used for calling the virtual machine manager VMM to determine whether the target free memory page meets the release condition;

[0159] The processing module 420 includes:

[0160] The release submodule is used to release the target free memory page if the target free memory page meets the release condition.

[0161] In a possible implementation manner, the device further includes:

[0162] The permission modification module is used to modify the usage permission of the memory page of the virtual machine corresponding to the memory release instruction to unavailable in response to the memory release instruction.

[0163] For the detailed description of the above optional methods, please refer to the above method embodiments, which will not be repeated here. In addition, the explanation of any virtual machine memory management device provided above and the description of its beneficial effects can refer to the above corresponding method embodiments, which will not be repeated here.

[0164] As an example, combining Figure 1 , the functions implemented in part or in whole in the acquisition module 410 and the processing module 420 in the memory management device for the virtual machine can be realized by Figure 1 101 in the VM, or by Figure 1 The VMM 102 in performs the implementation.

[0165] Figure 8 The schematic diagram of the structure of a server 1100 provided by an exemplary embodiment of the present application is shown. The server 1100 in the present application may include one or more of the following components: a processor 1110 and a memory 1120 .

[0166] The processor 1110 may include one or more processing cores. The processor 1110 uses various interfaces and lines to connect various parts of the entire terminal, and executes various functions of the terminal and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 1120, and calling data stored in the memory 1120. Optionally, the processor 1110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 1110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1110, but may be implemented separately through a communication chip.

[0167] The memory 1120 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 1120 includes a non-transitory computer-readable storage medium. The memory 1120 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 1120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function, instructions for implementing the above-mentioned various method embodiments, etc. The operating system may be: a Linux operating system, an Open Euler open source operating system, a CentOS open source operating system, etc.

[0168] In addition, those skilled in the art will appreciate that the structure of the server 1100 shown in the above figures does not constitute a limitation on the server 1100 , and the server 1100 may include more or fewer components than shown, or a combination of certain components, or a different arrangement of components.

[0169] The embodiment of the present application also provides a computer-readable storage medium, in which at least one computer instruction is stored, and the at least one computer instruction is loaded and executed by a processor to implement the virtual machine memory management method described in each of the above embodiments. For the explanation of the relevant content and the description of the beneficial effects in any of the above-mentioned computer-readable storage media, reference can be made to the above-mentioned corresponding embodiments, which will not be repeated here.

[0170] The embodiment of the present application also provides a chip. The chip integrates a control circuit and one or more ports for implementing the functions of the above-mentioned virtual machine memory management device. Optionally, the functions supported by the chip can be referred to above and will not be repeated here. A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned embodiment can be completed by instructing the relevant hardware through a program. The program can be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a random access memory, etc. The above-mentioned processing unit or processor can be a central processing unit, a general-purpose processor, an application specific integrated circuit (ASIC), a microprocessor (digital signal processor, DSP), a field programmable gate array (field programmable gatearray, FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.

[0171] The embodiment of the present application also provides a computer program product including instructions, when the instructions are run on a computer, the computer executes any one of the methods in the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more servers that can be integrated with the medium. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., an SSD), etc.

[0172] It should be noted that the above-mentioned device for storing computer instructions or computer programs provided in the embodiments of the present application, such as but not limited to, the above-mentioned memory, computer-readable storage medium and communication chip, etc., all have non-volatile (non-transitory). Those skilled in the art should be aware that in the above one or more examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware or any combination thereof. When implemented using software, these functions can be stored in a computer-readable storage medium or transmitted as one or more instructions or codes on a computer-readable storage medium. Computer-readable storage media include computer storage media and communication media, wherein the communication medium includes any medium that is convenient for transmitting a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.

[0173] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A virtual machine memory management method, characterized in that: The method comprises: Acquire first information of a memory page managed by a host machine corresponding to the virtual machine; the first information includes the size of the memory page managed by the host machine and the starting address of the memory page managed by the host machine; Acquire second information of the memory page of the virtual machine; the second information includes state information of the memory page of the virtual machine and a starting address of the memory page managed by the virtual machine; Based on the first information and the second information, determining a target free memory page that meets a release condition from free memory pages of the virtual machine; The release condition includes: the starting address of the target free memory page in the virtual machine is the same as the starting address of the memory page managed by the host machine, and the total memory size of the free memory pages consecutively starting from the starting address of the target free memory page is equal to the page size of the memory page managed by the host machine; Release the target free memory page.

2. The method according to claim 1, characterized in that The obtaining first information of a memory page managed by a host machine corresponding to the virtual machine includes: The first information of the memory page managed by the host machine in the configuration space of the virtual machine manager VMM is obtained.

3. The method according to claim 1 or 2, characterized in that: Before obtaining the second information of the memory page of the virtual machine, the method further includes: Obtaining a memory release instruction of the virtual machine; wherein the memory release instruction is used to instruct to release a memory page in the virtual machine; In response to the memory release instruction, the state information of the memory page of the virtual machine corresponding to the memory release instruction is set to an idle state.

4. The method according to claim 3, characterized in that Determining a target free memory page that meets a release condition from free memory pages of the virtual machine based on the first information and the second information includes: In response to the memory release instruction, determining whether the size of the memory page with continuous free mark bits in the virtual machine is equal to the size of the memory page managed by the host machine; If the size of the memory page with continuous free mark bits is equal to the size of the memory page managed by the host machine, determine whether the starting address of the first free memory page in the memory page with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine; If the starting address of the first free memory page in the memory pages with continuous free mark bits in the virtual machine is the same as the starting address of the memory page managed by the host machine, the memory page with continuous free mark bits is determined to be the target free memory page that meets the release condition.

5. The method according to claim 4, characterized in that The determining whether the size of the memory page with continuous free marking bits in the virtual machine is equal to the size of the memory page managed by the host machine includes: Determine whether the number of memory pages with continuous free marking bits in the virtual machine is the same as the number of first free memory pages, wherein the number of first free memory pages is a ratio of the size of memory pages managed by the host machine to the size of memory pages managed by the virtual machine; If the number of memory pages with continuous free marking bits in the virtual machine is the same as the number of the first free memory pages, it is determined that the size of the memory pages with continuous free marking bits in the virtual machine is equal to the size of the memory pages managed by the host machine.

6. The method according to any one of claims 1-2, 4-5, characterized in that: The state information of the memory page of the virtual machine is stored in a first data structure, wherein the first data structure includes any one of a bitmap, a hash table, and a linked list.

7. The method according to claim 6, characterized in that The first data structure is a bitmap; The determining, based on the first information and the second information, a target free memory page that meets a release condition from free memory pages of the virtual machine includes: If the number of continuous memory pages in the bitmap is the same as the number of first free memory pages, the continuous memory pages are determined to be the target free memory pages; wherein the number of the first free memory pages is the ratio of the size of the memory pages managed by the host machine to the size of the memory pages managed by the virtual machine.

8. The method according to any one of claims 1-2, 4-5, and 7, characterized in that: After determining the target free memory page that meets the release condition from the free memory pages of the virtual machine based on the first information and the second information, the method further includes: Sending information of the target free memory page to the virtual machine manager VMM; Calling the virtual machine manager VMM to determine whether the target free memory page meets the release condition; The releasing the target free memory page comprises: If the target free memory page meets the release condition, the target free memory page is released.

9. The method according to claim 3, characterized in that: The method further comprises: In response to the memory release instruction, the usage permission of the memory page of the virtual machine corresponding to the memory release instruction is modified to be unavailable.

10. A computing device, characterized in that: The computing device includes a processor and a memory; the processor is coupled to the memory; the memory is used to store computer instructions, and the computer instructions are loaded and executed by the processor so that the computing device implements the virtual machine memory management method as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method for checking memory leak for vxWorks operating system

    CN101587455A

  • Method and device for assisting bitmap object memory allocation

    CN110362311A

Cited By

  • Virtual machine memory management method and computing device

    EP4632566A1

  • Virtual machine memory management method and computing device

    WO2024124989A1