Data processing system and dynamic memory allocation method

By identifying invalid virtual machine addresses and generating page missing information in the data processing system, the host physical address is dynamically allocated, which solves the page missing problem when the data processing equipment accesses the virtual machine memory, and improves memory utilization and processing efficiency.

WO2024222015A1PCT designated stage expired Publication Date: 2024-10-31HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2023/142371
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-28
Filing Date
2023-12-27
Publication Date
2024-10-31

AI Technical Summary

Technical Problem

In cloud computing scenarios, when data processing equipment directly accesses virtual machine memory, how to deal with page missing problems, especially how to effectively allocate and manage virtual machine memory to improve host memory utilization and processing efficiency.

Method used

Provide a data processing system and a memory dynamic allocation method that generates page fault information by identifying invalid virtual machine addresses and sends the information to the host when needed to dynamically allocate the host physical address and avoid allocating a fixed address when the virtual machine is created. memory, reducing memory waste and improving the efficiency of data processing equipment.

Benefits of technology

It realizes page fault processing when the data processing device directly accesses the virtual machine memory, improves the effective utilization of the host memory, reduces the phenomenon that the memory is idle for a long time after the virtual machine applies for memory, and improves the data processing efficiency and dynamic memory allocation. efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023142371_31102024_PF_FP_ABST
    Figure CN2023142371_31102024_PF_FP_ABST
Patent Text Reader

Abstract

A data processing system and a dynamic memory allocation method, relating to the technical field of data storage. The data processing system comprises a host and a data processing device, and a virtual machine runs on the host. The data processing device can determine a virtual machine address associated with the virtual machine, and send first page fault information to the host when it is determined that the virtual machine address is an invalid virtual machine address, such that the host allocates a host physical address to the virtual machine according to the first page fault information. Therefore, the problem of page fault in the process that the data processing device directly accesses a virtual machine memory can be solved, such that the host does not need to allocate a fixed memory to the virtual machine when creating the virtual machine, and can allocate a memory to the virtual machine when the virtual machine has a page fault, thereby realizing dynamic memory allocation. Moreover, the phenomenon that most of the memory is in an idle state for a long time after the virtual machine applies for the memory can be reduced, and the effective utilization rate of the host memory is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Data processing system and memory dynamic allocation method

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on April 28, 2023, with application number 202310492993.8 and application name “Data Processing System and Memory Dynamic Allocation Method”, the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the technical field of data storage, and in particular to a data processing system and a dynamic memory allocation method. Background Art

[0004] Virtualization technology (VT) is used to support processor virtualization, enabling multiple operating systems running on the processor to run independently in isolated environments. Each operating system running in an isolated environment can be understood as a virtual machine (VM).

[0005] In cloud computing scenarios, a cloud computing cluster includes multiple servers, which can be called hosts. To conserve computing power and improve host performance, data processing devices can be configured for the hosts, offloading some of the host's functions to the data processing devices. In cloud virtualization scenarios, each host can run multiple virtual machines. Accordingly, the host's data processing devices can be virtualized into multiple virtual devices. Each virtual device can be assigned to a corresponding virtual machine through the virtual function I / O (VFIO) framework. Each virtual device has direct memory access (DMA) capabilities, allowing direct access to the memory of the corresponding virtual machine. Each virtual machine can send and receive data through its corresponding virtual device.

[0006] In the scenario where the virtual devices in the above-mentioned data processing device can directly access the corresponding virtual machine memory, how to handle page faults is an urgent problem to be solved.

[0007] Summary of the Invention

[0008] The present application provides a data processing system and a memory dynamic allocation method, which can solve the page missing problem in the process of a data processing device directly accessing the virtual machine memory.

[0009] In a first aspect, a data processing system is provided. The data processing system includes a host and a data processing device, wherein a virtual machine runs on the host.

[0010] After receiving a data processing request from a virtual machine, a data processing device may determine a virtual machine address associated with the virtual machine based on the data processing request. The data processing request instructs the data processing device to receive data to be processed by the virtual machine. When the virtual machine address is an invalid virtual machine address, a first page fault message is sent to the host. The invalid virtual machine address indicates that the virtual machine address associated with the virtual machine does not meet the requirements of the data processing request.

[0011] The host allocates a host physical address to the virtual machine according to the first page fault information, where the host physical address is used to indicate an address of a memory associated with the invalid virtual machine address.

[0012] The data processing system provided by the present application can determine the virtual machine address associated with a virtual machine. When the virtual machine address is determined to be an invalid virtual machine address, the data processing device sends a first page fault message to the host, so that the host allocates a host physical address to the virtual machine based on the first page fault message. This can solve the page fault problem that occurs when the data processing device directly accesses the virtual machine's memory, eliminating the need for the host to allocate fixed memory to the virtual machine when the virtual machine is created. Instead, the host can allocate memory to the virtual machine when a page fault occurs, thereby achieving dynamic memory allocation. Furthermore, it can reduce the phenomenon of a large portion of the virtual machine's memory being idle for a long time after applying for memory, thereby improving the effective utilization of the host's memory.

[0013] In one possible implementation, a data processing device may obtain mapping information for virtual machine addresses associated with a virtual machine from a host's memory. The virtual machine address mapping information indicates whether a corresponding virtual machine address has a corresponding host physical address. Based on the virtual machine address mapping information, the data processing device may identify the corresponding virtual machine address as a valid virtual machine address or an invalid virtual machine address. A valid virtual machine address has a corresponding host physical address; an invalid virtual machine address does not have a corresponding host physical address and therefore does not meet the requirements of the data processing request.

[0014] In a possible implementation, the data processing device may identify valid virtual machine addresses and invalid virtual machine addresses in the following manner:

[0015] The first virtual machine address among the idle virtual machine addresses associated with the virtual machine is used as the virtual machine address to be identified; wherein the idle virtual machine address refers to a storage unit corresponding to the virtual machine address in which no data is stored;

[0016] Repeat the following steps until you get a valid virtual machine address:

[0017] If the mapping information of the virtual machine address to be identified indicates that the virtual machine address to be identified does not have a corresponding host physical address, determining that the virtual machine address to be identified is an invalid virtual machine address, and generating first page fault information for the virtual machine address to be identified;

[0018] The next virtual machine address of the virtual machine address to be identified among the idle virtual machine addresses associated with the virtual machine is used as the new virtual machine address to be identified;

[0019] If the mapping information of the virtual machine address to be identified indicates that the virtual machine address to be identified has a corresponding host physical address, the virtual machine address to be identified is determined to be a valid virtual machine address.

[0020] In the above embodiment, when the data processing device identifies an invalid virtual machine address, it does not need to immediately send page fault information to the host and wait for the host's processing result of the page fault information. Instead, it can continue to identify valid virtual machine addresses from idle virtual machine addresses. Therefore, the time of the data processing device waiting for the host to perform page fault processing and return the page fault processing result can be saved, thereby improving the data processing efficiency of the data processing device.

[0021] In one possible implementation, when the data processing device determines that the virtual machine address to be identified is an invalid virtual machine address, the data length of the saved data in the page table entry corresponding to the invalid virtual machine address is modified to a set value to skip the virtual machine address to be identified and identify whether the next virtual machine address is valid.

[0022] In a possible implementation, when the data processing device determines that the to-be-identified virtual machine address is an invalid virtual machine address, it may generate first page fault information for the invalid virtual machine address and save the generated first page fault information to a ring buffer in the data processing device.

