Data processing system and memory dynamic allocation method

By identifying invalid virtual machine addresses and generating page fault information through data processing devices, and dynamically allocating host physical addresses, the page fault problem when data processing devices directly access virtual machine memory is solved, thereby improving memory utilization and data processing efficiency.

CN123157410APending Publication Date: 2026-11-24HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611047212.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-28
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In cloud computing scenarios, when data processing devices directly access virtual machine memory, how can page faults be handled to improve memory utilization and data processing efficiency?

Method used

The data processing device identifies invalid virtual machine addresses and generates page fault information, dynamically allocates host physical addresses, reduces the idle state of virtual machine memory, and improves the effective utilization of host memory.

Benefits of technology

It enables dynamic memory allocation when a virtual machine page fault occurs, reducing memory waste and improving the data processing efficiency and memory utilization of data processing devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157410A_ABST
    Figure CN123157410A_ABST
Patent Text Reader

Abstract

A data processing system and a dynamic memory allocation method are disclosed, relating to the field of data storage technology. The data processing system includes a host and a data processing device, with a virtual machine running on the host. The data processing device can determine the virtual machine address associated with the virtual machine. When the virtual machine address is determined to be invalid, it sends a first page fault to the host, enabling the host to allocate a physical address to the virtual machine based on the first page fault information. This solves the page fault problem during direct access to virtual machine memory by the data processing device, allowing the host to allocate memory to the virtual machine only when a page fault occurs, rather than allocating fixed memory at creation time, thus achieving dynamic memory allocation. Furthermore, it reduces the phenomenon of a large portion of memory remaining idle for extended periods after a virtual machine requests memory, improving the effective utilization of host memory.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application. The original application has the application number 202310492993.8 and the original application date is April 28, 2023. The entire contents of the original application are incorporated herein by reference. Technical Field

[0002] This application relates to the field of data storage technology, and in particular to a data processing system and a method for dynamic memory allocation. Background Technology

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

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

[0005] In scenarios where virtual devices in the aforementioned data processing equipment can directly access the corresponding virtual machine memory, how to handle page faults is a problem that urgently needs to be solved. Summary of the Invention

[0006] This application provides a data processing system and a dynamic memory allocation method that can solve the page fault problem during the process of data processing devices directly accessing virtual machine memory.

[0007] In a first aspect, a data processing system is provided, which includes a host and data processing devices, wherein a virtual machine runs on the host.

[0008] After receiving a data processing request from a virtual machine, the data processing device can determine the 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 the data to be processed from the virtual machine. When the virtual machine address is invalid, a first page fault message is sent to the host. The invalid virtual machine address indicates a virtual machine address among the associated virtual machine addresses that does not meet the requirements of the data processing request.

[0009] The host allocates a host physical address to the virtual machine based on the first page fault information. The host physical address is used to indicate the memory address associated with the invalid virtual machine address.

[0010] The data processing system provided in this application allows the data processing device to determine the virtual machine address associated with a virtual machine. When the virtual machine address is determined to be invalid, a first page fault message is sent to the host, enabling the host to allocate a physical address to the virtual machine based on the first page fault message. This solves the page fault problem that occurs when the data processing device directly accesses the virtual machine's memory. The host does not need to allocate fixed memory to the virtual machine during creation; instead, it can allocate memory when a page fault occurs, thus enabling dynamic memory allocation. Furthermore, it reduces the phenomenon of a large portion of the virtual machine's memory remaining idle for extended periods after requesting memory, improving the effective utilization of host memory.

[0011] In one possible implementation, the data processing device can obtain mapping information of virtual machine addresses associated with virtual machines from the host's memory. This mapping information indicates whether a corresponding virtual machine address has a corresponding host physical address. Based on this mapping information, the data processing device can identify whether a virtual machine address is valid or invalid. 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.

[0012] In one possible implementation, the data processing device can identify valid and invalid virtual machine addresses in the following way: The first virtual machine address among the free virtual machine addresses associated with the virtual machine is taken as the virtual machine address to be identified; where a free virtual machine address refers to a virtual machine address whose corresponding storage unit does not contain data. Repeat the following steps until a valid virtual machine address is obtained: If the mapping information of the virtual machine address to be identified indicates that there is no corresponding host physical address for the virtual machine address to be identified, then the virtual machine address to be identified is determined to be an invalid virtual machine address, and a first page fault is generated for the virtual machine address to be identified. Take the next virtual machine address in the free virtual machine addresses associated with the virtual machine to be identified as the new virtual machine address to be identified; 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, then the virtual machine address to be identified is determined to be a valid virtual machine address.

[0013] In the above embodiments, 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 to process the page fault information. Instead, it can continue to identify a valid virtual machine address from the free virtual machine addresses. Therefore, it can save the time that the data processing device spends waiting for the host to process the page fault and return the page fault processing result, thereby improving the data processing efficiency of the data processing device.

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

[0015] In one possible implementation, when the data processing device determines that the address of the virtual machine to be identified is an invalid virtual machine address, it can generate a first page fault for the invalid virtual machine address and save the generated first page fault to a circular buffer in the data processing device.

[0016] In one possible implementation, when the number of first page fault messages stored in the circular buffer reaches a predetermined number, the data processing device can send the first page fault messages stored in the circular buffer to the host. The predetermined number can be determined based on the capacity of the circular buffer, and can be equal to or less than the capacity of the circular buffer.

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

[0018] The data processing device can send the first page fault information to the host in batches. Compared with sending the first page fault information to the host one by one, it can not only save time, but also save mutual signaling.

