Memory processing method and related device

By actively reclaiming unmapped memory in virtual devices and pre-allocating memory mappings for pass-through, the problem of balancing memory reclamation efficiency and performance loss in virtualization scenarios is solved, improving memory super-allocation efficiency and performance, and is suitable for memory management of virtual machines and cloud containers.

WO2026007587A1PCT designated stage Publication Date: 2026-01-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/097799
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-07-05
Filing Date
2025-05-28
Publication Date
2026-01-08

AI Technical Summary

Technical Problem

In virtualization scenarios, during the memory over-allocation process of virtual devices, existing technologies cannot effectively balance memory reclamation efficiency and data pass-through performance loss, resulting in long memory reclamation time or high performance loss.

Method used

By obtaining load information from virtual devices, the system memory that has not undergone direct memory access mapping is proactively reclaimed, and memory reclamation instructions are sent to the target physical device. A portion of memory is pre-allocated for data pass-through, avoiding frequent mapping, improving memory reclamation efficiency and reducing performance loss.

Benefits of technology

It enables efficient memory reclamation in virtual devices, improves memory over-allocation efficiency, reduces performance loss, and ensures stable operation of virtual devices. It is suitable for memory over-allocation scenarios in virtual machines and cloud containers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025097799_08012026_PF_FP_ABST
    Figure CN2025097799_08012026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in embodiments of the present application are a memory processing method and a related device. The method comprises: during operation of a first virtual device, acquiring load information of the first virtual device; when usage information of a first system memory comprised in the load information satisfies a memory reclamation condition, determining a target reclamation amount on the basis of the usage information of the first system memory; according to the target reclamation amount, reclaiming, into a memory manager in the first virtual device, the first system memory that is reclaimable in the first virtual device, wherein the first system memory is managed by the memory manager in the first virtual device and is not subjected to direct memory access mapping, and the memory manager supports pre-allocating a portion of the first system memory to be subjected to the direct memory access mapping for data transparent transmission; and sending a memory reclamation instruction to a target physical device, so that the target physical device reclaims the first system memory from the memory manager. In this way, memory reclamation efficiency can be improved, and performance loss can also be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Memory processing method and related device

[0001] The present application claims priority to the Chinese patent application No. 202410903907.2, filed on July 5, 2024, and entitled "Memory processing method and related device", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the technical field of computers, and in particular to a memory processing method and related device. BACKGROUND

[0003] In a virtualization scenario, memory overcommit of a virtual device (i.e., a virtual machine) is an important memory management technology. Memory overcommit refers to that the total amount of physical memory of a physical device (i.e., a host) is less than the sum of memory configurations of each virtual device on the physical device. It allows multiple virtual devices to share the physical memory of the physical device, that is, in the case that the physical memory of the physical device is insufficient to meet the memory requirements of all virtual devices, more virtual devices can be supported to run, while there is generally free memory inside the virtual device, which can be recycled to the physical device and allocated to other virtual devices on the physical device for use, thereby improving the memory utilization of the physical device and realizing memory overcommit. However, in the current memory processing mechanism, in some virtual devices supporting data transparent transmission, the free memory in the virtual device cannot be efficiently recycled in order to ensure low performance loss, so that the time consumption of memory overcommit is long; while in the case that the free memory in the virtual device supports efficient recycling, data transparent transmission will have high performance loss; thus, the virtual device supporting data transparent transmission cannot well balance the efficiency of memory recycling and the performance loss caused by data transparent transmission. SUMMARY

[0004] The embodiments of the present application provide a memory processing method and related device, which can improve the memory recycling efficiency and reduce the performance loss caused by data transparent transmission.

[0005] In one aspect, the embodiments of the present application provide a memory processing method, which comprises:

[0006] In the running process of the first virtual device, load information of the first virtual device is acquired, the load information comprising usage information of a first system memory; the first virtual device runs in a target physical device, and the first system memory is a system memory allocated to the first virtual device by the target physical device; the first system memory is managed by a memory manager in the first virtual device, and is not executed for direct memory access mapping; the memory manager supports pre-allocating part of the first system memory to perform direct memory access mapping, so as to be used for data transparent transmission between the first virtual device and the target physical device;

[0007] determining the target reclaim amount according to the usage information of the first system memory when the usage information of the first system memory satisfies a memory reclaim condition;

[0008] reclaiming, according to the target reclaim amount, the first system memory that supports being reclaimed in the first virtual device to the memory manager in the first virtual device;

[0009] sending a memory reclaim instruction to the target physical device, the memory reclaim instruction being used to instruct the target physical device to reclaim the first system memory from the memory manager in the first virtual device.

[0010] In an aspect, an embodiment of the present application provides a memory processing apparatus, which comprises:

[0011] an obtaining unit, configured to obtain load information of a first virtual device in a running process of the first virtual device, the load information comprising usage information of a first system memory; the first virtual device runs in a target physical device; the first system memory is a system memory allocated by the target physical device to the first virtual device; the first system memory is managed by a memory manager in the first virtual device and is not mapped for direct memory access; the memory manager supports pre-allocating part of the first system memory to perform direct memory access mapping, which is used for data transparent transmission between the first virtual device and the target physical device;

[0012] a processing unit, configured to: determine a target reclaim amount according to the usage information of the first system memory when the usage information of the first system memory satisfies a memory reclaim condition; and reclaim, according to the target reclaim amount, the first system memory that supports being reclaimed in the first virtual device to the memory manager in the first virtual device;

[0013] a transceiving unit, configured to send a memory reclaim instruction to the target physical device, the memory reclaim instruction being used to instruct the target physical device to reclaim the first system memory from the memory manager in the first virtual device.

[0014] In an aspect, an embodiment of the present application provides a computer device, which comprises:

[0015] a processor, adapted to execute a computer program;

[0016] a computer readable storage medium, the computer readable storage medium storing the computer program, the computer program being executed by the processor to implement the memory processing method as described above.

[0017] Correspondingly, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being loaded and executed by a processor to implement the memory processing method as described above.

[0018] Correspondingly, the embodiment of the present application provides a computer program product, which comprises computer programs or computer instructions, and the computer programs or computer instructions are executed by a processor to implement the above memory processing method.

[0019] In the embodiment of the present application, the first virtual device can determine whether to perform active memory recovery based on the usage information of the first system memory included in the load information of the first virtual device. Since the first system memory is the system memory allocated to the first virtual device and no direct memory access mapping is performed, when the first system memory is recovered, it can be ensured that no memory is in the direct memory access mapping state, avoiding the need to perform demapping when memory is recovered, thereby improving the memory recovery efficiency. In addition, the first system memory managed by the memory manager supports allocating part of the first system memory to perform direct memory access mapping, which is used for data transparent transmission between the first virtual device and the target physical device. By preparing the memory to be used in advance when data transparent transmission is performed, it can avoid frequent execution of direct memory access mapping, improve the data transparent transmission efficiency, and reduce the performance loss of the first virtual device. In addition, when the memory recovery condition is met, the first virtual device recovers the internal recyclable first system memory, which can avoid the problems of operating system freezing and high latency caused by recycling non-recyclable memory in the first virtual device, and ensure the running performance of the first virtual device. Through the target recovery amount, the memory allocation pressure after the memory is recycled to the target physical device is limited. Furthermore, the first virtual device sends a memory recovery instruction to the target physical device to actively notify the target physical device to recycle the idle first system memory from the first virtual device. In this way, if multiple virtual devices are running in the target physical device, the target physical device does not need to monitor each virtual device, but the virtual device actively notifies the target physical device when there is idle system memory, so that the memory recovery can be further efficiently performed and the time consumption of memory overcommitment can be reduced. BRIEF DESCRIPTION OF DRAWINGS

[0020] FIG. 1 is an architecture diagram of a memory processing system according to an example embodiment of the present application;

[0021] FIG. 2 is a flow diagram of a memory processing method according to an example embodiment of the present application;

[0022] FIG. 3 is a flow diagram of a memory recovery according to an example embodiment of the present application;

[0023] FIG. 4 is a flow diagram of a memory processing method according to an example embodiment of the present application;

[0024] FIG. 5 is a flow diagram of memory dynamic adjustment according to an example embodiment of the present application;

[0025] Figure 6 is a flow diagram of a memory processing method according to an example embodiment of the present application;

[0026] Figure 7 is a flow diagram of a memory dynamic adjustment method according to an example embodiment of the present application;

[0027] Figure 8 is an interaction flow diagram of a memory processing method according to an example embodiment of the present application;

[0028] Figure 9 is a structural diagram of a memory processing apparatus according to an example embodiment of the present application;

[0029] Figure 10 is a structural diagram of a computer device according to an example embodiment of the present application. DETAILED DESCRIPTION

[0030] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the scope of the present application.

[0031] The application provides a memory processing scheme, which relates to a memory processing system, a method and related equipment. In the scheme, a first virtual device can obtain load information of itself during running, and the load information includes usage information of a first system memory. The first system memory is a system memory allocated to the first virtual device by a target physical device and not subjected to direct memory access mapping (i.e. DMA mapping). The first system memory is managed by a memory manager in the first virtual device. When the usage information of the first system memory meets memory recovery conditions, the first virtual device can actively recover the recoverable first system memory in the first virtual device to the memory manager, and send a memory recovery instruction to the target physical device, so that the target physical device recovers the idle first system memory from the memory manager in the first virtual device. In this way, on the one hand, when the first system memory is recovered, the application can ensure that the recovered first system memory is not in the direct memory access mapping state, avoiding the need to perform demapping when the memory is recovered, thereby improving the memory recovery efficiency; and through the target recovery amount, the memory allocation pressure after the memory is recovered to the target physical device is also limited. On the other hand, the first virtual device actively informs the target physical device to recover the idle first system memory from the first virtual device. If the target physical device runs multiple virtual devices, the target physical device can not rely on the monitoring of each virtual device, but the virtual device actively informs the target physical device when there is idle memory, so that the memory can be more efficiently recovered. In addition, the memory manager supports pre-allocating part of the first system memory to perform DMA mapping, so as to be used for data transparent transmission between the first virtual device and the target physical device. By pre-preparing the memory required for data transparent transmission, frequent direct memory access mapping can be avoided, the efficiency of data transparent transmission is improved, and the performance loss of the first virtual device is reduced.

[0032] The target physical device refers to a physically existing physical computer (for example, a cloud server or a terminal) in the real world. One or more virtual devices can be created in the target physical device through virtualization software (also referred to as a virtual device manager or a Hypervisor, for example, VMware, Hyper-V); each virtual device is a virtual computer (i.e., a virtual machine instance). Among them, the virtual machine (VM) is a software-simulated computer system that provides an environment isolated from physical hardware for users. Through virtualization, the processor, memory, storage, and network resources of the physical computer can be abstracted into multiple virtual resources to enable multiple operating systems and application programs to run on the physical computer. An operating system (Guest OS, virtual operating system / guest operating system; such as a Linux system) can be installed and run in each virtual device. In the case where there are virtual devices in the target physical device, the operating system installed in the target physical device can be referred to as a host operating system (i.e., Host OS; such as a Windows system), which is used to carry the virtual devices, and the resource allocation (such as memory allocation) of each virtual device is completed on the host operating system. The virtual devices that have been created in the target physical device can be started and run based on corresponding start instructions, and the first virtual device refers to one of the at least one virtual device that is running in the target physical device. It should be noted that the terms "first", "second", and the like in this application are used to distinguish the same items or similar items with basically the same function, and it should be understood that there is no logical or time sequence dependency between "first", "second", and "nth", and the number and execution order are not limited. The term "at least one" in this application refers to one or more, and the meaning of "multiple" is two or more; for example: at least one virtual machine refers to one, two, or two or more virtual machines.

[0033] The target physical device can allocate a corresponding amount of system memory to the first virtual device based on the memory configuration of the first virtual device, thereby ensuring the normal operation of the first virtual device and the operation of the application program in the first virtual device. For example, if the memory configuration of the first virtual device is 4G (G is GB, which represents the size of the memory), 4G of physical memory can be allocated from the target physical device for the first virtual device to use, so that the amount of memory of the system memory available in the first virtual device is 4G. The system memory of the first virtual device is the memory space that can be used by the operating system of the first virtual device, which simulates the function of the physical memory, so that the first virtual device can run the operating system and the application program as on the physical device. The system memory allocated to the first virtual device is part of the physical memory of the target physical device, which can be isolated and allocated through virtualization technology. The system memory is usually used to store some data (referred to as runtime data) that needs to be loaded immediately when the program in the first virtual device is executed. It can be understood that if the target physical device also allocates system memory to the second virtual device, for the sake of description, the system memory allocated to the second virtual device can be referred to as the second system memory and no DMA mapping is performed.