[0023] In one possible implementation, when the number of first page fault information stored in the ring buffer reaches a set number, the data processing device may send the first page fault information stored in the ring buffer to the host. The set number may be determined based on the capacity of the ring buffer and may be equal to or less than the capacity of the ring buffer.

[0024] In another possible implementation, when a valid virtual machine address is identified from the idle virtual machine addresses, the data processing device may transmit the first page fault information stored in the ring buffer to the host.

[0025] The data processing device can send the first page fault information in batches to the host, which can save not only time but also mutual signaling compared to sending one piece of first page fault information to the host.

[0026] In one possible implementation, the data processing device can also be used to receive a data sending request from a virtual machine, obtain a target virtual machine address for storing the data to be sent from the data sending request, and if the target virtual machine address is an invalid virtual machine address, send a second page fault information for the target virtual machine address to the host.

[0027] The host may also be configured to, based on the second page fault information, read the data to be sent stored at the target virtual machine address from the external storage device into the internal memory, and establish a mapping relationship between the target virtual machine address and the target host physical address. The target host physical address is the host physical address of a storage unit in the internal memory used to store the data to be sent. The data processing device is further configured to read the data to be sent from the storage unit corresponding to the target host physical address and send the data to be sent.

[0028] In the above implementation, in the direct-through scenario, this application can also solve the page missing problem when sending data and ensure the normal progress of the data sending process.

[0029] In one possible implementation, if the target virtual machine address does not have a corresponding host physical address, the data processing device may disable the virtual machine's data transmission queue, which stores unsent data in the order it was sent. After obtaining the mapping between the target virtual machine address and the target host physical address from the host, the data processing device may re-enable the virtual machine's data transmission queue to ensure normal data transmission.

[0030] In a possible implementation, a page table entry corresponding to a virtual machine address associated with the virtual machine includes a status bit; the status bit is used to indicate whether the corresponding virtual machine address has been accessed by the data processing device.

[0031] In one possible implementation, the host may further be configured to: after determining the to-be-reclaimed virtual machine address of the virtual machine, read the status bits in the page table entry corresponding to the to-be-reclaimed virtual machine address; and if all status bits of the to-be-reclaimed virtual machine address are in an unused state, demap the to-be-reclaimed virtual machine address. The unused status bits indicate that the corresponding to-be-reclaimed virtual machine address has not been accessed by the data processing device.

[0032] If the status bits of the virtual machine addresses to be reclaimed are all in an unused state, indicating that none of the virtual machine addresses to be reclaimed have been accessed by the data processing device, the host can then directly demap the virtual machine addresses to be reclaimed. In this case, the host does not need to send a data synchronization message to the data processing device, nor does it need to wait for the data processing device to return a synchronization completion message, thus saving time waiting for the data processing device to return a synchronization completion message. Because the time it takes to wait for the data processing device to return a synchronization completion message is typically very long, in the above embodiment, setting a status bit for the virtual machine address and querying the status bit of the virtual machine address can significantly reduce the synchronization wait time between the host and the data processing device, thereby improving the efficiency of the demapping process, the dynamic memory allocation process, and memory over-allocation.

[0033] In one possible implementation, if the to-be-reclaimed virtual machine address includes a to-be-synchronized virtual machine address whose status bit is in use, the host sends a data synchronization message to the data processing device for the to-be-synchronized virtual machine address; the use status bit indicates that the corresponding to-be-reclaimed virtual machine address has been accessed by the data processing device. After the data processing device determines that it has completed processing the data in the to-be-synchronized virtual machine address, it sends a synchronization completion message to the host. After receiving the synchronization completion message from the data processing device, the host demaps the to-be-reclaimed virtual machine address to ensure normal data processing operations of the data processing device.

[0034] In one possible implementation, the host may use a swap instruction to read the status bit in the page table entry corresponding to the address of the virtual machine to be recycled; the swap instruction indicates that after reading the status bit of the address of the virtual machine to be recycled, the status bit of the address of the virtual machine to be recycled is set to an unused state.

[0035] In a second aspect, a method for dynamic memory allocation is provided. The method can be applied to the data processing system described in the first aspect, wherein a data processing device obtains a data processing request from a virtual machine running on a host, the data processing request being used to instruct the data processing device to receive data to be processed by the virtual machine; a virtual machine address associated with the virtual machine is determined based on the data processing request, and when the virtual machine address is an invalid virtual machine address, a first page fault message is sent to the host, the invalid virtual machine address being used to indicate a virtual machine address among the virtual machine addresses associated with the virtual machine that does not meet the requirements of the data processing request. The host allocates a host physical address to the virtual machine based on the first page fault message, the host physical address being used to indicate the address of the memory associated with the invalid virtual machine address.

[0036] In a third aspect, a method for dynamic memory allocation is provided. The method can be applied to a data processing device connected to a host, comprising:

[0037] Obtaining a data processing request of a virtual machine running in a host; the data processing request is used to instruct a data processing device to receive data to be processed by the virtual machine;

[0038] Determine the virtual machine address associated with the virtual machine according to the data processing request, and send a first page fault message to the host when the virtual machine address is an invalid virtual machine address; the invalid virtual machine address is used to indicate the virtual machine address associated with the virtual machine that does not meet the data processing request requirements.

[0039] In a fourth aspect, a method for dynamic memory allocation is provided, which is applied to a host and includes:

[0040] Determine the virtual machine address to be recycled of the virtual machine running on the host;

[0041] Read the status bit in the page table entry corresponding to the address of the virtual machine to be reclaimed;

[0042] If the status bits of the to-be-reclaimed virtual machine address are all in unused state, the to-be-reclaimed virtual machine address is demapped; the unused state bits indicate that the corresponding to-be-reclaimed virtual machine address has not been accessed by the data processing device;

[0043] If the address of the virtual machine to be reclaimed includes the address of the virtual machine to be synchronized whose status bit is in use, a data synchronization message for the address of the virtual machine to be synchronized is sent to the data processing device. After receiving the synchronization completion message returned by the data processing device, the address of the virtual machine to be reclaimed is demapped.

[0044] In a fifth aspect, a memory dynamic allocation device is provided, which includes modules for executing the memory dynamic allocation method provided in the third aspect.

[0045] In a sixth aspect, a memory dynamic allocation device is provided, which includes modules for executing the memory dynamic allocation method provided in the fourth aspect.

[0046] In a seventh aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the operating steps of any one of the methods provided in the third aspect or the fourth aspect.

[0047] The technical effects that can be achieved in any of the second to seventh aspects can refer to the description of the beneficial effects in the first aspect, and will not be repeated here.

[0048] Based on the implementation methods provided in the above aspects, this application can also be further combined to provide more implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] FIG1 is a schematic structural diagram of a data processing system provided by the present application;

[0050] FIG2 is a diagram illustrating an interaction between a host and a data processing device during a data receiving process provided by the present application;

[0051] FIG3 is a schematic diagram of an address mapping table of a virtual machine provided in this application;

[0052] FIG4 is a schematic diagram of a page table entry of a virtual machine provided by the present application;

[0053] FIG5 is a schematic diagram of an address mapping table of another virtual machine provided in this application;

[0054] FIG6 is a schematic diagram of an address mapping table of another virtual machine provided in this application;

[0055] FIG7 is a logical diagram of a page fault handling process provided by the present application;