[0019] In one possible implementation, the data processing device can also be used to receive data transmission requests from virtual machines, obtain the target virtual machine address for storing the data to be transmitted from the data transmission 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.

[0020] The host can also be used to read the data to be sent stored in the target virtual machine address from external storage into memory based on the second page fault information, 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 memory used to store 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 target host physical address and send the data to be sent.

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

[0022] In one possible implementation, if the target virtual machine address does not have a corresponding host physical address, the data processing device can disable the virtual machine's data sending queue; the data sending queue is used to store unsent data in the order of transmission. After obtaining the mapping relationship between the target virtual machine address and the target host physical address from the host, the data processing device can re-enable the virtual machine's data sending queue to ensure normal data transmission.

[0023] In one possible implementation, 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.

[0024] In one possible implementation, the host can also be used to: after determining the address of the virtual machine to be reclaimed, read the status bits in the page table entry corresponding to the address of the virtual machine to be reclaimed; if all the status bits of the address of the virtual machine to be reclaimed are in an unused state, then perform demapping processing on the address of the virtual machine to be reclaimed. The unused status bits indicate that the corresponding address of the virtual machine to be reclaimed has not been accessed by the data processing device.

[0025] If all the status bits of the virtual machine addresses to be reclaimed are in an unused state, it means that none of the virtual machine addresses to be reclaimed have been accessed by the data processing device. In this case, the host can directly perform demapping on the virtual machine addresses to be reclaimed. 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, saving time spent waiting for the data processing device to return a synchronization completion message. Since the waiting time for the data processing device to return a synchronization completion message is usually very long, the above embodiment sets status bits for the virtual machine addresses. By querying the status bits of the virtual machine addresses, the synchronization waiting time between the host and the data processing device can be significantly reduced, improving the efficiency of the demapping process, the dynamic memory allocation process, and memory over-allocation.

[0026] In one possible implementation, if the address of the virtual machine to be reclaimed contains a virtual machine address to be synchronized that is in a "used" state, the host sends a data synchronization message to the data processing device for that virtual machine address. The "used" state indicates that the corresponding virtual machine address to be reclaimed has been accessed by the data processing device. After determining that it has completed processing the data in the virtual machine address to be synchronized, the data processing device sends a synchronization completion message to the host. Upon receiving the synchronization completion message from the data processing device, the host performs demapping processing on the virtual machine address to be reclaimed to ensure the normal operation of the data processing device's data processing operations.

[0027] In one possible implementation, the host can use a swap instruction to read the status bit in the page table entry corresponding to the address of the virtual machine to be reclaimed; the swap instruction instructs that after reading the status bit of the address of the virtual machine to be reclaimed, the status bit of the address of the virtual machine to be reclaimed be set to the unused state.

[0028] Secondly, a dynamic memory allocation method is provided, which can be applied to the data processing system described in the first aspect. The method involves a data processing device acquiring a data processing request from a virtual machine running on a host machine. The data processing request instructs the data processing device to receive data to be processed from the virtual machine. Based on the data processing request, a virtual machine address associated with the virtual machine is determined. When the virtual machine address is invalid, a first page fault message is sent to the host machine. The invalid virtual machine address indicates a virtual machine address among the associated virtual machine addresses that does not meet the requirements of the data processing request. The host machine allocates a host physical address to the virtual machine based on the first page fault message. The host physical address indicates the memory address associated with the invalid virtual machine address.

[0029] Thirdly, a method for dynamic memory allocation is provided, which can be applied to data processing devices connected to a host, including: Obtain data processing requests from virtual machines running on the host machine; data processing requests are used to instruct data processing devices to receive data to be processed from the virtual machines. The virtual machine address associated with the virtual machine is determined based on the data processing request. When the virtual machine address is invalid, a first page fault message is sent to the host. The invalid virtual machine address is used to indicate the virtual machine address among the virtual machine addresses associated with the virtual machine that does not meet the requirements of the data processing request.

[0030] Fourthly, a dynamic memory allocation method is provided for use in a host computer, including: Determine the address of the virtual machine to be reclaimed from the host machine; Read the status bits from the page table entry corresponding to the address of the virtual machine to be reclaimed; If all the status bits of the virtual machine address to be reclaimed are in an unused state, then the virtual machine address to be reclaimed will be de-mapped; the unused status bits indicate that the corresponding virtual machine address to be reclaimed has not been accessed by the data processing device. If the address of the virtual machine to be reclaimed contains the address of the virtual machine to be synchronized whose status bit is in use, a data synchronization message for the virtual machine address 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 de-mapped.

[0031] Fifthly, a memory dynamic allocation apparatus is provided, the memory dynamic allocation apparatus comprising modules for executing the memory dynamic allocation method provided in the third aspect.

[0032] In a sixth aspect, a memory dynamic allocation apparatus is provided, the memory dynamic allocation apparatus comprising modules for executing the memory dynamic allocation method provided in the fourth aspect.

[0033] In a seventh aspect, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, the computer-executable instructions being used to cause a computer to perform the operational steps of any of the methods provided in the third or fourth aspect above.

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

[0035] Based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods. Attached Figure Description

[0036] Figure 1 A schematic diagram of the structure of a data processing system provided in this application; Figure 2 This application provides an interaction diagram between a host and a data processing device during the data reception process; Figure 3 A schematic diagram of an address mapping table for a virtual machine provided in this application; Figure 4 A schematic diagram of a page table entry for a virtual machine provided in this application; Figure 5 A schematic diagram of an address mapping table for another virtual machine provided in this application; Figure 6 A schematic diagram of an address mapping table for another virtual machine provided in this application; Figure 7 A logical diagram illustrating a page fault handling process provided in this application; Figure 8 This application provides an interaction diagram between a host and a data processing device during data transmission. Figure 9 This application provides an interaction diagram between the host and the data processing device during the demapping process; Figure 10 A schematic diagram of an address mapping table for another virtual machine provided in this application; Figure 11 This is a logical diagram illustrating a demapping process provided in this application. Detailed Implementation