[0034] The first virtual device and the target physical device support data pass-through, which means that the first virtual device and the target physical device can transmit data without the central processing unit. The data pass-through includes a direct memory access (DMA) operation, which is a computer technology that allows external devices to directly access the main memory (such as the first virtual device directly accessing the corresponding physical memory) without the intervention of the CPU. Before performing the DMA operation, DMA mapping of the system memory is also required, which is an important concept in virtualization technology, allowing pass-through devices to bypass the CPU and directly write or read data from the memory. The system memory that has performed DMA mapping remains in the "pin" (or "locked") state, and when the system memory is "pinned", it will always remain in the physical memory and will not be swapped to the disk or other storage devices. If all the system memory allocated to the first virtual device is pre-executed DMA mapping, even if there is free memory, the host cannot efficiently reclaim it, but needs to first perform DMA unmapping on the free first system memory that has performed DMA mapping, so that the memory is un-pinned and can be reclaimed by other virtual devices, which will result in low memory resource utilization and affect the efficiency of memory overprovisioning. In the present application, by pre-executing DMA mapping on part of the first system memory, on the one hand, it can be directly used for DMA operation without frequent DMA mapping, reducing performance loss. On the other hand, since part of the first system memory has performed DMA mapping, the first system memory that has not performed DMA mapping can be directly reclaimed if there is free memory and it meets the reclaiming conditions, without wasting resources and time on memory unmapping.

[0035] Since the actual usage of the first system memory by the first virtual device during normal operation of the first virtual device can be less than the memory configuration, free first system memory can exist in the first virtual device, and the free first system memory can be recycled to the target physical device to be allocated to other virtual devices. For example, the free first system memory in the first virtual device can be recycled to the target physical device and then allocated to the second virtual device. In this way, memory over-provisioning of the virtual device can be achieved. Moreover, the free first system memory is not in the DMA mapping state, and thus the recycling speed of the free first system memory can be further accelerated, and the efficiency of memory over-provisioning can be improved. Based on this, the memory processing scheme provided in the present application can be applied to the following scenarios: memory over-provisioning of a virtual machine and cloud container over-provisioning relying on virtualization technology. For example, a cloud service provider can provide cloud computing, cloud storage and other services for a large number of service users, each service user can apply for a corresponding amount of memory to ensure the normal operation of the cloud service, but in the actual use process, there can be free parts in the corresponding amount of memory applied by the service user, therefore, the cloud service provider can recycle part of the free memory according to the actual use condition, and allocate it to other service users for use, thereby improving the resource utilization rate of the cloud server and providing more flexible and economical cloud services.

[0036] It should be noted that the term "module" or "unit" in the present application refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory) or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of an integral module or unit that includes the functions of the module or unit.

[0037] The present application relates to cloud technology, in particular to cloud computing in cloud infrastructure technology. Among them, cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software and network in a wide area network or local area network to realize data calculation, storage, processing and sharing. Cloud computing is a computing mode that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services according to needs. The network providing resources is called "cloud". The resources in the "cloud" are infinitely expandable to users and can be obtained at any time, used on demand, expanded at any time, and paid according to use. As a basic capability provider of cloud computing, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) is established, a plurality of types of virtual resources are deployed in the resource pool, and external customers can select and use them. The cloud computing resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, network devices. For example, the first virtual device in the present application is a virtual resource in the cloud computing resource pool.

[0038] The architecture of the memory processing system provided by the embodiment of the present application will be introduced below with reference to the drawings.

[0039] Please refer to FIG. 1, which is an architecture diagram of a memory processing system according to an example embodiment of the present application. As shown in FIG. 1, the memory processing system includes a target physical device and K virtual devices (virtual device V1, virtual device V2, …, and virtual device Vk). K is a positive integer, and at least one of the K virtual devices is running in the target physical device. Each virtual device is carried by an operating system (i.e., a host operating system) of the target physical device and is managed by a virtual device manager on the host operating system. The operating system of each virtual device can communicate with the operating system of the target physical device, and a memory manager runs in the operating system of each virtual device. The target physical device can be a terminal or a server. The terminal includes, but is not limited to, a smartphone, a tablet computer, a smart wearable device, a smart voice interaction device, a smart home appliance, a personal computer, a vehicle terminal, a smart camera, and the like. The number of terminal devices is not limited in the present application. The server can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms, but is not limited thereto. The number of servers is not limited in the present application.

[0040] The following describes the general process of memory processing by taking the first virtual device (virtual device V1) running on the target physical device as an example.

[0041] ①During the running of the first virtual device (i.e., virtual device V1), the first virtual device can obtain its load information, which can include the usage information of the first system memory, and the first system memory is managed by a memory manager in the first virtual device. The first system memory is the system memory allocated to the first virtual device by the target physical device and is not executed for direct memory access mapping. The first system memory managed by the memory manager supports pre-allocating part of the first system memory for direct memory access mapping, which is used for data transparent transmission between the first virtual device and the target physical device.

[0042] It can be understood that all the system memory allocated to the first virtual device can not be subjected to DMA mapping first, but managed by the memory manager, i.e., all the allocated system memory is the first system memory. The first system memory managed by the memory manager supports pre-allocation of a part of the first system memory to perform direct memory access mapping, and the part of the first system memory subjected to the direct memory access mapping is no longer managed by the memory manager, but managed by other special modules (such as a memory mapping pool).

[0043] In an implementation manner, the first virtual device can acquire load information of the first virtual device at a preset period. By periodically acquiring the load information of the first device, the load information of the first virtual device can be monitored, so as to determine whether to actively reclaim memory based on the usage information of the first system memory included in the load information.

[0044] ②The first virtual device determines whether the memory reclaim condition is met based on the usage information of the first system memory. In the case that the usage information of the first system memory meets the memory reclaim condition, the target reclaim amount can be determined according to the usage information of the first system memory, and the first system memory supporting being reclaimed in the first virtual device is reclaimed to the memory manager in the first virtual device according to the target reclaim amount. The target reclaim amount can be used to control the memory amount of the reclaimable memory reclaimed internally by the first virtual device, and the memory allocation pressure can be controlled considering the load information of the first virtual device.

[0045] ③The first virtual device sends a memory reclaim instruction to the target physical device, and the target physical device can reclaim the first system memory from the memory manager in the first virtual device after receiving the memory reclaim instruction. It can be understood that the first system memory reclaimed here is the first system memory in the idle state in the memory manager, and the first system memory reclaimed internally in the first virtual device to the memory manager is the first system memory in the usage state, and these memories are also in the idle state after being reclaimed to the memory manager.

[0046] ④The second virtual device (such as the virtual device V3) sends a memory usage request to the target physical device, and the target physical device confirms the existence of the memory usage demand of the second virtual device after receiving the memory usage request, so as to allocate the first system memory reclaimed from the first virtual device to the second virtual device for use.

[0047] For the four parts, in the part ①, it is supported to pre-allocate part of the memory from the first system memory managed by the memory manager to perform the direct memory access mapping, the memory in the first system memory which has performed the direct memory access mapping can be used to realize the data transparent transmission between the first virtual device and the target physical device. In the recycling step involved in the part ②, the memory of the first system memory with the size indicated by the target recycling amount can be recycled to the memory manager of the first virtual device according to the target recycling amount, and the recycled part of the memory in the first system memory is managed by the memory manager of the first virtual device, and the recycled part of the memory is no longer used for the data transparent transmission between the first virtual device and the target physical device. In the further recycling step involved in the part ③, the target physical device can perform the recycling processing on the idle memory available for recycling in the first system memory according to the indication of the memory recycling instruction, and the recycled idle memory can be allocated to a new virtual device, and after the target physical device completes the recycling of the idle memory, the target physical device can perform the reallocation when the new memory usage demand occurs in the part ④. In this way, the dynamic management of the system memory is realized.

[0048] In an implementation manner, the second virtual device triggers a page fault exception when the system memory is needed, and then the target physical device can allocate the system memory for the second virtual device. The page fault exception herein refers to that the memory address accessed by the operating system of the second virtual device is missing in the page table, wherein the page table is used to record the memory address of the second system memory which has been mapped with the physical memory of the target physical device, and the memory address is a virtual memory space address.

[0049] It is worth noting that each virtual device can perform the memory recycling logic shown in the parts ①-③ or the memory request logic shown in the part ④. If multiple virtual devices (such as the virtual device V1 and the virtual device V2) running on the target physical device can actively send the memory recycling instruction to the target physical device when there is idle system memory, the target physical device can recycle the idle system memory from the memory manager in the corresponding virtual device based on the memory recycling instruction, so that the virtual device with the memory usage demand can be allocated to the corresponding memory for use from the target physical device. Since not all of the system memory allocated to the first virtual device has performed the DMA mapping, but part of the first system memory has performed the DMA mapping, even if the first virtual device has the transparent device, all the memory does not need to be pinned, but the idle memory can be recycled at any time, so that the memory over-provisioning of the virtual device with the transparent device can be effectively supported, the memory of each virtual device is dynamically allocated, and the performance loss is controllable.

[0050] Next, the memory processing method provided by the embodiment of the present application is introduced.

[0051] Please refer to Fig. 2, which is a flowchart of a memory processing method according to an example embodiment of the present application. The memory processing method can be performed by a first virtual device (e.g., the first virtual device in Fig. 1), and can include the following.

[0052] S201, during the running of the first virtual device, obtaining load information of the first virtual device, the load information including usage information of a first system memory.

[0053] The first virtual device runs in a target physical device; the target physical device runs at least one virtual device, and the first virtual device is any one of the at least one virtual device. The at least one virtual device running in the target physical device is managed by a virtual device manager in the target physical device, the virtual device manager can be invoked by the target physical device and allocate a system memory to the first virtual device based on the memory configuration of the first virtual device.

[0054] The first system memory is a system memory allocated to the first virtual device by the target physical device; and is not executed direct memory access mapping, the first system memory is managed by a memory manager in the first virtual device. The first virtual device is installed with an operating system (i.e., a guest operating system, Guest OS), and the memory manager runs on the operating system (Guest OS) of the first virtual device. For the first system memory managed by the memory manager, the following (1) and (2) features can be included:

[0055] (1) The state of the first system memory managed by the memory manager can dynamically change.

[0056] The state of the first system memory managed by the memory manager can include at least one of the following: an idle state and a usage state. According to the state of the first system memory, the first system memory managed by the memory manager can include at least one of the following: idle first system memory and allocated first system memory. The idle first system memory refers to the first system memory in the idle state, i.e., the first system memory not allocated to any process or service in the first virtual device for use; the allocated first system memory refers to the first system memory in the usage state, e.g., the first system memory used for caching data. Moreover, the memory manager has different management permissions for the first system memory in different states, for example, the memory manager has allocation permission for the first system memory in the idle state, but has no allocation permission for the first system memory in the usage state. When the idle first system memory is allocated to a process in the first virtual device for use, the state of the idle first system memory can change to the usage state.

[0057] (2) The memory amount of the first system memory managed by the memory manager can dynamically change.

[0058] In one implementation, a portion of the first system memory managed by the memory manager can be allocated and DMA mapping can be performed on the allocated first system memory to obtain a mapped memory. The mapped memory is the first system memory in a DMA mapping state, or the first system memory after the DMA mapping is performed. Since the allocated first system memory is no longer managed by the memory manager after the DMA mapping is performed, the memory amount of the first system memory managed by the memory manager decreases. In another implementation, the system memory that has been DMA mapped can be de-mapped. The de-mapped system memory can be used as the first system memory and managed by the memory manager, and thus the memory amount of the first system memory managed by the memory manager increases.

[0059] The memory manager supports pre-allocation of a portion of the first system memory for DMA mapping, for data pass-through between the first virtual device and the target physical device. That is, a portion of the system memory allocated to the first virtual device can be allocated from the memory manager and DMA mapped, for data pass-through between the first virtual device and the target physical device. In a specific implementation, the system memory allocated to the first virtual device by the target physical device is managed by the memory manager and is not DMA mapped. In one embodiment, the first virtual device includes a memory mapping pool, and the memory mapping pool can request memory from the memory manager according to the memory requirement of the memory mapping pool. The memory manager can allocate a portion of the first system memory managed by the memory manager and perform DMA mapping on the allocated portion of the first system memory. The first system memory that has been DMA mapped is referred to as a mapped memory. After the allocated portion of the first system memory is DMA mapped, the portion of the first system memory is no longer managed by the memory manager, but is managed by the memory mapping pool (DMA pool) in the first virtual device.

[0060] A portion of the first system memory can be allocated and DMA mapped. The portion of the first system memory that has been DMA mapped is referred to as a mapped memory, and the mapped memory can be used for data pass-through between the first virtual device and the target physical device.

[0061] In one embodiment, the first virtual device can be started and run in the target physical device based on a start instruction. During the running of the first virtual device, the first virtual device can obtain load information of the first virtual device at a preset period (e.g., 1 second, 1 minute). Since the processes or services running in the first virtual device are dynamically changed, the load information obtained at different times is also dynamically changed.

[0062] The load information includes usage information of the first system memory. The usage information of the first system memory is used to indicate usage of the first system memory by various processes in the first virtual device, such as how much of the first system memory is used, how much of the first system memory is left, how long the first system memory is spent on allocation to processes, and the like. Optionally, the usage information of the first system memory can include: usage amount of the first system memory, time spent on allocation of the first system memory, I / O interface delay corresponding to the first system memory. The usage amount of the first system memory refers to the amount of the first system memory in a used state in the first system memory managed by a memory manager. The I / O interface delay corresponding to the first system memory refers to the time for which the first virtual device waits for completion of an I / O operation when reading and writing data using the first system memory. The memory allocation time of the first system memory refers to the time difference from a service request in the first virtual device for allocating the first system memory to successful allocation of the first system memory to the service. The first virtual device can determine whether the usage information of the first system memory included in the load information satisfies a memory recovery condition each time the first virtual device obtains the load information of the first virtual device, and then perform corresponding processing based on different determination results.

[0063] S202, when the usage information of the first system memory satisfies the memory recovery condition, determining a target recovery amount according to the usage information of the first system memory.