[0056] FIG8 is a diagram illustrating an interaction between a host and a data processing device during a data transmission process provided by the present application;

[0057] FIG9 is a diagram illustrating an interaction between a host and a data processing device during a demapping process provided by the present application;

[0058] FIG10 is a schematic diagram of an address mapping table of another virtual machine provided in this application;

[0059] FIG11 is a logic diagram of a demapping process provided by this application. DETAILED DESCRIPTION

[0060] To facilitate understanding, some terms in this application are first explained.

[0061] (1) Data processing device: used to offload some functions from the host processor. For example, high-performance data processing functions in the network, storage, or operating system that are not suitable for the central processor can be offloaded to the data processing device, thereby releasing the computing power of the host processor. Data processing devices may include, but are not limited to, data processing units (DPUs), infrastructure processing units (IPUs), intelligent network interface cards (iNICs), or smart network interface cards (smartNICs), and other computing units with offload functions.

[0062] (2) Memory over-allocation: The total memory space allocated by the host to the virtual machines is greater than the actual physical memory space available on the host. For example, suppose the total size of the host's physical memory space is 10G, there are 8 virtual machines running on the host, and the host allocates 2G of memory space to each virtual machine. At this time, the total memory space allocated by the host to the virtual machines is 16G, which has exceeded the total size of the host's physical memory space of 10G. This phenomenon is called memory over-allocation. In the memory over-allocation scenario, part of the 2G memory space allocated by the host to a virtual machine may not correspond to the actual physical memory space. In other words, a virtual machine has a 2G virtual machine address, and part of the virtual machine address does not have a corresponding host physical address.

[0063] (3) Ring buffer: Also known as a circular queue or cyclic buffer, it is a data structure used to represent fixed-size, end-to-end connected storage units. For example, a ring buffer may include 10 end-to-end connected storage units. Data is stored in each storage unit in sequence. After data is stored in the 10th storage unit, if the first storage unit is free, the next data can be stored in the first storage unit.

[0064] (4) Virtual machine (VM): It is an operating system running on a computing device. VM can access the host's external hardware resources, such as network cards, storage devices, etc., just like a physical machine.

[0065] (5) Host physical address (HPA): refers to the physical address of the storage unit in the host's memory, corresponding to the storage unit in the actual physical memory space.

[0066] (6) Virtual Machine Address: This is the virtual address of the memory space allocated to the virtual machine by the host when the virtual machine is created. It can also be called the guest physical address (GPA). Part of the memory space associated with the virtual machine address may not correspond to the actual physical memory space.

[0067] (7) Page fault: The virtual machine's address mapping table is used to store the mapping relationship between virtual machine addresses and host physical addresses. Due to the memory over-allocation phenomenon mentioned above, some virtual machine addresses may not have associated host physical addresses. These virtual machine addresses can be called invalid virtual machine addresses. The data processing device identifies invalid virtual machine addresses by searching the virtual machine's address mapping table. This indicates that the invalid virtual machine address does not correspond to actual physical memory space in the host's memory. This phenomenon is called a page fault.

[0068] The data processing system and dynamic memory allocation method provided by this application are introduced below with reference to the accompanying drawings.

[0069] The dynamic memory allocation method provided in this application can be applied to the application scenario shown in Figure 1. Figure 1 shows a schematic structural diagram of a data processing system 100. As shown in Figure 1, the data processing system 100 may include a host 110 and a data processing device 130. The data processing system 100 can receive data input by a user and process the data. For example, the data processing system 100 can receive data input by a user through a client, and the client can be deployed on the user's terminal device, and the terminal device can include but is not limited to a personal computer, a mobile phone, a tablet computer or an intelligent vehicle-mounted terminal, etc. The data processing system 100 can also receive data transmitted through a network by other computing devices and process the data.

[0070] Host 110 is the computing and control core of data processing system 100. Host 110 may be a central processing unit (CPU) or other specific integrated circuit. Host 110 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0071] The memory 120 in the host 110 is generally used to store various running software in the operating system, input data to be processed, and data processing results. For example, the memory 120 can use dynamic random access memory (DRAM) as the memory 120. In addition to DRAM, the memory 120 can also be other random access memories, such as static random access memory (SRAM). In addition, the memory 120 can also be read-only memory (ROM). As for the read-only memory, for example, it can be programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), etc. This embodiment does not limit the number and type of memory 120.

[0072] In some embodiments, host 110 may further include an input / output (I / O) interface. The I / O interface is used to communicate with devices external to host 110. For example, a terminal device may input data to host 110 through the I / O interface. Host 110 processes the input data and then sends the processed data results to the terminal device through the I / O interface.

[0073] Optionally, to provide persistent data storage, the data processing system is further provided with an external memory 140. External memory 140 can be located external to host 110 and exchange data with host 110 via an I / O interface or a network. External memory 140 can also be located internal to the host and exchange data with processor 110 via a bus. Different from the memory of host 110, external memory 140 can be, but is not limited to, a hard disk.

[0074] One or more virtual machines can run on the processor 110, and the virtual machines can also be called guests. For example, the host 110 shown in Figure 1 runs virtual machines 111 and 112. The memory 120 can be used to store the input data to be processed by each virtual machine and the processing results of the data. Each virtual machine has a corresponding memory space in the memory 120. Taking the virtual machine 111 as an example, when the virtual machine 111 is created, the host 110 allocates a corresponding memory space for the virtual machine 111 in the memory 120. The virtual machine 111 can access the memory space, read the data to be processed from the memory space, and save the data processing results to the memory space. When the host 110 clears the memory, the data to be processed or the data processing results of the virtual machine 111 stored in the memory 120 can be stored in the external memory 140.

[0075] The data processing device 130 is used to offload some functions of the host 110 to save the computing power of the host 110 and improve the performance of the host 110. In some embodiments, the data processing device 130 can be directly inserted into a card slot on the motherboard of the host 110 and exchange data with the processor 110 via the PCIe bus. It should be noted that the PCIe bus can be replaced with a bus using the Compute Express Link (CXL), Universal Serial Bus (USB) protocol, or other protocols. The data processing device 130 has direct memory access (DMA) capability and can directly access the memory 120 in the host 110.

[0076] In a cloud virtualization scenario, when multiple virtual machines are running on the host 110, the data processing device 130 can also be virtualized into multiple virtual devices through the Single Root I / O Virtualization (SR-IOV) technology. Among them, SR-IOV can be virtualized at the hardware level, so that one hardware device generates multiple virtual hardware devices, each virtual hardware device can be called a virtual device, and each virtual device can be recognized as an independent device by the operating system or virtual machine. Each virtual device generated by the data processing device 130 can be allocated to the corresponding virtual machine for use through the virtual I / O device pass-through (virtual function I / O, VFIO) framework. Each virtual device has direct memory access DMA capability and can directly access the memory space of the corresponding virtual machine. The virtual machine running on the host 110 can send and receive data through the corresponding virtual device.

[0077] Taking virtual machine 111 as an example, the virtual device corresponding to virtual machine 111 can directly access the memory space of virtual machine 111. When receiving data from virtual machine 111, the virtual device corresponding to virtual machine 111 can save the received data to the memory space of virtual machine 111; when virtual machine 111 has data to be sent, the virtual device corresponding to virtual machine 111 can read the data to be sent from the memory space of virtual machine 111 and then send the data to be sent.