[0037] To facilitate understanding, some of the terms used in this application will be explained first.

[0038] (1) Data processing equipment: Used to offload some functions of the host processor. For example, high-performance data processing functions that are not suitable for central processing unit processing in network, storage or operating system can be offloaded to data processing equipment to free up the computing power of the host processor. Data processing equipment may include, but is not limited to, computing units with offloading functions such as data processing unit (DPU), infrastructure processing unit (IPU), intelligent network interface card (iNIC) or smart network interface card (smartNIC).

[0039] (2) Memory Over-allocation: The total memory space allocated by the host to virtual machines exceeds the actual available physical memory space of the host. For example, suppose the total physical memory space of the host is 10GB, and there are 8 virtual machines running on the host. The host allocates 2GB of memory space to each virtual machine. In this case, the total memory space allocated by the host to the virtual machines is 16GB, which exceeds the total physical memory space of the host by 10GB. This phenomenon is called memory over-allocation. In the memory over-allocation scenario, a portion of the 2GB memory space allocated by the host to a virtual machine may not correspond to actual physical memory space. That is, a virtual machine has a virtual machine address of 2GB, but a portion of the virtual machine address does not correspond to a physical address on the host.

[0040] (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 storage units. For example, a ring buffer may include 10 end-to-end storage units. Data is stored into each storage unit sequentially. After data is saved to the 10th storage unit, if the first storage unit is idle, the next data can be saved to the first storage unit.

[0041] (4) Virtual machine (VM): is an operating system that runs on a computing device. VM can access the host’s external hardware resources, such as network cards and storage devices, just like a physical machine.

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

[0043] (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). A portion of the memory space associated with the virtual machine address may not correspond to actual physical memory space.

[0044] (7) Page Fault: The address mapping table of a virtual machine 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 an associated host physical address. These virtual machine addresses can be called invalid virtual machine addresses. The data processing device identifies invalid virtual machine addresses by looking up the address mapping table of the virtual machine, indicating that the invalid virtual machine address does not correspond to an actual physical memory space in the host's memory. This phenomenon is called a page fault.

[0045] The data processing system and dynamic memory allocation method provided in this application are described below with reference to the accompanying drawings.

[0046] The dynamic memory allocation method provided in this application can be applied to... Figure 1 In the application scenarios shown. Figure 1 A schematic diagram of the structure of a data processing system 100 is shown. Figure 1As shown, the data processing system 100 may include a host 100 and a data processing device 130. The data processing system 100 can receive and process data input by a user. For example, the data processing system 100 can receive data input by a user through a client, which can be deployed on the user's terminal device. The terminal device may include, but is not limited to, a personal computer, mobile phone, tablet computer, or smart vehicle terminal. The data processing system 100 can also process data transmitted via a network from other computing devices.

[0047] The host 110 is the computing and control core of the data processing system 100. The host 110 can be a central processing unit (CPU) or other specific integrated circuits. The host 110 can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0048] The memory 120 in the host 110 is typically 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 be Dynamic Random Access Memory (DRAM). Besides DRAM, the memory 120 can also be other random access memories, such as Static Random Access Memory (SRAM). Alternatively, the memory 120 can also be Read Only Memory (ROM). For example, a read only memory could be a programmable read only memory (PROM) or an erasable programmable read only memory (EPROM). This embodiment does not limit the number or type of memory 120.

[0049] In some embodiments, the host 110 may further include an input / output (I / O) interface. The I / O interface is used to communicate with devices located outside the host 110. For example, a terminal device can input data to the host 110 through the I / O interface, and after processing the input data, the host 110 can send the processing result of the data back to the terminal device through the I / O interface.

[0050] Optionally, for persistent data storage, the data processing system also includes an external storage device 140. The external storage device 140 can be located outside the host 110 and exchanges data with the host 110 via an I / O interface or network. Alternatively, the external storage device 140 can be located inside the host and exchanges data with the processor 110 via a bus. Unlike the host 110's memory, the external storage device 140 can be, but is not limited to, a hard disk.

[0051] One or more virtual machines can run on processor 110; virtual machines can also be called guests. For example, Figure 1 The host 110 shown in the diagram runs virtual machines 111 and 112. Memory 120 is used to store the input data to be processed by each virtual machine, as well as the data processing results. Each virtual machine has its own memory space within memory 120. Taking virtual machine 111 as an example, when virtual machine 111 is created, host 110 allocates corresponding memory space for virtual machine 111 within memory 120. Virtual machine 111 can access this memory space, read the data to be processed from it, and save the data processing results to this memory space. When host 110 cleans up memory, the data to be processed or the data processing results of virtual machine 111 stored in memory 120 can be transferred to external storage 140.

[0052] The data processing device 130 is used to offload some functions of the host 110 to save computing power and improve the performance of the host 110. In some embodiments, the data processing device 130 can be directly plugged into a 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 by a compute express link (CXL), Universal Serial Bus (USB) protocol, or other protocol buses. The data processing device 130 has direct memory access (DMA) capability and can directly access the memory 120 in the host 110.