[0064] In an implementation manner, the usage information of the first system memory includes at least one of: ① usage amount of the first system memory; ② I / O interface delay corresponding to the first system memory; and ③ memory allocation time of the first system memory. Based on the content included in the usage information of the first system memory, the usage information of the first system memory satisfying the memory recovery condition refers to at least one of: ④ the usage amount of the first system memory is less than or equal to a first preset usage amount; ⑤ the I / O interface delay corresponding to the first system memory is less than or equal to a first preset delay; and ⑥ the memory allocation time of the first system is less than or equal to a preset allocation time. The first preset usage amount, the first preset delay, and the preset allocation time can be set by a service provider according to the minimum service demand of the first virtual device, or set by the first virtual device according to a preset pressure threshold.

[0065] It should be noted that if the usage information of the first system memory includes ①-③, the usage information of the first system memory meeting the memory recycling condition refers to any one or more of ④-⑥; if the usage information of the first system memory includes any one of ①-③, the usage information of the first system memory meeting the memory recycling condition refers to any one of ④-⑥. For example, if the usage information of the first system memory includes ①, the usage information of the first system memory meeting the memory recycling condition refers to ④. If the usage information of the first system memory includes any two of ①-③, the usage information of the first system memory meeting the memory recycling condition can include at least one of any two of ④-⑥. For example, if the usage information of the first system memory includes ① and ②, the usage information of the first system memory meeting the memory recycling condition can be one or both of ④ and ⑤.

[0066] When the usage information of the first system memory meets the memory recycling condition, it indicates that the memory allocation pressure in the first virtual device is small, so that the target recycling amount can be determined based on the usage information of the first system memory, and the recyclable first system memory in the first virtual device can be recycled to the internal memory manager according to the target recycling amount.

[0067] In an implementable manner, the load information of the first system memory further includes demand information of the first system memory and a reference recycling amount of the first system memory, and the reference recycling amount is a memory amount of the recycled first system memory. The reference recycling amount can also be referred to as a recyclable amount. For example, if the reference recycling amount of the first system memory is 3 MB, it indicates that there is 3 MB of first system memory in the first system memory in the use state to support recycling. Wherein, MB is a storage capacity unit, specifically, a megabyte. The first virtual device can first determine the recycling ratio of the first system memory according to the usage information of the first system memory and the demand information of the first system memory, and then determine the target recycling amount according to the recycling ratio of the first system memory and the reference recycling amount of the first system memory.

[0068] The memory allocation pressure of the first system memory can be determined according to the demand information of the first system memory and the usage information of the first system memory, and then the recovery ratio can be determined according to the memory allocation pressure of the first system memory. The demand information includes a demand amount, and the usage information includes a usage amount of the first system memory and a total amount of memory of the first system memory. The allocable amount of the first system memory can be determined according to the usage amount of the first system memory and the total amount of memory of the first system memory, and then the recovery ratio can be determined according to the difference between the demand amount and the allocable amount. This is because the difference between the demand amount and the allocable amount of the first system memory can reflect the memory allocation pressure of the first system memory. If the difference between the demand amount and the allocable amount of the first system memory is greater, it can be determined that the memory allocation pressure of the first system memory is greater, and vice versa. The memory allocation pressure and the recovery ratio of the first system memory are negatively correlated. The greater the memory allocation pressure, the smaller the recovery ratio of the first system memory, and vice versa. The recovery ratio of the first system memory can be a percentage, such as 80%, 70%, and the like. The result of multiplying the reference recovery amount of the first system memory and the recovery ratio of the first system memory is the target recovery amount. For example, the reference recovery amount of the first system memory is 30MB, and the recovery ratio is 90%, so that the target recovery amount is determined to be 27MB according to the recovery ratio and the reference recovery amount. The recovery ratio is flexibly controlled by the memory allocation pressure, and then the intensity of the memory active recovery can be controlled, and the memory recovery does not affect the smoothness of the operation of the first virtual device.

[0069] In one embodiment, when the difference between the demand amount and the allocable amount is greater than 0, the recovery ratio can be set to 0, representing no recovery of the first system memory. On the contrary, when the difference between the allocable amount and the demand amount is greater than 0, the smaller the memory allocation pressure, the greater the recovery ratio can be set, and the greater the memory allocation pressure, the smaller the recovery ratio can be set. In order to determine the recovery ratio in a way that ensures that the first system memory is sufficient for use, meets the memory demand, and even reserves a certain available margin. In one embodiment, a mapping relationship between the difference between the allocable amount and the demand amount and the corresponding recovery ratio can be set in advance, so as to find and determine the recovery ratio according to the mapping relationship between the difference between the demand amount and the allocable amount and the recovery ratio.

[0070] S203, according to the target recovery amount, the first system memory supporting recovery in the first virtual device is recovered to the memory manager in the first virtual device.

[0071] The first system memory that supports being recycled refers to the first system memory that can be released in the first virtual device, also referred to as recyclable memory. The recyclable memory is in a used state before being recycled, that is, the first system memory that supports being recycled belongs to the allocated first system memory. For example, in a cache and a buffer used for storing frequently used data, the data occupies a certain amount of first system memory; when the data is no longer needed, the first system memory occupied by the data supports being recycled, and the recycling does not affect the running of the first virtual device and the running of the processes on the first virtual device. The first system memory that supports being recycled in the first virtual device can include the following types: ① the first system memory occupied by the cache or the buffer in the first virtual device; for example, the first system memory occupied by the page cache. ② the background processes or services that are not needed in the first virtual device. ③ the first system memory occupied by the temporary files or logs in the first virtual device. It can be understood that the first system memory in the used state can be updated to the idle state after being recycled to the memory manager in the first virtual device.

[0072] The first system memory that supports being recycled is recycled to the memory manager, which means that the first system memory that is no longer used is returned to the memory manager, so that it can be allocated to other programs or data that need memory, and the memory manager has the allocation permission therefor. In an embodiment, the memory manager stores a free list and an allocation list, the free list is used to record the memory addresses of the first system memory in the idle state, and the allocation list is used to record the memory addresses of the first system memory in the used state, that is, the first system memory is allocated to the processes inside the first virtual device for use. Based on this, when the first virtual device recycles the first system memory that supports being recycled, the memory address of the first system memory that supports being recycled can be deleted from the allocation list, and the memory address of the first system memory that supports being recycled can be added to the free list. The memory amount of the first system memory in the idle state managed by the memory manager can increase with the recycling of the first system memory that supports being recycled.

[0073] The target recycling amount is determined from the memory amount of the part of the memory that can be recycled from the first system memory indicated by the reference recycling amount, and then the memory of the size indicated by the target recycling amount in the first system memory is recycled and re-managed by the memory manager of the first virtual device, which facilitates the memory manager of the first virtual device to further determine the overall idle condition of the first system memory and execute subsequent steps.

[0074] S204, a memory recycling instruction is sent to the target physical device, the memory recycling instruction being used to instruct the target physical device to recycle the first system memory from the memory manager in the first virtual device.

[0075] The first system memory in the idle state in the memory manager includes at least one of the following: first system memory that has not been allocated (this part of the first system memory is in the idle state and has not been changed), and first system memory that has been allocated but has been recovered into the memory manager (this part of the first system memory was in the used state before being recovered and is in the idle state after being recovered). The memory addresses of the first system memory that has not been allocated are continuous, and the first system memory recovered into the memory manager is mostly discontinuous fragmented memory. The first system memory recovered by the target physical device from the memory manager in the first virtual device is all first system memory in the idle state (which can also be referred to as idle system memory).

[0076] In an implementation manner, the total amount of the first system memory recovered into the memory manager in the first virtual device is the target recovery amount, and the recovered first system memory is mostly fragmented memory. After the amount of the first system memory recovered into the memory manager in the first virtual device reaches the target recovery amount, the first virtual device can send a memory recovery instruction to the target physical device, so that the target physical device recovers the first system memory from the memory manager in the first virtual device based on the received memory recovery instruction.

[0077] In another implementation manner, a first memory amount of the first system memory in the idle state in the memory manager in the first virtual device can be detected first; if the first memory amount reaches a preset memory amount, a step of sending a memory recovery instruction to the target physical device is triggered to be performed. Specifically, the detection of the first memory amount can be performed periodically after a proactive memory recovery condition is met, which is not limited in the present application. For example, the detected first memory amount increases with the increase of the first system memory supporting recovery recovered into the memory manager. The preset memory amount mentioned above can be determined based on the memory block size corresponding to the physical memory in the target physical device, where the memory addresses of the physical memory in the memory block are continuous, such as 2MB, 4MB, 8MB, etc. The preset memory amount can be the size of a single memory block or a multiple of the size of a single memory block, for example, when the memory block size in the target physical device is 2MB, the preset memory amount can also be set to 2MB, or can be set to 4MB.

[0078] After determining that the first system memory satisfies the memory reclaiming condition, and before performing the reclaiming of the reclaimable memory, if the memory addresses of the first system memory in an idle state managed by the memory manager are continuous, and the first memory amount reaches the preset memory amount, a step of sending a memory reclaiming instruction to the target physical device can be directly triggered to be performed, so that the target physical device reclaims the continuous first system memory. For example, there are 2MB of continuous first system memory in the memory manager, and a memory reclaiming instruction can be sent to the target physical device, so that the target physical device can reclaim the 2MB of continuous first system memory. Since the reclaiming of the reclaimable memory is not performed, the step of reclaiming the reclaimable memory to the memory manager according to the target reclaiming amount can also be performed synchronously or asynchronously, and after the first system memory is reclaimed to the memory manager, the step of detecting and determining whether the preset memory amount is reached can be continuously performed.

[0079] In another implementation, in the first virtual device, the first system memory is managed in units of pages (i.e., memory page tables), and the page is the smallest unit of allocation and reclaiming by the memory manager. The operating system of the first virtual device can divide the memory space of the first system memory into pages of a fixed size, and each page is an independent block of the first system memory, which is used to map to the corresponding memory block in the physical memory. Since the first system memory reclaimed to the memory manager is mostly scattered memory fragments, in order to further reduce the performance loss, when it is detected that the first memory amount reaches the preset memory amount, the first system memory reclaimed to the memory manager can also be aggregated according to the preset memory amount to obtain at least one memory block.

[0080] Any memory block includes first system memory with continuous memory addresses and is managed by a corresponding memory page table. After the reclaimable first system memory is reclaimed to the memory manager, a special kernel thread can be called to perform aggregation processing to round up the scattered first system memory to continuous pages of the preset memory amount, and the strength of rounding up to continuous pages of the preset memory amount is controlled by the determination of the target reclaiming amount by the proactive reclaiming algorithm. After obtaining at least one memory block, a step of sending a memory reclaiming instruction to the target physical device can be triggered to be performed. The part of the first system memory reclaimed to the memory manager can be aggregated according to the preset memory amount to obtain one or more memory blocks, which facilitates the reclamation to the target physical device in the form of memory blocks.

[0081] The aggregation processing of the recycled first system memory can be performed under the precondition that the target recycling amount is greater than or equal to the preset memory amount. If the target recycling amount is less than the preset memory amount, the integration processing is not performed first, and after step S203, new load information of the first virtual device is acquired, and the logic of active memory recycling is performed according to the new load information, until the first system memory recycled into the memory manager reaches the preset memory amount, and then the integration processing is performed. After the memory integration, the memory addresses of the first system memory in the idle state are continuous. The target physical device can recycle the first system memory from the memory manager according to the preset memory amount, so as to realize the release of the first system memory in the idle state to the operating system of the target physical device in the preset memory amount unit.

[0082] In another implementation manner, the step of sending the memory recycling instruction to the target physical device can be triggered under a target condition based on the size relationship between the target recycling amount and the preset memory amount, or the step of performing the aggregation processing on the first system memory recycled into the memory manager according to the preset memory amount to obtain at least one memory block can be triggered under the target condition. For example, if the target recycling amount is less than the preset memory amount, the target condition is that the first memory amount reaches the target recycling amount; if the target recycling amount is greater than or equal to the preset memory amount, the target condition is that the first memory amount reaches the preset memory amount.

[0083] In one embodiment, the memory recycling module is included in the target physical device, and the memory recycling instruction is sent to the memory recycling module in the target physical device, and the memory recycling instruction is used to instruct the memory recycling module in the target physical device to recycle the first system memory from the memory manager in the first virtual device. That is, the memory recycling instruction is sent to the memory recycling module in the target physical device, so that the memory recycling module in the target physical device recycles the first system memory from the memory manager in the first virtual device. Moreover, since the first system memory in the idle state exists in the memory manager in the form of at least one memory block, the recycling instruction is used to instruct the memory recycling module in the target physical device to recycle at least one memory block from the memory manager in the first virtual device, so that the memory can be released from the operating system of the first virtual device to the operating system of the target physical device in the unit of the memory block, without the need of rearranging the scattered system memory in the host system, and the performance loss is reduced. It can be seen that the first system memory is recycled from the first virtual device to the target physical device by the recycling module, and since the recycled first system memory is all released from the DMA mapping, the first system memory can be directly released in the target physical device.