[0078] Before a virtual device corresponding to a virtual machine saves received data to the virtual machine's memory space, the data processing device can determine the host physical address where the data is stored by searching address mapping information. The address mapping information stores the correspondence between virtual machine addresses and host physical addresses, where the host physical addresses are the physical addresses of the host's memory. If the data processing device determines, while searching the address mapping information, that a virtual machine address does not have a corresponding host physical address, this phenomenon is called a page fault.

[0079] When a page fault occurs, the interaction process between the data processing device and the host may be as shown in FIG2 , including the following steps:

[0080] S201: When receiving data from a first virtual machine, a data processing device obtains address mapping information of the first virtual machine.

[0081] The first virtual machine can be any virtual machine running on the host. The data of the first virtual machine received by the data processing device can be the data processing result obtained after the first virtual machine processes data a, or it can be data sent to the first virtual machine by other devices received via the network, or it can be data input by a user for the first virtual machine. After receiving the data of the first virtual machine, the data processing device can save the data to the memory space of the first virtual machine, and the memory space of the first virtual machine is located in the memory of the host. It can also be understood that after receiving the data of the first virtual machine, the data processing device can save the data to the memory space of the first virtual machine through the virtual device corresponding to the first virtual machine in the data processing device.

[0082] When saving data of a first virtual machine, a data processing device obtains address mapping information for the first virtual machine. The address mapping information includes mapping information for idle virtual machine addresses of the first virtual machine. An idle virtual machine address refers to a storage unit corresponding to the virtual machine address where no data is stored. In some embodiments, the address mapping information may be obtained from an address mapping table for the first virtual machine. The address mapping table for the first virtual machine is stored in the host's memory. The address mapping table may store mappings between virtual machine addresses of the first virtual machine and host physical addresses. Due to memory over-allocation, some virtual machine addresses of the first virtual machine in the address mapping table may not have corresponding host physical addresses. For example, the format of an address mapping table may be as shown in FIG. 3 , where each virtual machine address in the address mapping table corresponds to one piece of mapping information. Virtual machine addresses GPA1 and GPA2 do not have corresponding host physical addresses, while virtual machine addresses GPA3 and GPA4 do have corresponding host physical addresses. The host physical address corresponding to virtual machine address GPA3 is HPA1, and the host physical address corresponding to virtual machine address GPA4 is HPA2.

[0083] The host's memory can store data in the form of memory pages. Each virtual machine address corresponds to a memory page. Some memory pages store data, while other memory pages may not store data.

[0084] In some embodiments, the host's memory may also store a page table entry (PTE) of the first virtual machine. The page table entry may store whether data is stored in each virtual machine address of the first virtual machine, as well as the data length (len) of the stored data. For example, as shown in FIG4 , data with a data length of 1000 bytes is stored in the virtual machine address GPA3 of the first virtual machine; data with a data length of 0 bytes is stored in the virtual machine address GPA4 of the first virtual machine, which can also be understood as no data being stored in the virtual machine address GPA4 of the first virtual machine. As can be seen from FIG4 , data is stored in the storage unit corresponding to the virtual machine address GPA3 of the first virtual machine, and the virtual machine address GPA3 is a non-idle virtual machine address. No data is currently stored in the storage unit corresponding to the virtual machine address GPA4 of the first virtual machine, and the virtual machine address GPA4 is an idle virtual machine address. The address mapping table and page table entries of the first virtual machine can both be stored in the form of a ring buffer.

[0085] In an optional embodiment, the data processing device can determine the idle virtual machine address in the first virtual machine based on the content stored in the page table entry, read the mapping information of the idle virtual machine address from the address mapping table of the first virtual machine, obtain the address mapping information, and save it to the cache of the data processing device.

[0086] In another optional embodiment, the data processing device may also read the mapping information of all virtual machine addresses in the address mapping table of the first virtual machine from the host memory into the cache of the data processing device as the address mapping information. In the subsequent step of searching for valid virtual machine addresses, the virtual machine addresses in the address mapping information are determined to be free virtual machine addresses based on the content stored in the page table entry.

[0087] It should be noted that in some embodiments, the address mapping table of the first virtual machine and the page table entries of the first virtual machine stored in the host's memory may be two independent tables. In other embodiments, the address mapping table of the first virtual machine and the page table entries of the first virtual machine may be unified in a single table. As shown in FIG5 , the address mapping table of the first virtual machine stored in the host's memory may include the page table entries of the first virtual machine.

[0088] S202: The data processing device identifies an invalid virtual machine address and generates first page fault information for the invalid virtual machine address.

[0089] The data processing device identifies an invalid virtual machine address and a valid virtual machine address from the idle virtual machine addresses, wherein the invalid virtual machine address refers to a virtual machine address for which a corresponding host physical address does not exist in the mapping information, and the valid virtual machine address refers to a virtual machine address for which a corresponding host physical address exists in the mapping information.

[0090] The process of a data processing device searching for a valid virtual machine address can be called an addressing process. During the addressing process, the data processing device can use the first virtual machine address among the idle virtual machine addresses as the virtual machine address to be identified, and repeatedly perform the following operations: determine whether the virtual machine address to be identified has a corresponding host physical address; if there is no corresponding host physical address, determine that the virtual machine address to be identified is an invalid virtual machine address, and generate first page fault information for the virtual machine address to be identified, and save the generated first page fault information to a ring buffer for temporary storage. Use the next virtual machine address of the virtual machine address to be identified among the idle virtual machine addresses as the new virtual machine address to be identified; if the virtual machine address to be identified has a corresponding host physical address, determine that the virtual machine address to be identified is a valid virtual machine address, and stop the repeated operation.

[0091] In some embodiments, when the data processing device determines that the to-be-identified virtual machine address is an invalid virtual machine address, it may set the data length corresponding to the to-be-identified virtual machine address in the page table entry of the first virtual machine to a set value. For example, the set value may be 0, indicating that data of length 0 has already been stored in the to-be-identified virtual machine address. Therefore, the to-be-identified virtual machine address may be skipped, and the next idle virtual machine address may be checked for validity.

[0092] For example, assuming the address mapping table shown in FIG5 is used as the address mapping information for the first virtual machine, when addressing, the data processing device first uses the first virtual machine address GPA1 among the idle virtual machine addresses as the virtual machine address to be identified, determines whether GPA1 has a corresponding host physical address, and after determining that GPA1 is an invalid virtual machine address, generates a first page fault message for GPA1, saves the first page fault message of GPA1 to a ring buffer for temporary storage, and sends a data save completion message for GPA1 to the first virtual machine, indicating that the first virtual machine has saved data of length 0 to GPA1. Then, the next idle virtual machine address GPA2 is used as the virtual machine address to be identified, determines whether GPA2 has a corresponding host physical address, and after determining that GPA2 is an invalid virtual machine address, generates a first page fault message for GPA2, saves the first page fault message of GPA2 to a ring buffer for temporary storage, and sends a data save completion message for GPA2 to the first virtual machine, indicating that the first virtual machine has saved data of length 0 to GPA2. Then, the next idle virtual machine address GPA4 is used as the virtual machine address to be identified, and it is determined whether GPA4 has a corresponding host physical address. If it is determined that GPA4 has a corresponding host physical address HPA2, GPA4 is used as the valid virtual machine address.