[0053] In a cloud virtualization scenario, when multiple virtual machines run on host 110, data processing device 130 can also be virtualized into multiple virtual devices through Single Root I / O Virtualization (SR-IOV) technology. SR-IOV enables virtualization at the hardware level, allowing one hardware device to generate 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 data processing device 130 can be allocated to the corresponding virtual machine through the Virtual Function I / O (VFIO) framework. Each virtual device has Direct Memory Access (DMA) capability, allowing direct access to the memory space of the corresponding virtual machine. Virtual machines running on host 110 can send and receive data through the corresponding virtual devices.

[0054] 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 data is received 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.

[0055] Before the virtual device corresponding to the virtual machine saves the received data to the virtual machine's memory space, the data processing device can determine the host physical address used to store the data by looking up address mapping information. Address mapping information stores the correspondence between virtual machine addresses and host physical addresses; the host physical address is the physical address in the host's memory. If the data processing device determines that a certain virtual machine address does not have a corresponding host physical address when looking up address mapping information, this phenomenon is called a page fault.

[0056] When page faults occur, the interaction process between the data processing device and the host can be as follows: Figure 2 As shown, it includes the following steps: S201, when the data processing device receives data from the first virtual machine, it obtains the address mapping information of the first virtual machine.

[0057] The first virtual machine can be any virtual machine running on the host. The data received by the data processing device from the first virtual machine 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 through the network, or it can be data input by the user to the first virtual machine. Upon receiving the data from the first virtual machine, the data processing device can save the data to the memory space of the first virtual machine, which is located in the host's memory; alternatively, after receiving the data from 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 within the data processing device.

[0058] When saving data for the first virtual machine, the data processing device obtains the address mapping information of the first virtual machine. The address mapping information includes the mapping information of the free virtual machine addresses of the first virtual machine. Here, a free virtual machine address refers to a memory location corresponding to that virtual machine address where no data is stored. In some embodiments, the address mapping information can be obtained from the address mapping table of the first virtual machine. The address mapping table of the first virtual machine is stored in the host's memory, and the address mapping table can store the mapping relationship between the virtual machine addresses of the first virtual machine and the host's 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 can be as follows: Figure 3 As shown, each virtual machine address in the address mapping table corresponds to one mapping record. 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.

[0059] Data can be stored in the host's memory in the form of memory pages. Each virtual machine address corresponds to one memory page. Some memory pages contain data, while others may not.

[0060] In some embodiments, the host's memory may also store page table entries (PTEs) of the first virtual machine. These PTEs may store whether data is stored at each virtual machine address of the first virtual machine, and the length (len) of the stored data. For example, as shown... Figure 4 As shown, the virtual machine address GPA3 of the first virtual machine stores data with a length of 1000 bytes; the virtual machine address GPA4 of the first virtual machine stores data with a length of 0 bytes, which can also be understood as the virtual machine address GPA4 of the first virtual machine storing no data. From Figure 4 As can be seen, the memory cell corresponding to the virtual machine address GPA3 of the first virtual machine contains data, and virtual machine address GPA3 is a non-idle virtual machine address. The memory cell corresponding to the virtual machine address GPA4 of the first virtual machine currently does not contain data, and 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 circular buffer.

[0061] In one optional embodiment, the data processing device can determine the address of an idle virtual machine 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.

[0062] In another alternative 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 address mapping information. In the subsequent step of finding valid virtual machine addresses, the device then determines which virtual machine addresses in the address mapping information are free virtual machine addresses based on the content stored in the page table entries.

[0063] It should be noted that in some embodiments, the address mapping table and page table entries of the first virtual machine stored in the host's memory can be two separate tables. In other embodiments, the address mapping table and page table entries of the first virtual machine can be unified in a single table. For example... Figure 5 As shown, the address mapping table of the first virtual machine stored in the host's memory may include page table entries of the first virtual machine.

[0064] S202, the data processing device identifies an invalid virtual machine address and generates a first page fault message for the invalid virtual machine address.

[0065] The data processing device identifies invalid and valid virtual machine addresses from the idle virtual machine addresses. Invalid virtual machine addresses refer to virtual machine addresses for which there is no corresponding host physical address in the mapping information, while valid virtual machine addresses refer to virtual machine addresses for which there is a corresponding host physical address in the mapping information.

[0066] The process by which a data processing device searches for a valid virtual machine address can be called an addressing process. During this process, the data processing device can use the first virtual machine address from the available virtual machine addresses as the address to be identified, and repeatedly perform the following operations: It determines whether the address to be identified has a corresponding host physical address. If no corresponding host physical address exists, the address to be identified is determined to be an invalid virtual machine address, and a first page fault is generated for that address. This first page fault is then temporarily stored in a circular buffer. The next virtual machine address from the available virtual machine addresses is then used as the new address to be identified. If a corresponding host physical address exists for the address to be identified, the address to be identified is determined to be a valid virtual machine address, and the repeated operation stops.

[0067] In some embodiments, when the data processing device determines that the virtual machine address to be identified is an invalid virtual machine address, it can set the data length corresponding to the virtual machine address to be identified in the page table entry of the first virtual machine to a preset value. For example, the preset value can be 0, indicating that data of length 0 has already been saved to the virtual machine address to be identified, so the virtual machine address to be identified can be skipped and the next free virtual machine address can be queried for validity.