[0084] Optionally, the first virtual device comprises a memory recycling algorithm module, which can be used to execute the steps S202-S204 or S201-S204. The memory recycling algorithm module deploys an active memory recycling algorithm to implement the logic of active memory recycling. For the above process, please refer to the flowchart of an exemplary memory recycling process shown in FIG. 3. The obtained load information of the virtual machine can be used as an input for triggering the active memory recycling algorithm. After comprehensively considering the usage information of the first system memory (such as memory usage, memory allocation time consumption, and IO delay latency, etc.), the memory recycling algorithm module can determine whether to trigger the active memory recycling. If the active memory recycling is not triggered, the load information of the virtual machine is continuously obtained. If the active memory recycling is triggered, the recyclable amount R can be determined based on the recyclable amount and the recycling ratio, and the memory recycling within the virtual machine operating system is performed according to the recyclable amount R. Then, it is determined whether the idle first system memory in the memory manager reaches the preset memory amount. If yes, the idle memory is recycled from the memory manager through the memory recycling module. If no, the memory recycling within the virtual machine operating system is continuously performed until the preset memory amount is reached.

[0085] When the usage information of the first system memory does not satisfy the memory recycling condition, it indicates that the memory allocation pressure in the first virtual device is large. In an implementation, the first virtual device can not perform the memory recycling processing, but continuously obtain the latest usage information of the first system memory until the active memory recycling is performed when the obtained usage information of the first system memory satisfies the memory recycling condition.

[0086] In an embodiment, the first virtual device runs at least one container, and each container runs an application. The containers can be cloud containers, which can include at least one of the following according to the open range: public cloud containers, private cloud containers, and hybrid cloud containers. Each container has a container memory configuration, and according to the container memory configuration of each container, a corresponding amount of first system memory can be allocated from the memory manager. The sum of the container memory configurations of each container is greater than the memory amount of the first system memory managed by the memory manager, so that the first system memory used by each container can also be dynamically recycled or allocated. Each container supports a direct memory access operation, and each container shares the transparent device and the memory mapping pool of the first virtual device. If there is a DMA operation in the container, the mapping memory can also be allocated from the memory mapping pool, and the DMA operation is performed in the container based on the allocated mapping memory.

[0087] In another embodiment, the first system memory is recycled to the operating system of the target physical device and provided for use by other virtual devices in various ways, such as: a second virtual device is also running in the target physical device, and the second virtual device is any virtual device other than the first virtual device among at least one virtual device running in the target physical device. If the second virtual device has a memory usage requirement, the first system memory recycled from the memory manager in the first virtual device is allocated to the second virtual device by the target physical device. The memory usage requirement can be confirmed to exist based on that the second virtual device can send a memory allocation request to the target physical device, and the memory usage requirement of the second virtual device is generated in one or more of the following situations: ① the memory configuration of the second virtual device is changed, and the changed memory configuration is higher than the memory configuration before the change; ② the memory usage amount of the second virtual device is greater than the actual amount of memory allocated to the second virtual device. For example, the originally allocated system memory of the second virtual device can be recycled, so that the system memory possessed by the second virtual device is less than the memory configuration, and when the second virtual device needs more system memory to process services, it needs to request the target physical device to allocate memory due to insufficient memory. That is, the part of the first system memory finally recycled to the target physical device can be allocated to other virtual devices running in the target physical device that have a memory requirement.

[0088] The memory allocation request sent by the second virtual device includes the memory amount of the system memory required by the second virtual device. Therefore, after receiving the memory allocation request, the target physical device can allocate system memory to the second virtual device according to the memory amount in the memory allocation request, and the system memory allocated to the second virtual device includes the first system memory recycled from the memory manager in the first virtual device.

[0089] The memory processing scheme provided by the embodiments of the present application can actively monitor whether the first virtual device meets the memory recycling condition, and when the memory recycling condition is met, the recyclable memory in the first virtual device is recycled to the memory manager first, and then the target physical device is notified to recycle the idle first system memory in the first virtual device through the sending of a memory recycling instruction, so that the idle first system memory in the first virtual device can be released to the host computer and provided for use by other virtual devices, realizing memory overcommitment under virtualization and being applicable to virtual machines with transparent devices. Since the load of the first virtual device and the recycling of recyclable memory inside the virtual machine are considered, the recyclable memory in the first virtual device can be safely recycled to other virtual devices for use, and the performance loss generated in the first virtual device is also within a controllable range.

[0090] Please refer to FIG. 4, which is a flowchart of a memory processing method according to an example embodiment of the present application. The memory processing method can be performed by a first virtual device (e.g., the first virtual device in FIG. 1). Before introducing the present embodiment, a brief introduction to data pass-through is provided.

[0091] Data pass-through between the first virtual device and the target physical device is performed by a pass-through device (also referred to as a pass-through device) in the first virtual device. The pass-through device allows the first virtual device to directly access physical hardware on the target physical device. The pass-through device can be hardware or software, such as a PCI (Peripheral Component Interconnect) device. In a virtualization environment, a physical PCI device in a host machine can be directly assigned to a guest machine using a virtualization technology called PCI device passthrough. PCI device passthrough allows a virtual machine to directly access a physical PCI device on a host machine, and this virtualization technology is often used in scenarios that require high performance or specific hardware functions, such as scenarios in which a high-performance network interface card (NIC) is used in a virtual machine. The pass-through device can operate in a direct memory access (DMA) mode, which is specifically used to perform direct memory access (DMA) operations. In DMA mode, memory can be directly accessed without going through a CPU (central processing unit), thereby transparently (i.e., without user or CPU intervention) transferring data between a device and memory. In DMA mode, data transfer is handled by a dedicated hardware device (i.e., a DMA controller) rather than a CPU. The DMA controller can directly read data from a device and write data to memory, or directly read data from memory and write data to a device, without the intervention of a CPU. The pass-through device can directly access memory under the management of the DMA controller, thereby performing read and write operations on data.

[0092] The first virtual device further comprises a memory mapping pool (denoted as DMA Pool) in addition to the memory manager. The memory mapping pool can be deployed in the operating system of the first virtual device. The memory mapping pool comprises mapping memory, which is the first system memory that has been subjected to direct memory access mapping. The mapping memory is used in the process of data transparent transmission. Specifically, the transparent device needs to use a corresponding amount of mapping memory when performing DMA operations. In addition, the memory amount N1 of the mapping memory managed by the memory mapping pool and the memory amount N2 of the first system memory managed by the memory manager are equal to the memory amount N of the allocated system memory; N, N1, and N2 are all numbers greater than 0. That is, among all the system memory allocated to the first virtual device, part of the system memory is not subjected to DMA mapping, this part of the system memory is the first system memory and is managed by the memory manager; another part of the system memory is subjected to DMA mapping, this part of the system memory is the mapping memory and is managed by the memory mapping pool. The memory managed by the memory manager and the memory managed by the memory mapping pool can be dynamically adjusted. For example, the first system memory managed by the memory manager is no longer managed by the memory manager after being subjected to DMA mapping, but is managed by the memory mapping pool; the mapping memory managed by the memory mapping pool can be regarded as dedicated system memory, which is specifically used to allocate to the transparent device; when the mapping memory managed by the memory mapping pool is subjected to DMA demapping, it is no longer managed by the memory mapping pool, but is managed by the memory manager. That is, the first system memory is divided into two parts, the part of the first system memory that is not subjected to DMA mapping is managed by the memory manager, and the part of the first system memory that is subjected to DMA mapping is managed by the memory mapping pool. The mapping memory managed by the memory mapping pool is allocated to the transparent device to perform transparent processing.

[0093] Since only part of the first system memory in the first virtual device with the transparent device is subjected to DMA mapping in advance, it is not necessary to keep all the system memory allocated to the first virtual device in the pin state. On the one hand, the system memory in the idle state in the first virtual device can be directly recycled, shortening the processing path of memory recycling and improving the memory recycling efficiency, thereby improving the use rate of memory resources. On the other hand, the DMA mapping of part of the system memory in advance can prepare the mapping memory required for DMA operations, so that the mapping memory can be immediately obtained when there is a processing demand for data transparent transmission, without triggering DMA mapping when actually performing DMA operations. In this way, the time consumption caused by the long interaction path of DMA mapping front and back end is avoided, the processing efficiency of data transparent transmission is improved, and the performance loss caused by dynamic DMA mapping is greatly reduced.

[0094] Based on the above introduction, the first virtual device based on the included memory manager and memory mapping pool can also perform the memory processing procedure shown in S401-S404.

[0095] S401, obtaining a first memory requirement amount corresponding to a target pass-through device in the first virtual device.

[0096] The first virtual device includes M pass-through devices (which can be denoted as PassThrough Device), and M is a positive integer; the target pass-through device refers to one pass-through device in the M pass-through devices that has a data pass-through requirement, which indicates that the target pass-through device needs to transmit target data between the first virtual device and a target physical device, and the target data transmitted here can be data written into the physical memory or data that needs to be read from the physical memory. In an implementation manner, the load information of the first virtual device further includes a first memory requirement amount corresponding to the target pass-through device, and the first virtual device can obtain the first memory requirement amount corresponding to the target pass-through device from the load information. The first memory requirement amount refers to the memory amount of the mapping memory required by the target pass-through device to perform data pass-through. For example, the target pass-through device needs 4 MB of mapping memory to perform data pass-through.

[0097] S402, calling a memory allocation interface provided by the first virtual device to obtain mapping memory of the first memory requirement amount from a memory mapping pool in the first virtual device.

[0098] In order to reduce the impact of frequent dynamic DMA mapping on performance, the first virtual device can capture a memory allocation interface provided by the first virtual device, so that the mapping memory that needs to perform DMA operation is allocated from a memory mapping pool (DMA pool), and the mapping memory managed by the memory mapping pool is obtained by performing DMA mapping on a batch of first system memory in advance. The data pass-through requirement of any pass-through device refers to the need to call the pass-through device to perform data pass-through, and when data pass-through, the first virtual device can call the memory allocation interface to obtain mapping memory of a corresponding amount from the memory mapping pool and allocate it to the pass-through device for use.

[0099] In an implementation manner, whether the first virtual device can obtain mapping memory of the first requirement amount from the memory mapping pool can be determined based on the size relationship between the memory amount of the unused mapping memory (i.e., the mapping memory in the idle state) in the memory mapping pool and the first memory requirement amount. The first virtual device can monitor the mapping memory remaining amount corresponding to the memory mapping pool in the first virtual device; if it is monitored that the mapping memory remaining amount is less than the first memory requirement amount, mapping memory of the first memory requirement amount is not supported to be obtained; and if it is monitored that the mapping memory remaining amount is greater than or equal to the first memory requirement amount, mapping memory of the first memory requirement amount is supported to be obtained.

[0100] Specifically, since there can be other pass-through devices in the first virtual device that are using a certain amount of mapping memory for performing DMA operations, or other pass-through devices have released the used mapping memory to the memory mapping pool after completing the DMA operations, the amount of unused mapping memory in the memory mapping pool is dynamically changing. The mapping memory remaining amount refers to the amount of mapping memory in the idle state in the memory mapping pool; the amount N1 of mapping memory managed by the memory mapping pool is the memory management amount, and the mapping memory remaining amount is determined according to the memory management amount of the memory mapping pool and the usage amount of the mapping memory, that is, the mapping memory remaining amount = memory management amount - usage amount.

[0101] In a case where the amount of mapping memory in the idle state is less than the first memory requirement amount, it is indicated that the amount of unused mapping memory in the memory mapping pool is insufficient, and the memory mapping pool cannot provide sufficient idle mapping memory for the target pass-through device to use, so that sufficient mapping memory cannot be obtained from the memory mapping pool, and the first virtual device does not obtain the mapping memory of the first memory requirement amount. In a case where the amount of mapping memory in the idle state is greater than or equal to the first memory requirement amount, it is indicated that the amount of unused mapping memory in the memory mapping pool is sufficient, and the memory mapping pool can provide sufficient idle mapping memory for the target pass-through device to use, and the mapping memory of the first memory requirement amount can be obtained from the memory mapping pool. Based on whether the mapping memory of the first memory requirement amount is obtained from the memory mapping pool, the following S403 or S404 can be performed.

[0102] S403, if the mapping memory of the first memory requirement amount is obtained, the mapping memory of the first memory requirement amount is allocated to the target pass-through device, and a direct memory access operation is called based on the mapping memory of the first memory requirement amount to perform the direct memory access operation to transmit the target data between the first virtual device and the target physical device.

[0103] Specifically, the target transparent device is configured to perform the DMA operation, and a buffer is required for storing data in the transmission process. The first memory requirement amount of the mapping memory is allocated to the target transparent device. Specifically, a buffer for the target transparent device is constructed by using the first memory requirement amount of the mapping memory, so that the target transparent device can perform the DMA operation on the buffer without the CPU of the first virtual device, and the target data can be transmitted between the first virtual device and the target physical device. The mapping memory can be the first system memory in the DMA mapping state, so as to ensure that the memory allocated to the target transparent device is in the DMA mapping state, and the memory allocated from the memory mapping pool does not need to be performed by the DMA mapping. The state of the mapping memory based on whether it is occupied can also include an idle state and a use state. The first memory requirement amount of the mapping memory obtained from the memory mapping pool is in the idle state, and after the first memory requirement amount of the mapping memory is allocated to the target transparent device, the state of the first memory requirement amount of the mapping memory changes to the use state. It can be seen that there is sufficient mapping memory in the memory mapping pool, and the required memory amount of the mapping memory can be obtained when there is a data transparent requirement, so as to ensure the smooth execution of the DMA operation and improve the efficiency of the data transparent.