[0093] In some embodiments, when the data processing device determines that the virtual machine address to be identified is an invalid virtual machine address, the mapping information of the virtual machine address to be identified stored in the cache of the data processing device may be invalidated to avoid using the mapping information of the virtual machine address to be identified for addressing again in subsequent processes, thereby obtaining an incorrect addressing result.

[0094] S203: The data processing device saves the data of the first virtual machine to a valid virtual machine address.

[0095] When the data processing device receives data from the first virtual machine, it also receives the data storage address of the data, which can be understood as a logical address. After the data processing device identifies a valid virtual machine address, it can establish a correspondence between the data storage address and the valid virtual machine address and save the data of the first virtual machine to the host physical address corresponding to the valid virtual machine address.

[0096] S204: The data processing device sends first page fault information to the host.

[0097] In some embodiments, step S204 may also be performed before step S203.

[0098] In an optional embodiment, when the number of first page fault information stored in the ring buffer reaches a set number, the data processing device transmits the first page fault information stored in the ring buffer to the host. The set number can be determined according to the capacity of the ring buffer, and the set number can be equal to or less than the capacity of the ring buffer. For example, when the capacity of the ring buffer is 10, the set number can be 10, that is, when the generated first page fault information fills the ring buffer, the regenerated first page fault information can no longer be saved in the ring buffer. At this time, the data processing device can transmit the first page fault information stored in the ring buffer to the host.

[0099] In another optional embodiment, when a valid virtual machine address is identified from the idle virtual machine addresses, the data processing device may transmit the first page fault information stored in the ring buffer to the host.

[0100] In the above process, when the data processing device reads data from the host's memory or writes data to the host's memory, it can access the host's memory through the virtual device corresponding to the first virtual machine.

[0101] S205 , the host saves the first page fault information into a page fault information queue, and performs page fault processing on the first page fault information in the page fault information queue in sequence.

[0102] The host receives one or more first page fault information sent by the data processing device, saves the first page fault information into the page fault information queue, and performs page fault processing together when idle. The page fault information queue can also use a ring buffer to save the page fault information.

[0103] When performing page fault processing, the host can sequentially assign a host physical address to the invalid virtual machine address based on the first page fault information in the page fault information queue, and update the mapping information of the invalid virtual machine address in the address mapping table of the first virtual machine based on the host physical address assigned to the invalid virtual machine address. For example, the updated address mapping table can be shown in FIG6 . As can be seen from FIG6 , the host physical address assigned by the host to virtual machine address GPA1 is HPA11, and the host physical address assigned by the host to virtual machine address GPA2 is HPA22. The address mapping table shown in FIG5 or FIG6 can also be referred to as a DMMU page table.

[0104] In some embodiments, a dynamic memory management unit (DMMU) is provided in the data processing device, and the data processing device can use the DMMU to identify invalid virtual machine addresses and valid virtual machine addresses. The DMMU can be a software module, a hardware module, or a combination of software and hardware, which is not limited in this application.

[0105] In some embodiments, the host can perform page fault processing through a driver. For example, as shown in Figure 7, the data processing device can use a DMMU unit to identify invalid virtual machine addresses from virtual machine addresses associated with a first virtual machine. When the DMMU unit identifies an invalid virtual machine address, it generates page fault information for the invalid virtual machine address and stores the page fault information in a ring buffer in the data processing device's cache. The DMMU unit also modifies the page table entry for the virtual machine address associated with the first virtual machine. The page table entry for the virtual machine address associated with the first virtual machine can be stored in a ring buffer in the memory space of the first virtual machine, which is located in the host's memory. The DMMU unit can set the data length of the page table entry corresponding to the invalid virtual machine address to 0 and then continue to identify whether the next virtual machine address associated with the first virtual machine is valid. When the number of page fault information stored in the ring buffer in the data processing device's cache reaches a set number, the data processing device sends the page fault information in the cache to the host, and the driver in the host performs page fault processing. After receiving the page fault information, the host can store it in a ring buffer in the host memory, which is used to store a page fault information queue. The driver performs page fault processing on the page fault information in the page fault information queue in turn, assigns a host physical address to the invalid virtual machine address, and creates a mapping relationship between the invalid virtual machine address and the host physical address assigned to it, and adds the newly created mapping relationship to the address mapping information of the page table entry of the first virtual machine stored in the memory space of the first virtual machine.

[0106] In the above-mentioned page fault processing process, when the data processing device identifies an invalid virtual machine address, it does not need to immediately send page fault information to the host and wait for the host's processing result of the page fault information. Instead, it can continue to identify whether the next virtual machine address is valid, thereby saving time waiting for the page fault processing result and improving the page fault processing efficiency and data processing efficiency.

[0107] In some embodiments, the page table entry for the first virtual machine also includes a status bit (flag) for each virtual machine address. The status bit is used to indicate whether the corresponding virtual machine address has been accessed by the data processing device. For example, a status bit of "0" may indicate that the corresponding virtual machine address has not been accessed by the data processing device; a status bit of "1" may indicate that the corresponding virtual machine address has been accessed by the data processing device. The status bit corresponding to the virtual machine address is used during the demapping process of the mapping information, which is described in detail below.

[0108] The data processing device receives data from the first virtual machine, identifies a valid virtual machine address from the idle virtual machine addresses, and after saving the data of the first virtual machine to the valid virtual machine address, may set the data length corresponding to the valid virtual machine address in the page table entry of the first virtual machine to len1, indicating that the data has been saved to the valid virtual machine address and the data length is len1. Furthermore, the data processing device sets a status bit of the valid virtual machine address recorded in the page table entry of the first virtual machine to a used state.

[0109] For example, when the data processing device recognizes that virtual machine address GPA4 is a valid virtual machine address, it can save the data of the first virtual machine to virtual machine address GPA4 and then set the data length corresponding to virtual machine address GPA4 in the page table entry of the first virtual machine to len1. Exemplarily, len1 can be 1000 bytes. As shown in Figure 6, the address mapping table of the first virtual machine includes a page table entry. After the data processing device saves the data of the first virtual machine to virtual machine address GPA4, it can set the data length of virtual machine address GPA4 in the page table entry of the first virtual machine to 1000 and set the status bit of virtual machine address GPA4 recorded in the page table entry to the use state "1". "1" indicates that virtual machine address GPA4 has been accessed by the data processing device.

[0110] When a virtual machine has data to send, the data processing device can read the data from the virtual machine's memory space and then send it. The virtual machine's memory space is located in the host's memory. If the data to be sent has already been stored from the host's memory to external storage, the data processing device will encounter a page fault when reading the data from the virtual machine's memory space.

[0111] When a page fault occurs during data transmission, the interaction process between the data processing device and the host may be as shown in FIG8 , including the following steps:

[0112] S801: When receiving a data sending request from a first virtual machine, a data processing device obtains an address of a target virtual machine for storing data to be sent from the data sending request.

[0113] The first virtual machine may be any virtual machine running on the host. The data sending request of the first virtual machine indicates that the first virtual machine has data to be sent, and the data sending request carries the target virtual machine address of the data to be sent.

[0114] S802: The data processing device obtains first address mapping information of the first virtual machine, and generates second page fault information for the target virtual machine address when determining based on the first address mapping information that the target virtual machine address does not have a corresponding host physical address.

[0115] S803: The data processing device sends second page fault information to the host.

