Virtual Machine Memory Management Method, Apparatus, System, and Physical Machine
By migrating the memory pages in the physical machine that meet the migration conditions to the storage device, the problem of memory being unable to be used again after the virtual machine is occupied, and efficient memory utilization is achieved.
Patent Information
- Application Number
- CN202110351746.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-31
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2041-03-31
AI Technical Summary
In the prior art, once the memory of a physical machine is occupied by a virtual machine, it cannot be used again, resulting in low memory usage efficiency.
Reuse of memory by determining the memory page in the physical machine that meets the migration conditions, migrating it to the storage device and freeing the memory in the physical machine.
It improves the efficiency of the use of the physical machine memory, reduces the memory footprint of the virtual machine in the physical machine, and realizes efficient memory utilization.
Smart Images

Figure CN113296886B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of electronic devices, and in particular, to a virtual machine memory management method, apparatus, system, and physical machine. Background Art
[0002] A virtual machine (VM) refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. The computer on which the virtual machine is created can be called a physical machine, also known as a host machine. Usually, a part of the hard disk and memory capacity of the physical machine needs to be used as the hard disk and memory capacity of the virtual machine. The memory of the virtual machine stores data in the form of memory pages.
[0003] Currently, when cloud providers sell cloud servers, they generally sell the physical machines of the servers in the form of virtual machines. The memory of a physical machine can be divided into multiple virtual machines according to user needs. For example, a physical machine with a memory of 100G can be divided into 5 virtual machine memories of 20G each, and each virtual machine can be allocated to the corresponding user.
[0004] In practical applications, once the memory of the physical machine is sold, it can only be used by the user who purchases the virtual machine, and this block of memory is occupied, and the memory of the physical machine cannot be used again, resulting in low memory utilization efficiency. Summary of the Invention
[0005] In view of this, embodiments of the present application provide a virtual machine memory management method, apparatus, system, and physical machine to solve the technical problem that the memory of a physical machine cannot be used again once it is occupied by a virtual machine in the prior art.
[0006] In a first aspect, an embodiment of the present application provides a virtual machine memory management method, including:
[0007] Determine a plurality of memory pages configured in any one of the first virtual machines in the first physical machine;
[0008] Determine at least one eviction memory page that meets the eviction condition among the plurality of memory pages;
[0009] Evict the at least one eviction memory page to a storage device, and release the physical memory occupied by the at least one eviction memory page in the first physical machine.
[0010] In a second aspect, an embodiment of the present application provides a virtual machine memory management apparatus, including:
[0011] A first determination module, configured to determine a plurality of memory pages configured in any one of the first virtual machines in the first physical machine;
[0012] A second determination module, configured to determine at least one memory page to be evicted that meets the eviction condition among the multiple memory pages;
[0013] A memory eviction module, configured to evict the at least one memory page to be evicted to a storage device, and release the physical memory occupied by the at least one memory page to be evicted in the first physical machine.
[0014] In a third aspect, an embodiment of the present application provides a physical machine, including: a storage component and a processing component; the storage component is configured to store one or more computer instructions; the one or more computer instructions are called by the processing component to execute any virtual machine memory management method of the embodiments of the present application.
[0015] In a fourth aspect, an embodiment of the present application provides a virtual machine memory management system, including: a first physical machine and a storage device;
[0016] The first physical machine is configured to: determine multiple memory pages of any first virtual machine configured in the first physical machine; determine at least one memory page to be evicted that meets the eviction condition among the multiple memory pages; evict the at least one memory page to be evicted to the storage device, and release the physical memory occupied by the at least one memory page to be evicted in the first physical machine;
[0017] The storage device is configured to: receive and store the at least one memory page to be evicted sent by the first physical machine.
[0018] In the embodiments of the present application, after determining multiple memory pages of any first virtual machine configured in the first physical machine, it is possible to determine at least one memory page to be evicted that meets the eviction condition among the multiple memory pages, and then evict the at least one memory page to be evicted to the storage device. After that, release the physical memory occupied by the at least one memory page to be evicted in the first physical machine, thereby reducing the memory occupancy of the first virtual machine in the first physical machine. By performing an eviction judgment on the multiple memory pages in the first virtual machine, it is possible to evict at least one memory page to be evicted that meets the eviction condition, reduce the memory occupancy of the first virtual machine in the first physical machine, release the memory in the first physical machine, so that the memory in the first physical machine can be reused, and thereby improve the usage efficiency of the memory of the first physical machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0020] Figure 1Flowchart of an embodiment of a virtual machine memory management method provided by an embodiment of the present application;
[0021] Figure 2 Flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application;
[0022] Figure 3 Flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application;
[0023] Figure 4 Flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application;
[0024] Figure 5 Flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application;
[0025] Figure 6 Example diagram of a virtual machine memory management method provided by an embodiment of the present application;
[0026] Figure 7 Structure diagram of an embodiment of a virtual machine memory management device provided by an embodiment of the present application;
[0027] Figure 8 Structure diagram of an embodiment of a physical machine provided by an embodiment of the present application;
[0028] Figure 9 Structure diagram of an embodiment of a virtual machine memory management system provided by an embodiment of the present application. Detailed implementation manners
[0029] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0030] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The singular forms "a", "said", and "the" used in the embodiments of the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. "Multiple" generally includes at least two, but does not exclude the case of including at least one.
[0031] It should be understood that the term "and / or" used herein is merely a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. Additionally, the character " / " in this text generally indicates that the associated objects before and after are in an "or" relationship.
[0032] Depending on the context, as used herein, the words "if" and "when" can be interpreted as "when...", "when...", "in response to determining", or "in response to recognizing". Similarly, depending on the context, the phrase "if determined" or "if recognized (stated condition or event)" can be interpreted as "when determined", "in response to determining", "when (stated condition or event) is recognized", or "in response to recognizing (stated condition or event)".
[0033] It should also be noted that the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, such that a commodity or system comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed, or elements inherent to such commodity or system. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the commodity or system comprising said element.
[0034] The technical solution of the embodiment of the present application can be applied to the management scenario of virtual machines, especially for effectively managing the memory occupancy of virtual machines, so as to reduce the memory occupancy of virtual machines in the physical machine and enable the efficient utilization of physical memory in the physical machine.
[0035] To facilitate the understanding of the technical solution of the present application, the following first explains the technical terms that may appear in the embodiments of the present application:
[0036] Virtual machine: A computer system with complete hardware system functions simulated through a software environment, which is actually a process running on a physical machine. The hardware and memory of the virtual machine are part of the hardware and memory on the physical machine.
[0037] Physical machine: A dedicated physical server deployed with a virtualized computer system, having an entity.
[0038] Live migration: When the virtual machine remains in a running state, it migrates from one physical machine to another physical machine. During the migration process, the user is not aware of the migration of the virtual machine.
[0039] GVA (Guest Virtual Address, the virtual address of the virtual machine): The virtual address inside the virtual machine.
[0040] GPA (Guest Physical Address, the physical address of the virtual machine): The physical address inside the virtual machine.
[0041] The virtual machine maintains the mapping relationship between GVA and GPA. After the virtual machine is established, the mapping relationship between GVA and GPA will no longer change.
[0042] HVA (Host Virtual Address, the virtual address of the physical machine): The virtual address inside the physical machine.
[0043] HPA (Host Physical Address, the physical address of the physical machine): The physical address inside the physical machine.
[0044] When the virtual machine actually stores data, mapping table entries are established. The mapping relationship from GPA to HPA is stored in the mapping table entries, and the physical memory of the virtual machine is mapped to the physical memory of the physical machine to achieve data reading or writing. When the virtual machine performs operations such as file reading and writing, it is necessary to map the GPA of the virtual memory page to the HPA of the physical memory frame or map the HPA of the physical memory frame to the GPA of the virtual memory page.
[0045] To facilitate the use of memory by the virtual machine, the memory of the virtual machine can be managed using the paging method. Generally, the physical memory of the virtual machine can be divided into blocks of a fixed size. These memory blocks are called frames. The virtual memory corresponding to the physical memory is divided into memory blocks of the same size. Each memory block is called a memory page or a memory page. Each memory page corresponds to GVA, GPA, HVA, and HPA respectively. Memory pages can store data. For example, the memory pages in this case can be memory data with a size of 4KB (Kilobyte, byte). The size of the memory page can be set according to actual usage requirements.
[0046] For the convenience of unified marking and description, the virtual address in the embodiments of the present application, that is, the address set inside the virtual machine, can include GVA and GPA. The physical address in the embodiments of the present application, that is, the address set inside the physical machine, can include HVA and HPA.
[0047] Currently, when cloud providers sell cloud servers, they generally sell the servers in the form of virtual machines. The memory of a physical machine can be divided among multiple virtual machines according to user needs. For example, a physical machine with 100G of memory can be divided into 5 virtual machine memories of 20G each, and each virtual machine can be assigned to the corresponding user. In actual applications, once the memory of the physical machine is sold, it can only be used by the users who purchase the virtual machines, and this block of memory is occupied, and the memory of this physical machine cannot be used again, resulting in low memory usage efficiency.
[0048] In an embodiment of the present application, after determining multiple memory pages of any first virtual machine configured in a first physical machine, at least one migrated memory page that meets the migration condition can be determined among the multiple memory pages. Then, the at least one migrated memory page is migrated to a storage device, and afterwards, the physical memory occupied by the at least one migrated memory page in the first physical machine is released, thereby reducing the memory occupancy of the first virtual machine in the first physical machine. By performing a migration determination on the multiple memory pages in the first virtual machine, at least one migrated memory page that meets the migration condition can be migrated out, reducing the memory occupancy of the first virtual machine in the first physical machine, releasing the memory in the first physical machine, enabling the memory in the first physical machine to be reused again, and thereby improving the utilization efficiency of the memory of the first physical machine.
[0049] Hereinafter, embodiments of the present application will be described in detail with reference to the accompanying drawings.
[0050] As Figure 1 shown, it is a flowchart of an embodiment of a virtual machine memory management method provided by an embodiment of the present application. The method may include the following steps:
[0051] 101: Determine multiple memory pages of any first virtual machine configured in a first physical machine.
[0052] Optionally, there may be multiple first virtual machines, that is, multiple first virtual machines may be configured in the first physical machine, and memory page migration can be performed for any first virtual machine to reduce the physical memory occupied by the first virtual machine in the first physical machine.
[0053] The multiple memory pages are the memory pages stored in the first virtual machine. The memory of the virtual machine is divided into multiple memory blocks of the same size according to the paging mechanism, and memory data can be stored in any memory page.
[0054] Optionally, the virtual machine memory management method provided by the embodiment of the present application can be configured in a physical machine, which may be the same as the first physical machine or different from the first physical machine. The physical machine may be an electronic device such as a high-performance computer, a cloud server, a supercomputer, etc. In the embodiment of the present application, no excessive limitation is made on the specific type of the physical machine.
[0055] 102: Determine at least one migrated memory page that meets the migration condition among the multiple memory pages.
[0056] Wherein, the at least one migrated memory page is the memory page that meets the migration condition among the multiple memory pages.
[0057] 103: Migrate the at least one migrated memory page to a storage device and release the physical memory occupied by the at least one migrated memory page in the first physical machine.
[0058] The storage device can receive at least one migrated memory page and store it. The usage cost of the storage device is much lower than that of the physical machine. For example, the physical machine can be a high - configuration and high - performance computer, and the storage device can be a cheaper physical machine, cheaper memory, NVME (Non - Volatile Memory Express), or a device such as memory simulated by software from a disk, etc.
[0059] Migrate at least one migrated memory page to the storage device, specifically, it can be to migrate the memory data corresponding to at least one migrated memory page to the storage device respectively.
[0060] After the physical memory occupied by at least one migrated memory page in the first physical machine is released, the physical memory occupied by the first virtual machine in the first physical machine can be released, realizing memory multiplexing of the first physical machine.
[0061] In addition, in practical applications, there can be multiple first physical machines, and there can also be multiple storage devices. Multiple first physical machines can form a "hot" memory pool, and multiple storage devices can form a "cold" memory pool. Any physical machine can execute the memory management method of the embodiment of the present application for multiple first virtual machines configured on it. Any storage device in the memory pool can receive the memory pages migrated from any physical machine.
[0062] In the embodiment of the present application, when determining multiple memory pages of any first virtual machine configured in the first physical machine, at least one migrated memory page that meets the migration condition can be determined among the multiple memory pages, and then at least one migrated memory page can be migrated to the storage device. The storage device can be the storage device of the first physical machine and can store the memory pages that meet the migration condition in the first physical machine. Then, the physical memory occupied by at least one migrated memory page in the first physical machine can be released. Reducing the memory occupancy of the first virtual machine in the first physical machine and releasing the memory in the first physical machine enables the memory in the first physical machine to be reused again, thereby improving the usage efficiency of the memory of the first physical machine.
[0063] In practical applications, the users of virtual machines are mostly purchasers of cloud servers. To improve the user's management efficiency of virtual machines, the user can decide whether to perform memory management on the virtual machine by themselves.
[0064] As an embodiment, determining multiple memory pages of any first virtual machine configured in the first physical machine may include:
[0065] Receive a memory management request initiated by the user for the first physical machine.
[0066] In response to the memory management request, determine multiple memory pages of any first virtual machine configured in the first physical machine.
[0067] The user who initiates a memory management request for the first physical machine can be the background operation and maintenance personnel of the first physical machine, so as to improve the management efficiency of the operation and maintenance personnel for the first physical machine. The user who initiates a memory management request for the first physical machine can also be the user of the first virtual machine, so as to give the user the memory management right for the first virtual machine and improve the management efficiency of the user for the first virtual machine.
[0068] In some embodiments, whether any memory page meets the migration-out condition can be specifically determined by comparing the access frequency of the memory page with a first frequency threshold. Whether any memory page meets the migration-in condition can be specifically determined by comparing the access frequency of the memory page with a second frequency threshold. The first frequency threshold and the second frequency threshold can also be obtained by setting by the user who initiates the memory management request.
[0069] As a possible implementation, a threshold input interface can be output for the user who initiates the memory management request to detect and obtain the first frequency threshold and the second frequency threshold input by the user in the threshold input interface.
[0070] In practical applications, if a user initiates an access request for the first virtual machine, data can be read from the first physical machine and the storage device. As an embodiment, the method can further include:
[0071] Receiving a memory access request initiated by a target user for the first virtual machine.
[0072] Responding to the memory access request to determine the target memory page.
[0073] Based on the first physical machine and the storage device, obtaining the target memory data corresponding to the target memory page.
[0074] Outputting the target memory data for the target user.
[0075] The target user can be the user who uses the first virtual machine. In a possible design, if the first physical machine is a user terminal, after the first physical machine starts the first virtual machine, the target user can directly initiate a memory access request in the first virtual machine. In another possible design, if the first physical machine is a server, such as a cloud server, the target user uses the first virtual machine through a network connection between an electronic device such as a computer, a laptop, or a tablet and the first physical machine, and the first virtual machine can receive a memory access request initiated by the target user through the electronic device during operation.
[0076] Optionally, different memory pages can be identified by memory pages to identify the memory pages to be accessed. Responding to the memory access request to determine the target memory page can include: responding to the memory access request, obtaining the memory page identifier in the memory access request, and determining the target memory page corresponding to the memory page identifier.
[0077] Since the storage addresses of different memory pages are different, in order to reduce the identification cost and improve the identification efficiency, the storage address of the memory page can be used as the page identifier. And because it is used for the memory page in the first virtual machine, the storage address of the memory page can be the virtual address of the memory page in the first virtual machine, for example, it can be the virtual machine physical address (GPA). The actual physical address of the memory page is determined by the virtual address of the memory page in the first virtual machine and the mapping relationship of the memory page. The actual physical address may include the physical address (HPA) of the physical machine. In addition, in the address mapping process, it is necessary to first map the GPA to the HVA, and then map the HVA to the HPA. The mapping process is mainly determined by the mapping relationship corresponding to the memory page.
[0078] Optionally, the mapping relationships corresponding to the multiple memory pages may form a mapping table entry, and the mapping relationship of a certain memory page may be determined by querying the mapping table entry.
[0079] In the embodiment of the present application, a memory access request initiated for the first virtual machine can be received, and then the memory access request can be responded to, and the target memory page can be determined, so as to obtain the target memory data corresponding to the target memory page based on the first physical machine and the storage device, and output the target memory data for the target user. The target memory page is smoothly read to ensure the normal use of the first virtual machine.
[0080] In some embodiments, the migration condition of a memory page may be, for example, a threshold value judgment of the access frequency of the memory page to determine whether to migrate a certain memory page. Therefore, when a user initiates an access request, the probability that the access request belongs to an access request for a memory page that has not been migrated is higher, in order to improve data acquisition efficiency. When querying a memory page, the memory page local to the first physical machine may be queried first, and then the memory page in the storage device may be queried.
[0081] like Figure 2 FIG. 1 is a flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application. The method may include:
[0082] 201: Determine a plurality of memory pages of any first virtual machine configured in a first physical machine.
[0083] 202: Determine at least one memory page to be moved out that meets a move-out condition among a plurality of memory pages.
[0084] 203: Migrate at least one migrated memory page to a storage device, and release the physical memory occupied by the at least one migrated memory page in the first physical machine.
[0085] 204: Receive a memory access request initiated by a target user for the first virtual machine.
[0086] 205: In response to a memory access request, determine a target memory page.
[0087] 206: Query whether the target memory page exists among the non-evicted memory pages in multiple memory pages. If it exists, execute step 207; if not, execute step 208.
[0088] The non-evicted memory pages among multiple memory pages may include the memory pages in multiple memory pages whose memory data is stored in the first physical machine. Correspondingly, the evicted memory pages among multiple memory pages may include the memory pages in multiple memory pages whose memory data is stored in the storage device.
[0089] Optionally, multiple memory pages may be divided into two groups of memory pages according to different storage locations. At least one first memory page stored in the first physical machine and at least one second memory page stored in the storage device among multiple memory pages. In the embodiments of the present application, querying whether the target memory page exists among the non-evicted memory pages in multiple memory pages may specifically include querying whether the target memory page exists among at least one first memory page stored in the first physical machine in multiple memory pages.
[0090] 207: Obtain the target memory data of the target memory page from the first physical machine.
[0091] 208: Obtain the target memory data of the target memory page from the storage device.
[0092] When obtaining the target memory data of the target memory page from the first physical machine or the storage device, the data reading method may be used to obtain the target memory data of the target memory page from the first physical machine or the storage device.
[0093] In the embodiments of the present application, after determining multiple memory pages configured in any one first virtual machine in the first physical machine, at least one evicted memory page that meets the eviction conditions among the multiple memory pages may be determined. Then, at least one evicted memory page is evicted to the storage device, and the physical memory occupied by at least one evicted memory page in the first physical machine is released. The memory occupancy of the first virtual machine in the first physical machine is reduced. When the target user initiates a page access request, the target memory page corresponding to the page access request may be determined. Since some of the multiple memory pages of the first virtual machine are evicted to the storage device, that is, at least one evicted memory page is evicted to the storage device, and the remaining evicted part continues to be stored in the physical memory of the first physical machine, separate storage of different memories of the first virtual machine is realized. When querying the target memory page, the locally stored memory pages may be queried first, and then the memory pages stored in the storage device may be queried, so as to realize efficient query of memory pages, and further improve the acquisition efficiency of memory data.
[0094] In a possible design, since the storage method of the memory pages of the first virtual machine is significantly different from that of the existing virtual machines, in order to significantly distinguish the technical solution of this application, a migration flag can be added to the virtual machine during the establishment of the virtual machine. Since in practical applications, the virtual machine is a structural object running on a physical machine, the migration flag of the virtual machine can be a migration flag bit (FLAG) added to the memory object corresponding to the first virtual machine. If the first virtual machine needs to manage the memory using the technical solution of this application, the migration flag can be set to a predetermined identifier. If the first virtual machine does not need to use the technical solution of this application to manage the memory, the migration flag can be set to a non-predetermined identifier.
[0095] Therefore, the steps for obtaining the target memory data from the storage device can specifically include:
[0096] Obtain the flag information corresponding to the migration flag that is the threshold for the first virtual machine.
[0097] If the flag information matches the predetermined identifier, generate a memory read event for the target memory page.
[0098] Based on the memory read event, read the target memory data of the target memory page from the storage device.
[0099] The flag information can be the predetermined identifier set for the migration flag. The matching of the flag information with the predetermined identifier can specifically mean that the identification information is the same as the predetermined identifier.
[0100] In another possible design, if the flag information does not match the predetermined identifier, that is, the flag information is a non-predetermined identifier, a prompt message indicating that the page acquisition fails can be generated, and then the prompt message indicating that the page acquisition fails can be output to the target user to prompt the target user that the access fails.
[0101] The access to the memory page needs to query the corresponding physical address based on the virtual address of the memory page, and then read or write data from the physical address. As described in the foregoing embodiments, the target memory page can be identified using the virtual address. During the data reading process of the target memory page, the virtual address of the target memory page needs to be used as the basis for generating the read event.
[0102] Therefore, as another embodiment, the steps for generating the memory read event can specifically include:
[0103] Determine the virtual address of the target memory page in the first virtual machine.
[0104] Generate a memory read event corresponding to the virtual address of the target memory page.
[0105] The steps for reading the target storage data of the target memory page from the storage device based on the memory read event can include:
[0106] Run memory read event to obtain the virtual address of the target memory page at the physical address of the storage device;
[0107] Based on the physical address of the target memory page at the storage device, read the target storage data of the target memory page.
[0108] In practical applications, the virtual machine can retain the virtual addresses of all memory pages internally. When a certain memory page in the virtual machine is accessed, it can be queried whether there is a predetermined first mapping relationship for this memory page. If not, it is determined that the target memory page does not exist among the non-evicted memory pages. If so, it is determined that the target memory page exists among the non-evicted memory pages. When the target memory page does not exist among the non-evicted memory pages, that is, it is determined that the target memory page is not associated with the first mapping relationship locally, the second mapping relationship of the target memory page can be queried from the storage device, and after obtaining the target memory data, the second mapping relationship can be saved locally. Therefore, in addition to reading the target storage data of the target memory page from the storage device based on the physical address of the target memory page at the storage device, the mapping relationship of the target memory page can also be established based on the virtual address of the target memory page in the virtual machine and the storage address at the storage device. For example, according to HPA and HVA, the physical mapping relationship between HVA and HPA can be established in the virtual machine, and then the actual mapping relationship between GPA and HPA can be established to complete the storage of the second mapping relationship of the target memory page in the virtual machine, so as to improve the subsequent query efficiency.
[0109] In practical applications, in order to accelerate the reading of the target memory data, a high-speed network channel of RDMA (Remote Direct Memory Access) can be used to read the target memory data from the storage device. At this time, a network communication is established between the first physical machine and the storage device through the high-speed network of RDMA to achieve high-speed data transmission.
[0110] As an embodiment, the storage location of the memory pages of the first virtual machine is dynamically adjusted. After determining multiple memory pages of any first virtual machine configured in the first physical machine, the method may further include:
[0111] Determine multiple first memory pages stored in the first physical machine and multiple second memory pages stored in the storage device among the multiple memory pages;
[0112] The determining of at least one evicted memory page that meets the eviction condition among the multiple memory pages includes:
[0113] Determine at least one evicted memory page that meets the eviction condition from the multiple first memory pages.
[0114] In practical applications, during the process of establishing a memory object in a virtual machine, the technical solution of the embodiment of the present application can be used to migrate the data of memory pages, that is, migrate the memory pages with a lower access frequency to a storage device. However, in practical applications, the migration in and out of memory pages can be continuously adjusted according to the real-time access situation of the memory pages.
[0115] Reference Figure 3 , which is a flowchart of another embodiment of a virtual machine memory management method provided by the embodiment of the present application. The method may include the following steps:
[0116] 301: Determine multiple memory pages of any first virtual machine configured in a first physical machine.
[0117] 302: Determine at least one first memory page stored in the first physical machine and at least one second memory page stored in a storage device among the multiple memory pages.
[0118] 303: Determine at least one migrated memory page that meets the migration-out condition from the multiple first memory pages.
[0119] 304: Migrate at least one migrated memory page to the storage device to release the physical memory occupied by the at least one migrated memory page in the first physical machine.
[0120] 305: Determine at least one migrated-in memory page that meets the migration-in condition among the multiple second memory pages.
[0121] 306: Set physical memory for the at least one migrated-in memory page in the first physical machine, and migrate the at least one migrated-in memory page from the storage device to the physical memory of the first physical machine.
[0122] After any migrated-in memory page is stored in the first physical machine, the migrated-in memory page can be used as a first memory page in the next memory management process. After any migrated-out memory page is migrated to the storage device, the migrated-out memory page can be used as a second memory page in the next memory management process.
[0123] In an embodiment of the present application, after determining multiple memory pages of any one of the first virtual machines configured in the first physical machine, at least one first memory page stored in the first physical machine and at least one second memory page stored in the storage device can be determined among the multiple memory pages. After differentiating the multiple memory pages in the first virtual machine according to different storage devices, at least one evicted memory page that meets the eviction condition can be determined from the multiple first memory pages, and the at least one evicted memory page can be evicted to the storage device to release the physical memory occupied by the at least one evicted memory page in the first physical machine. At the same time, at least one migrated memory page that meets the migration condition can be determined from the multiple second memory pages, and the at least one migrated memory page can be migrated to the first physical machine. With respect to the first physical machine, migration and eviction can perform real-time migration and eviction adjustments on the multiple memory pages in the first virtual machine, realizing dynamic storage of memory pages, reducing the physical memory occupied by the first virtual machine in the first physical machine while ensuring the reading efficiency of memory pages, and improving the utilization efficiency of the physical memory of the first physical machine.
[0124] When the first virtual machine evicts at least one evicted memory page from the first physical machine to the storage device, specifically, the virtual address of the at least one evicted memory page in the first virtual machine can be retained, and the data of the at least one evicted memory page stored in the physical memory of the first physical machine can be evicted to the storage device. The mapping relationship between the virtual address of each of the at least one evicted memory page in the first virtual machine and the physical address of the corresponding first physical machine is cancelled, and a new mapping relationship between the virtual address and the physical address of the memory data in the storage device is established to ensure that the memory pages inside the first virtual machine can still be used normally.
[0125] As an embodiment, evicting at least one evicted memory page to the storage device to release the physical memory occupied by the at least one evicted memory page in the first physical machine may specifically include:
[0126] Based on the virtual address of each of the at least one evicted memory page in the first virtual machine and the first mapping relationship, determine the physical address corresponding to each of the at least one evicted memory page in the first physical machine.
[0127] Wherein, the first mapping relationship of any memory page is the corresponding relationship between the virtual address of the memory page in the first virtual machine and the physical address of the first physical machine.
[0128] According to the physical address corresponding to each of the at least one evicted memory page in the first physical machine, obtain the memory data corresponding to each of the at least one evicted memory page.
[0129] Copy the memory data corresponding to each of the at least one evicted memory page to the storage device, and obtain the physical address of the memory data of each of the at least one evicted memory page in the storage device.
[0130] Establish a second mapping relationship between the virtual address of any memory page migrated out in the first virtual machine and the physical address of its memory data in the storage device, so as to obtain the second mapping relationship corresponding to at least one migrated-out memory page respectively.
[0131] Delete the memory data of at least one migrated-out memory page in the first physical machine according to the physical addresses corresponding to the at least one migrated-out memory page in the first physical machine respectively.
[0132] Optionally, copying the memory data corresponding to at least one migrated-out memory page to the storage device specifically may be writing the memory data corresponding to at least one migrated-out memory page to the physical memory of the storage device, so that the physical memory of the storage device stores the memory data corresponding to at least one migrated-out memory page respectively.
[0133] When the first virtual machine migrates at least one migrated-in memory page from the storage device to the first physical machine, specifically, according to the virtual addresses of the at least one migrated-in memory page in the first virtual machine, query the memory data of the at least one migrated-in memory page stored in the physical memory of the storage device, and re-copy the memory data of the at least one migrated-in memory page to the physical memory of the first physical machine. Cancel the mapping relationship between the virtual address of each of the at least one migrated-in memory page and the physical address in the corresponding storage device, and establish a new mapping relationship between the virtual address and the physical address of the memory data in the first physical machine, so as to ensure that the memory page can be used normally.
[0134] As another embodiment, setting physical memory for at least one migrated-in memory page in the first physical machine, and migrating at least one migrated-in memory page from the storage device to the first physical machine may specifically include:
[0135] Based on the virtual addresses of the at least one migrated-in memory page in the first virtual machine respectively and the second mapping relationship, determine the physical addresses corresponding to the at least one migrated-in memory page in the storage device respectively.
[0136] Among them, the second mapping relationship of any memory page is the corresponding relationship between the virtual address of this memory page in the first virtual machine and the physical address of the storage device.
[0137] According to the physical addresses corresponding to the at least one migrated-in memory page in the storage device respectively, obtain the memory data corresponding to the at least one migrated-in memory page respectively.
[0138] Copy the memory data corresponding to the at least one migrated-in memory page to the physical memory of the first physical machine, and obtain the physical addresses of the memory data of each of the at least one migrated-in memory page in the first physical device;
[0139] Establish a first mapping relationship between the virtual address of any memory page migrated into the virtual machine and the physical address of its memory data in the first physical machine, so as to obtain the first mapping relationship corresponding to at least one migrated memory page respectively.
[0140] Delete the memory data of at least one migrated memory page in the storage device according to the physical addresses corresponding to the at least one migrated memory page in the storage device respectively.
[0141] Optionally, copying the memory data corresponding to at least one migrated memory page to the physical memory of the first physical machine is actually writing the memory data corresponding to at least one migrated memory page to the physical memory of the first physical machine, so that the physical memory of the first physical machine stores the memory data corresponding to at least one migrated memory page respectively.
[0142] In practical applications, the memory of the virtual machine is divided into "hot" and "cold" areas. The hot memory can be the area frequently accessed by the program, and the cold memory can be the area infrequently accessed by the program. In the embodiments of the present application, the migration out and the condition judgment of the migration out are executed according to the high and low access frequencies of the program to the memory area.
[0143] As an embodiment, the judgment step of whether any memory page meets the migration out condition may specifically include:
[0144] Obtain the access frequency of any memory page;
[0145] If the access frequency of the memory page is higher than the first frequency threshold, determine that the memory page does not meet the migration out condition;
[0146] If the access frequency of the memory page is lower than the first frequency threshold, determine that the memory page meets the migration out condition.
[0147] After the memory pages of the first virtual machine have been divided into multiple first memory pages and multiple second memory pages according to the storage location, the memory pages for which the migration out condition is judged can be the first memory pages, and the memory pages for which the migration out condition is judged can be the second memory pages.
[0148] As another embodiment, the judgment step of whether any second memory page meets the migration in condition specifically includes:
[0149] Obtain the access frequency of any second memory page;
[0150] If the access frequency of the second memory page is higher than the second frequency threshold, determine that the second memory page meets the migration in condition;
[0151] If the access frequency of the second memory page is lower than the second frequency threshold, determine that the second memory page does not meet the migration in condition.
[0152] Optionally, in addition to using the access frequency of memory pages as the basis for judging the memory migration conditions, the last access time, average access time, etc. of the memory pages can also be used as the basis for judging the memory migration conditions.
[0153] In practical applications, after the physical memory occupied by the first virtual machine in the first physical machine is released, it can be reused. For example Figure 4 As shown, it is a flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application. The method may include:
[0154] 401: Determine multiple memory pages configured for any one of the first virtual machines in the first physical machine.
[0155] 402: Determine at least one migrated memory page that meets the migration conditions among the multiple memory pages.
[0156] 403: Migrate at least one migrated memory page to a storage device, and release the physical memory occupied by at least one migrated memory page in the first physical machine.
[0157] 404: In response to a virtual machine creation request, generate a second virtual machine in the first physical machine.
[0158] Optionally, in response to a virtual machine creation request, generating a second virtual machine in the first physical machine may specifically include: in response to a virtual machine creation request, running a process of the second virtual machine in the first physical machine to generate the second virtual machine.
[0159] 405: Based on the unoccupied physical memory of the first physical machine, establish multiple memory pages for the second virtual machine.
[0160] In an embodiment of the present application, after migrating at least one migrated memory page to a storage device, the physical memory occupied by at least one migrated memory page in the first physical machine can be released, so that the physical memory in the first physical machine is released. When responding to a virtual machine creation request, a second virtual machine can be generated, and then based on the unoccupied physical memory of the first physical machine, multiple memory pages can be established for the second virtual machine. Realize the reuse of the physical memory in the first virtual machine and improve the utilization efficiency of the physical memory of the virtual machine.
[0161] In practical applications, multiple virtual machines can be configured in one physical machine, and there may be a need to migrate virtual machines. For the virtual machine after memory management using the technical solution of the embodiment of the present application, when migrating, only the memory pages stored by the virtual machine in the physical machine can be migrated, and the physical pages stored by it in the storage device can not be migrated, effectively improving the migration efficiency of the virtual machine.
[0162] As another embodiment, the method may further include:
[0163] Obtain multiple first virtual machines configured in the first physical machine.
[0164] Determine a third virtual machine that needs to perform virtual machine migration from the multiple first virtual machines.
[0165] Migrate the memory pages that have not been migrated out among the multiple memory pages of the third virtual machine to the second physical machine.
[0166] After migrating the memory pages that have not been migrated out among the multiple memory pages of the third virtual machine to the second physical machine, it may further include: establishing a communication connection between the second physical machine and the storage device. In practical applications, an RDMA communication connection between the second physical machine and the storage device can be established.
[0167] Optionally, when migrating the memory pages that have not been migrated out among the multiple memory pages of the third virtual machine to the second physical machine, the memory pages that have not been migrated out among the multiple memory pages of the third virtual machine can be migrated to the second physical machine by means of virtual machine live migration.
[0168] As Figure 5 shown, it is a flowchart of another embodiment of a virtual machine memory management method provided by an embodiment of the present application. The method may include:
[0169] 501: Determine multiple memory pages of any one first virtual machine configured in the first physical machine.
[0170] 502: Determine at least one migrated-out memory page that meets the migration-out condition among the multiple memory pages.
[0171] 503: Migrate at least one migrated-out memory page to the storage device, and release the physical memory occupied by at least one migrated-out memory page in the first physical machine.
[0172] Among them, the migration-out conditions can be judged for the multiple first virtual machines in the first physical machine respectively, so as to migrate the at least one migrated-out memory page corresponding to each of the multiple first virtual machines to the storage device, and release the physical memory occupied by the at least one migrated-out memory page of each of the multiple first virtual machines in the first physical machine. Effectively reduce the memory occupation of multiple first virtual machines in the first physical machine.
[0173] 504: Obtain multiple first virtual machines configured in the first physical machine.
[0174] 505: Determine the physical memory occupied by the multiple first virtual machines in the first physical machine respectively.
[0175] 506: According to the physical memory occupied by the multiple first virtual machines respectively, judge whether the first physical machine meets the virtual machine migration condition. If so, execute step 507. If not, execute step 505.
[0176] 507: Determine a third virtual machine that needs to perform virtual machine migration from multiple first virtual machines.
[0177] 508: Migrate the memory pages that have not been migrated among the multiple memory pages of the third virtual machine to the second physical machine.
[0178] In the embodiments of the present application, multiple first virtual machines are configured in the first physical machine. For any one of the first virtual machines, it can be determined whether the first virtual machine needs to perform memory page migration according to the judgment result of the migration conditions of its multiple memory pages, so as to reduce the physical memory occupied by the first virtual machine in the first physical machine. In practical applications, the migration conditions can be judged one by one for multiple first virtual machines to minimize the physical memory occupation of the first physical machine. In addition, migration judgment can also be performed on the memory occupation of the first physical machine to migrate the virtual machines therein when the memory usage is relatively high. Therefore, the physical memory occupied by each of the multiple first virtual machines in the first physical machine can be determined. According to the physical memory occupied by each of the multiple first virtual machines, it is judged whether the first physical machine meets the virtual machine migration conditions. If it is satisfied, a third virtual machine that needs to be migrated among the multiple first virtual machines is determined, and the memory pages that have not been migrated among the multiple memory pages of the third virtual machine are migrated to the second physical machine. By detecting the memory occupation situation of the first physical machine, the operation situation of the first physical machine can be effectively managed. When it is judged that the first physical machine needs to be migrated, the memory pages that have not been migrated among the multiple memory pages of the third virtual machine can be migrated to the second physical machine. During the migration process of the third virtual machine, only the un-migrated memory pages stored in the first physical machine need to be migrated to achieve efficient virtual machine migration.
[0179] As an embodiment, migrating the memory pages that have not been migrated among the multiple memory pages of the third virtual machine to the second physical machine may include:
[0180] Determine multiple third memory pages stored in the first physical machine among the multiple memory pages of the third virtual machine.
[0181] Migrate the multiple third memory pages to the second physical machine.
[0182] After migrating the memory pages, due to the change of the physical address of the physical machine, it is necessary to re-establish the first mapping relationship of the memory pages.
[0183] As a possible implementation manner, migrating the multiple third memory pages to the second physical machine may include:
[0184] According to the virtual addresses respectively corresponding to the multiple third memory pages and the first mapping relationship, determine the physical addresses respectively corresponding to the multiple third memory pages in the first physical machine; wherein, the first mapping relationship of any one memory page is the correspondence between the virtual address of the memory page in the third virtual machine and the physical address of the first physical machine;
[0185] Obtain the memory data corresponding to multiple third memory pages respectively according to the physical addresses of the multiple third memory pages corresponding to the first physical machine;
[0186] Copy the memory data corresponding to the multiple third memory pages respectively to the second physical device, and obtain the physical memory corresponding to the multiple third memory pages in the second physical device respectively;
[0187] Establish a third mapping relationship between the virtual address corresponding to any third memory page in the third virtual machine and the physical address corresponding to the second physical machine, so as to obtain the third mapping relationships corresponding to the multiple third memory pages respectively;
[0188] Delete the memory data corresponding to the multiple third memory pages in the first physical machine respectively according to the physical addresses of the multiple third memory pages corresponding to the first physical machine.
[0189] In some embodiments, in addition to determining the multiple third memory pages stored in the first physical machine among the multiple memory pages of the third virtual machine, it is also possible to determine the fourth memory pages stored in the storage device among the multiple memory pages of the third virtual machine. When migrating the multiple third memory pages to the second physical machine, it is not necessary to migrate the fourth memory pages stored in the storage device, and the fourth memory pages continue to be stored in the storage device.
[0190] The fourth memory pages continue to be stored in the storage device, and the original corresponding second mapping relationships of the fourth memory pages in the third virtual machine do not change. At this time, after establishing the communication connection between the second physical machine and the third virtual machine, the fourth memory pages in the storage device can be accessed through the original second mapping relationships of the fourth memory pages. Therefore, after managing the memory of the virtual machine based on the migration-in conditions and migration-out conditions as the judgment basis, the number of memory pages of the virtual machine in the physical machine can be reduced. Furthermore, when actually migrating the virtual machine, only the memory pages of the virtual machine in the physical machine need to be migrated, and the memory pages stored by the virtual machine in the storage device do not need to be migrated. After establishing the communication connection between the new physical machine where the virtual machine is located and the storage device, the non-migrated memory pages in the storage device can be accessed, thereby improving the migration efficiency of the virtual machine.
[0191] For the sake of easy understanding, taking the first physical machine as a cloud server, in Figure 6 it is marked as M1, the storage device is NVME, and in Figure 6 it is marked as M2 as an example to introduce the technical solutions of the embodiments of the present application in detail.
[0192] Such as Figure 6As shown in the figure, the virtual machine memory management method of the present application can be configured in the cloud server M1 to manage the memory of the first virtual machine configured therein. Multiple first virtual machines can be configured in the cloud server M1. The cloud server M1 can 601 determine multiple memory pages of any one of the first virtual machines, and 602 determine at least one eviction memory page that meets the eviction condition among the multiple memory pages. Then, 603 at least one eviction memory page will be evicted to the NVME, M2.
[0193] When actually reading the memory pages of the first virtual machine, it can be read from both the cloud server M1 and the storage device NVME, M2. For example, if the target memory page targeted by the access request initiated by the target user is the memory page migrated to the NVME, M2, the target memory data of the target memory page can be 604 read from the NVME, M2.
[0194] The NVME, M2 can receive at least one eviction memory page sent by the cloud server M1 and store at least one eviction memory page. To improve the communication efficiency between the NVME, M2 and the cloud server M1, data transmission can be carried out between the NVME, M2 and the cloud server M1 through a high-speed network channel of RDMA.
[0195] As Figure 7 shown, it is a flowchart of an embodiment of a virtual machine memory management device provided by an embodiment of the present application. The device may include:
[0196] The first determination module 701: is used to determine multiple memory pages of any one of the first virtual machines configured in the first physical machine.
[0197] The second determination module 702: is used to determine at least one eviction memory page that meets the eviction condition among the multiple memory pages.
[0198] The memory eviction module 703: is used to evict at least one eviction memory page to the storage device and release the physical memory occupied by at least one eviction memory page in the first physical machine.
[0199] As an embodiment, the device may further include:
[0200] The request receiving module: is used to receive the memory access request initiated by the target user for the first virtual machine.
[0201] The request response module: is used to respond to the memory access request and determine the target memory page.
[0202] The data acquisition module: is used to acquire the target memory data of the target memory page based on the first physical machine and the storage device.
[0203] The data output module: is used to output the target memory data for the target user.
[0204] In a possible design, the data acquisition module may include:
[0205] A memory query unit, configured to query whether there is a target memory page among the non-evicted memory pages in multiple memory pages;
[0206] A first acquisition unit, configured to, if it exists, acquire target memory data of the target memory page from a first physical machine;
[0207] A second acquisition unit, configured to, if it does not exist, acquire target memory data of the target memory page from a storage device.
[0208] As a possible implementation manner, the second acquisition unit may specifically include:
[0209] A marker determination subunit, configured to acquire marker information corresponding to a migration marker preset for a first virtual machine.
[0210] A marker matching subunit, configured to, if the marker information matches a preset identifier, generate a memory read event for the target memory page.
[0211] A data acquisition subunit, configured to, based on the memory read event, read target memory data of the target memory page from the storage device.
[0212] In a possible design, the data acquisition subunit may specifically be configured to:
[0213] Determine the virtual address of the target memory page in the first virtual machine; generate a memory read event corresponding to the virtual address of the target memory page; run the memory read event to obtain the physical address of the virtual address of the target memory page in the storage device; based on the physical address of the virtual address of the target memory page in the storage device, read the target storage data of the target memory page.
[0214] As another embodiment, the apparatus may further include:
[0215] A first partitioning module, configured to determine multiple first memory pages stored in a first physical machine and multiple second memory pages stored in a storage device among multiple memory pages.
[0216] The second determination module may include:
[0217] A first determination unit, configured to determine at least one evicted memory page that meets the eviction condition from multiple first memory pages.
[0218] It further includes:
[0219] A third determination module, configured to determine at least one migrated-in memory page that meets the migration-in condition from multiple second memory pages.
[0220] A memory migration-in module, configured to set physical memory in a first physical machine for at least one memory page to be migrated in, and migrate the at least one memory page to be migrated in from a storage device to the first physical machine.
[0221] In a possible design, the memory migration-out module may include:
[0222] A second determination unit, configured to determine physical addresses respectively corresponding to at least one memory page to be migrated out in the first physical machine based on virtual addresses of the at least one memory page to be migrated out in a first virtual machine and a first mapping relationship. Wherein, the first mapping relationship of any memory page is the corresponding relationship between the virtual address of the memory page in the first virtual machine and the physical address in the first physical machine.
[0223] A third acquisition unit, configured to acquire memory data respectively corresponding to the at least one memory page to be migrated out according to the physical addresses respectively corresponding to the at least one memory page to be migrated out in the first physical machine.
[0224] A first copying unit, configured to copy the memory data respectively corresponding to the at least one memory page to be migrated out to a storage device, and acquire physical addresses of the memory data of the at least one memory page to be migrated out in the storage device.
[0225] A first mapping unit, configured to establish a second mapping relationship between the virtual address of any memory page to be migrated out in the first virtual machine and the physical address of its memory data in the storage device, so as to obtain second mapping relationships respectively corresponding to the at least one memory page to be migrated out.
[0226] A first deletion unit, configured to delete the memory data of the at least one memory page to be migrated out in the first physical machine according to the physical addresses respectively corresponding to the at least one memory page to be migrated out in the first physical machine.
[0227] In another possible design, the memory migration-in module may include:
[0228] A third determination unit, configured to determine physical addresses respectively corresponding to at least one memory page to be migrated in in a storage device based on virtual addresses of the at least one memory page to be migrated in in a first virtual machine and a second mapping relationship. Wherein, the second mapping relationship of any memory page is the corresponding relationship between the virtual address of the memory page in the first virtual machine and the physical address of the storage device.
[0229] A fourth acquisition unit, configured to acquire memory data respectively corresponding to the at least one memory page to be migrated in according to the physical addresses respectively corresponding to the at least one memory page to be migrated in in the storage device.
[0230] A second copying unit, configured to copy the memory data of the at least one memory page to be migrated in to the physical memory of the first physical machine, and acquire physical addresses of the memory data of the at least one memory page to be migrated in in the first physical device.
[0231] A second mapping unit, configured to establish a first mapping relationship between the virtual address of any memory page migrated into the memory in the first virtual machine and the physical address of its memory data in the first physical machine, so as to obtain the first mapping relationships respectively corresponding to at least one memory page migrated into the memory;
[0232] A second deletion unit, configured to delete the memory data of at least one memory page migrated into the memory in the storage device according to the physical addresses respectively corresponding to the at least one memory page migrated into the memory in the storage device.
[0233] As an embodiment, the second determination module may include:
[0234] A frequency acquisition unit 1, configured to acquire the access frequency of any memory page.
[0235] A first processing unit, configured to determine that the memory page does not meet the migration-out condition if the access frequency of the memory page is higher than a first frequency threshold.
[0236] A second processing unit, configured to determine that the memory page meets the migration-out condition if the access frequency of the memory page is lower than the first frequency threshold.
[0237] In some embodiments, the third determination module may include:
[0238] A frequency acquisition unit 2, configured to acquire the access frequency of any second memory page;
[0239] A third processing unit, configured to determine that the second memory page meets the migration-in condition if the access frequency of the second memory page is higher than a second frequency threshold;
[0240] A fourth processing unit, configured to determine that the second memory page does not meet the migration-in condition if the access frequency of the second memory page is lower than the second frequency threshold.
[0241] As another embodiment, the apparatus may further include:
[0242] A first generation module, configured to generate a second virtual machine in response to a virtual machine establishment request;
[0243] A memory establishment module, configured to establish multiple memory pages for the second virtual machine based on the unoccupied physical memory of the first physical machine.
[0244] In some embodiments, the apparatus may further include:
[0245] A virtual machine acquisition module, configured to acquire multiple first virtual machines configured in the first physical machine;
[0246] A migration determination module, configured to determine a third virtual machine that needs to perform virtual machine migration from the multiple first virtual machines;
[0247] A memory migration module for migrating the unmigrated memory pages among multiple memory pages of a third virtual machine to a second physical machine.
[0248] As a possible implementation, the migration determination module may include:
[0249] A physical determination unit for determining the physical memory occupied by multiple first virtual machines in a first physical machine respectively;
[0250] A migration judgment unit for judging whether the first physical machine meets the virtual machine migration condition according to the physical memory occupied by multiple first virtual machines respectively;
[0251] A fifth processing unit for, if so, determining a third virtual machine that needs to be migrated among multiple first virtual machines.
[0252] A sixth processing unit for, if not, returning to the step of determining the physical memory occupied by multiple first virtual machines in the first physical machine to continue execution.
[0253] In some embodiments, the memory migration module may include:
[0254] A seventh determination unit for determining multiple third memory pages stored in the first physical machine and multiple fourth memory pages stored in a storage device among multiple memory pages of the third virtual machine;
[0255] A memory migration unit for migrating multiple third memory pages to the second physical machine.
[0256] In a possible design, the memory migration unit may specifically be used for:
[0257] Determining the physical addresses corresponding to multiple third memory pages in the first physical machine respectively according to the virtual addresses corresponding to multiple third memory pages respectively and a first mapping relationship; wherein, the first mapping relationship of any memory page is the corresponding relationship between the virtual address of the memory page in the third virtual machine and the physical address of the first physical machine;
[0258] Obtaining the memory data corresponding to multiple third memory pages respectively according to the physical addresses corresponding to multiple third memory pages in the first physical machine respectively;
[0259] Copying the memory data corresponding to multiple third memory pages respectively to a second physical device, and obtaining the physical memory corresponding to multiple third memory pages in the second physical device respectively;
[0260] Establishing a third mapping relationship between the virtual address corresponding to any third memory page in the third virtual machine and the physical address corresponding to the second physical machine to obtain the third mapping relationships corresponding to multiple third memory pages respectively;
[0261] Delete the memory data corresponding to multiple third memory pages in the first physical machine according to the physical addresses corresponding to the multiple third memory pages in the first physical machine.
[0262] Figure 7 The virtual machine memory management device can execute Figure 1 The virtual machine memory management method shown in the embodiments, and its implementation principle and technical effects will not be elaborated. The specific manners of the various steps executed by each module, unit, and subunit in the above embodiments have been described in detail in the embodiments related to the method, and will not be elaborated here.
[0263] In practical applications, Figure 7 The virtual machine memory management device shown can be configured as a physical machine, such as Figure 8 As shown, it is a schematic structural diagram of a physical machine provided by an embodiment of the present application. The physical machine may include: a storage component 801 and a processing component 802. The storage component 801 can be used to store one or more computer instructions. One or more computer instructions are called by the processing component 802 to execute any one of the virtual machine memory management methods in the foregoing embodiments.
[0264] For example, the processing component can be used to: determine multiple memory pages of any one of the first virtual machines configured in the first physical machine; determine at least one migrated memory page that meets the migration condition among the multiple memory pages; migrate at least one migrated memory page to a storage device, and release the physical memory occupied by at least one migrated memory page in the first physical machine.
[0265] Among them, the processing component 802 can include one or more processors to execute computer instructions to complete all or part of the steps in the above method. Of course, the processing component can also be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components, and is used to execute the above virtual machine memory management method.
[0266] The storage component 801 is configured to store various types of data to support the operation of the terminal. The storage component can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0267] Of course, the server may also necessarily include other components, such as input / output interfaces, communication components, etc. The input / output interface provides an interface between the processing component and the peripheral interface module, and the above-mentioned peripheral interface module may be an output device, an input device, etc. The communication component is configured to facilitate communication between the server and other devices, such as user devices, in a wired or wireless manner, etc.
[0268] In addition, an embodiment of the present application also provides a computer-readable storage medium, and the storage medium may store one or more computer instructions. When the one or more computer instructions are executed, they are used to implement Figure 1 the virtual machine memory management method in embodiments such as
[0269] As Figure 9 shown, it is a flowchart of an embodiment of a virtual machine memory management system provided by an embodiment of the present application. The system may include: a first physical machine 901 and a storage device 902.
[0270] A plurality of first virtual machines may be configured in the first physical machine 901.
[0271] The first physical machine 901 may be used to: determine a plurality of memory pages configured in any one of the first virtual machines in the first physical machine. Determine at least one evicted memory page among the plurality of memory pages that meets the eviction condition. Evict at least one evicted memory page to the storage device 902 and release the physical memory occupied by at least one evicted memory page in the first physical machine.
[0272] The storage device 902 may be used to: receive and store at least one evicted memory page sent by the first physical machine.
[0273] The first physical machine in the embodiment of the present application may be Figure 8 the physical machine shown, and specifically may execute Figure 1 the virtual machine memory management method shown, to implement the memory management of the first physical machine and improve the memory usage efficiency of the first physical machine. The management steps executed during the memory management process of the first physical machine may refer to Figure 1 the virtual machine memory management method shown. For the sake of simplicity of description, it will not be elaborated here.
[0274] In the embodiments of the present application, when determining multiple memory pages of any first virtual machine configured in a first physical machine, at least one migrated memory page that meets the migration condition can be determined from the multiple memory pages, and then the at least one migrated memory page can be migrated to a storage device. The storage device can be the storage device of the first physical machine and can store the memory pages in the first physical machine that meet the migration condition. Subsequently, the physical memory occupied by the at least one migrated memory page in the first physical machine can be released. The memory occupation of the first virtual machine in the first physical machine is reduced, and the memory in the first physical machine is released, enabling the memory in the first physical machine to be reused again, thereby improving the utilization efficiency of the memory of the first physical machine.
[0275] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative labor.
[0276] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. Based on such an understanding, the above technical solution, in essence, or the part that makes a contribution to the prior art can be embodied in the form of a computer product. The present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0277] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the specified functions in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0278] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction device that implements the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 specified in one block or multiple blocks.
[0279] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, thereby providing steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 specified in one block or multiple blocks.
[0280] In a typical configuration, a physical machine may include one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0281] Memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0282] Computer-readable media includes permanent and non-permanent, removable and non-removable media and can be implemented by any method or technology for information storage. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0283] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A virtual machine memory management method, characterized in that Including: Determine multiple memory pages of any one of the first virtual machines configured in the first physical machine; Determine at least one evicted memory page among the multiple memory pages that meets the eviction condition; Evict the at least one evicted memory page to a storage device, and release the physical memory occupied by the at least one evicted memory page in the first physical machine; In response to a memory access request initiated by a target user for the first virtual machine, determine a target memory page; And query whether the target memory page exists among the non-evicted memory pages of the multiple memory pages; If not, obtain the marker information corresponding to the migration marker preset for the first virtual machine; If the marker information matches a preset identifier, generate a memory read event for the target memory page; Based on the memory read event, read the target memory data of the target memory page from the storage device; Output the target memory data for the target user.
2. The method according to claim 1, wherein Further including: If it exists, obtain the target memory data of the target memory page from the first physical machine.
3. The method according to claim 1, wherein The step of generating the memory read event specifically includes: Determine the virtual address of the target memory page in the first virtual machine; Generate a memory read event corresponding to the virtual address of the target memory page; The reading the target memory data of the target memory page from the storage device based on the memory read event includes: Run the memory read event to obtain the physical address of the virtual address of the target memory page in the storage device; Based on the physical address of the virtual address of the target memory page in the storage device, read the target memory data of the target memory page.
4. The method according to claim 1, wherein After determining the multiple memory pages of any one of the first virtual machines configured in the first physical machine, further including: Determine multiple first memory pages stored in the first physical machine and multiple second memory pages stored in the storage device among the multiple memory pages; The determining at least one evicted memory page among the multiple memory pages that meets the eviction condition includes: Determine at least one evicted memory page that meets the eviction condition from the multiple first memory pages.
5. The method according to claim 4, wherein Further including: Determine at least one migrated-in memory page that meets the migrated-in condition from the multiple second memory pages; Set physical memory in the first physical machine for the at least one migrated-in memory page, and migrate the at least one migrated-in memory page from the storage device to the physical memory of the first physical machine.
6. The method according to any one of claims 1 or 4, characterized in that The evicting the at least one evicted memory page to a storage device and releasing the physical memory occupied by the at least one evicted memory page in the first physical machine includes: Based on the virtual address of the at least one evicted memory page in the first virtual machine and a first mapping relationship respectively, determine the physical addresses corresponding to the at least one evicted memory page in the first physical machine respectively; wherein, the first mapping relationship of any one memory page is the corresponding relationship between the virtual address of the memory page in the first virtual machine and the physical address of the first physical machine; According to the physical addresses corresponding to the at least one evicted memory page in the first physical machine respectively, obtain the memory data corresponding to the at least one evicted memory page respectively; Copy the memory data corresponding to each of the at least one migrated memory pages to the storage device, and obtain the physical address of the memory data of each of the at least one migrated memory pages in the storage device; Establish a second mapping relationship between the virtual address of any one of the migrated memory pages in the first virtual machine and the physical address of its memory data in the storage device, so as to obtain the second mapping relationships corresponding to each of the at least one migrated memory pages; Delete the memory data of the at least one migrated memory pages in the first physical machine according to the physical addresses corresponding to the at least one migrated memory pages in the first physical machine respectively.
7. The method according to claim 5, characterized in that, The setting of physical memory for the at least one migrated memory pages in the first physical machine and the migrating of the at least one migrated memory pages from the storage device to the first physical machine include: Based on the virtual addresses of the at least one migrated memory pages in the first virtual machine respectively and the second mapping relationship, determine the physical addresses corresponding to the at least one migrated memory pages in the storage device respectively; wherein, the second mapping relationship of any one memory page is the corresponding relationship between the virtual address of the memory page in the first virtual machine and the physical address of the storage device; According to the physical addresses corresponding to the at least one migrated memory pages in the storage device respectively, obtain the memory data corresponding to the at least one migrated memory pages respectively; Copy the memory data of each of the at least one migrated memory pages to the physical memory of the first physical machine, and obtain the physical address of the memory data of each of the at least one migrated memory pages in the first physical machine; Establish a first mapping relationship between the virtual address of any one of the migrated memory pages in the first virtual machine and the physical address of its memory data in the first physical machine, so as to obtain the first mapping relationships corresponding to each of the at least one migrated memory pages; Delete the memory data of the at least one migrated memory pages in the storage device according to the physical addresses corresponding to the at least one migrated memory pages in the storage device respectively.
8. The method according to any one of claims 1 or 4, characterized in that, The judgment step of whether any one memory page meets the migration-out condition specifically includes: Obtain the access frequency of any one memory page; If the access frequency of the memory page is higher than the first frequency threshold, determine that the memory page does not meet the migration-out condition; If the access frequency of the memory page is lower than the first frequency threshold, determine that the memory page meets the migration-out condition.
9. The method according to claim 5, wherein The judgment step of whether any one second memory page meets the migration-in condition specifically includes: Obtain the access frequency of any one second memory page; If the access frequency of the second memory page is higher than the second frequency threshold, determine that the second memory page meets the migration-in condition; If the access frequency of the second memory page is lower than the second frequency threshold, determine that the second memory page does not meet the migration-in condition.
10. The method according to claim 1, characterized in that, Further includes: In response to a virtual machine creation request, generate a second virtual machine in the first physical machine; Based on the unoccupied physical memory of the first physical machine, create multiple memory pages for the second virtual machine.
11. The method according to claim 1, wherein Further includes: Obtain multiple first virtual machines configured in the first physical machine; Determine a third virtual machine that needs to be migrated from the multiple first virtual machines; Migrate the memory pages that have not been migrated among the multiple memory pages of the third virtual machine to the second physical machine.
12. The method according to claim 11, wherein Determining the third virtual machine that needs virtual machine migration from the multiple first virtual machines includes: Determine the physical memory occupied by each of the multiple first virtual machines in the first physical machine; Based on the physical memory occupied by each of the multiple first virtual machines, determine whether the first physical machine meets the virtual machine migration condition; If so, determine the third virtual machine that needs to be migrated among the multiple first virtual machines; If not, return to the step of determining the physical memory occupied by each of the multiple first virtual machines in the first physical machine and continue to execute.
13. The method according to claim 11, wherein The migrating the memory pages that have not been migrated among the multiple memory pages of the third virtual machine to the second physical machine includes: Determine the multiple third memory pages stored in the first physical machine among the multiple memory pages of the third virtual machine; Migrate the multiple third memory pages to the second physical machine.
14. The method according to claim 13, characterized in that, The migrating the multiple third memory pages to the second physical machine includes: Based on the virtual addresses corresponding to the multiple third memory pages and the first mapping relationship, determine the physical addresses corresponding to the multiple third memory pages in the first physical machine; wherein, the first mapping relationship of any memory page is the correspondence between the virtual address of the memory page in the third virtual machine and the physical address of the first physical machine; Based on the physical addresses corresponding to the multiple third memory pages in the first physical machine, obtain the memory data corresponding to the multiple third memory pages; Copy the memory data corresponding to the multiple third memory pages to the second physical machine, and obtain the physical memory corresponding to the multiple third memory pages in the second physical machine; Establish a third mapping relationship between the virtual address corresponding to any third memory page in the third virtual machine and the physical address corresponding to it in the second physical machine, so as to obtain the third mapping relationships corresponding to the multiple third memory pages; Based on the physical addresses corresponding to the multiple third memory pages in the first physical machine, delete the memory data corresponding to the multiple third memory pages in the first physical machine.
15. A virtual machine memory management device, characterized in that, Includes: A first determination module, configured to determine multiple memory pages of any first virtual machine configured in the first physical machine; A second determination module, configured to determine at least one migrated memory page that meets the migration condition among the multiple memory pages; A memory migration module, configured to migrate the at least one migrated memory page to a storage device and release the physical memory occupied by the at least one migrated memory page in the first physical machine; A request response module, configured to determine a target memory page in response to a memory access request initiated by a target user for the first virtual machine; A data acquisition module, configured to query whether the target memory page exists among the memory pages that have not been migrated among the multiple memory pages; If not, obtain the marker information corresponding to the migration marker preset for the first virtual machine; If the marker information matches a preset identifier, generate a memory read event for the target memory page; Based on the memory read event, read the target memory data of the target memory page from the storage device; A data output module for outputting target memory data for a target user.
16. A physical machine, characterized in that, It includes: A storage component and a processing component; the storage component is used to store one or more computer instructions; the one or more computer instructions are called by the processing component to execute the virtual machine memory management method according to any one of claims 1 to 13.
17. A virtual machine memory management system, characterized in that, It includes: A first physical machine and a storage device; The first physical machine is used to: determine multiple memory pages of any one of the first virtual machines configured in the first physical machine; Determine at least one evicted memory page among the multiple memory pages that meets the eviction condition; evict the at least one evicted memory page to the storage device and release the physical memory occupied by the at least one evicted memory page in the first physical machine; The storage device is used to: receive and store the at least one evicted memory page sent by the first physical machine; The first physical machine is further used to: in response to a memory access request initiated by a target user for the first virtual machine, determine a target memory page; and query whether the target memory page exists among the memory pages that have not been evicted in the multiple memory pages; If not, obtain the marker information corresponding to the migration marker preset for the first virtual machine; If the marker information matches a preset identifier, generate a memory read event for the target memory page; Based on the memory read event, read the target memory data of the target memory page from the storage device; Output the target memory data for the target user.
Citation Information
Patent Citations
Virtual machine migration method, virtual machine migration processing method and system, device, chip and medium
CN112363801A