[0104] In S404, if the first memory requirement amount of the mapping memory is not obtained, it is determined whether the memory manager satisfies the memory allocation condition, and the first system memory supported by the memory manager is allocated to the memory mapping pool if the memory manager satisfies the memory allocation condition.

[0105] If the first memory requirement amount of the mapping memory is not obtained from the memory mapping pool, it indicates that the memory amount of the mapping memory in the idle state in the memory mapping pool is insufficient, so that the first system memory of the memory manager can be checked first, and the first system memory is executed by the DMA mapping and then managed by the memory mapping pool. In a specific implementation, the determination of whether the memory manager satisfies the memory allocation condition can include the following steps (1)-(3).

[0106] In step (1), the target allocation amount is determined according to the mapping memory amount corresponding to the memory mapping pool in the first virtual device and the first memory requirement amount.

[0107] The mapping memory amount and the first memory requirement amount are subtracted to obtain a memory difference, and then the absolute value of the memory difference is determined as the target allocation amount. The target allocation amount is used to indicate the difference amount of the mapping memory required for performing the DMA operation.

[0108] In step (2), the first memory allocation amount corresponding to the memory manager in the first virtual device is obtained.

[0109] The first memory allocation margin refers to a memory margin of first system memory in the memory manager that supports performing direct memory access mapping. In a specific implementation, there can be some first system memory in the first system memory managed by the memory manager that is pre-allocated to key services in the first virtual device, and this part of the first system memory carries a corresponding service mark and is not allowed to be allocated to other services. Therefore, the first virtual device can query the memory amount of allocable first system memory from the first system memory in an idle state in the memory manager based on the service mark carried by the first system memory, and the allocable first system memory supports performing DMA mapping. The first memory allocation margin is used for size comparison with the target allocation amount, and different processing can be performed based on the size relationship between the first memory allocation margin and the target allocation amount.

[0110] Step (3) If the first memory allocation margin is greater than or equal to the target allocation amount, it is determined that the memory manager meets the memory allocation condition.

[0111] If the first memory allocation margin is greater than or equal to the target allocation amount, it means that there is enough first system memory in an idle state in the memory manager that can be allocated to the memory mapping pool, and therefore it can be determined that the memory manager meets the memory allocation condition, so that the first system memory can be allocated from the memory manager in batches. Conversely, if the first memory allocation margin is less than the target allocation amount, it can be determined that the memory manager does not meet the memory allocation condition, and it can be waited for other transparent devices to release mapping memory to the mapping memory pool, or for other processes to release the first system memory so that the memory manager has enough memory to allocate. Among them, the other device refers to a transparent device that is using mapping memory in addition to the target transparent device in the plurality of transparent devices.

[0112] Based on the above steps (1)-(3), the memory manager meets the memory allocation condition includes that the first memory allocation margin is greater than or equal to the target allocation amount; the target allocation amount can be used to indicate the memory amount of the first system memory allocated from the memory manager to the memory mapping pool for management. In another implementation manner, the memory manager meeting the memory allocation condition can also include that the first memory allocation margin is greater than zero, that is, as long as there is idle first system memory in the memory manager, the first system memory can be allocated from the memory manager to the memory mapping pool. In the case where the first memory allocation margin is less than the target allocation amount, it is also necessary to wait for other transparent devices to release mapping memory to the memory mapping pool, or for the used first system memory to be released to the memory manager (for example, the page cache releases the first system memory to the memory manager after using the first system memory).

[0113] The memory manager satisfies the memory allocation condition, that is, the first memory allocation residual corresponding to the memory manager is greater than or equal to the target allocation amount; when the first virtual device allocates the first system memory supported by the memory manager to the memory mapping pool, the first system memory supported by the memory manager can be allocated to the memory mapping pool according to the target allocation amount, so that the target allocation amount of the first system memory in the memory manager is supported and allocated to the memory mapping pool. In the specific process, the first system memory can be obtained from the memory manager according to the target allocation amount, and then DMA mapping processing (mmap) is performed on the target allocation amount of the first system memory to obtain the target allocation amount of the mapping memory, which is managed by the memory mapping pool.

[0114] The first virtual device and the recovery module on the operating system side of the target physical device establish a communication connection, and when the DMA mapping processing is performed, the physical address of the target allocation amount of the first system memory in the first virtual device can be obtained; the physical address of the target allocation amount of the first system memory in the first virtual device is sent to the recovery module in the target physical device, so that the recovery module establishes the mapping relationship between the physical address (GPA, that is, the physical address of the GuestOS) of the target allocation amount of the first system memory in the first virtual device and the corresponding physical address (HPA, that is, the physical address of the HostOS) in the target physical device. The physical address of the first virtual device is obtained by converting the virtual address (Guest Virtual Address, GVA) of the first virtual device, and the physical address of the first virtual device is converted into the virtual address (Host Virtual Address, HPA) of the target physical device and then into the physical address of the target physical device. The mapping page table in the target physical device is used to record the DMA mapping relationship, so the mapping page can be updated based on the establishment of the mapping relationship of the corresponding physical address. After the recovery module is established, the recovery module can send a first completion instruction to the first virtual device, and the first virtual device can receive the first completion instruction sent by the recovery module to obtain the target allocation amount of the mapping memory, that is, the memory manager can release the management of the target allocation amount of the first system memory, and the memory mapping pool can manage the target allocation amount of the first system memory after the DMA mapping is performed, that is, the target allocation amount of the mapping memory is managed by the memory mapping pool.

[0115] That is, in the case where the memory allocation residual is sufficient, the target allocation amount of the memory in the first system memory can be executed by the DMA processing to be managed by the memory mapping pool to realize data transparent transmission. When the DMA mapping processing is performed, the mapping relationship is established based on the physical address of the target allocation amount corresponding to the memory in the first system memory in the first virtual device and the corresponding physical address in the target physical device.

[0116] Further, after the memory manager allocates a portion of the first system memory to the mapping memory pool in batches, the first virtual device can re-detect the memory allocation margin of the mapping memory pool, and then re-call the memory allocation interface to obtain the first memory requirement amount of mapping memory from the mapping memory pool in the case that the detected memory allocation margin is sufficient to allocate to the target pass-through device. That is, after the first system memory is allocated, the memory allocation interface is re-called to obtain the first memory requirement amount of mapping memory from the mapping memory pool.

[0117] In one embodiment, in the case that the memory manager does not meet the memory allocation condition, the release of the used first system memory can be waited for, such as setting a preset waiting time, and after the preset waiting time is reached, it is re-determined whether the memory manager meets the memory allocation condition.

[0118] In another embodiment, if the first virtual device includes a plurality of pass-through devices, in the case that the memory manager does not meet the memory allocation condition, it can be determined whether other pass-through devices in the first virtual device are using mapping memory, so that the release of the mapping memory by the other pass-through devices can be waited for, and then it is determined whether the mapping memory pool has sufficient mapping memory to support allocation. The number M of pass-through devices in the first virtual device is greater than 1, and the mapping memory used by any pass-through device after performing a direct memory access operation based on the mapping memory is released to the memory mapping pool, and the state of the mapping memory released to the memory mapping pool changes from the used state to the idle state. Based on this: if the memory manager does not meet the memory allocation condition, and other pass-through devices in the M pass-through devices are performing data pass-through, at least the release of the mapping memory used by the other pass-through devices to the memory mapping pool is waited for. Among them, the other pass-through devices refer to any pass-through device in the M pass-through devices except the target pass-through device, and the memory amount of the mapping memory in the idle state in the memory mapping pool increases with the release of the mapping memory by the other pass-through devices. After the memory amount of the mapping memory in the idle state in the memory mapping pool reaches the first memory requirement amount, the first virtual device can re-call the memory allocation interface to obtain the first requirement amount of mapping memory from the memory mapping pool.

[0119] In one implementation, if the first memory allocation margin of the memory manager is a non-zero value, since there is also a small amount of allocatable first system memory in the memory manager, in addition to waiting for other transparent devices to release the used mapping memory to the memory mapping pool, the first system memory of the first memory allocation margin in the memory manager can also be allocated to the memory mapping pool, and the memory amount of the idle mapping memory in the memory mapping pool increases with the allocation of the first system memory. For example, the first memory requirement of the transparent device P1 is 4MB, and there is only 2MB in the memory mapping pool, the transparent device P2 is using 1MB of mapping memory to perform DMA mapping, and the memory manager also supports the allocation of 1MB, so ① 1MB of first system memory can be allocated from the memory manager, and the 1MB of first system memory is allocated to the memory mapping pool after performing DMA mapping; ② wait for the transparent device P2 to release 1MB of mapping memory. In this way, the memory amount of the unused mapping memory in the memory mapping pool reaches the first memory requirement of 4MB.

[0120] Based on the memory processing of steps S401-S404, an exemplary flowchart of dynamic memory adjustment can be provided as shown in FIG. 5. That is, the mapping memory required by the target transparent device is first allocated from the memory mapping pool (DMA Pool) through the memory allocation interface. Then it is determined whether the acquisition is supported. If it is supported, the corresponding amount of mapping memory can be allocated to the target transparent device, and the target transparent device performs direct memory access mapping (i.e. DMA mapping) based on the allocated mapping memory. Otherwise, if it is not supported, it can be determined whether the memory manager meets the memory allocation condition. If yes, a batch of first system memory is allocated from the memory manager to the memory mapping pool, and if not, at least one of the following can be waited for: waiting for other transparent devices to release mapping memory, waiting for the release of the used first system memory.

[0121] It can be understood that the steps S401-S404 and the flowchart shown in FIG. 2 / FIG. 3 can be independent of each other. That is, when the target physical device recovers the first system memory from the memory manager in the first virtual device, the first virtual device can also allocate mapping memory from the memory mapping pool to the transparent device for use, and the transparent device performs DMA operation based on the obtained mapping memory.

[0122] The memory processing method provided by the embodiments of the present application can support memory overcommitment of virtual devices with transparent devices. Since the operating system of the first virtual device allocates memory to the DMA pool in advance, and the memory is recovered from the operating system of the first virtual device to the operating system of the target physical device, it is also ensured that the memory has been released from the DMA mapping in advance. Therefore, the memory overcommitment of virtual devices with transparent devices can be effectively supported, and the memory of the virtual device can be dynamically allocated.

[0123] Referring to FIG. 6, a flowchart of a memory processing method is provided according to an example embodiment of the present application. The memory processing method can be performed by a first virtual device (e.g., the first virtual device in FIG. 1). In the case where the first virtual device comprises a mapping memory pool and a memory manager, a first system memory of a target memory amount is designated to support allocation to at least one service, where any service is, for example, the start of an application program; any service is referred to as a target service. The first virtual device has a running requirement for the target service. The first virtual device can further perform steps S601-S603.

[0124] S601, receiving a running request for the target service, and allocating the first system memory from the memory manager in the first virtual device according to the running request for the target service.

[0125] The target service refers to any of the at least one service; the running request for the target service is used to indicate running the target service, and the first system memory required by the target service is allocated from the memory manager. The running request for the target service can be initiated according to the operation of the target object on the target application program or automatically initiated by the first virtual device. According to the running request, the corresponding amount of the first system memory required by the target service can be allocated from the memory manager, but if there is not enough amount of free first system memory in the memory manager to allocate to the target service, the allocation will fail, so that the target service cannot run. Therefore, it is determined whether the target service can be allocated with the required amount of the first system memory; if there is enough amount of the first system memory in the memory manager to allocate to the target service, the corresponding amount of the first system memory required by the target service can be allocated from the memory manager, and the target service is run based on the allocated first system memory.

[0126] In an implementation, the running request for the target service comprises a second memory requirement amount corresponding to the target service, based on which it is determined whether the target service can be allocated with the required amount of the first system memory, which can comprise steps ①-③.

[0127] ①The second memory requirement amount corresponding to the target service is obtained from the running request for the target service. The second memory requirement amount refers to the memory amount of the first system memory required by the target service in the running process. For example, the target service is a data processing task of an application program, and the second memory requirement amount is 2MB, i.e., 2MB of free system memory is required to store the data of the data processing task.

[0128] ②obtaining a second memory allocation margin corresponding to the memory manager. The second memory allocation margin refers to a memory margin in the memory manager supporting the allocation of the first system memory to the target service. In a specific implementation, if other services are running in the first virtual device, the other services will occupy a part of the first system memory, and then the memory margin in the memory manager supporting the allocation of the first system memory to the target service, i.e., the second memory allocation margin, can be determined according to the target memory amount n1 and the memory amount n2 of the first system memory occupied by the other services running. Wherein, n1 and n2 are greater than zero. In another specific implementation, if no other service is running in the first virtual device, the target memory amount n1 can be determined as the second memory allocation margin.

[0129] ③comparing the size between the second memory allocation margin and the second memory requirement; if the second memory allocation margin is less than the second memory requirement, it is determined that the second requirement of the first system memory is not allocated. By comparing the second memory allocation margin and the second memory requirement, it can be determined whether the first system memory sufficient for the normal operation of the target service can be allocated from the memory manager in the first virtual device. In the case that the second memory allocation margin is less than the second memory requirement, it is indicated that the memory manager does not support the allocation of sufficient first system memory to the target service, so it can be determined that the second requirement of the first system memory is not allocated, at this time, it can be checked whether there is excess idle mapping memory in the memory mapping pool to release, or the release of the first system memory to be used is waited. Conversely, if the second memory allocation margin is greater than or equal to the second memory requirement, it is indicated that the memory manager supports the allocation of sufficient first system memory to the target service, and then the second requirement of the first system memory can be allocated, and based on the second memory requirement of the first system memory allocated from the memory manager, the target service can be run.