[0116] The data processing device obtains first address mapping information for the first virtual machine and saves it to a cache of the data processing device. The first address mapping information may include mapping information for idle virtual machine addresses and non-idle virtual machine addresses. The first address mapping information may be obtained from an address mapping table for the first virtual machine. The specific process for the data processing device to obtain the first address mapping information can be implemented with reference to the above embodiment and is not further described here.

[0117] The data processing device searches the first address mapping information for the target virtual machine address, and determines, based on the mapping information for the target virtual machine address, whether a corresponding host physical address exists for the target virtual machine address. If the mapping information for the target virtual machine address indicates that the target virtual machine address does not have a corresponding host physical address, the data processing device generates second page fault information for the target virtual machine address and sends the second page fault information to the host.

[0118] In some embodiments, the data processing device may determine, through a DMMU unit, whether a target virtual machine address has a corresponding host physical address.

[0119] Taking the address mapping table shown in Figure 5 as an example, assuming that the target virtual machine address is virtual machine address GPA2, the data processing device can find out by looking up the table that there is no corresponding host physical address for virtual machine address GPA2. The data processing device then generates a second page fault information for virtual machine address GPA2 and sends the second page fault information to the host.

[0120] In other embodiments, if the mapping information for the target virtual machine address in the first address mapping information indicates that a corresponding host physical address exists for the target virtual machine address, the status bit of the target virtual machine address recorded in the page table entry of the first virtual machine is set to an in-use state. For example, assuming the target virtual machine address is virtual machine address GPA3, the data processing device can determine through a table lookup that a corresponding host physical address exists for virtual machine address GPA3. In this case, the data processing device sets the status bit of virtual machine address GPA3 to "1," indicating that virtual machine address GPA3 has been accessed by the data processing device. Furthermore, the data processing device reads the data to be sent from the host physical address corresponding to the target virtual machine address and sends the data to be sent.

[0121] S804: The host obtains the target virtual machine address in the second page fault information, and reads the to-be-sent data stored in the target virtual machine address from the external memory to the host's memory.

[0122] The host receives second page fault information for the target virtual machine address sent by the data processing device. The second page fault information indicates that a page fault occurs when reading data in the target virtual machine address, indicating that the data to be sent stored in the target virtual machine address is not stored in the host's memory, but has been saved to the external memory. Therefore, the target virtual machine address does not have a corresponding host physical address in the host's memory.

[0123] The host can query the physical address corresponding to the target virtual machine address in the external memory, read the data to be sent from the physical address, and then save it to the host's memory.

[0124] In some embodiments, the host may perform page fault processing on the second page fault information through the DMMU driver unit.

[0125] S805: The host updates the mapping information of the target virtual machine address according to the host physical address of the data to be sent stored in the host memory.

[0126] After the host saves the data to be sent in the target virtual machine address to the host's memory, it determines the host physical address where the data to be sent is saved, establishes a correspondence between the host physical address and the target virtual machine address, and updates the mapping information of the target virtual machine address in the address mapping table of the first virtual machine.

[0127] For example, assuming that the target virtual machine address is virtual machine address GPA2, after the host saves the data to be sent in virtual machine address GPA2 to the host's memory, it determines that the host physical address where the data to be sent is saved is GPA15. The host updates the mapping information of virtual machine address GPA2 in the address mapping table of the first virtual machine to: virtual machine address GPA2 corresponds to host physical address GPA15.

[0128] S806: The host sends a page fault processing completion message to the data processing device.

[0129] S807: The data processing device obtains second address mapping information of the first virtual machine from the memory of the host.

[0130] The data processing device receives a page fault handling completion message from the host. The page fault handling completion message carries the target virtual machine address and indicates that page fault handling for the target virtual machine address has been completed. In some embodiments, the data processing device may delete or invalidate the first address mapping information stored in the data processing device's cache and retrieve updated address mapping information from the address mapping table for the first virtual machine stored in the host's memory. To distinguish it from the first address mapping information, the updated address mapping information is referred to as second address mapping information.

[0131] S808: The data processing device reads and sends the data to be sent from the memory of the host based on the second address mapping information.

[0132] In some embodiments, if the data processing device queries the first address mapping information and determines that the target virtual machine address does not have a corresponding host physical address, the data transmission queue of the first virtual machine may be disabled, thereby blocking the transmission of data to be transmitted. The data transmission queue is used to store unsent data in the order in which it is transmitted, and the data transmission queue of the first virtual machine may be located within the data processing device. Disabling the data transmission queue of the first virtual machine can prevent data transmission errors caused by the failure to transmit data corresponding to the target virtual machine address.

[0133] After obtaining the second address mapping information of the first virtual machine from the host, the data processing device may re-enable the data sending queue of the first virtual machine to trigger the retransmission of the blocked data.

[0134] Based on the second address mapping information, the data processing device determines that the target virtual machine address has a corresponding host physical address. The data processing device then sets the status bit of the target virtual machine address recorded in the page table entry of the first virtual machine to the used state. For example, assuming the target virtual machine address is virtual machine address GPA2, and the data processing device determines, based on the second address mapping information, that virtual machine address GPA2 has a corresponding host physical address GPA15, the data processing device sets the status bit of virtual machine address GPA2 to "1," indicating that virtual machine address GPA2 has been accessed by the data processing device. The data processing device then reads the data to be sent from host physical address GPA15 and sends the data to be sent.

[0135] During the above data transmission process, when the data processing device reads data from the host's memory or writes data to the host's memory, it can access the host's memory through the virtual device corresponding to the first virtual machine.

[0136] Through the above steps, in the direct pass scenario, this application can also solve the page missing problem when sending data and ensure the normal progress of the data sending process.

[0137] To improve the effective utilization of host memory, the host can use memory over-allocation to allocate memory to multiple virtual machines. For example, upon receiving a memory request from a second virtual machine and determining that there is insufficient free memory, the host can reclaim some of the memory space allocated to the first virtual machine and reallocate it to the second virtual machine. This is called memory reallocation. The first virtual machine can be any one of the multiple virtual machines, and the second virtual machine can also be any one of the multiple virtual machines.

[0138] During the memory reallocation process, the interaction process between the data processing device and the host can be shown in FIG9 , including the following steps:

[0139] S901: The host determines a to-be-reclaimed virtual machine address of a first virtual machine, and reads a status bit of the to-be-reclaimed virtual machine address in a page table entry of the first virtual machine.

[0140] When the host receives a memory request from the second virtual machine and determines that there is insufficient free memory, it can choose to reclaim part of the memory space allocated to the first virtual machine. Specifically, the host determines to reclaim part of the host physical addresses occupied by the first virtual machine. The host then determines the virtual machine address to be reclaimed corresponding to this portion of the host physical addresses and reads the status bit of the virtual machine address to be reclaimed from the page table entry of the first virtual machine.

[0141] As described above, the status bit of each virtual machine address is used to indicate whether the corresponding virtual machine address has been accessed by the data processing device.

[0142] In some embodiments, the host may use a swap instruction to read the status bit of the to-be-reclaimed virtual machine address. The swap instruction indicates that after reading the status bit of the to-be-reclaimed virtual machine address, the status bit of the to-be-reclaimed virtual machine address is set to an unused state.

[0143] S902: The host determines that the addresses of the virtual machines to be reclaimed include the addresses of the virtual machines to be synchronized whose status bits are in the used state.

[0144] S903: The host sends a data synchronization message for the address of the virtual machine to be synchronized to the data processing device.