[0068] For example, suppose that Figure 5 The address mapping table shown serves as the address mapping information for the first virtual machine. During addressing, the data processing device first uses the first virtual machine address in the free virtual machine address pool, GPA1, as the virtual machine address to be identified. It then determines whether GPA1 has a corresponding host physical address. If GPA1 is determined to be an invalid virtual machine address, a first page fault is generated for GPA1, and this first page fault information is temporarily stored in a circular buffer. A data saving completion message for GPA1 is then sent to the first virtual machine, indicating that the first virtual machine has saved data of length 0 to GPA1. Next, the next free virtual machine address, GPA2, is used as the virtual machine address to be identified. It then determines whether GPA2 has a corresponding host physical address. If GPA2 is determined to be an invalid virtual machine address, a first page fault is generated for GPA2, and this first page fault information is temporarily stored in a circular buffer. A data saving completion message for GPA2 is then sent to the first virtual machine, indicating that the first virtual machine has saved data of length 0 to GPA2. Then, the next available virtual machine address, GPA4, is used as the address of the virtual machine to be identified. It is determined whether GPA4 has a corresponding host physical address. If it is determined that GPA4 has a corresponding host physical address, HPA2, then GPA4 is used as a valid virtual machine address.

[0069] In some embodiments, when a data processing device determines that the address to be identified is an invalid virtual machine address, it can invalidate the mapping information of the address to be identified stored in the cache of the data processing device, so as to avoid using the mapping information of the address to be identified again for addressing in subsequent processes and obtaining incorrect addressing results.

[0070] S203, the data processing device saves the data of the first virtual machine to the valid virtual machine address.

[0071] When the data processing device receives data from the first virtual machine, it also receives the data storage address of that data, which can be understood as a logical address. After identifying a valid virtual machine address, the data processing device 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.

[0072] S204, the data processing device sends the first page fault information to the host.

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

[0074] In one optional embodiment, when the number of first page fault messages stored in the circular buffer reaches a predetermined number, the data processing device transmits the first page fault messages stored in the circular buffer to the host. The predetermined number can be determined based on the capacity of the circular buffer, and can be equal to or less than the capacity of the circular buffer. For example, when the capacity of the circular buffer is 10, the predetermined number can be 10. That is, when the generated first page fault messages fill the circular buffer, any further generated first page fault messages cannot be stored in the circular buffer. At this point, the data processing device can transmit the first page fault messages stored in the circular buffer to the host.

[0075] In another alternative embodiment, when a valid virtual machine address is identified from the free virtual machine addresses, the data processing device can transmit the first page fault information stored in the circular buffer to the host.

[0076] During 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.

[0077] S205, the host saves the first page fault information to the page fault information queue, and processes the first page fault information in the page fault information queue in turn.

[0078] When the host receives one or more first page fault messages from the data processing device, it saves these messages to a page fault queue, and processes them all at once when the host has free time. The page fault queue can also use a circular buffer to store page fault information.

[0079] During page fault handling, the host can sequentially allocate 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 allocated to the invalid virtual machine address. For example, the updated address mapping table can be as follows: Figure 6 As shown, from Figure 6 As can be seen, the host physical address assigned to virtual machine address GPA1 is HPA11, and the host physical address assigned to virtual machine address GPA2 is HPA22. Figure 5 or Figure 6 The address mapping table shown can also be called the DMMU page table.

[0080] In some embodiments, the data processing device includes a dynamic memory management unit (DMMU), which can identify invalid and valid virtual machine addresses. The DMMU can be a software module, a hardware module, or a combination of both; this application does not limit the specific type of DMMU.

[0081] In some embodiments, the host can handle page faults via a driver. For example, such as... Figure 7As shown, the data processing device can identify invalid virtual machine addresses from the virtual machine addresses associated with the first virtual machine through the DMMU unit. When the DMMU unit identifies an invalid virtual machine address, it generates page fault information for that address and saves the page fault information to the circular buffer in the data processing device's cache. The DMMU unit also modifies the page table entries of the virtual machine addresses associated with the first virtual machine. The page table entries of the virtual machine addresses associated with the first virtual machine can be stored in the circular 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 in the page table entry corresponding to the invalid virtual machine address to 0, and then continue to identify whether the next virtual machine address is valid from the virtual machine addresses associated with the first virtual machine. When the number of page fault information stored in the circular 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, where the driver performs page fault processing. After receiving the page fault information, the host can store it in the circular buffer in the host's memory, which is used to store the page fault information queue. The driver sequentially processes page fault information in the page fault information queue, allocates host physical addresses to invalid virtual machine addresses, and establishes a new mapping relationship between invalid virtual machine addresses and the allocated host physical addresses. The newly established mapping relationship is added to the address mapping information of the page table entries of the first virtual machine stored in the memory space of the first virtual machine.

[0082] In the page fault handling process described above, 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 to process the page fault information. Instead, it can continue to identify whether the next virtual machine address is valid. Therefore, it can save the time of waiting for the page fault handling result and improve the page fault handling efficiency and data processing efficiency.

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

[0084] The data processing device receives data from the first virtual machine, identifies a valid virtual machine address from the available virtual machine addresses, saves the data of the first virtual machine to that valid virtual machine address, and then sets the data length corresponding to that valid virtual machine address in the page table entry of the first virtual machine to len1, indicating that data has been saved to that valid virtual machine address with a data length of len1. Furthermore, the data processing device sets the status bit of that valid virtual machine address recorded in the page table entry of the first virtual machine to "in use".

[0085] For example, when the data processing device identifies virtual machine address GPA4 as 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. For example, len1 can be 1000 bytes. Figure 6 As shown, the address mapping table of the first virtual machine includes page table entries. After the data processing device saves the data of the first virtual machine to the virtual machine address GPA4, it can set the data length of the virtual machine address GPA4 in the page table entry of the first virtual machine to 1000, and set the status bit of the virtual machine address GPA4 recorded in the page table entry to the usage status "1". "1" indicates that the virtual machine address GPA4 has been accessed by the data processing device.