[0130] The above ①-③ can accurately determine whether the memory amount of the first system memory managed by the memory manager needs to be adjusted based on the size comparison between the memory margin supported by the memory manager and the requirement of the target service for the first system memory.

[0131] S602, if not allocated, it is determined whether the memory mapping pool meets the memory release condition.

[0132] In a specific implementation, if the corresponding amount of first system memory is not allocated from the memory manager, then the first system memory can be released by other processes in the memory manager, and at the same time, it can be checked whether the memory mapping pool meets the memory release condition, so that the excess mapping memory can be released to the memory manager after demapping to increase the memory amount of the available first system memory in the memory manager.

[0133] That is, when there is a specific service that needs to occupy the first system memory managed by the memory manager in the first virtual device, the memory manager can allocate part of the first system memory for the specific service to run. If the memory manager determines that there is not enough allocatable memory in the first system memory to allocate to the target service, it can wait for the memory occupied by other services to be released to make the memory manager have more allocatable memory, and obtain more second memory allocation margin; it can also determine whether the part of the first system memory that is not managed by the memory manager (executed direct memory access mapping) can be released back to the memory manager to obtain more allocatable memory and obtain more second memory allocation margin. The first virtual device can wait for other processes to release part of the memory occupied by them in the first system memory, and / or can check whether the memory mapping pool meets the memory release condition to release part or all of the memory in the first system memory that is executed direct memory access mapping.

[0134] In one implementation, the determination of whether the memory mapping pool meets the memory release condition can include the following steps 1-4.

[0135] Step 1, obtain the memory idle amount corresponding to the memory mapping pool and the preset reserved amount corresponding to the memory mapping pool. The memory idle amount refers to the mapping memory in the idle state in the memory mapping pool. The first virtual device includes at least one pass-through device, each pass-through device has a data pass-through function, and the preset memory reserve amount is determined based on the number of pass-through devices in the first virtual device or specified by a target object. The target object refers to an object that has operating authority for the first virtual device, such as a cloud service provider. If the preset memory reserve amount is determined based on the number of pass-through devices in the first virtual device, then the preset memory reserve amount can be positively correlated with the number of pass-through devices, the more the number of pass-through devices, the larger the preset memory reserve amount, and the smaller the number of pass-through devices, the smaller the preset memory reserve amount. Through the preset reserve amount, a minimum amount of mapping memory can be reserved in the memory mapping pool, thereby ensuring the basic operation of the pass-through device.

[0136] Step 2, compare the size of the memory idle amount and the preset memory reserve amount. By comparing the size of the memory idle amount corresponding to the memory mapping pool and the corresponding preset memory reserve amount, it can be determined whether the memory mapping pool can release excess mapping memory while reserving a minimum amount of idle mapping memory.

[0137] Step 3, if the memory idle amount is greater than the preset memory reserve amount, it is determined that the memory mapping pool meets the memory release condition. If the memory idle amount is greater than the preset memory reserve amount, then it means that there is excess idle mapping memory in the memory mapping pool that can be released, so it can be determined that the memory mapping pool meets the memory release condition.

[0138] Step 4, if the memory free amount is less than or equal to the preset memory reserved amount, it is determined that the memory mapping pool does not meet the memory release condition.

[0139] If the memory free amount is less than or equal to the preset memory reserved amount, it means that there is no extra free mapping memory in the memory mapping pool that can be released, so it can be determined that the memory mapping pool does not meet the memory release condition, and it can wait for other transparent devices to release the mapping memory back to the memory mapping pool.

[0140] In another implementation, the determination of whether the memory mapping pool meets the memory release condition can include the following: obtaining the memory free amount corresponding to the memory mapping pool, if the memory free amount is greater than zero, it is determined that the memory mapping pool meets the memory release condition; if the memory free amount is less than or equal to zero, it is determined that the memory mapping pool meets the memory release condition.

[0141] S603, in the case that the memory mapping pool meets the memory release condition, determine the target release amount, and release the mapping memory in the memory mapping pool to the memory manager according to the target release amount.

[0142] In one implementation, the memory mapping pool meeting the memory release condition means that the memory free amount corresponding to the memory mapping pool is greater than the preset reserved amount corresponding to the memory mapping pool. If the memory free amount is greater than the preset memory reserved amount, it means that there is extra free mapping memory in the memory mapping pool that can be released, so when determining the target release amount, the target release amount can be determined according to the memory free amount corresponding to the memory mapping pool and the preset reserved amount corresponding to the memory mapping pool. Specifically, the memory free amount and the preset memory reserved amount can be subtracted to obtain a memory difference, that is, the memory free amount minus the preset memory reserved amount, thereby obtaining the memory difference; then the memory difference is determined as the target release amount; or the product between the memory difference and a preset release ratio is determined as the target release amount, the preset release ratio is a value less than 1, and the preset release ratio is used to further control the release amount of the mapping memory. It can be seen that the target release amount refers to the mapping memory in the memory mapping pool that is more than the preset memory reserved amount. This part of the mapping memory supports being released to the memory manager, and does not affect the demand of the transparent device.

[0143] In another implementation, the memory mapping pool meeting the memory release condition means that the memory free amount corresponding to the memory mapping pool is greater than zero, and the memory free amount corresponding to the memory mapping pool can be directly determined as the target release amount.

[0144] The first virtual device can obtain the target release amount of mapping memory from the memory mapping pool. Since the target release amount of mapping memory is obtained by performing DMA mapping on the first system memory, the target release amount of mapping memory needs to be un-mapped before being released to the memory manager. Therefore, the target release amount of mapping memory can be un-mapped to obtain the target release amount of first system memory. Then, the memory addresses of the target release amount of first system memory are added to the free list in the memory manager, so that the target release amount of first system memory is managed by the memory manager.

[0145] In an implementation, the first virtual device and the recycling module in the target physical device are connected in communication. When un-mapping, the first virtual device can obtain the physical address of the target release amount of mapping memory in the first virtual device, and send the physical address of the target release amount of mapping memory in the first virtual device (i.e., the GPA, the GuestOS physical address) to the recycling module of the target physical device, so that the recycling module in the target physical device un-maps the mapping relationship between the physical address of the target release amount of mapping memory in the first virtual device and the corresponding physical address (HPA, HostOS physical address) in the target physical device. Similarly, the mapping page table in the target physical device is used to record the DMA mapping relationship, and when un-mapping, the recycling module can delete the mapping relationship of the corresponding physical address in the mapping page. After the recycling module is established, the recycling module can send a second completion instruction to the first virtual device. The first virtual device can receive the second completion instruction sent by the recycling module to obtain the target release amount of first system memory, that is, the memory mapping pool can release the management of the target release amount of mapping memory, and the memory manager can manage the target release amount of first system memory.

[0146] Based on the steps shown in S601-S603, an exemplary flow diagram of memory dynamic adjustment can be provided as shown in FIG. 7. As shown in FIG. 7, when receiving the running request of the target service, it can be determined whether the memory of the memory manager is sufficient, that is, whether the free first system memory in the memory manager can support the running of the target service. If yes, the first system memory can be allocated to the target service from the memory manager and the target service can be run. If not, the release of the used first system memory can be waited, and at the same time, it can be determined whether the memory mapping pool meets the memory release condition. If not, the mapping memory released by other transparent devices to the memory mapping pool can be waited. If yes, the free mapping memory in the memory mapping pool is released to the memory manager. As can be seen, when the memory of the memory manager in the first virtual device is insufficient, a part of the unused memory in the DMA Pool can also be released to the memory manager in batches, and the dynamic adjustment between the DMA mapping memory and the first system memory can be realized through the DMA Pool.

[0147] Based on the embodiments shown in FIG. 2, FIG. 4 and FIG. 6, a memory processing interaction flowchart can be provided as shown in FIG. 8, which is based on the virtual machine operating system and the host operating system. As shown in FIG. 8, the virtual machine operating system (GuestOS) includes a memory mapping pool (DMA Pool), a pass-through device (PassThrough Device), a memory manager and a memory recycling algorithm module. The host operating system (HostOS) includes a memory recycling module. The interaction flow between the modules is represented by numbers. Process "0" and process "6" correspond to the memory recycling process shown in FIG. 2. Process "0" includes recycling the memory inside the virtual machine operating system into the memory manager through the memory recycling algorithm module. Process "6" means recycling the memory from the GuestOS to the HostOS through the memory recycling module. Since the memory not in the DMA Pool is DMA-unmapped, it can be directly released in the HostOS. Process "1" can correspond to the memory processing flow of FIG. 6. That is, when the general memory manager of the virtual machine is out of memory, if the DMA Pool has unused memory, a part of the memory is released in batches to the memory manager. Process "2" can correspond to the memory processing flow shown in FIG. 4. That is, when the memory of the DMA Pool of the virtual machine is insufficient, if the memory manager has free memory, a part of the memory is allocated in batches to the DMA Pool. FIG. 2 and FIG. 4 are both dynamic memory adjustment logic, and involve process "5". That is, before releasing to the memory manager, the memory DMA mapping (mmap) needs to be un-mapped, and before allocation to the DMA Pool, the memory DMA mapping (mmap) needs to be performed, and the mmap / unmap operation is performed by the DMA Pool communicating with the "recycling module" on the HostOS side, and the GPA information of the GuestOS that needs to be mapped or un-mapped is transmitted to the HostOS, and the "recycling module" completes the mapping or un-mapping action. Process "3" and process "4" correspond to the content of the memory processing flow shown in FIG. 4. Process "3": when the PassThrough Device device driver needs to allocate memory (for data transmission), memory is allocated from the DMA Pool, and the memory allocated from the DMA Pool has been ensured to be in the DMA mapping state. Process "4": when the PassThrough Device device driver uses the memory, the memory is directly released to the DMA Pool when the memory is released.It can be seen that in the above interaction process, the actual usage of the DMA mapped memory and the first system memory can be used to adjust the respective quantities, and the first virtual device does not need to complete DMA mapping of all the memory at the time of creation; and the performance problem caused by dynamic memory DMA mapping can be solved, that is, the DMA Pool is implemented in the following manner: a batch of memory is pre-mapped, and then batch mapping (expanding the Pool) or batch unmapping (shrinking the Pool) of the memory of the DMA Pool is performed according to the actual demand, so as to reduce the performance impact of dynamic memory DMA mapping.

[0148] Please refer to FIG. 9, which is a structural schematic diagram of a memory processing apparatus provided in an example embodiment of the present application. The memory processing apparatus shown in FIG. 9 can be a computer program (including program code) running in a computer device, and can be used to execute part or all of the steps in the method embodiments shown in FIG. 2, FIG. 4 or FIG. 6. Please refer to FIG. 9, the memory processing apparatus can include the following units:

[0149] The obtaining unit 901 is configured to obtain load information of the first virtual device in a running process of the first virtual device, the load information including usage information of the first system memory; the first virtual device runs in a target physical device, and the first system memory is system memory allocated to the first virtual device by the target physical device; the first system memory is managed by a memory manager in the first virtual device and has not been executed direct memory access mapping; the memory manager supports pre-allocating part of the first system memory to perform direct memory access mapping, so as to be used for data transparent transmission between the first virtual device and the target physical device;

[0150] The processing unit 902 is configured to determine a target recovery amount according to the usage information of the first system memory when the usage information of the first system memory meets a memory recovery condition; and recover the first system memory supporting recovery in the first virtual device to the memory manager in the first virtual device according to the target recovery amount.

[0151] The transceiving unit 903 is configured to send a memory recovery instruction to the target physical device, the memory recovery instruction being used to instruct the target physical device to recover the first system memory from the memory manager in the first virtual device.

[0152] In an embodiment, the usage information of the first system memory comprises at least one of: a memory usage of the first system memory; an I / O interface delay corresponding to the first system memory; a memory allocation time consumption of the first system memory; and the memory usage information of the first system memory satisfying the memory reclaiming condition comprises at least one of: the memory usage of the first system memory being less than or equal to a first preset usage; the I / O interface delay corresponding to the first system memory being less than or equal to a first preset delay; and the memory allocation time consumption of the first system being less than or equal to a preset allocation time consumption.

[0153] In an embodiment, the processing unit 902 is further configured to: detect a first memory amount of the first system memory in an idle state in the memory manager in the first virtual device; and trigger the step of sending the memory reclaiming instruction to the target physical device if the first memory amount reaches a preset memory amount.

[0154] In an embodiment, if the first memory amount reaches the preset memory amount, the processing unit 902 is further configured to: aggregate the first system memory reclaimed into the memory manager according to the preset memory amount to obtain at least one memory block; and the memory reclaiming instruction is used to instruct the target physical device to reclaim the at least one memory block from the memory manager in the first virtual device.

[0155] In an embodiment, the load information of the first system memory further comprises demand information of the first system memory and a reference reclaiming amount of the first system memory, the reference reclaiming amount being a memory amount supporting the reclaimed first system memory; and the processing unit 902 is specifically configured to: determine a reclaiming ratio of the first system memory according to the usage information of the first system memory and the demand information of the first system memory; and determine a target reclaiming amount according to the reclaiming ratio of the first system memory and the reference reclaiming amount of the first system memory.