[0145] The status bit of the usage status indicates that the corresponding virtual machine address has been accessed by the data processing device. Since these virtual machine addresses are likely still being accessed by the data processing device, to avoid abnormalities in the data processing device's memory access process, the host sends a data synchronization message to the data processing device for the virtual machine address to be synchronized.

[0146] Taking the address mapping table shown in Figure 6 as an example, assuming that the virtual machine addresses to be reclaimed are virtual machine address GPA2, virtual machine address GPA3 and virtual machine address GPA4, wherein the status bit of virtual machine address GPA4 is in use, therefore, virtual machine address GPA4 is the virtual machine address to be synchronized.

[0147] S904: The data processing device sends a synchronization completion message to the host.

[0148] The data processing device receives a data synchronization message sent by the host for the virtual machine address to be synchronized, and determines whether the data processing of the virtual machine address to be synchronized has been completed. If it has been completed, the data processing device sends a synchronization completion message to the host. For example, assuming that the virtual machine address to be synchronized is virtual machine address GPA4, the data processing device has completed the operation of writing data to virtual machine address GPA4, that is, the data processing device has completed the data processing of virtual machine address GPA4, and the data processing device can send a synchronization completion message to the host. If the data processing of the virtual machine address to be synchronized has not been completed, the data processing device will give priority to processing the data in the virtual machine address to be synchronized, and send a synchronization completion message to the host after the processing is completed. In some embodiments, assuming that the data processing of the virtual machine address to be synchronized is an operation of reading the data in the virtual machine address to be synchronized, the data processing device sends a synchronization completion message to the host after completing the operation of reading the data in the virtual machine address to be synchronized.

[0149] For VM addresses whose status bits are unused and waiting to be reclaimed, the host does not need to send data synchronization messages to the data processing device or wait for the data processing device to return a synchronization completion message. This not only reduces signaling overhead but also saves waiting time for the data processing device to return the synchronization completion message. Because VM addresses accessed by the data processing device typically only occupy a small portion of the VM's memory space, this process can save a significant amount of time.

[0150] S905: The host demaps the address of the virtual machine to be reclaimed.

[0151] The host receives the synchronization completion message sent by the data processing device. If the address of the virtual machine to be reclaimed contains data, the host can save the data stored in the address of the virtual machine to external memory and unmap the address of the virtual machine to be reclaimed. Specifically, the host clears the host physical address corresponding to the address of the virtual machine to be reclaimed from the address mapping table of the first virtual machine. The host can then allocate part of the memory space of the reclaimed first virtual machine to the second virtual machine, thereby achieving memory over-allocation.

[0152] For example, based on the address mapping table shown in FIG. 6 , after demapping the virtual machine address GPA2 , the virtual machine address GPA3 , and the virtual machine address GPA4 , the address mapping table shown in FIG. 10 can be obtained.

[0153] In some embodiments, a memory management unit (MMU), a virtual machine management unit, and a driver unit are provided in the host, wherein the virtual machine management unit may also be referred to as a kernel-based virtual machine (KVM) unit, and the driver unit may also be referred to as a DMMU driver unit. The driver unit may be a software module, a hardware module, or a module combining software and hardware, which is not limited in this application. The memory management unit, the virtual machine management unit, and the driver unit may all be provided in the kernel of the host. A dynamic memory allocation process of the host may be shown in FIG11 , and may include the following steps:

[0154] S1, the second virtual machine running in the host sends a memory request to the memory management unit;

[0155] S2, the memory management unit finds that there is insufficient memory and needs to reclaim part of the memory space allocated to the first virtual machine, determines the virtual machine address of the first virtual machine to be reclaimed corresponding to the host physical address of this part of the memory space, and sends a memory reclaim notification to the virtual machine management unit. The memory reclaim notification carries the virtual machine address of the first virtual machine to be reclaimed.

[0156] S3: The virtual machine management unit receives the memory recycling notification, and the service routine in the virtual machine management unit sends a table lookup notification to the driver unit. The table lookup notification carries the address of the first virtual machine to be recycled.

[0157] S4: The driver unit queries the page table entry of the first virtual machine based on the to-be-reclaimed virtual machine address of the first virtual machine to determine whether the to-be-reclaimed virtual machine address includes the to-be-synchronized virtual machine address whose status bit is in use. If the driver unit determines that the to-be-reclaimed virtual machine address includes the to-be-synchronized virtual machine address whose status bit is in use, the driver unit sends a data synchronization message for the to-be-synchronized virtual machine address to the data processing device, where the data synchronization message carries the to-be-synchronized virtual machine address.

[0158] S5. The data processing device receives the data synchronization message and sends a synchronization completion message to the driving unit after completing data processing of the data in the virtual machine address to be synchronized. The synchronization completion message indicates that data processing of the virtual machine address to be synchronized of the first virtual machine has been completed.

[0159] S6. The driving unit transmits the synchronization completion message sent by the data processing device to the virtual machine management unit.

[0160] S7, the virtual machine management unit transmits the synchronization completion message to the memory management unit.

[0161] S8. The memory management unit receives the synchronization completion message, demaps the to-be-reclaimed virtual machine address of the first virtual machine, and reclaims part of the memory space of the first virtual machine.

[0162] S9, the memory management unit allocates the recovered portion of the memory space of the first virtual machine to the second virtual machine, and establishes a mapping relationship between the virtual machine address of the second virtual machine and the host physical address of this portion of the memory space.

[0163] In other embodiments, if the status bits of the to-be-reclaimed virtual machine addresses are all in the unused state, indicating that none of the to-be-reclaimed virtual machine addresses have been accessed by the data processing device, the host can directly demap the to-be-reclaimed virtual machine addresses. In this case, the host does not need to send a data synchronization message to the data processing device, nor does it need to wait for the data processing device to return a synchronization completion message, thus saving time waiting for the data processing device to return a synchronization completion message.

[0164] Since the time waiting for the data processing device to return the synchronization completion message is usually very long, in the above embodiment, a status bit is set for the virtual machine address. By querying the status bit of the virtual machine address, the synchronization waiting time between the host and the data processing device can be greatly reduced, and the efficiency of the demapping process and the dynamic memory allocation process can be improved.

[0165] The method steps in the embodiments of the present application can be implemented by hardware, or by a processor executing a computer program or instruction. The computer program or instruction can constitute a computer program product.

[0166] The present application also provides a computer program product comprising computer-executable instructions. In one embodiment, the computer-executable instructions are used to enable a computer to perform the functions of any of the above method embodiments.

[0167] Computer-executable instructions can be stored in a computer-readable storage medium. The present application also provides a computer-readable storage medium having executable instructions stored therein. In one embodiment, the computer-executable instructions are used to cause a computer to perform the functions of any of the above method embodiments.

[0168] The computer-readable storage medium provided in this application may be a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of computer-readable storage medium known in the art.

[0169] Computer-executable instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium such as a floppy disk, hard disk, or magnetic tape; an optical medium such as a digital video disc (DVD); or a semiconductor medium such as a solid-state drive.

[0170] One or more of the above modules or units can be implemented in software, hardware, or a combination of the two. When any of the above modules or units is implemented in software, the software exists in the form of computer program instructions and is stored in a memory, and the processor can be used to execute the program instructions and implement the above method flow. The processor may include but is not limited to at least one of the following: a CPU, a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or an artificial intelligence processor, etc., and each computing device may include one or more cores for executing software instructions to perform calculations or processing. The processor may be built into an SoC, a DPU or an ASIC, or it may be an independent semiconductor chip. In addition to the core for executing software instructions for calculations or processing within the processor, it may further include necessary hardware accelerators, such as FPGAs, PLDs, or logic circuits for implementing dedicated logic operations.