[0086] When a virtual machine has data to be sent, the data processing device can read the data from the virtual machine's memory space and then send it. Since the virtual machine's memory space resides in the host's memory, if the data to be sent has already been stored from the host's memory to external storage, a page fault will occur when the data processing device tries to read the data from the virtual machine's memory space.

[0087] When a page fault occurs during data transmission, the interaction between the data processing device and the host can be as follows: Figure 8 As shown, it includes the following steps: S801, when the data processing device receives a data transmission request from the first virtual machine, it obtains the address of the target virtual machine used to store the data to be transmitted from the data transmission request.

[0088] The first virtual machine can be any virtual machine running on the host. The data transmission request of the first virtual machine indicates that the first virtual machine has data to be transmitted, and the data transmission request carries the address of the target virtual machine to which the data is to be transmitted.

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

[0090] S803, the data processing device sends a second page fault message to the host.

[0091] The data processing device obtains the first address mapping information of the first virtual machine and saves it to the cache of the data processing device. The first address mapping information may include mapping information of free virtual machine addresses and non-free virtual machine addresses, and the first address mapping information may be obtained from the address mapping table of the first virtual machine. The specific process of the data processing device obtaining the first address mapping information can be implemented with reference to the above embodiment, and will not be repeated here.

[0092] The data processing device searches for the mapping information of the target virtual machine address in the first address mapping information, and determines whether the target virtual machine address has a corresponding host physical address based on the mapping information. If the mapping information of 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 a second page fault information for the target virtual machine address and sends the second page fault information to the host.

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

[0094] by Figure 5 Taking the address mapping table shown as an example, assuming 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. Then, the data processing device generates a second page fault information for virtual machine address GPA2 and sends the second page fault information to the host.

[0095] In other embodiments, if the mapping information of the target virtual machine address in the first address mapping information indicates that the target virtual machine address has a corresponding host physical address, then the status bit of the target virtual machine address recorded in the page table entry of the first virtual machine is set to the used state. For example, assuming the target virtual machine address is virtual machine address GPA3, the data processing device can find out by looking up the table that virtual machine address GPA3 has a corresponding host physical address. Therefore, 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.

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

[0097] The host receives a second page fault message for the target virtual machine address sent by the data processing device. The second page fault message indicates that a page fault occurred when reading data from the target virtual machine address. This means that the data to be sent stored in the target virtual machine address is not stored in the host's memory, but has been stored in external storage. Therefore, the target virtual machine address does not have a corresponding host physical address in the host's memory.

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

[0099] In some embodiments, the host can process the second page fault information through the DMMU driver unit.

[0100] S805: The host updates the mapping information of the target virtual machine address based on the host physical address of the data to be sent stored in the host's memory.

[0101] After the host saves the data to be sent from the target virtual machine address to the host's memory, it determines the physical address of the host that stores the data to be sent, establishes the 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.

[0102] For example, assuming the target virtual machine address is virtual machine address GPA2, after the host saves the data to be sent from virtual machine address GPA2 to the host's memory, it determines that the host physical address storing the data to be sent is GPA15. The host then 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.

[0103] S806, the host sends a page fault completion message to the data processing device.

[0104] S807, the data processing device obtains the second address mapping information of the first virtual machine from the host's memory.

[0105] The data processing device receives a page fault completion message from the host. This message carries the target virtual machine address, indicating that page fault handling for that address has been completed. In some embodiments, the data processing device may delete or invalidate the first address mapping information stored in its cache and retrieve the updated address mapping information from the address mapping table of 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 the second address mapping information.

[0106] S808, the data processing device reads and sends data to be sent from the host's memory based on the second address mapping information.

[0107] 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, it can disable the data transmission queue of the first virtual machine, blocking the continued transmission of data that needs to be sent. The data transmission queue is used to store unsent data in the order of transmission, and the data transmission queue of the first virtual machine can 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 send data corresponding to the target virtual machine address.

[0108] After obtaining the second address mapping information of the first virtual machine from the host, the data processing device can re-enable the data transmission queue of the first virtual machine and trigger the retransmission of blocked data.

[0109] Based on the second address mapping information, the data processing device determines that the target virtual machine address has a corresponding host physical address. It then sets the status bit of the target virtual machine address recorded in the page table entry of the first virtual machine to "used". For example, assuming the target virtual machine address is virtual machine address GPA2, and the data processing device determines that virtual machine address GPA2 has a corresponding host physical address GPA15 based on the second address mapping information, 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 the host physical address GPA15 and sends the data.

[0110] During the aforementioned data transmission process, when the data processing device reads data from 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.

[0111] Through the above steps, this application can also solve the page fault problem when sending data in a pass-through scenario, ensuring the normal operation of the data transmission process.

[0112] To improve the efficient utilization of host memory, the host can use memory over-allocation to allocate memory to multiple virtual machines. For example, when the host receives a memory request from a second virtual machine and determines that there is insufficient free memory, it can choose to reclaim some memory space already allocated to the first virtual machine and reallocate it to the second virtual machine. This can be called a memory reallocation process. The first virtual machine can be any one of multiple virtual machines, and the second virtual machine can also be any one of multiple virtual machines.

[0113] During memory reallocation, the interaction between the data processing device and the host can be as follows: Figure 9 As shown, it includes the following steps: S901, the host determines the address of the virtual machine to be reclaimed in the first virtual machine and reads the status bit of the address of the virtual machine to be reclaimed in the page table entry of the first virtual machine.