[0156] In an embodiment, the target physical device further runs a second virtual device; and if the second virtual device has a memory usage demand, the first system memory reclaimed from the memory manager in the first virtual device is allocated to the second virtual device by the target physical device.

[0157] In an embodiment, the data transparent transmission is performed by a transparent transmission device in the first virtual device; and the first virtual device further comprises a memory mapping pool, the memory mapping pool being used to manage a mapping memory, the mapping memory being the first system memory that has performed direct memory access mapping and being used in the process of the data transparent transmission.

[0158] The obtaining unit 901 is further configured to obtain a first memory requirement corresponding to a target transparent device in the first virtual device; the first virtual device includes M transparent devices, M being a positive integer; the target transparent device is one of the M transparent devices that has a data transparent requirement; and the first memory requirement is a memory amount of a mapping memory required by the target transparent device to perform data transparent transmission.

[0159] The obtaining unit 901 is further configured to call a memory allocation interface provided by the first virtual device to obtain the mapping memory of the first memory requirement from a memory mapping pool in the first virtual device.

[0160] The processing unit 902 is further configured to, if the mapping memory of the first memory requirement is not obtained, determine whether the memory manager satisfies a memory allocation condition, and allocate first system memory supported by the memory manager to the memory mapping pool if the memory manager satisfies the memory allocation condition.

[0161] In one embodiment, the obtaining unit 901 is configured to monitor a mapping memory amount corresponding to the memory mapping pool in the first virtual device; the mapping memory amount is a memory amount of the mapping memory in the memory mapping pool in an idle state; if it is monitored that the mapping memory amount is less than the first memory requirement, the mapping memory of the first memory requirement is not supported to be obtained; and if it is monitored that the mapping memory amount is greater than or equal to the first memory requirement, the mapping memory of the first memory requirement is supported to be obtained.

[0162] In one embodiment, the processing unit 902 is configured to determine a target allocation amount according to the mapping memory amount corresponding to the memory mapping pool in the first virtual device and the first memory requirement; the obtaining unit 901 is configured to obtain a first memory allocation amount corresponding to a memory manager in the first virtual device; the first memory allocation amount is a memory amount of first system memory supported by the memory manager to perform direct memory access mapping; and the processing unit 902 is configured to determine that the memory manager satisfies the memory allocation condition if the first memory allocation amount is greater than or equal to the target allocation amount.

[0163] In one embodiment, M is greater than 1, the mapping memory used by any transparent device is released to the memory mapping pool after the direct memory access operation based on the mapping memory is performed; the processing unit 902 is further configured to: if the memory manager does not meet the memory allocation condition and other transparent devices in the M transparent devices are performing data transparent transmission, at least waiting for the other transparent devices to release the mapping memory used to the memory mapping pool; the memory amount of the mapping memory in the idle state in the memory mapping pool increases with the release of the mapping memory by the other transparent devices; the obtaining unit 901 is further configured to: after the memory amount of the mapping memory in the idle state in the memory mapping pool reaches the first memory requirement amount, re-calling the memory allocation interface to obtain the first requirement amount of the mapping memory from the memory mapping pool.

[0164] In one embodiment, the first virtual device and the recycling module in the target physical device have a communication connection established therebetween; the memory manager meeting the memory allocation condition means that the first memory allocation margin corresponding to the memory manager is greater than or equal to the target allocation amount; the processing unit 902 is specifically configured to: obtaining the physical address of the first system memory of the target allocation amount in the first virtual device; sending the physical address of the first system memory of the target allocation amount in the first virtual device to the recycling module in the target physical device, so that the recycling module establishes the mapping relationship between the physical address of the first system memory of the target allocation amount in the first virtual device and the corresponding physical address in the target physical device; receiving the first completion instruction sent by the recycling module to obtain the mapping memory of the target allocation amount, the mapping memory of the target allocation amount being managed by the memory mapping pool.

[0165] In one embodiment, the first virtual device further includes a memory mapping pool, the memory mapping pool being configured to manage the mapping memory, the mapping memory being the first system memory that has performed the direct memory access mapping; the first system memory of the target memory amount is designated to support allocation to at least one service; the transceiving unit 903 is further configured to: receiving a running request for a target service, and allocating the first system memory from the memory manager in the first virtual device according to the running request for the target service; wherein the target service refers to any one of the at least one service;

[0166] The processing unit 902 is further configured to: if no allocation is made, determining whether the memory mapping pool meets the memory release condition; in the case where the memory mapping pool meets the memory release condition, determining the target release amount and releasing the mapping memory in the memory mapping pool to the memory manager according to the target release amount.

[0167] In an embodiment, the second memory requirement of the target service is included in the running request of the target service; the obtaining unit 901 is further configured to: obtain the second memory requirement of the target service from the running requirement of the target service, the second memory requirement being a memory amount of the first system memory required by the target service in a running process; and obtain the second memory allocation margin of the memory manager, the second memory allocation margin being a memory margin of the first system memory in the memory manager that supports being allocated to the target service.

[0168] The processing unit 902 is further configured to: compare the second memory allocation margin and the second memory requirement; and determine that the target release amount is not allocated if the second memory allocation margin is less than the second memory requirement.

[0169] In an embodiment, the obtaining unit 901 is further configured to: obtain a memory idle amount of the memory mapping pool and a preset memory reservation amount of the memory mapping pool; the memory idle amount being a mapping memory in an idle state in the memory mapping pool; and the preset memory reservation amount being determined based on a number of pass-through devices in the first virtual device or being specified by the target object.

[0170] The processing unit 902 is further configured to: compare the memory idle amount and the preset memory reservation amount; and determine that the memory mapping pool satisfies the memory release condition if the memory idle amount is greater than the preset memory reservation amount.

[0171] In an embodiment, the first virtual device and a recovery module in the target physical device are communicatively connected; and the processing unit 902 is specifically configured to: obtain a physical address of the target release amount of the mapping memory in the first virtual device; send the physical address of the target release amount of the mapping memory in the first virtual device to the recovery module in the target physical device, so that the recovery module removes a mapping relationship between the physical address of the target release amount of the mapping memory in the first virtual device and a corresponding physical address in the target physical device; and receive a second completion instruction sent by the recovery module, to obtain the target release amount of the first system memory, the target release amount of the first system memory being managed by the memory manager.

[0172] It can be understood that the specific functions of each unit of the memory processing apparatus described in the embodiments of the present application can be implemented according to the methods in the above method embodiments, and the specific implementation process can refer to the related description of the above method embodiments, which will not be described here. In addition, the beneficial effects of using the same method are not described again.

[0173] An example embodiment of the present application further provides a structural diagram of a computer device, which can be seen from FIG. 10. The computer device can include a processor 1001, an input device 1002, an output device 1003 and a memory 1004. The processor 1001, the input device 1002, the output device 1003 and the memory 1004 are connected through a bus. The memory 1004 is used for storing a computer readable storage medium, which includes a computer program. The processor 1001 is used for executing the computer program stored in the memory 1004, so as to perform the following operations: obtaining load information of a first virtual device in a running process of the first virtual device, the load information including usage information of a first system memory; the first virtual device runs in a target physical device, and the first system memory is a system memory allocated to the first virtual device by the target physical device; the first system memory is managed by a memory manager in the first virtual device and is not mapped for direct memory access; the memory manager supports pre-allocating part of the first system memory for performing direct memory access mapping, so as to be used for data transparent transmission between the first virtual device and the target physical device; when the usage information of the first system memory meets a memory recycling condition, determining a target recycling amount according to the usage information of the first system memory; recycling, according to the target recycling amount, the first system memory in the first virtual device which supports being recycled to the memory manager in the first virtual device; and sending a memory recycling instruction to the target physical device, the memory recycling instruction being used for instructing the target physical device to recycle the first system memory from the memory manager in the first virtual device.

[0174] In an example embodiment, the usage information of the first system memory includes at least one of the following: a memory usage amount of the first system memory; an I / O interface delay corresponding to the first system memory; a memory allocation time consumption of the first system memory; and the usage information of the first system memory meeting the memory recycling condition refers to at least one of the following: the memory usage amount of the first system memory is less than or equal to a first preset usage amount; the I / O interface delay corresponding to the first system memory is less than or equal to a first preset delay; and the memory allocation time consumption of the first system is less than or equal to a preset allocation time consumption.

[0175] In an example embodiment, the processor 1001 is further used for: detecting a first memory amount of the first system memory in the idle state in the memory manager in the first virtual device; and if the first memory amount reaches a preset memory amount, triggering the step of sending the memory recycling instruction to the target physical device.

[0176] In an embodiment, if the first memory amount reaches the preset memory amount, the processor 1001 is further configured to: aggregate the first system memory recycled into the memory manager according to the preset memory amount, to obtain at least one memory block; and the memory recycling instruction is configured to instruct the target physical device to recycle the at least one memory block from the memory manager in the first virtual device.

[0177] In an embodiment, the load information of the first system memory further includes demand information of the first system memory and a reference recycling amount of the first system memory, the reference recycling amount being a memory amount supporting the recycled first system memory; and the processor 1001 is specifically configured to: determine a recycling ratio of the first system memory according to the usage information of the first system memory and the demand information of the first system memory; and determine the target recycling amount according to the recycling ratio of the first system memory and the reference recycling amount of the first system memory.

[0178] In an embodiment, the target physical device further runs a second virtual device; and if the second virtual device has a memory usage demand, the first system memory recycled from the memory manager in the first virtual device is allocated to the second virtual device by the target physical device.

[0179] In an embodiment, the data transparent transmission is performed by a transparent transmission device in the first virtual device; the first virtual device further includes a memory mapping pool, the memory mapping pool being configured to manage mapping memory, the mapping memory being the first system memory that has been subjected to direct memory access mapping and is used in the process of data transparent transmission; and the processor 1001 is further configured to: obtain a first memory demand amount corresponding to a target transparent transmission device in the first virtual device; the first virtual device includes M transparent transmission devices, M being a positive integer; the target transparent transmission device is one of the M transparent transmission devices that has a data transparent transmission demand; and the first memory demand amount is a memory amount of mapping memory required by the target transparent transmission device to perform data transparent transmission; invoke a memory allocation interface provided by the first virtual device to obtain the mapping memory of the first memory demand amount from the memory mapping pool in the first virtual device; and if the mapping memory of the first memory demand amount is not obtained, determine whether the memory manager satisfies a memory allocation condition, and allocate the first system memory supporting allocation in the memory manager to the memory mapping pool if the memory manager satisfies the memory allocation condition.

[0180] In an embodiment, the processor 1001 is configured to: monitor a mapping memory surplus amount corresponding to the memory mapping pool in the first virtual device; the mapping memory surplus amount being a memory amount of the mapping memory in the memory mapping pool in an idle state; if it is monitored that the mapping memory surplus amount is less than the first memory demand amount, the mapping memory of the first memory demand amount is not supported to be obtained; and if it is monitored that the mapping memory surplus amount is greater than or equal to the first memory demand amount, the mapping memory of the first memory demand amount is supported to be obtained.

[0181] In an embodiment, the processor 1001 is configured to: determine a target allocation amount according to a mapping memory remaining amount corresponding to the memory mapping pool in the first virtual device and a first memory requirement; obtain a first memory allocation remaining amount corresponding to a memory manager in the first virtual device; the first memory allocation remaining amount refers to a memory remaining amount of a first system memory supporting execution of a direct memory access mapping in the memory manager; and determine that the memory manager satisfies a memory allocation condition if the first memory allocation remaining amount is greater than or equal to the target allocation amount.

[0182] In an embodiment, M is greater than 1, and the mapping memory used by any transparent device after execution of a direct memory access operation based on the mapping memory is released to the memory mapping pool; and the processor 1001 is further configured to: if the memory manager does not satisfy the memory allocation condition and other transparent devices in the M transparent devices are executing data transparent transmission, wait at least for the other transparent devices to release the used mapping memory to the memory mapping pool; the memory amount of the mapping memory in an idle state in the memory mapping pool increases with the release of the mapping memory by the other transparent devices; and after the memory amount of the mapping memory in the idle state in the memory mapping pool reaches the first memory requirement, the memory allocation interface is reinvoked to obtain the first requirement amount of the mapping memory from the memory mapping pool.

[0183] In an embodiment, a communication connection is established between the first virtual device and a recovery module in a target physical device; the memory manager satisfies the memory allocation condition if a first memory allocation remaining amount corresponding to the memory manager is greater than or equal to the target allocation amount; and the processor 1001 is specifically configured to: obtain a physical address of the first system memory of the target allocation amount in the first virtual device; send the physical address of the first system memory of the target allocation amount in the first virtual device to the recovery module in the target physical device, so that the recovery module establishes a mapping relationship between the physical address of the first system memory of the target allocation amount in the first virtual device and a corresponding physical address in the target physical device; and receive a first completion instruction sent by the recovery module to obtain the mapping memory of the target allocation amount, the mapping memory of the target allocation amount being managed by the memory mapping pool.

[0184] In an embodiment, the first virtual device further comprises a memory mapping pool, the memory mapping pool being configured to manage mapped memory, the mapped memory being first system memory that has performed direct memory access mapping; the first system memory of a target memory amount is designated to support allocation to at least one service; the processor 1001 is further configured to: receive a running request for a target service, and allocate the first system memory from the memory manager in the first virtual device according to the running request for the target service; wherein the target service is any one of the at least one service; if not allocated, determine whether the memory mapping pool satisfies a memory release condition; in a case where the memory mapping pool satisfies the memory release condition, determine a target release amount, and release the mapped memory in the memory mapping pool to the memory manager according to the target release amount.

