Memory access method and device, and storage medium
By monitoring available ring index information update events in the virtual machine manager and building a clone page, the problem of physical memory waste in the device direct-through scenario is solved, and the elastic scheduling and efficient utilization of physical memory is achieved.
Patent Information
- Application Number
- PCT/CN2024/116639
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-27
- Filing Date
- 2024-09-03
- Publication Date
- 2025-04-03
AI Technical Summary
In the device direct-through scenario, the existing technology requires that all memory of the virtual machine remain exclusive to the host's physical memory, resulting in waste of physical memory, because the pass-through device accesses virtual machine memory incomplete periods or incomplete address space.
By monitoring the index information update event on the available ring in the virtual machine manager, determine the virtual machine memory address to be accessed, and build a clone page when the address is in a page-deficient state, ensuring that the clone page is consistent with the target physical memory page, and thus allowing the straight-through device to access other physical memory pages except the target physical memory page.
It realizes elastic scheduling of physical memory in the device direct-through scenario, improves the utilization rate of physical memory, supports memory page-free, and ensures that the DMA access of the direct-through device is normal.
Smart Images

Figure CN2024116639_03042025_PF_FP_ABST
Abstract
Description
Memory access method, device and storage medium
[0001] This disclosure claims priority to the Chinese patent application filed with the China Patent Office on September 27, 2023, with application number 202311267294X and application name “A Memory Access Method, Device and Storage Medium,” the entire contents of which are incorporated by reference into this disclosure. Technical Field
[0002] The present disclosure relates to the field of virtualization technology, and in particular to a memory access method, device, and storage medium. Background Art
[0003] Device Pass-Through (DPT) is a technology that allows a virtual machine to directly access external devices on the host machine. These devices are called pass-through devices. This technology sacrifices the shared nature of pass-through devices and dedicates them to a single virtual machine, providing the virtual machine with comprehensive device functionality and improved performance.
[0004] In the device passthrough scenario, the passthrough device will directly access the virtual machine's memory through DMA (Direct Memory Access). This requires that all of the virtual machine's memory must maintain exclusive ownership of the corresponding physical memory in the host machine. This physical memory cannot be reused with other virtual machines. Otherwise, the passthrough device may access the memory data of other virtual machines, causing data security issues.
[0005] However, since the memory access of the virtual machine by the pass-through device is usually not full-time or full-address space, this physical memory exclusive requirement in the device pass-through scenario will lead to a huge waste of physical memory.
[0006] Summary of the Invention
[0007] Various aspects of the present disclosure provide a memory access method, device, and storage medium for improving utilization of physical memory in a host machine in a device-direct scenario.
[0008] The present disclosure provides a memory access method applicable to a virtual machine manager in a host machine, wherein a target virtual machine on the host machine and a target pass-through device transfer a memory address of the virtual machine to be accessed based on an available ring. The method includes:
[0009] In response to monitoring an index information update event occurring on the available ring, determining a memory address of the virtual machine to be accessed that is pointed to by the updated index information on the available ring;
[0010] If it is detected that the determined virtual machine memory address to be accessed is in a page fault state, after the page fault recovery is completed, the clone page constructed for the target physical memory page where the index information is located is updated to make the clone page consistent with the target physical memory page;
[0011] The update event is notified to the target pass-through device to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed.
[0012] The present disclosure also provides a virtual machine manager, including:
[0013] A monitoring module configured to determine, in response to detecting an update event of index information on an available ring, a memory address of a virtual machine to be accessed that is pointed to by the updated index information on the available ring;
[0014] a processing module configured to, if it is detected that the memory address of the virtual machine to be accessed is in a page fault state, update the clone page constructed for the target physical memory page where the index information is located after the page fault recovery is completed, so that the clone page is consistent with the target physical memory page;
[0015] a notification module configured to notify the target pass-through device of the update event, so as to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed;
[0016] The target virtual machine on the host machine and the target pass-through device transfer the memory address of the virtual machine to be accessed based on the available ring.
[0017] The embodiment of the present disclosure further provides a physical machine, comprising a memory and a processor, wherein a virtual machine manager runs on the processor;
[0018] The memory is used to store one or more computer instructions;
[0019] The processor is coupled to the memory and configured to execute the one or more computer instructions to utilize the virtual machine manager to perform the aforementioned memory access method:
[0020] An embodiment of the present disclosure further provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the aforementioned memory access method.
[0021] An embodiment of the present disclosure provides a computer program product, including a computer program, which implements the method described in any one of the above aspects when executed by a processor.
[0022] In an embodiment of the present disclosure, in a device pass-through scenario, it is proposed to construct a clone page for the target physical memory page where the index information in the available ring is located. In this way, during the transfer of the virtual machine memory address to be accessed between the target virtual machine and the target pass-through device based on the available ring, the virtual machine manager can monitor the update event of the index information occurring on the available ring, and when there is a page fault problem in the virtual machine memory address to be accessed pointed to by the updated index information, after ensuring that the virtual machine memory address has completed page fault recovery, update the clone page to make the clone page and the target physical memory page consistent; after completing the update of the clone page, the virtual machine manager will notify the target pass-through device of the update event; the target pass-through device will access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page to obtain the virtual machine memory address to be accessed. Based on this, in this embodiment, by maintaining the clone page, the index information accessed by the passthrough device can lag behind the index information maintained by the virtual machine, and this lag period can be used to complete tasks such as page fault recovery, thereby ensuring that memory data preparation is completed before the passthrough device obtains the memory address of the virtual machine to be accessed, ensuring that the passthrough device can perform DMA access normally without being aware of page fault issues. In this way, memory page faults can also be supported in device passthrough scenarios. On this basis, physical memory pages can be reused on demand without affecting the memory access of the passthrough device, thereby effectively improving the utilization of physical memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:
[0024] FIG1 is a flow chart of a memory solution method provided by an exemplary embodiment of the present disclosure;
[0025] FIG2 is a logic diagram of a memory access method provided by an exemplary embodiment of the present disclosure;
[0026] FIG3 is a schematic diagram of a processing logic of available rings provided by an exemplary embodiment of the present disclosure;
[0027] FIG4 is a flow chart of another memory access method provided by an exemplary embodiment of the present disclosure;
[0028] FIG5 is a logical diagram of the memory access method shown in FIG4 ;
[0029] FIG6 is a schematic structural diagram of a virtual machine manager provided by another exemplary embodiment of the present disclosure;
[0030] FIG7 is a schematic structural diagram of a physical machine provided by yet another exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] To make the objectives, technical solutions, and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.
[0032] Figure 1 is a flow chart of a memory solution method provided by an exemplary embodiment of the present disclosure. Figure 2 is a logic chart of a memory access method provided by an exemplary embodiment of the present disclosure.
[0033] 2 , in this embodiment, a host machine may be deployed with a plurality of virtual machines (VMs) and a virtual machine manager (VMM).
[0034] The host machine in this embodiment may refer to a computer device with computing, storage, and communication capabilities. For example, it may be a single server device or a cloud-based server array. The virtual machine manager in this embodiment may be used to schedule tasks, perform load balancing, monitor status, and manage resources for virtual machines on the host machine. For example, the virtual machine manager may be a hypervisor.
[0035] Referring to Figure 2, the host machine is also equipped with external devices. External devices may refer to various I / O devices external to the host machine. Based on device pass-through technology, the virtual machine can directly access the external I / O devices on the host machine through the virtual machine manager, so that the I / O operation path of the virtual machine is almost the same as the I / O path in a non-virtualized environment. Such I / O devices are the pass-through devices mentioned in the background technology. The pass-through devices in this embodiment may include but are not limited to network cards, storage media, etc. Among them, the storage medium may be a persistent storage medium such as a disk or a hard disk. The pass-through device can be connected to the CPU of the host machine through a communication interface; depending on the form of the communication interface, the pass-through device can be implemented as a PCI device, a PCIe device, etc.
[0036] In this embodiment, virtio technology may be used to support the virtual machine's I / O operations on the pass-through device.
[0037] Virtio is an I / O paravirtualization technology that abstracts a set of common external devices within a paravirtualized virtual machine (VMM). It is a front-end and back-end architecture consisting of device drivers, virtualized devices, and virtualized queues (virt queues) for communication between the device drivers and the virtualized devices. The device driver resides in the virtual machine and serves as the virtual device's corresponding driver within the virtual machine. The virtualized device is obtained by the VMM based on the virtualization of the external device. Both the device driver and the virtualized device can read and write data from the virtualized queue. The device driver saves I / O request information to the virtual queue and then notifies the virtualized device, which then retrieves the I / O request information from the virtual queue for processing. The virtualized queue can include an available ring, a used ring, and a descriptor queue. The available and used rings can store logical buffer block indexes, while the descriptor queue stores logical buffer block descriptions. Each logical buffer block can point to a virtual machine memory address.
[0038] Based on Virtio technology, virtual machines and their associated passthrough devices can transmit the virtual machine memory addresses corresponding to I / O operations through virtualized queues.
[0039] During their research, the inventors discovered that currently, direct access devices can directly access virtual machine memory via DMA. That is, after obtaining the virtual machine memory address corresponding to an I / O operation through the aforementioned virtualization queue, the direct access device can initiate a DMA access operation based on the virtual machine memory address to access the corresponding physical memory. Therefore, existing device direct access technology requires that all virtual machine memory maintain exclusive ownership of the corresponding physical memory in the host machine, preventing this portion of physical memory from being reused with other virtual machines, resulting in significant waste of physical memory.
[0040] To this end, this embodiment proposes an improved memory access solution to support flexible scheduling of physical memory in a device direct passthrough scenario to improve physical memory utilization. Referring to Figure 1, the memory access method provided by this embodiment may include:
[0041] Step 100: In response to monitoring an index information update event on an available ring, determining a memory address of a virtual machine to be accessed that is pointed to by the updated index information on the available ring;
[0042] Step 102: If it is detected that the determined virtual machine memory address to be accessed is in a page fault state, after the page fault recovery is completed, the clone page constructed for the target physical memory page where the index information is located is updated to make the clone page consistent with the target physical memory page;
[0043] Step 103: Notify the target pass-through device of the update event to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed.
[0044] For ease of description, this embodiment takes the target virtual machine on the host machine and its corresponding target pass-through device as an example to illustrate the memory access method. It should be understood that the target virtual machine can be any virtual machine on the host machine, and the target pass-through device can be any pass-through device associated with the target virtual machine on the host machine.
[0045] 2 , the memory access method provided in this embodiment can be implemented by a virtual machine manager in a host machine. The memory access method provided in this embodiment is a technical improvement based on the existing Virtio technology to improve the utilization of the physical memory of the host machine.
[0046] As mentioned above, after the pass-through device obtains the virtual machine memory address corresponding to the I / O operation through the aforementioned virtualization queue, it will initiate a DMA access operation according to the virtual machine memory address. To this end, this embodiment proposes a technical concept for supporting memory elasticity in a device pass-through scenario: before the pass-through device obtains the virtual machine memory address corresponding to the I / O operation through the aforementioned virtualization queue, the memory data preparation work under the virtual machine memory address is completed to ensure that the pass-through device can normally access the corresponding memory data after obtaining the virtual machine memory address. Under this concept, the physical memory occupied by the target virtual machine can be reused to other virtual machines, and the swapped-out memory data can be swapped back before the target pass-through device initiates DMA access to the virtual memory address, thereby supporting the normal implementation of DMA access of the target pass-through device. In other words, the target pass-through device will not be aware of the memory swapping / swapping back process under the target virtual machine, thereby not affecting the DMA process of the target pass-through device.
[0047] To implement this concept, this embodiment proposes delaying the time it takes for the target passthrough device to learn the virtual machine memory address corresponding to the I / O operation until after the aforementioned memory data preparation is completed. This provides sufficient processing time for the aforementioned memory data preparation work.
[0048] During the research process, the inventors found that the available rings in the aforementioned virtualized queue usually include the following parts:
[0049] Index information index: points to the next available index position in the available ring;
[0050] Index position ring[]: It records the descriptor identifier, pointing to a descriptor in the descriptor queue descriptor ring or the head descriptor of the descriptor chain.
[0051] Of course, the available ring may also include other parts, such as flags, etc., which will not be further explained here.
[0052] Only the device driver in the virtual machine has permission to write to the available ring. When a new I / O operation is available, the device driver updates the index information in the available ring. The passthrough device then searches the available rings one level at a time, ultimately determining the virtual machine memory address to be accessed, and then enabling real-time DMA access. This shows that the transfer of the target virtual machine's memory address to be accessed between the target virtual machine and the passthrough device is essentially based on the available ring.
[0053] To this end, this embodiment proposes that the time for the target pass-through device to perceive the index information in the available ring can be delayed to achieve the technical goal of delaying the time for the target pass-through device to know the virtual machine memory address corresponding to the I / O operation.
[0054] It should be understood that the available rings in this embodiment, as well as other components such as the used rings in the aforementioned virtualization queue, are all stored in the host machine's physical memory. The virtual machine manager in this embodiment may maintain a page table for the target virtual machine. This page table can be used to map virtual machine memory addresses accessed by the target virtual machine to physical memory addresses on the host machine. Optionally, this page table may employ an extended page table (EPT) or a shadow page table. This embodiment does not limit the type of page table technology employed; it only needs to support mapping virtual machine memory addresses accessed by the target virtual machine to physical memory addresses on the host machine. Thus, when the device driver in the target virtual machine initiates a write operation to the index information in the available rings, the virtual machine memory address (GPA) in the write operation can be translated into the host machine's physical memory address (HPA) based on the page table, thereby updating the index information in the available rings in physical memory. Furthermore, in practical applications, the index information typically occupies only one physical memory page; that is, the size of the index information is typically less than 4 KB (the size of a single memory page).
[0055] In order to delay the time for the target pass-through device to perceive the index information in the available ring, this embodiment proposes that a clone page can be constructed for the target physical memory page where the index information is located, and the clone page can be made visible to the target pass-through device, while the target physical memory page is invisible to the target pass-through device. In other words, what the target pass-through device can access is the clone page, rather than the target physical memory page that the device driver can directly write to. In actual applications, in addition to index information, the target physical memory page may also contain other contents in the virtualization queue, such as the contents in the used ring or descriptor queue. In this embodiment, the virtual machine manager can perform maintenance based on the target physical memory page as a unit, and does not make a more detailed distinction on the specific contents in the target physical memory page.
[0056] Based on this, referring to FIG1 , in step 100 , in response to monitoring an index information update event on the available ring, the virtual machine memory address to be accessed pointed to by the updated index information on the available ring is determined.
[0057] In this step, the virtual machine manager monitors index information update events that occur on the available ring, and the target passthrough device is no longer allowed to perform such monitoring. This is different from traditional Virtio technology. Through this setting in step 100, it is ensured that the target passthrough device is unaware of index information update events that occur on the available ring.
[0058] As mentioned above, the index information update event on the available ring is initiated by the device driver in the target virtual machine. According to traditional Virtio technology, after completing the index information update operation, the device driver will send an update notification to the target passthrough device, triggering the target passthrough device to access the available ring. To prevent the target passthrough device from receiving this update notification, in this embodiment, the virtual machine manager can intercept this update notification.
[0059] In an optional implementation, the virtual machine manager may intercept the specified write instruction when detecting that a specified write instruction for a specified base register address of a target pass-through device is issued in the target virtual machine, so as to determine that an index information update event has been detected on the available ring. In traditional Virtio technology, the device driver may write specified content to the specified base register address through the specified write instruction to trigger the target pass-through device to learn about the index information update event that has occurred on the available ring based on the specified content. In this optional implementation, it is proposed to set an interception point on the notification link from the device driver to the target pass-through device, that is, to intercept the specified write instruction from the device driver to the specified base register address of the target pass-through device. In this way, the write instruction will be exited and will not be executed, and the specified content will not be written to the specified base register address of the target pass-through device. Accordingly, the target pass-through device will not perceive the index information update event, and further, the target pass-through device will temporarily not access the index information in the available ring.
[0060] Of course, since the virtual machine manager has control authority over many operations in the target virtual machine, other implementation methods can also be used in this embodiment to ensure that the target pass-through device is unaware of the update events of the index information occurring on the available ring. No further examples are given here.
[0061] In step 100 , the virtual machine manager may also determine the virtual machine memory address to be accessed, which is pointed to by the updated index information on the available ring.
[0062] Figure 3 is a schematic diagram of the logic for processing an available ring, provided in an exemplary embodiment of the present disclosure. Referring to Figure 3, the virtual machine manager can determine the index location pointed to by the updated index information on the available ring; obtain the descriptor identifier at the index location; and search the descriptor queue associated with the available ring for the descriptor corresponding to the descriptor identifier to obtain the virtual machine memory address pointed to by the found descriptor as the virtual machine memory address to be accessed. A single descriptor in the descriptor queue points to a single virtual machine memory address.
[0063] It should be understood that in step 100, the available ring accessed by the virtual machine manager is the available ring maintained by the device driver, and the aforementioned clone page is not involved here. As mentioned above, the virtual machine manager maintains a page table for the target virtual machine. The virtual machine manager can obtain the virtual machine memory address GPA where the index information is located from the aforementioned intercepted specified write instruction, and then perform address translation based on the page to determine the physical memory address HPA of the target physical memory page where the index information is located, and then access the target physical memory page. According to the same address translation method, the virtual machine manager can also access the descriptor queue, and then obtain the virtual machine memory address to be accessed pointed to by the updated index information.
[0064] As mentioned above, the memory access method provided based on this embodiment can support memory elasticity, that is, it supports memory swapping of the physical memory occupied by the target virtual machine. Memory swapping (Swap) technology is a technology that copies infrequently used memory pages to disk and releases physical memory to increase the available memory of the system. The use of memory swapping technology can significantly improve the memory utilization rate of the physical machine. This technology plays an important role in high-density memory data centers and cloud computing; and memory swapping may cause page faults. In this way, page faults may occur on the virtual machine memory address in the target virtual machine.
[0065] Continuing with reference to FIG. 1 , in step 101 , the virtual machine manager may further detect whether the virtual machine memory address to be accessed determined in step 100 is in a page fault state, that is, whether there is a page fault problem.
[0066] In an optional implementation: the virtual machine manager can query the page table entry information corresponding to the virtual machine memory address to be accessed from the page table maintained for the target virtual machine; if the page table entry information carries a page fault indicator, it is determined that the virtual machine memory address to be accessed is in a page fault state. As mentioned above, the page table can be used to map the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host machine. Therefore, in the process of memory interaction with the physical memory occupied by the target virtual machine, the virtual machine manager can add a page fault indicator to the physical memory address that is swapped out. In this way, in the page table, the virtual machine memory address mapped to this type of physical memory address is in a page fault state. That is, in this optional implementation, the page fault indicator can be recorded in the page table maintained by the virtual machine manager for the target virtual machine as a basis for the virtual machine manager to determine whether the virtual machine memory address to be accessed is in a page fault state.
[0067] Of course, in this embodiment, other implementation methods can also be used to implement the page fault status detection work in step 101, for example, the virtual machine manager sends a page fault status query request to the operating system of the host machine, and the operating system returns the query result, etc. No further examples are given here, and the detection methods supported by this embodiment are not limited to these.
[0068] The following two cases describe the subsequent processing logic after detection:
[0069] In one case, the virtual machine manager detects that there is a page fault problem in the virtual machine memory address to be accessed determined in step 100. The virtual machine manager can update the clone page corresponding to the target physical memory page where the index information is located after completing the page fault recovery of the virtual machine memory address to make the clone page consistent with the target physical memory page.
[0070] In this case, the virtual machine manager will only update the clone page after confirming that the page fault has been recovered at the target VM memory address. This ensures that when the target passthrough device accesses the clone page, the target VM memory address has already recovered from the page fault. In other words, the corresponding memory data is ready, and the target passthrough device can perform DMA access normally without being aware of the page fault that has occurred at the target VM memory address.
[0071] Optionally, in step 101, the virtual machine manager may perform page fault recovery processing for the virtual machine memory address to be accessed: when the virtual machine memory address to be accessed is in a page fault state, a page fault request is sent to the host machine's operating system to trigger the operating system to call the memory management unit MMU to perform page fault recovery on the virtual machine memory address to be accessed; after receiving the page fault response fed back by the operating system, it is determined that the virtual machine memory address to be accessed has completed page fault recovery. More specifically, the virtual machine manager may write a page fault request for the virtual machine memory address to be accessed into a message queue maintained in the host machine's operating system and send an interrupt to the operating system; after receiving the interrupt, the operating system may read the page fault request from the message queue; the operating system may restore the memory data in the physical memory page mapped to the virtual machine memory address (that is, the memory data belonging to the target virtual machine) by calling the memory management unit MMU. After completing the page fault recovery, the operating system may return a page fault response to the virtual machine manager, at which point the virtual machine manager may determine that the virtual machine memory address to be accessed has completed page fault recovery.
[0072] Of course, other implementations can also be used in this embodiment to complete page fault recovery for the memory address of the virtual machine to be accessed. For example, the target virtual machine can actively request the host machine's operating system to perform page fault recovery, etc. Further examples are not provided here. This embodiment does not limit the execution subject and specific execution logic of page fault recovery. Reference can be made to page fault recovery technologies available now or in the future.
[0073] In another case, if the virtual machine manager detects that there is no page missing problem in the virtual machine memory address to be accessed determined in step 100, it can directly execute the aforementioned update index information corresponding to the clone page of the target physical memory page to make the clone page consistent with the target physical memory page.
[0074] In either case, the virtual machine manager updates the aforementioned clone page after a delay after the index information in the available ring is updated. Since the target pass-through device can only access the clone page and is not allowed to access the target physical memory page where the index information is located, the target pass-through device will not be able to view the index information until a period of time has passed after the index information in the available ring is updated. During this period of time, the page fault recovery work in the first case mentioned above can be completed, thereby ensuring that in either case, when the target pass-through device accesses the clone page, the memory data corresponding to the virtual machine memory address to be accessed is ready, and the DMA access of the target pass-through device can be implemented normally.
[0075] In this way, based on step 101, in this embodiment, a page fault problem can be allowed to occur in the physical memory page used by the pass-through device. The page fault recovery process in step 101 can ensure that the pass-through device will not have access failures and other problems due to memory page faults. Instead, the memory access initiated by the pass-through device can be promptly perceived through the clone page, and the required memory data can be prepared in advance for the pass-through device through page fault recovery. Therefore, the physical memory pages used by the pass-through device can be dynamically scheduled without the pass-through device being aware of it. This makes it no longer necessary to provide exclusive physical memory pages for the pass-through device in the device pass-through scenario. The freed-up physical memory pages can be scheduled to other users as needed, thereby supporting memory elasticity in the device pass-through scenario.
[0076] Continuing to refer to Figure 1, in step 102, the update event can be notified to the target pass-through device to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page to obtain the virtual machine memory address to be accessed.
[0077] Referring to Figure 2, in this embodiment, the update time is notified to the target pass-through device by the virtual machine manager. In an optional notification method: the virtual machine manager can write specified content to the specified base address register address of the target pass-through device to trigger the target pass-through device to obtain the update event of the index information occurring on the available ring based on the specified content. Continuing the optional implementation method of monitoring the update event of the index information occurring on the available ring provided in step 100 in the previous text, here, the virtual machine manager can replace the device driver to execute the aforementioned write instruction, that is, to write the specified content to the specified base address register address of the target pass-through device. According to traditional virtio technology, the target pass-through device can perceive the specified content written on its specified base address register address, and use this as a notification of the update event, thereby triggering the access operation to the index information.
[0078] As mentioned above, the available ring is stored in the physical memory of the host machine, and the available ring usually occupies multiple physical memory pages. The target pass-through device does not have access to the target physical memory page where the index information is located, but the target pass-through device still has access to other physical memory pages in the physical memory page where the available ring is located except the target physical memory page. Therefore, after receiving the notification, the target pass-through device can access the aforementioned clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page to obtain the memory address of the virtual machine to be accessed.
[0079] Here, the target pass-through device can refer to the logic of the aforementioned virtual machine manager to determine the access address of the virtual machine to be accessed pointed to by the updated index information from the available ring, and obtain the memory address of the virtual machine to be accessed by accessing the aforementioned clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page. No further details will be given here.
[0080] In this embodiment, after obtaining the memory address of the virtual machine to be accessed, the target direct device can perform memory access using DMA. Because the memory address of the virtual machine to be accessed does not suffer from page faults, the target direct device can accurately access the corresponding memory data. This embodiment does not modify the DMA process of the target direct device, so the DMA process of the target direct device will not be further described.
[0081] In summary, in this embodiment, in the device pass-through scenario, it is proposed to construct a clone page for the target physical memory page where the index information in the available ring is located. In this way, during the transfer of the virtual machine memory address to be accessed between the target virtual machine and the target pass-through device based on the available ring, the virtual machine manager can monitor the update event of the index information occurring on the available ring, and when there is a page fault problem in the virtual machine memory address to be accessed pointed to by the updated index information, after ensuring that the virtual machine memory address has completed page fault recovery, update the clone page to make the clone page and the target physical memory page consistent; after completing the update of the clone page, the virtual machine manager will notify the target pass-through device of the update event; the target pass-through device will access the clone page and other physical memory pages in the physical memory page where the available ring is located, except the target physical memory page, to obtain the virtual machine memory address to be accessed. Based on this, in this embodiment, by maintaining the clone page, the index information accessed by the passthrough device can lag behind the index information maintained by the virtual machine, and this lag period can be used to complete tasks such as page fault recovery, thereby ensuring that memory data preparation is completed before the passthrough device obtains the memory address of the virtual machine to be accessed, ensuring that the passthrough device can perform DMA access normally without being aware of page fault issues. In this way, memory page faults can also be supported in device passthrough scenarios. On this basis, physical memory pages can be reused on demand without affecting the memory access of the passthrough device, thereby effectively improving the utilization of physical memory.
[0082] FIG4 is a flow chart of another memory access method provided by an exemplary embodiment of the present disclosure. FIG5 is a logic diagram of the memory access method shown in FIG4. Referring to FIG4, the method may include:
[0083] Step 400: When receiving a memory elastic mode enable instruction, replace the physical memory address of the target physical memory page originally recorded in the IOMMU address mapping table with the physical memory address of the clone page, so that the target pass-through device accesses the clone page instead of the target physical memory page.
[0084] Step 401: In response to monitoring an index information update event on an available ring, determining a virtual machine memory address to be accessed that is pointed to by the updated index information on the available ring;
[0085] Step 402: If it is detected that the determined virtual machine memory address to be accessed is in a page fault state, then after completing the page fault recovery, the clone page constructed for the target physical memory page where the index information is located is updated to make the clone page consistent with the target physical memory page;
[0086] Step 403: Notify the target pass-through device of the update event to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page to obtain the virtual machine memory address to be accessed.
[0087] Among them, steps 401 to 403 can refer to the relevant descriptions in the above embodiments, and are not repeated here to save space.
[0088] In this embodiment, at least two modes are supported: elastic memory mode and inelastic memory mode. In elastic memory mode, the physical memory occupied by the target virtual machine can be reused; in inelastic memory mode, the physical memory occupied by the target virtual machine cannot be reused.
[0089] In this embodiment, switching between the above two modes is supported.
[0090] In this embodiment, the pass-through device can access the host machine's physical memory address (Host physical address, HPA) through direct memory access (DMA). For the DMA method, there is a data path between the pass-through device and the host machine's physical memory, which is used to realize data transmission between the pass-through device and the physical memory. During the data transmission process between the pass-through device and the physical memory, the host machine's CPU does not need to participate. As mentioned above, the pass-through device can obtain the virtual machine memory address (Guest physical address, GPA) corresponding to the I / O operation through the aforementioned virtualization queue. However, the pass-through device does not know the mapping relationship between GPA and HPA. Moreover, if the pass-through device knows the entire physical memory address space of the host machine without restriction, it can initiate DMA access to any physical memory of the host machine, which may lead to the risk of malicious access to the physical memory. To this end, referring to Figure 5, in this embodiment, an input-input memory management unit (IOMMU) is introduced.
[0091] The IOMMU provides communication between the passthrough device and physical memory. Optionally, the IOMMU can communicate with the passthrough device and the host machine's physical memory via a communication interface bus. The serial interface bus can be a PCI bus, a PCIe bus, or other similar bus. The IOMMU ensures that the passthrough device can access the physical memory occupied by its associated virtual machine on the host machine when performing DMA operations.
[0092] The IOMMU can maintain an address mapping table, which is used to map the virtual machine memory address GPA accessed by the pass-through device to the host machine's physical memory address HPA. When the pass-through device accesses the host machine's physical memory through DMA, the VMM can capture the DMA request issued by the pass-through device and pass the DMA request transparently to the IOMMU. The IOMMU can obtain the GPA to be accessed from the DMA request; then, the GPA to be accessed is matched in the address mapping table stored in the IOMMU to obtain the HPA corresponding to the GPA to be accessed. For the pass-through device, the physical memory page in the host machine's physical memory can be accessed through the HPA corresponding to the GPA to be accessed.
[0093] Based on this, in this embodiment, an implementation method is provided through step 400 to ensure that the target pass-through device accesses the clone page but is not allowed to access the aforementioned target physical memory page. Referring to Figure 5, in this implementation method, after receiving the memory elasticity mode start instruction, the address mapping table of the IOMMU can be modified, and the physical memory address of the target physical memory page is replaced with the physical memory address of the clone page. In this way, when the target pass-through device initiates a DMA request for the memory page where the index information is located, the virtual machine memory address carried in the DMA request will be mapped by the IOMMU to the physical memory address of the clone page, so that the target pass-through device accesses the clone page and no longer accesses the target physical memory page.
[0094] In the memory elasticity mode, the aforementioned steps 401 to 403 can ensure that the memory data preparation is completed before the target pass-through device obtains the memory address of the virtual machine to be accessed, thereby ensuring that the target pass-through device is unaware of the page fault problem, thereby supporting memory elasticity.
[0095] In the case where it is necessary to switch to the memory non-elastic mode, the virtual machine manager can modify the physical memory address of the clone page in the address mapping table of the aforementioned IOMMU to the physical memory address of the target physical memory page after receiving the memory elastic mode shutdown instruction, so that the target pass-through device can access the target physical memory page.
[0096] In this way, by switching the physical memory address HPA of the memory page where the index information is located in the address mapping table of the IOMMU, the target pass-through device can be adjusted to access the clone page or the target physical memory page on demand, thereby supporting memory access in the corresponding mode.
[0097] It should be understood that the above implementation method provided in this embodiment is only exemplary, and other implementation methods can also be used in this embodiment to ensure that the target pass-through device accesses the clone page but is not allowed to access the aforementioned target physical memory page. For example, without modifying the address mapping table of the IOMMU, the virtual machine manager can perform access control on the target physical page in the memory elastic mode, and when an access request to the target physical memory page is detected, it can be redirected to the clone page; and after switching to the memory non-elastic mode, the access control function can be turned off. This embodiment is not limited to this, and no further examples are given here.
[0098] In addition to switching access rights to the clone page and the target physical page, during the switching between the two modes mentioned above, in this embodiment, after receiving the memory elasticity mode on command, the virtual machine manager can start monitoring and intercepting the specified write instructions issued by the target virtual machine to the specified base address register address of the target direct device. In the case of receiving the memory elasticity mode off command, the virtual machine manager stops intercepting the specified write instructions issued by the target virtual machine. The aforementioned monitoring of the specified write instructions can be stopped or not, and will not affect the normal operation of the memory non-elastic mode. Accordingly, after the memory elasticity mode is turned off, the device driver will write the specified content to the specified base address register address based on the specified write instruction to trigger the target direct device to obtain the index information update event occurring on the available ring based on the specified content. That is, the device driver directly notifies the target direct device of the update event, and no longer notifies the virtual machine manager.
[0099] In summary, in this embodiment, after switching to the memory elastic mode, by modifying the address mapping table in the IOMMU, etc., the target pass-through device can access the clone page instead of the target physical memory page, and the virtual machine manager can be enabled to monitor and intercept the index information update events on the available ring, so that the target pass-through device no longer directly perceives the update event. After switching to the memory inelastic mode, the aforementioned related settings can be modified to the related configuration status under the traditional device pass-through technology. Therefore, in this embodiment, seamless switching between the memory elastic mode and the memory inelastic mode can be supported. Moreover, since only the target physical memory page where the index information is located may have other versions of data, in an I / O operation, the data version inconsistency problem during the target pass-through device accessing the virtualization queue can be effectively avoided, ensuring that the mode switch does not affect the accuracy of the I / O operation.
[0100] In the above or following embodiments, in order to further ensure that mode switching does not affect the accuracy of I / O operations, further improvement schemes are proposed:
[0101] When receiving a memory elastic mode shutdown instruction, write-protect the aforementioned target physical memory page;
[0102] After determining that all memory access operations that have not been completed when the memory elasticity mode closing instruction is received are completed, the write protection of the target physical memory page is released.
[0103] During write protection, updates to index information can be temporarily suspended until related I / O operations are completed, and then resumed. Other write operations can be rejected and wait for rewrites.
[0104] In this improved solution, the virtual machine manager can write-protect the target physical memory page when switching to non-elastic memory mode. That is, write operations to the physical memory page are not allowed during the switch. This ensures that data version consistency is maintained between the target physical memory page and the clone page during the switch. This prevents data version inconsistencies when the target passthrough device accesses the virtualization queue.
[0105] It should be noted that some of the processes described in the above embodiments and the accompanying drawings include multiple operations that appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel. The sequence numbers of the operations, such as 101, 102, etc., are merely used to distinguish between different operations and do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel.
[0106] FIG6 is a schematic diagram of the structure of a virtual machine manager provided by another exemplary embodiment of the present disclosure. As shown in FIG6 , the virtual machine manager may include:
[0107] The monitoring module 60 is configured to determine, in response to detecting an index information update event on the available ring, a memory address of the virtual machine to be accessed that is pointed to by the updated index information on the available ring;
[0108] The processing module 61 is configured to update the clone page constructed by the target physical memory page where the index information is located after completing the page fault recovery if it is detected that the virtual machine memory address to be accessed is in a page fault state, so that the clone page is consistent with the target physical memory page;
[0109] Notification module 62 is configured to notify the target pass-through device of the update event, so as to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed;
[0110] The target virtual machine on the host machine and the target pass-through device transfer the memory address of the virtual machine to be accessed based on the available ring.
[0111] In an optional embodiment, the virtual machine manager may further include a configuration module 63. Before responding to detecting an index information update event on an available ring, the configuration module 63 may be configured to:
[0112] When receiving the memory elasticity mode enable instruction, the physical memory address of the target physical memory page originally recorded in the IOMMU address mapping table is replaced with the physical memory address of the clone page, so that the target passthrough device accesses the clone page instead of the target physical memory page;
[0113] The target passthrough device performs address mapping through the IOMMU to access the host machine's physical memory; in memory elasticity mode, the physical memory occupied by the target virtual machine is allowed to be reused.
[0114] In an optional embodiment, the configuration module 63 may also be configured to:
[0115] When receiving a memory elastic mode shutdown instruction, the physical memory address of the clone page in the address mapping table of the IOMMU is modified to the physical memory address of the target physical memory page, so that the target pass-through device can access the target physical memory page;
[0116] When the memory elasticity mode is turned off, the physical memory occupied by the target virtual machine is no longer allowed to be reused.
[0117] In an optional embodiment, the monitoring module 60 may also be configured as:
[0118] When a designated write instruction for a designated base register address of a target pass-through device is detected in the target virtual machine, the designated write instruction is intercepted to determine that an index information update event occurs on the available ring;
[0119] The designated write instruction is used to write designated content to the designated base register address, so as to trigger the target pass-through device to obtain an update event of index information occurring on the available ring based on the designated content.
[0120] In an optional embodiment, the notification module 62 may be specifically configured to:
[0121] Writing specified content to a specified base address register of a target pass-through device triggers the target pass-through device to acquire an update event of index information occurring on an available ring based on the specified content.
[0122] In an optional embodiment, the monitoring module 60 may also be configured as:
[0123] When receiving a memory elasticity mode shutdown instruction, stop intercepting the specified write instruction issued by the target virtual machine;
[0124] Among them, after the memory elasticity mode is turned off, the target virtual machine issues a specified write instruction to write specified content to the specified base address register address to trigger the target pass-through device to obtain an update event of the index information occurring on the available ring based on the specified content.
[0125] In an optional embodiment, the monitoring module 60 may be specifically configured as:
[0126] Determine the index position pointed to by the updated index information on the available ring;
[0127] Get the descriptor identifier at the index position;
[0128] Searching for the descriptor corresponding to the descriptor identifier from the descriptor queue associated with the available ring to obtain the virtual machine memory address pointed to by the found descriptor as the virtual machine memory address to be accessed;
[0129] Among them, a single descriptor in the descriptor queue points to a single virtual machine memory address.
[0130] In an optional embodiment, the processing module 61 may be specifically configured as follows:
[0131] Query the page table entry information corresponding to the memory address of the virtual machine to be accessed from the page table maintained for the target virtual machine;
[0132] If the page table entry information carries a page fault flag, it is determined that the virtual machine memory address to be accessed is in a page fault state;
[0133] The page table is used to map the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host machine.
[0134] In an optional embodiment, the configuration module 63 may also be configured to:
[0135] When receiving a memory elastic mode shutdown instruction, write-protect the target physical memory page;
[0136] After determining that all memory access operations that have not been completed when the memory elastic mode closing instruction is received are completed, the write protection is released.
[0137] In an optional embodiment, the processing module 61 may be specifically configured as follows:
[0138] When the memory address of the virtual machine to be accessed is in a page fault state, a page fault request is sent to the operating system of the host machine to trigger the operating system to call the memory management unit to perform page fault recovery on the memory address of the virtual machine to be accessed;
[0139] After receiving the page fault response fed back by the operating system, the virtual machine memory address to be accessed is determined to complete the page fault recovery.
[0140] It is worth noting that the technical details of the above-mentioned virtual machine manager embodiments can be referred to the relevant descriptions in the aforementioned method embodiments. In order to save space, they will not be repeated here, but this should not cause any loss of the protection scope of this disclosure.
[0141] Figure 7 is a schematic diagram of the structure of a physical machine provided by another exemplary embodiment of the present disclosure. Referring to Figure 7 , the physical machine may include: a memory 70 and a processor 71 , in which a virtual machine manager 72 may run.
[0142] The processor 71 is coupled to the memory 70 and is configured to execute the computer program in the memory 70 to utilize the virtual machine manager 72 to perform the following logic:
[0143] In response to monitoring an index information update event occurring on the available ring, determining a virtual machine memory address to be accessed that is pointed to by the updated index information on the available ring;
[0144] If it is detected that the determined virtual machine memory address to be accessed is in a page fault state, then after the page fault recovery is completed, the clone page constructed by the target physical memory page where the index information is located is updated to make the clone page consistent with the target physical memory page;
[0145] Notify the target pass-through device of the update event to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed;
[0146] The target virtual machine on the host machine and the target pass-through device transfer the memory address of the virtual machine to be accessed based on the available ring.
[0147] In an optional embodiment, before responding to detecting an index information update event on an available ring, the virtual machine manager 72 may further be configured to:
[0148] When receiving the memory elasticity mode enable instruction, the physical memory address of the target physical memory page originally recorded in the IOMMU address mapping table is replaced with the physical memory address of the clone page, so that the target passthrough device accesses the clone page instead of the target physical memory page;
[0149] The target passthrough device performs address mapping through the IOMMU to access the host machine's physical memory; in memory elasticity mode, the physical memory occupied by the target virtual machine is allowed to be reused.
[0150] In an optional embodiment, the virtual machine manager 72 may also be configured to:
[0151] When receiving a memory elastic mode shutdown instruction, the physical memory address of the clone page in the address mapping table of the IOMMU is modified to the physical memory address of the target physical memory page, so that the target pass-through device can access the target physical memory page;
[0152] When the memory elasticity mode is turned off, the physical memory occupied by the target virtual machine is no longer allowed to be reused.
[0153] In an optional embodiment, the virtual machine manager 72 may also be configured to:
[0154] When a designated write instruction for a designated base register address of a target pass-through device is detected in the target virtual machine, the designated write instruction is intercepted to determine that an index information update event occurs on the available ring;
[0155] The designated write instruction is used to write designated content to the designated base register address, so as to trigger the target pass-through device to obtain an update event of index information occurring on the available ring based on the designated content.
[0156] In an optional embodiment, when notifying the target pass-through device of the update event, the virtual machine manager 72 may further be configured to:
[0157] Writing specified content to a specified base address register of a target pass-through device triggers the target pass-through device to acquire an update event of index information occurring on an available ring based on the specified content.
[0158] In an optional embodiment, the virtual machine manager 72 may also be configured to:
[0159] When receiving a memory elasticity mode shutdown instruction, stop intercepting the specified write instruction issued by the target virtual machine;
[0160] Among them, after the memory elasticity mode is turned off, the target virtual machine issues a specified write instruction to write specified content to the specified base address register address to trigger the target pass-through device to obtain an update event of the index information occurring on the available ring based on the specified content.
[0161] In an optional embodiment, when determining the virtual machine memory address to be accessed pointed to by the updated index information on the available ring, the virtual machine manager 72 may further be configured to:
[0162] Determine the index position pointed to by the updated index information on the available ring;
[0163] Get the descriptor identifier at the index position;
[0164] Searching for the descriptor corresponding to the descriptor identifier from the descriptor queue associated with the available ring to obtain the virtual machine memory address pointed to by the found descriptor as the virtual machine memory address to be accessed;
[0165] Among them, a single descriptor in the descriptor queue points to a single virtual machine memory address.
[0166] In an optional embodiment, the virtual machine manager 72 may also be configured to:
[0167] Query the page table entry information corresponding to the memory address of the virtual machine to be accessed from the page table maintained for the target virtual machine;
[0168] If the page table entry information carries a page fault flag, it is determined that the virtual machine memory address to be accessed is in a page fault state;
[0169] The page table is used to map the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host machine.
[0170] In an optional embodiment, the virtual machine manager 72 may also be configured to:
[0171] When receiving a memory elastic mode shutdown instruction, write-protect the target physical memory page;
[0172] After determining that all memory access operations that have not been completed when the memory elastic mode closing instruction is received are completed, the write protection is released.
[0173] In an optional embodiment, the virtual machine manager 72 may also be configured to:
[0174] When the memory address of the virtual machine to be accessed is in a page fault state, a page fault request is sent to the operating system of the host machine to trigger the operating system to call the memory management unit to perform page fault recovery on the memory address of the virtual machine to be accessed;
[0175] After receiving the page fault response fed back by the operating system, the virtual machine memory address to be accessed is determined to complete the page fault recovery.
[0176] Furthermore, as shown in Figure 7 , the physical machine also includes other components such as a communication component 73 and a power supply component 74. Figure 7 only schematically shows some components, which does not mean that the physical machine only includes the components shown in Figure 7 .
[0177] It is worth noting that the technical details of the above-mentioned embodiments of the physical machine can refer to the relevant descriptions in the aforementioned method system embodiments. In order to save space, they will not be repeated here, but this should not cause any loss of the protection scope of this disclosure.
[0178] Accordingly, an embodiment of the present disclosure further provides a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be executed by the virtual machine manager in the above method embodiment.
[0179] The memory in FIG. 7 is used to store computer programs and can be configured to store various other data to support operations on the computing platform. Examples of such data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, images, videos, etc. The memory 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.
[0180] The communication component in Figure 7 above is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0181] The power supply assembly in Figure 7 provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.
[0182] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0183] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0184] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0185] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0186] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0187] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0188] The above are merely embodiments of the present disclosure and are not intended to limit the present disclosure. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure shall be included within the scope of protection of the present disclosure.
Claims
1. A memory access method, wherein: The method is applicable to a virtual machine manager in a host machine, wherein a target virtual machine on the host machine and a target pass-through device transfer a memory address of the virtual machine to be accessed based on an available ring, and the method comprises: In response to monitoring an update event of index information on the available ring, determining a memory address of a virtual machine to be accessed that is pointed to by the updated index information on the available ring; If it is detected that the determined virtual machine memory address to be accessed is in a page fault state, then after the page fault recovery is completed, the clone page constructed for the target physical memory page where the index information is located is updated to make the clone page consistent with the target physical memory page; The update event is notified to the target pass-through device to trigger the target pass-through device to access the avatar page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed.
2. The method according to claim 1, wherein: Before responding to monitoring an update event of index information occurring on the available ring, the method further includes: When receiving a memory elastic mode enable instruction, the physical memory address of the target physical memory page originally recorded in the address mapping table of the input / output memory management unit IOMMU is replaced with the physical memory address of the clone page, so that the target pass-through device accesses the clone page instead of the target physical memory page; The target pass-through device performs address mapping through the IOMMU to access the physical memory of the host machine; in the memory elasticity mode, the physical memory occupied by the target virtual machine is allowed to be reused.
3. The method according to claim 2, wherein: Also includes: When receiving a memory elastic mode closing instruction, modifying the physical memory address of the clone page in the address mapping table of the IOMMU to the physical memory address of the target physical memory page, so that the target pass-through device can access the target physical memory page; After the memory elasticity mode is turned off, the physical memory occupied by the target virtual machine is no longer allowed to be reused.
4. The method according to claim 1, wherein: Also includes: In the case of monitoring that a designated write instruction for a designated base register address of the target pass-through device is issued in the target virtual machine, intercepting the designated write instruction to determine that an update event of index information on the available ring is monitored; The designated write instruction is used to write designated content to the designated base register address, so as to trigger the target pass-through device to learn, based on the designated content, an update event of the index information occurring on the available ring.
5. The method according to claim 4, wherein: Notifying the target pass-through device of the update event includes: The designated content is written into the designated base address register address of the target pass-through device, so as to trigger the target pass-through device to learn an update event of the index information occurring on the available ring based on the designated content.
6. The method according to claim 4, wherein: Also includes: When receiving a memory elastic mode closing instruction, stopping interception of the designated write instruction issued by the target virtual machine; After the memory elasticity mode is turned off, the target virtual machine issues a write instruction based on the specified write instruction to write the specified content to the specified base address register address, so as to trigger the target pass-through device to obtain the specified content based on the specified content. Describes the update events of index information that occur on the available ring.
7. The method according to claim 1, wherein: Determining the memory address of the virtual machine to be accessed pointed to by the updated index information on the available ring includes: Determine the index position pointed to by the updated index information on the available ring; Obtaining the descriptor identifier at the index position; Searching for a descriptor corresponding to the descriptor identifier from the descriptor queue associated with the available ring, so as to obtain a virtual machine memory address pointed to by the found descriptor as the virtual machine memory address to be accessed; Wherein, a single descriptor in the descriptor queue points to a single virtual machine memory address.
8. The method according to claim 1, wherein: Also includes: Querying page table entry information corresponding to the memory address of the virtual machine to be accessed from a page table maintained for the target virtual machine; If a page missing flag is carried in the page table entry information, determining that the virtual machine memory address to be accessed is in a page missing state; The page table is used to map the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host machine.
9. The method according to claim 8, wherein: Also includes: When receiving a memory elastic mode closing instruction, write-protecting the target physical memory page; After determining that all memory access operations that have not been completed when the memory elastic mode closing instruction is received are completed, the write protection is released.
10. The method according to claim 1, wherein: Also includes: When the memory address of the virtual machine to be accessed is in a page fault state, sending a page fault request to the operating system of the host machine to trigger the operating system to call a memory management unit to perform page fault recovery on the memory address of the virtual machine to be accessed; After receiving the page fault response fed back by the operating system, the virtual machine memory address to be accessed is determined to complete page fault recovery.
11. A virtual machine manager, wherein: include: A monitoring module, configured to determine, in response to monitoring an update event of index information on an available ring, a memory address of a virtual machine to be accessed that is pointed to by the updated index information on the available ring; a processing module configured to update the clone page constructed for the target physical memory page where the index information is located after completing the page fault recovery if it is detected that the memory address of the virtual machine to be accessed is in a page fault state, so that the clone page is consistent with the target physical memory page; A notification module, configured to notify the target pass-through device of the update event, so as to trigger the target pass-through device to access the avatar page and other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed; The target virtual machine on the host machine and the target direct-pass device transfer the memory address of the virtual machine to be accessed based on the available ring.
12. The virtual machine manager according to claim 11, wherein: The invention also includes a configuration module, which can be used to: When receiving the memory elastic mode enable instruction, the address originally recorded in the IOMMU address mapping table is The physical memory address of the target physical memory page is replaced by the physical memory address of the clone page, so that the target pass-through device accesses the clone page instead of the target physical memory page; The target pass-through device performs address mapping through the IOMMU to access the physical memory of the host machine; in the memory elasticity mode, the physical memory occupied by the target virtual machine is allowed to be reused.
13. A physical machine, wherein: The method comprises a memory and a processor, wherein a virtual machine manager runs in the processor; The memory is used to store one or more computer instructions; The processor is coupled to the memory and is used to execute the one or more computer instructions to use the virtual machine manager to execute the memory access method described in any one of claims 1-10.
14. A computer-readable storage medium storing computer instructions, wherein: When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the memory access method according to any one of claims 1 to 10.
15. A computer program product, wherein: The method comprises a computer program, which implements the method according to any one of claims 1 to 10 when being executed by a processor.
Citation Information
Patent Citations
Memory access method and device and storage medium
CN119718970A
Method, device and equipment for acquiring descriptor by back-end equipment and readable medium
CN113609055A
Shared memory access method and device, equipment and storage medium
CN114936064A
Page missing processing method and device and storage medium
CN116303123A
Computing system, memory page fault processing method, and storage medium
WO2023165400A1