[0114] 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 a portion of the memory space already allocated to the first virtual machine. In other words, the host determines to reclaim a portion of the host physical addresses occupied by the first virtual machine. At this point, the host can determine the virtual machine address to be reclaimed corresponding to this portion of the host physical address and read the status bit of the virtual machine address to be reclaimed from the page table entry of the first virtual machine.

[0115] As mentioned above, the status bits of each virtual machine address are used to indicate whether the corresponding virtual machine address has been accessed by the data processing device.

[0116] In some embodiments, the host may use a swap instruction to read the status bits of the virtual machine address to be reclaimed. The swap instruction instructs that after reading the status bits of the virtual machine address to be reclaimed, the status bits of the virtual machine address to be reclaimed be set to an unused state.

[0117] S902, the host determines that the address of the virtual machine to be reclaimed contains the address of the virtual machine to be synchronized whose status bit is in use.

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

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

[0120] by Figure 6 Taking the address mapping table shown as an example, assume the addresses of the virtual machines to be reclaimed are virtual machine address GPA2, virtual machine address GPA3, and virtual machine address GPA4. Among them, the status bit of virtual machine address GPA4 is the usage status; therefore, virtual machine address GPA4 is the address of the virtual machine to be synchronized.

[0121] S904, the data processing device sends a synchronization completion message to the host.

[0122] The data processing device receives a data synchronization message from the host for the virtual machine address to be synchronized. It determines whether the data processing for the virtual machine address to be synchronized has been completed. If completed, the data processing device sends a synchronization completion message to the host. For example, assuming the virtual machine address to be synchronized is virtual machine address GPA4, and the data processing device has completed the operation of writing data to virtual machine address GPA4, i.e., the data processing device has completed the data processing for virtual machine address GPA4, the data processing device can send a synchronization completion message to the host. If the data processing for the virtual machine address to be synchronized has not yet been completed, the data processing device prioritizes processing the data in the virtual machine address to be synchronized and sends a synchronization completion message to the host after processing is complete. In some embodiments, assuming the data processing for the virtual machine address to be synchronized is an operation of reading data from 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 data from the virtual machine address to be synchronized.

[0123] For virtual machine addresses awaiting reclaiming that are in an unused state, 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. This saves both signaling overhead and the time spent waiting for the data processing device to return a synchronization completion message. Since virtual machine addresses accessed by the data processing device typically only occupy a small portion of the virtual machine's memory space, this process can save a significant amount of time.

[0124] S905, the host performs demapping processing on the addresses of virtual machines to be reclaimed.

[0125] Upon receiving the synchronization completion message from the data processing device, if the address of the virtual machine to be reclaimed contains data, the host can save the data to external storage and unmap the address of the virtual machine to be reclaimed, that is, clear 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. Then, the host can allocate part of the memory space of the reclaimed first virtual machine to the second virtual machine, thereby achieving memory over-allocation.

[0126] For example, in Figure 6 Based on the address mapping table shown, after demapping virtual machine address GPA2, virtual machine address GPA3, and virtual machine address GPA4, we can obtain... Figure 10 The address mapping table shown.

[0127] In some embodiments, the host includes a memory management unit (MMU), a virtual machine management unit (VM unit), and a driver unit. The VM unit can also be called a kernel-based virtual machine (KVM) unit, and the driver unit can be called a DMMU driver unit. The driver unit can be a software module, a hardware module, or a combination of software and hardware; this application does not limit this. The memory management unit, VM unit, and driver unit can all be located within the host kernel. A dynamic memory allocation process for the host can be as follows: Figure 11 As shown, it includes the following steps: S1, the second virtual machine running on the host sends a memory request to the memory management unit; S2, the memory management unit detects insufficient memory and needs to reclaim a portion of the memory space already allocated to the first virtual machine. It determines the virtual machine address of the first virtual machine corresponding to the host physical address of this portion of memory space and sends a memory reclamation notification to the virtual machine management unit. The memory reclamation notification carries the virtual machine address of the first virtual machine to be reclaimed.

[0128] S3, the virtual machine management unit receives a memory reclamation notification, and the service routine in the virtual machine management unit sends a table lookup notification to the driver unit, which carries the address of the virtual machine to be reclaimed for the first virtual machine.

[0129] S4, the driver unit queries the page table entry of the first virtual machine based on the address of the virtual machine to be reclaimed, and determines whether the address of the virtual machine to be reclaimed contains a virtual machine address to be synchronized whose status bit is in use. When the driver unit determines that the address of the virtual machine to be reclaimed contains a virtual machine address to be synchronized whose status bit is in use, it sends a data synchronization message for the virtual machine address to be synchronized to the data processing device, and the data synchronization message carries the address of the virtual machine to be synchronized.

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

[0131] S6, the drive unit transmits the synchronization completion message sent by the data processing device to the virtual machine management unit.

[0132] S7, the Virtual Machine Management Unit will synchronously complete the message transmission to the Memory Management Unit.

[0133] S8, the memory management unit receives the synchronization completion message, performs demapping on the virtual machine address to be reclaimed in the first virtual machine, and reclaims part of the memory space of the first virtual machine.

[0134] S9, the memory management unit allocates a portion of the memory space of the first virtual machine that has been reclaimed 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 memory space.

[0135] In other embodiments, if all the status bits of the virtual machine addresses to be reclaimed are in an unused state, it means that none of the virtual machine addresses to be reclaimed have been accessed by the data processing device. In this case, the host can directly perform demapping processing on 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, which can save the time of waiting for the data processing device to return a synchronization completion message.

[0136] Since the time for waiting for the data processing device to return a synchronization completion message is usually very long, the above embodiment sets a status bit 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.