[0185] In an embodiment, the running request for the target service comprises a second memory requirement amount of the target service; the processor 1001 is further configured to: obtain the second memory requirement amount corresponding to the target service from the running requirement for the target service, the second memory requirement amount being a memory amount of the first system memory required by the target service during running; obtain a second memory allocation residual amount corresponding to the memory manager, the second memory allocation residual amount being a memory residual amount of the first system memory in the memory manager that supports allocation to the target service; compare the second memory allocation residual amount and the second memory requirement amount; if the second memory allocation residual amount is less than the second memory requirement amount, it is determined that the target release amount is not allocated.

[0186] In an embodiment, the processor 1001 is further configured to: obtain a memory idle amount corresponding to the memory mapping pool and a preset memory reservation amount corresponding to the memory mapping pool; wherein the memory idle amount is the mapped memory in the memory mapping pool in an idle state; the preset memory reservation amount is determined based on a number of pass-through devices in the first virtual device, or is designated by a target object; compare the memory idle amount and the preset memory reservation amount; if the memory idle amount is greater than the preset memory reservation amount, it is determined that the memory mapping pool satisfies the memory release condition.

[0187] In an embodiment, the first virtual device and a recovery module in a target physical device have a communication connection; the processor 1001 is specifically configured to: obtain a physical address of the mapped memory of the target release amount in the first virtual device; send the physical address of the mapped memory of the target release amount in the first virtual device to the recovery module in the target physical device, so that the recovery module removes a mapping relationship between the physical address of the mapped memory of the target release amount in the first virtual device and a corresponding physical address in the target physical device; receive a second completion instruction sent by the recovery module, to obtain the first system memory of the target release amount, the first system memory of the target release amount being managed by the memory manager.

[0188] It should be understood that the computer device described in the embodiments of the present application can execute the description of the memory processing method in the foregoing corresponding embodiments, and can also execute the description of the memory processing device in the foregoing corresponding embodiments, which will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated.

[0189] In addition, it should be noted here that the embodiments of the present application also provide a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program includes program instructions. When the processor executes the above-mentioned program instructions, the method in the foregoing corresponding embodiments of FIG. 2, FIG. 4 and FIG. 6 can be executed, and therefore, this will not be repeated here.

[0190] According to an aspect of the present application, a computer program product is provided, which includes a computer program stored in a computer readable storage medium. The processor of the computer device reads the computer program from the computer readable storage medium, and the processor executes the computer program, so that the computer device can execute the method in the foregoing corresponding embodiments of FIG. 2, FIG. 4 and FIG. 6, and therefore, this will not be repeated here.

[0191] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a computer readable storage medium, and the program can include the processes of the above-mentioned embodiments when executed.

[0192] The above only discloses a preferred embodiment of the present application, and of course cannot limit the scope of the present application. A person of ordinary skill in the art can understand that all or part of the processes of the above-mentioned embodiments can be implemented, and equivalent changes made according to the claims of the present application still belong to the scope of the present application.

Claims

1. A memory processing method, characterized by, The method comprises: During running of a first virtual device, obtaining load information of the first virtual device, the load information comprising usage information of a first system memory; the first virtual device is running in a target physical device, and the first system memory is a system memory allocated to the first virtual device by the target physical device; the first system memory is managed by a memory manager in the first virtual device and is not mapped for direct memory access; the memory manager supports pre-allocation of part of the first system memory for direct memory access mapping, for data transparent transmission between the first virtual device and the target physical device; When the usage information of the first system memory satisfies a memory recovery condition, determining a target recovery amount according to the usage information of the first system memory; Recovering, according to the target recovery amount, the first system memory that supports being recovered in the first virtual device to the memory manager in the first virtual device; Sending a memory recovery instruction to the target physical device, the memory recovery instruction being used for instructing the target physical device to recover the first system memory from the memory manager in the first virtual device.

2. The method of claim 1, wherein, The usage information of the first system memory comprises at least one of the following: a memory usage amount of the first system memory; an I / O interface delay corresponding to the first system memory; a memory allocation time consumption of the first system memory; The usage information of the first system memory satisfying the memory recovery condition refers to at least one of the following: the memory usage amount of the first system memory being less than or equal to a first preset usage amount; the I / O interface delay corresponding to the first system memory being less than or equal to a first preset delay; the memory allocation time consumption of the first system being less than or equal to a preset allocation time consumption.

3. The method of claim 1 or 2, wherein, The method further comprises: detecting a first memory amount of the first system memory in an idle state in the memory manager in the first virtual device; if the first memory amount reaches a preset memory amount, triggering execution of the step of sending the memory recovery instruction to the target physical device.

4. The method according to any one of claims 1 to 3, characterized in that, If the first memory amount reaches a preset memory amount, the method further comprises: aggregating the first system memory recovered to the memory manager according to the preset memory amount, to obtain at least one memory block; wherein the memory recovery instruction is used for instructing the target physical device to recover the at least one memory block from the memory manager in the first virtual device.

5. The method according to any one of claims 1 to 4, characterized in that, The load information of the first system memory further comprises demand information of the first system memory and a reference recovery amount of the first system memory, the reference recovery amount referring to a memory amount of the first system memory that supports being recovered; The determining of the target recovery amount according to the usage information of the first system memory comprises: determining a recovery ratio of the first system memory according to the usage information of the first system memory and the demand information of the first system memory; determining the target recovery amount according to the recovery ratio of the first system memory and the reference recovery amount of the first system memory.

6. The method according to any one of claims 1 to 5, wherein, The target physical device also runs a second virtual device; if the second virtual device has a memory usage requirement, the first system memory recovered from the memory manager in the first virtual device is allocated to the second virtual device by the target physical device.

7. The method according to any one of claims 1 to 6, wherein The data transparent transmission is performed by a transparent transmission device in the first virtual device; the first virtual device also includes a memory mapping pool, which is used to manage mapping memory, the mapping memory being the first system memory that has been performed direct memory access mapping, and the mapping memory being used in the process of the data transparent transmission; the method further comprises: Obtaining a first memory requirement corresponding to a target transparent transmission device in the first virtual device; wherein the first virtual device includes M transparent transmission devices, M being a positive integer; the target transparent transmission device being one of the M transparent transmission devices that has a data transparent transmission requirement, and the first memory requirement being the memory amount of the mapping memory required by the target transparent transmission device to perform data transparent transmission; Calling a memory allocation interface provided by the first virtual device to obtain the mapping memory of the first memory requirement from the memory mapping pool in the first virtual device; If the mapping memory of the first memory requirement is not obtained, determining whether the memory manager meets the memory allocation condition, and in the case that the memory manager meets the memory allocation condition, allocating the first system memory supported by the memory manager to the memory mapping pool.

8. The method according to any one of claims 1 to 7, wherein, The method further comprises: Monitoring the mapping memory amount corresponding to the memory mapping pool in the first virtual device; wherein the mapping memory amount is the memory amount of the mapping memory in the idle state in the memory mapping pool; If it is monitored that the mapping memory amount is less than the first memory requirement, the mapping memory of the first memory requirement is not supported to be obtained; If it is monitored that the mapping memory amount is greater than or equal to the first memory requirement, the mapping memory of the first memory requirement is supported to be obtained.

9. The method according to any one of claims 1 to 8, wherein, The method further comprises: Determining a target allocation amount according to the mapping memory amount corresponding to the memory mapping pool in the first virtual device and the first memory requirement; Obtaining a first memory allocation amount corresponding to the memory manager in the first virtual device; the first memory allocation amount being the memory amount of the first system memory supported by the memory manager to perform direct memory access mapping; If the first memory allocation amount is greater than or equal to the target allocation amount, it is determined that the memory manager meets the memory allocation condition.

10. The method of any one of claims 1-9, wherein, The M is greater than 1, and the mapping memory used by any transparent transmission device after performing the direct memory access operation is released to the memory mapping pool; The method further comprises: If the memory manager does not meet the memory allocation condition, and other transparent transmission devices in the M transparent transmission devices are performing data transparent transmission, at least waiting for other transparent transmission devices to release the used mapping memory to the memory mapping pool; the memory amount of the mapping memory in the idle state in the memory mapping pool increases with the release of the mapping memory by other transparent transmission devices. After the memory amount of the mapping memory in the idle state in the memory mapping pool reaches a first memory requirement amount, the memory allocation interface is called again to obtain the first requirement amount of the mapping memory from the memory mapping pool.

11. The method of any one of claims 1-10, wherein, The first virtual device and a recycling module in the target physical device have a communication connection established therebetween; the memory manager satisfying a memory allocation condition means that a first memory allocation surplus amount corresponding to the memory manager is greater than or equal to a target allocation amount; The first system memory supported by the memory manager for allocation is allocated to the memory mapping pool, including: Obtaining a physical address of the target allocation amount of the first system memory in the first virtual device; Sending the physical address of the target allocation amount of the first system memory in the first virtual device to the recycling module in the target physical device, so that the recycling module establishes a mapping relationship between the physical address of the target allocation amount of the first system memory in the first virtual device and a corresponding physical address in the target physical device; Receiving a first completion instruction sent by the recycling module to obtain the target allocation amount of the mapping memory, the target allocation amount of the mapping memory being managed by the memory mapping pool.

12. The method of any one of claims 1-11, wherein, The first virtual device further includes a memory mapping pool, and the memory mapping pool is used to manage mapping memory, the mapping memory being first system memory that has performed direct memory access mapping; The target memory amount of the first system memory is designated to support allocation to at least one service; the method further includes: Receiving a running request for a target service and allocating first system memory from the memory manager in the first virtual device according to the running request for the target service; wherein the target service is any one of the at least one service; If not allocated, determining whether the memory mapping pool satisfies a memory release condition; In the case that the memory mapping pool satisfies the memory release condition, determining a target release amount and releasing the mapping memory in the memory mapping pool to the memory manager according to the target release amount.

13. The method of any one of claims 1-12, wherein, The running request for the target service includes a second memory requirement amount of the target service; the method further includes: Obtaining the second memory requirement amount corresponding to the target service from the running requirement for the target service, the second memory requirement amount being a memory amount of the first system memory required by the target service in the running process; Obtaining a second memory allocation surplus amount corresponding to the memory manager, the second memory allocation surplus amount being a memory surplus amount of the first system memory supported by the memory manager for allocation to the target service; Comparing the second memory allocation surplus amount and the second memory requirement amount; If the second memory allocation surplus amount is less than the second memory requirement amount, it is determined that the allocation is not made.

14. The method of any one of claims 1-13, wherein, The method further includes: acquire a memory idle amount corresponding to the memory mapping pool and a preset memory reserved amount corresponding to the memory mapping pool; the memory idle amount refers to mapping memory in an idle state in the memory mapping pool; the preset memory reserved amount is determined based on a number of pass-through devices in the first virtual device or is specified by a target object; compare the memory idle amount and the preset memory reserved amount; if the memory idle amount is greater than the preset memory reserved amount, determine that the memory mapping pool satisfies a memory release condition.

15. The method of any one of claims 1-14, wherein, The first virtual device and the recycling module in the target physical device have a communication connection; the releasing of the mapping memory in the memory mapping pool into the memory manager according to the target release amount includes: acquiring a physical address of the target release amount of mapping memory in the first virtual device; sending the physical address of the target release amount of mapping memory in the first virtual device to the recycling module in the target physical device, so that the recycling module cancels the mapping relationship between the physical address of the target release amount of mapping memory in the first virtual device and the corresponding physical address in the target physical device; receiving a second completion instruction sent by the recycling module to obtain a target release amount of first system memory, the target release amount of first system memory being managed by the memory manager.

16. A memory processing device, comprising: The apparatus includes: an acquisition unit, configured to acquire load information of a first virtual device in a running process of the first virtual device, the load information including usage information of first system memory; the first virtual device runs in a target physical device; the first system memory is system memory allocated to the first virtual device by the target physical device; the first system memory is managed by a memory manager in the first virtual device and is not executed for direct memory access mapping; the memory manager supports pre-allocation of part of the first system memory for direct memory access mapping, for data pass-through between the first virtual device and the target physical device; a processing unit, configured to determine a target recycling amount according to the usage information of the first system memory when the usage information of the first system memory satisfies a memory recycling condition; recycle the first system memory in the first virtual device that supports recycling into the memory manager in the first virtual device according to the target recycling amount; a transceiving unit, configured to send a memory recycling instruction to the target physical device, the memory recycling instruction being used to instruct the target physical device to recycle first system memory from the memory manager in the first virtual device.

17. A computer device, comprising: include: a processor adapted to execute a computer program; a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by the processor to perform the memory processing method of any one of claims 1-15.

18. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to perform the memory processing method of any one of claims 1-15.

19. A computer program product, characterised in that, The computer program product comprises computer programs or computer instructions which are executed by a processor to implement the memory processing method according to any one of claims 1-15.

Citation Information

Patent Citations

  • Cloud platform virtual machine memory capacity reduction method and device and storage medium

    CN115309504A

  • Memory recovery method and server

    CN117827687A

  • Memory reclaim management for virtual machines

    US10346313B1