[0171] When the above modules or units are implemented in hardware, the hardware can be any one or any combination of a CPU, a microprocessor, a DSP, an MCU, an artificial intelligence processor, an ASIC, a SoC, an FPGA, a PLD, a dedicated digital circuit, a hardware accelerator or a non-integrated discrete device, which can run the necessary software or not rely on the software to execute the above method flow.

[0172] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A data processing system, characterized in that: It includes a host computer and a data processing device, wherein: The data processing device is used to obtain a data processing request of a virtual machine running in the host, wherein the data processing request is used to instruct the data processing device to receive data to be processed by the virtual machine; determine a virtual machine address associated with the virtual machine according to the data processing request, and send first page fault information to the host when the virtual machine address is an invalid virtual machine address, wherein the invalid virtual machine address is used to indicate a virtual machine address among virtual machine addresses associated with the virtual machine that does not meet the requirements of the data processing request; The host is used to allocate a host physical address to the virtual machine according to the first page fault information, and the host physical address is used to indicate an address of a memory associated with the invalid virtual machine address.

2. The data processing system according to claim 1, characterized in that The data processing device is also used for: The data length of the stored data in the page table entry corresponding to the invalid virtual machine address is modified to a set value.

3. The data processing system according to claim 1 or 2, characterized in that: The data processing device is specifically used for: Generate first page fault information for the invalid virtual machine address, and save the generated first page fault information to a ring buffer in the data processing device; When the number of first page fault information stored in the ring buffer reaches a set number, the first page fault information stored in the ring buffer is sent to the host.

4. The data processing system according to any one of claims 1 to 3, characterized in that: The data processing device is further used to: receive a data sending request from the virtual machine, obtain a target virtual machine address for storing the data to be sent from the data sending request; if the target virtual machine address is an invalid virtual machine address, send second page fault information for the target virtual machine address to the host; The host is further used to, based on the second page fault information, read the data to be sent stored in the target virtual machine address from the external memory to the internal memory, and establish a mapping relationship between the target virtual machine address and the target host physical address; the target host physical address is the host physical address of the storage unit in the internal memory for storing the data to be sent; The data processing device is also used to: read the data to be sent from the storage unit corresponding to the physical address of the target host, and send the data to be sent.

5. The data processing system according to any one of claims 1 to 4, characterized in that: The page table entry corresponding to the virtual machine address associated with the virtual machine includes a status bit; the status bit is used to indicate whether the corresponding virtual machine address has been accessed by the data processing device.

6. The data processing system according to claim 5, characterized in that: The host is also used to: Determine a virtual machine address to be recycled of the virtual machine; Reading a status bit in a page table entry corresponding to the address of the virtual machine to be recycled; If the status bits of the to-be-reclaimed virtual machine addresses are all in an unused state, the to-be-reclaimed virtual machine addresses are demapped; the unused status bits indicate that the corresponding to-be-reclaimed virtual machine addresses have not been accessed by the data processing device.

7. The data processing system according to claim 6, characterized in that: The host is further configured to: if the to-be-reclaimed virtual machine address includes a to-be-synchronized virtual machine address whose status bit is in use status, send a data synchronization message for the to-be-synchronized virtual machine address to the data processing device; the status bit in use status indicates that the corresponding to-be-reclaimed virtual machine address has been accessed by the data processing device; The data processing device is further configured to, after determining that the processing of the data in the address of the virtual machine to be synchronized has been completed, send a synchronization completion message to the host; The host is further configured to: after receiving a synchronization completion message sent by the data processing device, demap the address of the to-be-reclaimed virtual machine.

8. The data processing system according to claim 7, characterized in that: The host is specifically used for: The status bit in the page table entry corresponding to the address of the virtual machine to be recycled is read by using a swap instruction; the swap instruction indicates that after reading the status bit of the address of the virtual machine to be recycled, the status bit of the address of the virtual machine to be recycled is set to an unused state.

9. A memory dynamic allocation method, characterized in that: Applied to a data processing system, the data processing system includes a host and a data processing device; the method includes: The data processing device obtains a data processing request of the virtual machine running in the host, the data processing request is used to instruct the data processing device to receive the to-be-processed data of the virtual machine; determines a virtual machine address associated with the virtual machine according to the data processing request, and sends first page fault information to the host when the virtual machine address is an invalid virtual machine address, the invalid virtual machine address is used to indicate a virtual machine address that does not meet the requirements of the data processing request among the virtual machine addresses associated with the virtual machine; The host allocates a host physical address to the virtual machine according to the first page fault information, where the host physical address is used to indicate an address of a memory associated with the invalid virtual machine address.

10. A memory dynamic allocation method, characterized in that: Applied to a data processing device connected to a host, the method comprises: Obtaining a data processing request of a virtual machine running in the host; the data processing request is used to instruct the data processing device to receive data to be processed by the virtual machine; Determine a virtual machine address associated with the virtual machine according to the data processing request, and when the virtual machine address is an invalid virtual machine address, send a first page fault message to the host; the invalid virtual machine address is used to indicate a virtual machine address among the virtual machine addresses associated with the virtual machine that does not meet the requirements of the data processing request.

11. The method according to claim 10, characterized in that The method further comprises: receiving a data synchronization message sent by the host; the data synchronization message carries an address of a virtual machine to be synchronized; the address of the virtual machine to be synchronized is a virtual machine address to be recycled of the virtual machine, and the status bit is a virtual machine address in a use state; the status bit in the use state indicates that the corresponding virtual machine address to be recycled has been accessed by the data processing device; After determining that the processing of the data in the address of the to-be-synchronized virtual machine has been completed, a synchronization completion message is sent to the host.

12. A memory dynamic allocation method, characterized in that: Applied to a host, the host being connected to a data processing device, the method comprising: Determine a virtual machine address to be recycled of a virtual machine running in the host; Reading a status bit in a page table entry corresponding to the address of the virtual machine to be recycled; If the status bits of the to-be-reclaimed virtual machine addresses are all in an unused state, demapping the to-be-reclaimed virtual machine addresses; the status bits in the unused state indicate that the corresponding to-be-reclaimed virtual machine addresses have not been accessed by the data processing device; If the address of the virtual machine to be recycled contains the address of the virtual machine to be synchronized whose status bit is in use, a data synchronization message for the address of the virtual machine to be synchronized is sent to the data processing device, and after receiving the synchronization completion message returned by the data processing device, the address of the virtual machine to be recycled is demapped.

13. A computer-readable storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to make a computer execute the method according to any one of claims 10 to 12.

Citation Information

Patent Citations

  • Memory virtualization method and system under Shenwei architecture

    CN112363824A

  • Virtual machine memory management method, device and system and physical machine

    CN113296886A

  • Memory management method and device of virtual machine and electronic equipment

    CN114880074A

  • Link cloning method, system and equipment based on hardware unloading and storage medium

    CN115794296A

  • Fast switching between virtual machines without interrupt virtualization for high-performance, secure trusted-execution enviornment

    US20170185435A1

Cited By

  • Direct storage access method, device and equipment of virtual machine and storage medium

    CN119441074A