[0137] The method steps in the embodiments of this application can be implemented in hardware or by a processor executing a computer program or instructions. The computer program or instructions can constitute a computer program product.

[0138] This application also provides a computer program product comprising computer-executable instructions. In one embodiment, the computer-executable instructions are used to cause a computer to perform the functions described in any of the above method embodiments.

[0139] Computer-executable instructions can be stored in a computer-readable storage medium. This application also provides a computer-readable storage medium storing executable instructions. In one embodiment, the computer-executable instructions are used to cause a computer to perform the functions described in any of the above method embodiments.

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

[0141] 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 a computer can access, 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; it can also be an optical medium, such as a digital video disc (DVD); or it can be a semiconductor medium, such as a solid-state drive (SSD).

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

[0143] When the above modules or units are implemented in hardware, the hardware can be any one or any combination of CPU, microprocessor, DSP, MCU, artificial intelligence processor, ASIC, SoC, FPGA, PLD, special purpose digital circuit, hardware accelerator or non-integrated discrete device, which can run the necessary software or perform the above method flow independently of software.

[0144] The above description is merely a specific embodiment of this application, but the scope of protection of this 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 this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data processing system, characterized by Includes host and data processing equipment, among which, The data processing device is configured to acquire a data processing request from a virtual machine running on the host, the data processing request being used to instruct the data processing device to receive data to be processed from the virtual machine; determine the virtual machine address associated with the virtual machine based on the data processing request; and when the virtual machine address is an invalid virtual machine address, send a first page fault information 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 is configured to allocate a host physical address to the virtual machine based on the first page fault information, wherein the host physical address is used to indicate the address of memory associated with the invalid virtual machine address.

2. The data processing system of claim 1, wherein, The data processing device is also used for: Modify the length of the saved data in the page table entry corresponding to the invalid virtual machine address to the set value.

3. The data processing system according to claim 1 or 2, characterized in that, The data processing device is specifically used for: A first page fault is generated for the invalid virtual machine address, and the generated first page fault is saved to the circular buffer in the data processing device. When the number of first page fault information stored in the circular buffer reaches a set number, the first page fault information stored in the circular 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 configured to: receive a data transmission request from the virtual machine, obtain the target virtual machine address for storing the data to be transmitted from the data transmission request; 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; The host is further configured 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 into the 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 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 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 for: Determine the address of the virtual machine to be reclaimed; Read the status bits from the page table entry corresponding to the address of the virtual machine to be reclaimed; If all the status bits of the virtual machine address to be reclaimed are in an unused state, then the virtual machine address to be reclaimed is de-mapped; the unused status bits indicate that the corresponding virtual machine address to be reclaimed has 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 address of the virtual machine to be reclaimed contains a virtual machine address to be synchronized whose status bit is in use, then send a data synchronization message to the data processing device for the virtual machine address to be synchronized; the status bit of the use status indicates that the corresponding virtual machine address to be reclaimed has been accessed by the data processing device; The data processing device is further configured to send a synchronization completion message to the host after determining that the processing of the data in the virtual machine address to be synchronized has been completed. The host is also used to: after receiving the synchronization completion message sent by the data processing device, perform demapping processing on the virtual machine address to be reclaimed.

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

9. A method for dynamic memory allocation, characterized in that, The method is applied to a data processing system, which includes a host and data processing devices; the method includes: The data processing device acquires a data processing request from a virtual machine running on the host. The data processing request instructs the data processing device to receive the data to be processed from the virtual machine. The device determines the virtual machine address associated with the virtual machine based on the data processing request. When the virtual machine address is an invalid virtual machine address, the device sends a first page fault message to the host. The invalid virtual machine address indicates 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 information. The host physical address is used to indicate the memory address associated with the invalid virtual machine address.

10. A method for dynamic memory allocation, characterized in that, The method, applied to a data processing device connected to a host, includes: Obtain a data processing request from a virtual machine running on the host; the data processing request is used to instruct the data processing device to receive the data to be processed from the virtual machine; The virtual machine address associated with the virtual machine is determined according to the data processing request. When the virtual machine address is an invalid virtual machine address, a first page fault information is sent to the host. The invalid virtual machine address is used to indicate the virtual machine address 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 includes: The system receives a data synchronization message sent by the host; the data synchronization information carries the address of the virtual machine to be synchronized; the address of the virtual machine to be synchronized is the address of the virtual machine to be reclaimed, and the status bit is the address of the virtual machine in the usage state; the status bit of the usage state indicates that the corresponding address of the virtual machine to be reclaimed has been accessed by the data processing device. After confirming that the processing of the data in the virtual machine address to be synchronized has been completed, a synchronization completion message is sent to the host.

12. A method for dynamic memory allocation, characterized in that, Applied to a host computer connected to a data processing device, the method includes: Determine the address of the virtual machine to be reclaimed in the host machine; Read the status bits from the page table entry corresponding to the address of the virtual machine to be reclaimed; If all the status bits of the virtual machine address to be reclaimed are in an unused state, then the virtual machine address to be reclaimed is de-mapped; the unused status bits indicate that the corresponding virtual machine address to be reclaimed has not been accessed by the data processing device. If the virtual machine address to be reclaimed contains a virtual machine address to be synchronized whose status bit is in use, then a data synchronization message for the virtual machine address to be synchronized is sent to the data processing device. After receiving the synchronization completion message returned by the data processing device, the virtual machine address to be reclaimed is de-mapped.

13. A computer-readable storage medium, characterized in that, The device stores computer-executable instructions for causing a computer to perform the method as described in any one of claims 10 to 12.