Memory processing method and related equipment
By actively reclaiming unmapped virtual device memory and sending memory reclamation commands, the problem of balancing memory reclamation efficiency and performance loss in virtualization scenarios is solved, achieving efficient memory super-allocation and resource utilization.
Patent Information
- Application Number
- CN202410903907.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2026-01-13
AI Technical Summary
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.
By acquiring the load information of virtual devices, determining the conditions for memory reclamation, and actively reclaiming system memory that has not undergone direct memory access mapping, memory reclamation instructions are sent to physical devices to achieve efficient memory reclamation and data pass-through.
It improves memory reclamation efficiency, reduces performance loss of virtual devices, and enhances memory over-division efficiency and resource utilization.
Smart Images

Figure CN121326480A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a memory processing method and related equipment. Background Technology
[0002] In virtualization scenarios, memory super-division of virtual devices (i.e., virtual machines) is an important memory management technique. Memory super-division refers to the situation where the total physical memory of the physical device (i.e., the host machine) is less than the sum of the memory configurations of all virtual devices on the physical device. It allows multiple virtual devices to share the physical memory of the physical device, supporting the operation of more virtual devices even when the physical memory of the physical device is insufficient to meet the memory requirements of all virtual devices. Virtual devices typically have idle memory, which can be reclaimed from the physical device and allocated to other virtual devices on the physical device, thereby improving the memory utilization of the physical device and achieving memory super-division. However, in current memory processing mechanisms, some virtual devices supporting data pass-through cannot efficiently reclaim idle memory in order to ensure low performance loss, resulting in a long memory super-division time. Conversely, even when idle memory in the virtual device can be efficiently reclaimed, data pass-through incurs significant performance losses. Therefore, virtual devices supporting data pass-through cannot effectively balance memory reclamation efficiency with the performance losses associated with data pass-through. Summary of the Invention
[0003] This application provides a memory processing method and related equipment, which can improve memory reclamation efficiency and reduce performance loss caused by data pass-through.
[0004] On one hand, embodiments of this application provide a memory processing method, the method comprising:
[0005] During the operation of the first virtual device, the load information of the first virtual device is obtained, including the usage information of the first system memory; the first virtual device runs in the target physical device, and the first system memory is the system memory allocated to the first virtual device by the target physical device; the first system memory is managed by the memory manager in the first virtual device and is not subject to direct memory access mapping; the memory manager supports pre-allocating a portion of the first system memory to perform direct memory access mapping for data pass-through between the first virtual device and the target physical device;
[0006] When the memory usage information of the first system meets the memory reclamation conditions, the target reclamation amount is determined based on the memory usage information of the first system.
[0007] According to the target reclamation amount, the first system memory that can be reclaimed in the first virtual device is reclaimed to the memory manager in the first virtual device;
[0008] Send a memory reclamation command to the target physical device. The memory reclamation command is used to instruct the target physical device to reclaim the first system memory from the memory manager in the first virtual device.
[0009] On one hand, embodiments of this application provide a memory processing apparatus, the apparatus comprising:
[0010] The acquisition unit is used to acquire the load information of the first virtual device during its operation. The load information includes the usage information of the first system memory. The first virtual device runs in the target physical device. The first system memory is the system memory allocated to the first virtual device by the target physical device. The first system memory is managed by the memory manager in the first virtual device and is not subject to direct memory access mapping. The memory manager supports pre-allocating a portion of the first system memory to perform direct memory access mapping for data pass-through between the first virtual device and the target physical device.
[0011] The processing unit is configured to: when the usage information of the first system memory meets the memory reclamation conditions, determine the target reclamation amount based on the usage information of the first system memory; and reclaim the first system memory that is eligible for reclamation in the first virtual device to the memory manager in the first virtual device according to the target reclamation amount.
[0012] The transceiver unit is used to send memory reclamation instructions to the target physical device. The memory reclamation instructions are used to instruct the target physical device to reclaim the first system memory from the memory manager in the first virtual device.
[0013] On one hand, embodiments of this application provide a computer device, the computer device comprising:
[0014] A processor is used to execute computer programs;
[0015] A computer-readable storage medium that stores a computer program, which, when executed by a processor, implements the memory processing method described above.
[0016] Accordingly, embodiments of this application provide a computer-readable storage medium storing a computer program, which is loaded by a processor and executed as described above in the memory processing method.
[0017] Accordingly, this application provides a computer program product, which includes a computer program or computer instructions, and the computer program or computer instructions implement the above-described memory processing method when executed by a processor.
[0018] In this embodiment, the first virtual device can determine whether to perform proactive memory reclamation based on the usage information of the first system memory included in its own load information. Since the first system memory is system memory allocated to the first virtual device and does not undergo direct memory access mapping, reclamation of the first system memory ensures that none of the memory is in a direct memory access mapping state, avoiding the need for demapping during memory reclamation and thus improving memory reclamation efficiency. Furthermore, the first system memory managed by the memory manager supports allocating a portion of the first system memory for direct memory access mapping to facilitate data pass-through between the first virtual device and the target physical device. By pre-preparing the memory needed for data pass-through, frequent execution of direct memory access mapping can be avoided, improving data pass-through efficiency while reducing performance loss for the first virtual device. Additionally, when the memory reclamation conditions are met, the first virtual device reclaims its internally reclaimable first system memory, avoiding operating system lag and high latency issues caused by reclaiming unreclaimable memory within the first virtual device, thus ensuring the operating performance of the first virtual device. The target reclamation amount limits the memory allocation pressure after the memory is reclaimed to the target physical device. Furthermore, the first virtual device sends a memory reclamation command to the target physical device, actively notifying the target physical device to reclaim the idle first system memory from within the first virtual device. In this way, if multiple virtual devices are running in the target physical device, it does not rely on the target physical device to monitor each virtual device. Instead, the virtual devices actively notify the target physical device when there is idle system memory, thereby enabling more efficient memory reclamation and reducing the time consumed by memory over-allocation. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is an architectural diagram of a memory processing system provided in an exemplary embodiment of this application;
[0021] Figure 2 This is a flowchart illustrating a memory processing method provided in an exemplary embodiment of this application;
[0022] Figure 3 This is a schematic diagram of a memory reclamation process provided in an exemplary embodiment of this application;
[0023] Figure 4 This is a flowchart illustrating a memory processing method provided in an exemplary embodiment of this application;
[0024] Figure 5 This is a schematic diagram of a dynamic memory adjustment process provided in an exemplary embodiment of this application;
[0025] Figure 6 This is a flowchart illustrating a memory processing method provided in an exemplary embodiment of this application;
[0026] Figure 7 This is a schematic diagram of a dynamic memory adjustment process provided in an exemplary embodiment of this application;
[0027] Figure 8 This is an interactive flowchart of memory processing provided in an exemplary embodiment of this application;
[0028] Figure 9 This is a schematic diagram of the structure of a memory processing device provided in an exemplary embodiment of this application;
[0029] Figure 10 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0031] This application proposes a memory processing scheme involving a memory processing system, method, and related devices. In this scheme, a first virtual device can acquire its own load information during operation, including the usage information of the first system memory. This first system memory is system memory allocated to the first virtual device by the target physical device and not subject to direct memory access mapping (i.e., DMA mapping). This first system memory is managed by a memory manager within the first virtual device. When the usage information of the first system memory meets the memory reclamation conditions, the first virtual device can actively reclaim reclaimable first system memory within itself to the memory manager and send a memory reclamation command to the target physical device, causing the target physical device to reclaim free first system memory from the memory manager within the first virtual device. Thus, on the one hand, when reclamating the first system memory, this application can ensure that the reclaimed first system memory is not in a DMA mapping state, avoiding the need for demapping during memory reclamation, thereby improving memory reclamation efficiency; on the other hand, by targeting the amount of memory to be reclaimed, it also limits the memory allocation pressure after the memory is reclaimed to the target physical device. On the other hand, the first virtual device actively notifies the target physical device to reclaim idle first system memory from within the first virtual device. If multiple virtual devices are running on the target physical device, this can be achieved without relying on the target physical device monitoring each virtual device. Instead, the virtual devices actively notify the target physical device when idle memory exists, thus enabling more efficient memory reclamation. Furthermore, since the memory manager supports pre-allocating a portion of the first system memory for DMA mapping, this is used for data pass-through between the first virtual device and the target physical device. By pre-preparing the memory needed for data pass-through, frequent direct memory access mapping can be avoided, improving data pass-through efficiency and reducing performance loss for the first virtual device.
[0032] A target physical device refers to a real-world physical computer (such as a cloud server or terminal). One or more virtual devices can be created within a target physical device using virtualization software (also known as a virtual device manager or hypervisor, such as VMware or Hyper-V); each virtual device is a virtual computer (i.e., a virtual machine instance). A virtual machine (VM) is a software-simulated computer system that provides a user with an environment isolated from physical hardware. Virtualization abstracts the resources of a physical computer, such as its processor, memory, storage, and network, into multiple virtual resources, enabling the running of multiple operating systems and applications on the physical computer. Each virtual device can install and run an operating system (GuestOS; such as Linux). When virtual devices exist within a target physical device, the operating system installed on that device can be called the host operating system (i.e., HostOS; such as Windows). This host operating system is used to host the virtual devices, and resource allocation (such as memory allocation) for each virtual device is completed on the host operating system. Virtual devices created in the target physical device can be started and run based on corresponding startup instructions. The first virtual device refers to one of at least one virtual device currently running in the target physical device. It should be noted that the terms "first," "second," etc., used in this application are used to distinguish identical or similar items with essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor is there a limitation on quantity or execution order. The term "at least one" in this application refers to one or more, and "multiple" means two or more; for example, "at least one virtual machine" refers to one, 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 applications within it. For example, if the memory configuration of the first virtual device is 4GB ("G" stands for gigabyte, representing memory size), then 4GB of physical memory can be allocated from the target physical device for the first virtual device, resulting in 4GB of usable system memory within the first virtual device. The system memory of the first virtual device is the memory space usable by the operating system of the first virtual device. It simulates the function of physical memory, enabling the first virtual device to run the operating system and applications as if they were on a physical device. The system memory allocated to the first virtual device is a part of the physical memory of the target physical device and can be isolated and allocated through virtualization technology. System memory is typically used to store data that needs to be loaded immediately when some programs in the first virtual device are executed (called runtime data). It is understandable that if the target physical device also allocates system memory for a second virtual device, for ease of description, the system memory allocated to the second virtual device can be referred to as second system memory and is not subject to direct memory access mapping (i.e., DMA mapping).
[0034] Data pass-through is supported between the first virtual device and the target physical device. Data pass-through means that data can be transferred between the first virtual device and the target physical device without going through the central processing unit (CPU). Data pass-through includes Direct Memory Access (DMA) operations. DMA is a computer technology that allows external devices to directly access main memory (such as the first virtual device directly accessing its corresponding physical memory) without CPU intervention. Before performing a DMA operation, the system memory needs to be DMA-mapped. DMA mapping is also an important concept in virtualization technology; it allows pass-through devices to bypass the CPU and directly write data to or read data from memory. The system memory undergoing DMA mapping is kept in a "pin" (or "locked") state. Once the system memory is "pinned," it remains in physical memory and will not be swapped to disk or other storage devices. If all system memory allocated to the first virtual device is pre-mapped using DMA, even if there is free memory, the host machine cannot efficiently reclaim it. Instead, it needs to first demap the free first system memory that has undergone DMA mapping before the memory can be unpinned and reclaimed for use by other virtual devices. This leads to low memory resource utilization and affects the efficiency of memory over-allocation. In this application, by pre-mapping a portion of the first system memory using DMA, on the one hand, it can be directly used for DMA operations without frequent DMA mapping, reducing performance loss. On the other hand, since a portion of the first system memory is DMA-mapped, any free first system memory that has not undergone DMA mapping can be directly reclaimed if it meets the reclamation conditions, without wasting resources and time demapping the memory.
[0035] During the normal operation of the first virtual device, its actual usage of the first system memory may be less than the memory configuration, resulting in idle first system memory within the first virtual device. This idle first system memory can be reclaimed from the target physical device for allocation to other virtual devices. For example, after being reclaimed from the target physical device, the idle first system memory can be allocated to a second virtual device. This enables memory over-allocation for virtual devices. Furthermore, the idle first system memory is not in a DMA-mapped state, further accelerating the reclamation of idle first system memory and improving the efficiency of memory over-allocation. Based on this, the memory processing solution provided in this application can be applied to the following scenarios: memory over-allocation for virtual machines and cloud container over-allocation relying on virtualization technology. For example, cloud service providers can provide cloud computing, cloud storage and other services to a large number of service users. Each service user can apply for a corresponding amount of memory to ensure the normal operation of cloud services. However, in actual use, there may be idle parts in the corresponding amount of memory applied for by service users. Therefore, cloud service providers can reclaim some idle memory according to actual usage and allocate it to other service users to improve the resource utilization of cloud servers and provide more flexible and economical cloud services.
[0036] It should be noted that, in this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0037] This application relates to cloud technology, specifically cloud computing within the category of cloud infrastructure technologies. Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Cloud computing is a computing model that distributes computing tasks across a resource pool composed of numerous computers, enabling various application systems to access computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." Resources in the "cloud" appear infinitely scalable to users, readily available, on-demand, expandable, and pay-as-you-go. As a provider of basic cloud computing capabilities, a cloud computing resource pool (referred to as a cloud platform, generally called an IaaS (Infrastructure as a Service) platform) is established, deploying various types of virtual resources within the pool for external customers to choose from. The cloud computing resource pool primarily includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices. For example, the first virtual device in this application is a type of virtual resource within the cloud computing resource pool.
[0038] The architecture of the memory processing system provided in the embodiments of this application will now be described with reference to the accompanying drawings.
[0039] Please see Figure 1 , Figure 1 This is an architectural diagram of a memory processing system provided in an exemplary embodiment of this application. (See diagram for details.) Figure 1As shown, the memory processing system includes a target physical device and K virtual devices (virtual device V1, virtual device V2, ..., virtual device Vk, respectively); K is a positive integer, where at least one of the K virtual devices is running on the target physical device. Each virtual device is hosted by the operating system of the target physical device (i.e., the host operating system) and managed by a virtual device manager on the host operating system. The operating systems of each virtual device and the target physical device can communicate with each other, and each virtual device's operating system runs a memory manager. The target physical device can be a terminal or a server. Terminals include, but are not limited to, smartphones, tablets, smart wearable devices, smart voice interaction devices, smart home appliances, personal computers, in-vehicle terminals, smart cameras, etc., and this application does not impose any restrictions on their number. A server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as 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 big data and artificial intelligence platforms, but it is not limited to these. This application does not limit the number of servers.
[0040] The following section uses virtual device V1, which runs on the first virtual device as the target physical device, as an example to introduce the general process of memory processing:
[0041] ① During the operation of the first virtual device (i.e., virtual device V1), the first virtual device can obtain its own load information, which may include the usage information of the first system memory. The first system memory is managed by the memory manager within the first virtual device. The first system memory is the system memory allocated to the first virtual device by the target physical device, and which has not undergone direct memory access mapping. The first system memory managed by the memory manager supports pre-allocating a portion of the first system memory for direct memory access mapping, used for data pass-through between the first virtual device and the target physical device.
[0042] It is understandable that all system memory allocated to the first virtual device can be managed by the memory manager without performing DMA mapping initially; that is, all allocated system memory is considered first system memory. Within the first system memory managed by the memory manager, a portion of pre-allocated first system memory can be used for direct memory access mapping. This portion of first system memory used for direct memory access mapping is no longer managed by the memory manager but by other dedicated modules (such as memory mapping pools).
[0043] In one implementation, the first virtual device can acquire the load information of the first virtual device according to a preset period. By periodically acquiring the load information of the first virtual device, the load information of the first virtual device can be monitored, and the memory usage information of the first system included in the load information can be used to determine whether to actively reclaim memory.
[0044] ② The first virtual device determines whether the memory reclamation conditions are met based on the usage information of the first system memory. If the usage information of the first system memory meets the memory reclamation conditions, a target reclamation amount can be determined based on the usage information of the first system memory, and the first system memory that can be reclaimed in the first virtual device can be reclaimed to the memory manager in the first virtual device according to the target reclamation amount. The target reclamation amount can control the amount of reclaimable memory that the first virtual device reclaims internally, and the memory allocation pressure can be controlled by taking into account the load information of the first virtual device.
[0045] ③ The first virtual device sends a memory reclamation command to the target physical device. After receiving the memory reclamation command, the target physical device can reclaim the first system memory from the memory manager in the first virtual device. It can be understood that the first system memory reclaimed here is the first system memory in the memory manager that is in an idle state, while the first system memory reclaimed to the memory manager inside the first virtual device is the first system memory in use, and this memory is also in an idle state after being reclaimed to the memory manager.
[0046] ④ The second virtual device (such as virtual device V3) sends a memory usage request to the target physical device. Upon receiving the memory usage request, the target physical device confirms that the second virtual device has a memory usage requirement and allocates the first system memory reclaimed from the first virtual device to the second virtual device.
[0047] In one implementation, the second virtual device triggers a page fault when it needs system memory, allowing the target physical device to allocate system memory to the second virtual device. Here, a page fault refers to a missing memory address in the page table that the operating system of the second virtual device is accessing. The page table records the memory address of the second system memory that is mapped to the physical memory of the target physical device; this memory address is a virtual memory space address.
[0048] It is worth noting that each virtual device can execute the memory reclamation logic shown in ①-③ above or the memory request logic shown in ④. If multiple virtual devices running on the target physical device (such as virtual device V1 and virtual device V2, etc.) have idle system memory, they can actively send memory reclamation instructions to the target physical device. Based on the memory reclamation instructions, the target physical device can reclaim idle system memory from the memory manager in the corresponding virtual device, so that virtual devices with memory usage needs can allocate the corresponding memory from the target physical device for use. Since not all of the system memory allocated to the first virtual device is DMA mapped, but only a portion of the first system memory is DMA mapped, even if the first virtual device has a pass-through device, it is not necessary to pin all the memory. Instead, idle memory can be reclaimed at any time. In this way, it can effectively support memory over-allocation for virtual devices with pass-through devices, enabling dynamic memory allocation for each virtual device and keeping performance loss controllable.
[0049] The memory processing method provided in the embodiments of this application will be described next.
[0050] Please see Figure 2 This is a schematic flowchart illustrating a memory processing method provided in an exemplary embodiment of this application. The memory processing method can be implemented by a first virtual device (such as...). Figure 1 The memory handling method can be executed by the first virtual device in the system and may include the following.
[0051] S201, during the operation of the first virtual device, the load information of the first virtual device is obtained, including the memory usage information of the first system.
[0052] The first virtual device runs on the target physical device; the target physical device has at least one virtual device running on it, and the first virtual device is any one of the at least one virtual devices. The at least one virtual device running on the target physical device is managed by a virtual device manager in the target physical device, which can be invoked by the target physical device and allocates system memory for the first virtual device based on its memory configuration.
[0053] The first system memory is the system memory allocated to the first virtual device by the target physical device; and it is not subject to direct memory access mapping. The first system memory is managed by the memory manager in the first virtual device. An operating system (i.e., guest operating system) is installed in the first virtual device, and the memory manager runs on the operating system (GuestOS) of the first virtual device. The first system memory managed by the memory manager may include the characteristics shown in (1) and (2) below:
[0054] (1) The state of the first system memory managed by the memory manager can change dynamically.
[0055] The state of the first system memory managed by the memory manager can include at least one of the following: idle state and used state. Depending on the state of the first system memory, the first system memory managed by the memory manager can include at least one of the following: free first system memory and allocated first system memory. Free first system memory refers to first system memory in an idle state, that is, first system memory not allocated to any process or service in the first virtual device; allocated first system memory refers to first system memory in a used state, such as first system memory used for caching data. Furthermore, the memory manager has different management permissions for first system memory in different states. For example, the memory manager has allocation permissions for first system memory in an idle state, but not for first system memory in a used state. When free first system memory is allocated to a process in the first virtual device, the state of the free first system memory can change to a used state.
[0056] (2) The amount of memory in the first system memory managed by the memory manager can change dynamically.
[0057] 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 mapped memory. Mapped memory is the first system memory in a DMA-mapped state, or in other words, the first system memory after DMA mapping has been performed. Since the allocated first system memory is no longer managed by the memory manager after DMA mapping, the amount of first system memory managed by the memory manager will decrease. In another implementation, the system memory that has undergone DMA mapping can also be unmapped. This unmapped system memory can then be used as first system memory and managed by the memory manager; therefore, the amount of first system memory managed by the memory manager will increase.
[0058] The memory manager supports pre-allocating a portion of the first system memory for direct memory access mapping (DMA) to facilitate data pass-through between the first virtual device and the target physical device. In other words, 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 no DMA mapping is performed. In one embodiment, the first virtual device includes a memory mapping pool. Based on the memory requirements of the memory mapping pool, it can request memory from the memory manager. The memory manager can allocate a portion of the managed first system memory and perform DMA mapping on this allocated portion. This DMA-mapped first system memory is called mapped memory. After the first system memory allocated from the memory manager is DMA-mapped, this portion of the first system memory is no longer managed by the memory manager but by the memory mapping pool (DMA pool) in the first virtual device.
[0059] In one embodiment, the first virtual device can be started and run on the target physical device based on a startup command. During the operation of the first virtual device, the load information of the first virtual device can be obtained at a preset period (such as 1 second or 1 minute). Since the processes or services running in the first virtual device are dynamic, the load information obtained at different times is also dynamic.
[0060] The load information includes usage information for the first system memory. This first system memory usage information indicates the usage of the first system memory by various processes in the first virtual device, such as how much first system memory is used, how much is remaining, and the time spent allocating it to processes. Optionally, the first system memory usage information may include: the amount of first system memory used, the allocation time of the first system memory, and the I / O interface latency corresponding to the first system memory. Here, the amount of first system memory used refers to the amount of first system memory in use managed by the memory manager. The I / O interface latency corresponding to the first system memory refers to the time the first virtual device waits for I / O operations to complete when reading and writing data using the first system memory. The memory allocation time of the first system memory refers to the time difference between a service request to allocate first system memory in the first virtual device and the successful allocation of the first system memory to the service. Each time the first virtual device obtains the load information, it can determine whether the first system memory usage information included in the load information meets the memory reclamation conditions, and then perform corresponding processing based on different determination results.
[0061] S202, when the memory usage information of the first system meets the memory reclamation conditions, determine the target reclamation amount based on the memory usage information of the first system.
[0062] In one implementation, the usage information of the first system memory includes at least one of the following: ① the memory usage of the first system memory; ② the I / O interface latency corresponding to the first system memory; ③ the memory allocation time of the first system memory. Based on the content included in the usage information of the first system memory, the memory reclamation condition is met if at least one of the following is true: ④ the memory usage of the first system memory is less than or equal to a first preset usage; ⑤ the I / O interface latency corresponding to the first system memory is less than or equal to a first preset latency; ⑥ the memory allocation time of the first system is less than or equal to a preset allocation time. The first preset usage, the first preset latency, and the preset allocation time can be set by the service provider based on the minimum business requirements of the first virtual device, or by the first virtual device based on a preset pressure threshold.
[0063] It should be noted that if the first system memory usage information includes ①-③, then the first system memory usage information satisfying the memory reclamation condition means any one or more of ④-⑥; if the first system memory usage information includes any one of ①-③, then the first system memory usage information satisfying the memory reclamation condition means any one of the corresponding ④-⑥. For example, if the first system memory usage information includes ①, then the first system memory usage information satisfying the memory reclamation condition means ④. If the first system memory usage information includes any two of ①-③, then the first system memory usage information satisfying the memory reclamation condition can include at least one of any two of the corresponding ④-⑥. For example, if the first system memory usage information includes ① and ②, then the first system memory usage information satisfying the memory reclamation condition can be one or both of ④ and ⑤.
[0064] When the usage information of the first system memory meets the memory reclamation conditions, it indicates that the memory allocation pressure in the first virtual device is relatively small. Therefore, the target reclamation amount can be determined based on the usage information of the first system memory, and then the reclaimable first system memory in the first virtual device can be reclaimed to the internal memory manager according to the target reclamation amount.
[0065] In one feasible approach, the load information of the first system memory also includes the demand information of the first system memory and a reference reclamation amount of the first system memory. This reference reclamation amount is the amount of first system memory that can be reclaimed; it can also be called the reclaimable amount. For example, if the reference reclamation amount of the first system memory is 3MB, it means that there is 3MB of first system memory in use that can be reclaimed. Here, MB is a unit of storage capacity, specifically representing megabytes. The first virtual device can first determine the reclamation ratio of the first system memory based on the usage information and the demand information, and then determine the target reclamation amount according to the reclamation ratio and the reference reclamation amount.
[0066] By analyzing the memory demand and usage information of the first system memory, the memory allocation pressure of the first system memory can be determined, and then the memory reclamation ratio can be determined based on this pressure. The demand information includes the required amount, and the usage information includes the amount of memory used and the total amount of memory in the first system. Based on the usage and total memory, the available amount of memory can be determined, and the reclamation ratio is then determined based on the difference between the demand and the available amount. This is because the difference between the demand and the available amount of memory reflects the memory allocation pressure; the larger the difference, the greater the memory allocation pressure, and vice versa. There is a negative correlation between memory allocation pressure and the memory reclamation ratio: the greater the allocation pressure, the smaller the reclamation ratio, and vice versa. The memory reclamation ratio can be a percentage, such as 80% or 70%. The target amount of memory to be reclaimed is the result of multiplying the reference amount of memory to be reclaimed and the reclaim ratio of the first system memory. For example, if the reference amount of memory to be reclaimed is 30MB and the reclaim ratio is 90%, then based on the reclaim ratio and the reference amount, the target amount to be reclaimed is determined to be 27MB. By flexibly controlling the reclaim ratio through memory allocation pressure, the intensity of active memory reclamation can be controlled, ensuring that memory reclamation does not affect the smooth operation of the first virtual device.
[0067] S203, according to the target reclamation amount, reclaim the first system memory in the first virtual device that supports reclamation to the memory manager in the first virtual device.
[0068] The first system memory eligible for reclamation refers to the freeable memory within the first virtual device, also known as reclaimable memory. This reclaimable memory is in use before being reclaimed; that is, the first system memory eligible for reclamation belongs to the allocated first system memory. For example, in caches and buffers used to store frequently used data, data occupies a certain amount of first system memory. When this data is no longer needed, the first system memory it occupies can be reclaimed, and the reclamation will not affect the operation of the first virtual device or the processes running on the first virtual device. The first system memory eligible for reclamation in the first virtual device can include the following types: ① First system memory occupied by caches or buffers in the first virtual device; for example, the first system memory occupied by page caches. ② Unnecessary background processes or services in the first virtual device. ③ First system memory occupied by temporary files or logs in the first virtual device. It can be understood that the state of first system memory in use can be updated to free after it is reclaimed to the memory manager in the first virtual device.
[0069] The reclamation of first-system memory that is eligible for reclamation back to the memory manager means returning unused first-system memory to the memory manager so that it can be allocated to other programs or data that need memory, and the memory manager has allocation authority over it. In one embodiment, the memory manager stores a free list and an allocation list. The free list records the memory addresses of first-system memory that is in a free state, and the allocation list records the memory addresses of first-system memory that is in use, i.e., this first-system memory is allocated to processes within the first virtual device. Based on this, when the first virtual device reclaims first-system memory that is eligible for reclamation, it can remove the memory address of the first-system memory that is eligible for reclamation from the allocation list and add the memory address of the first-system memory that is eligible for reclamation to the free list. The amount of first-system memory that is in a free state managed by the memory manager can increase as first-system memory that is eligible for reclamation is reclaimed.
[0070] S204, a memory reclamation instruction is sent to the target physical device, which instructs the target physical device to reclaim the first system memory from the memory manager in the first virtual device.
[0071] The first system memory in a free state in the memory manager includes at least one of the following: unallocated first system memory (this portion of first system memory is free and has not been changed), and first system memory that has been allocated but reclaimed by the memory manager (this portion of first system memory was in use before being reclaimed and is now free after being reclaimed). The memory addresses of unallocated first system memory are contiguous, while the first system memory reclaimed by the memory manager is mostly fragmented memory with non-contiguous memory addresses. The first system memory reclaimed by the target physical device from the memory manager of the first virtual device is all first system memory in a free state (also referred to as idle system memory).
[0072] In one implementation, the total amount of first system memory reclaimed to the memory manager of the first virtual device is the target reclamation amount, and most of this reclaimed first system memory consists of fragmented memory. After the target reclamation amount is reached, the first virtual device can send a memory reclamation command to the target physical device, so that the target physical device can reclaim the first system memory from the memory manager of the first virtual device based on the received memory reclamation command.
[0073] In another implementation, the first amount of idle first system memory in the memory manager of the first virtual device can be detected first. If the first amount of memory reaches a preset amount, the step of sending a memory reclamation instruction to the target physical device is triggered. Specifically, the detection of the first amount of memory can be performed periodically after the active memory reclamation conditions are met, and this application does not limit this. For example, the detected first amount of memory increases as more first system memory that supports reclamation is reclaimed to the memory manager. The preset amount of memory mentioned above can be determined based on the size of the memory block corresponding to the physical memory in the target physical device, wherein the memory addresses of the physical memory in the memory block are contiguous, such as memory block sizes of 2MB, 4MB, 8MB, etc. The preset amount of memory can be the size of a single memory block or a multiple of the size of a single memory block. For example, if the memory block size in the target physical device is 2MB, then the preset amount of memory can be set to 2MB or 4MB.
[0074] After determining that the first system memory meets the memory reclamation conditions, and before reclaiming the reclaimable memory, if the memory addresses of the first system memory in the idle state managed by the memory manager are contiguous, and the first memory amount reaches a preset memory amount, the step of sending a memory reclamation command to the target physical device can be directly triggered, thereby enabling the target physical device to reclaim the contiguous first system memory. For example, if the memory manager has 2MB of contiguous first system memory, a memory reclamation command can be sent to the target physical device, allowing the target physical device to reclaim the 2MB of contiguous first system memory. Since the reclamation of reclaimable memory has not yet been performed, the step of reclaiming the reclaimable memory to the memory manager according to the target reclamation amount can also be performed synchronously or asynchronously. After the first system memory is reclaimed to the memory manager, the steps of detecting and determining whether the preset memory amount has been reached can continue.
[0075] In another implementation, the first system memory in the first virtual device is managed in units of pages (i.e., memory page tables). A page is the smallest unit for allocation and reclamation by the memory manager. The operating system of the first virtual device can divide the memory space of the first system memory into fixed-size pages, each page being an independent block of the first system memory used to map to a corresponding memory block in physical memory. Since most of the first system memory reclaimed into the memory manager is fragmented, to further reduce performance loss, when the first memory amount is detected to have reached a preset amount, the reclaimed first system memory can be aggregated according to the preset amount to obtain at least one memory block.
[0076] Each memory block comprises contiguous primary system memory and is managed by a corresponding memory page table. After the reclaimable primary system memory is returned to the memory manager, a dedicated kernel thread can be invoked for aggregation, consolidating fragmented primary system memory into contiguous pages of a predetermined amount. The extent to which these pages are consolidated is controlled by an active reclamation algorithm that determines the target amount to be reclaimed. Once at least one memory block is obtained, the step of sending a memory reclamation command to the target physical device can be triggered.
[0077] The above-described aggregation process for the reclaimed first system memory is conditional upon the target reclamation amount being greater than or equal to a preset memory amount. If the target reclamation amount is less than the preset memory amount, since the reclaimable memory has not reached the preset amount, the consolidation process can be temporarily suspended. Instead, after step S203, new load information for the first virtual device is obtained, and active memory reclamation logic is executed based on this new load information until the reclaimed first system memory in the memory manager reaches the preset memory amount, at which point the consolidation process is performed. After memory consolidation, the memory addresses of the first system memory in the idle state are contiguous. The target physical device can reclaim the first system memory from the memory manager according to the preset memory amount, thereby releasing the idle first system memory to the operating system of the target physical device in units of the preset memory amount.
[0078] In another implementation, the step of sending a memory reclamation instruction to the target physical device can be triggered based on the relationship between the target reclamation amount and the preset memory amount, under the target condition; or, the step of aggregating the first system memory reclaimed to the memory manager according to the preset memory amount can be triggered under the target condition to obtain at least one memory block. For example, if the target reclamation amount is less than the preset memory amount, then the target condition is that the first memory amount reaches the target reclamation amount; if the target reclamation amount is greater than or equal to the preset memory amount, then the target condition is that the first memory amount reaches the preset memory amount.
[0079] In one embodiment, the target physical device includes a memory reclamation module. A memory reclamation command is sent to the memory reclamation module in the target physical device, instructing it to reclaim first system memory from the memory manager in the first virtual device. That is, a memory reclamation command is sent to the memory reclamation module in the target physical device to reclaim the first system memory from the memory manager in the first virtual device. Furthermore, since the first system memory in an idle state exists in the memory manager as at least one memory block, the reclamation command instructs the memory reclamation module in the target physical device to reclaim at least one memory block from the memory manager in the first virtual device. This allows memory to be released from the operating system of the first virtual device to the operating system of the target physical device in units of memory blocks, without needing to reorganize fragmented system memory in the host system, thus reducing performance loss. Therefore, the reclamation of the first system memory from the first virtual device to the target physical device is executed by the reclamation module, and since the reclaimed first system memory is unmapped by DMA, it can be directly released in the target physical device.
[0080] Optionally, the first virtual device includes a memory reclamation algorithm module, which can be used to execute steps S202-S204 or S201-S204 as described above. This memory reclamation algorithm module deploys an active memory reclamation algorithm to implement the logic of active memory reclamation. For the above process, please refer to... Figure 3 The diagram illustrates an exemplary memory reclamation flowchart. The acquired virtual machine load information serves as input for determining whether to trigger an active memory reclamation algorithm. After comprehensively considering the first system memory usage information (such as memory usage, memory allocation time, and I / O latency), the memory reclamation algorithm module decides whether to trigger active memory reclamation. If active memory reclamation is not triggered, the virtual machine load information is continuously acquired. If active memory reclamation is triggered, the reclamation amount R is determined based on the reclaimable amount and the reclamation ratio. Memory reclamation within the virtual machine operating system is then executed according to the reclamation amount R. Finally, it is determined whether the free first system memory in the memory manager has reached a preset memory amount. If so, the memory reclamation module reclaims free memory from the memory manager; otherwise, memory reclamation within the virtual machine operating system continues until the preset memory amount is reached.
[0081] When the memory usage information of the first system does not meet the memory reclamation conditions, it indicates that the memory allocation pressure in the first virtual device is relatively high. In one implementation, the first virtual device may not perform memory reclamation, but instead continuously obtain the latest memory usage information of the first system until the obtained memory usage information of the first system meets the memory reclamation conditions, at which point it will actively reclaim memory.
[0082] In one embodiment, at least one container runs in the first virtual device, and each container can run an application. These containers can be cloud containers, and according to their scope, can include at least one of the following: 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 all containers is greater than the amount of first system memory managed by the memory manager, so the first system memory used by each container can also be dynamically reclaimed or allocated. Each container supports direct memory access operations, and each container shares the pass-through device and memory mapping pool of the first virtual device. If DMA operations exist in a container, mapped memory can also be allocated from the memory mapping pool, and DMA operations can be performed in the container based on the allocated mapped memory.
[0083] In another embodiment, there are several ways in which the first system memory is reclaimed by the operating system of the target physical device and made available to other virtual devices. For example, the target physical device may also run a second virtual device, which is any virtual device other than the first virtual device among at least one virtual device running on the target physical device. If the second virtual device has memory usage requirements, the first system memory reclaimed from the memory manager of the first virtual device is allocated to the second virtual device by the target physical device. The memory usage requirements can be confirmed based on the second virtual device sending a memory allocation request to the target physical device. The memory usage requirements of the second virtual device arise under one or more of the following conditions: ① The memory configuration of the second virtual device changes, and the changed memory configuration is higher than the previous memory configuration; ② The memory usage of the second virtual device is greater than the amount of memory actually allocated to the second virtual device. For example, the system memory originally allocated to the second virtual device may be reclaimed, resulting in the second virtual device having less system memory than its memory configuration. When the second virtual device needs more system memory to process business, it needs to request memory allocation from the target physical device due to insufficient memory.
[0084] The memory allocation request sent by the second virtual device includes the amount of 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 amount of memory in the memory allocator request. The system memory allocated to the second virtual device includes the first system memory reclaimed from the memory manager in the first virtual device.
[0085] The memory processing scheme provided in this application embodiment allows the first virtual device to actively monitor whether it meets the memory reclamation conditions. When the conditions are met, the reclaimable memory in the first virtual device is first reclaimed to the memory manager. Then, a memory reclamation command is sent to the target physical device to reclaim the idle first system memory in the first virtual device. Thus, the idle first system memory in the first virtual device can be released back to the host machine and made available to other virtual devices, achieving memory super-allocation under virtualization and applicable to virtual machines with pass-through devices. Considering the load of the first virtual device and the internal reclamation processing of reclaimable memory within the virtual machine, memory can be safely reclaimed from the reclaimable memory of the first virtual device for use by other virtual devices, and the performance loss in the first virtual device is within a controllable range.
[0086] Please see Figure 4 This is a schematic flowchart illustrating a memory processing method provided in an exemplary embodiment of this application. The memory processing method can be implemented by a first virtual device (such as...). Figure 1The first virtual device in the process will be used to execute this. Before introducing this embodiment, we will first briefly introduce the relevant content of data pass-through.
[0087] Data pass-through between the first virtual device and the target physical device is performed by a pass-through device within the first virtual device. This pass-through device allows the first virtual device to directly access the 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, PCI device passthrough can be used to directly allocate physical PCI devices from the host machine to guest machines. PCI device passthrough allows virtual machines to directly access physical PCI devices on the host machine, and this virtualization technology is often used in scenarios requiring high performance or specific hardware functions, such as using high-performance network interface cards (NICs) in virtual machines. The pass-through device can operate in Direct Memory Access (DMA) mode, specifically for performing DMA operations. In DMA mode, memory can be accessed directly without going through the CPU (Central Processing Unit), thus transparently (i.e., without user or CPU intervention) transferring data between the device and memory. In DMA mode, data transfer is handled by a dedicated hardware device (the DMA controller), rather than the CPU. The DMA controller can directly read data from the device and write it to memory, or directly read data from memory and write it to the device, without CPU intervention. Pass-through devices can directly access memory under the management of the DMA controller to perform data read and write operations.
[0088] The first virtual device includes a memory manager and a memory mapping pool (denoted as DMA Pool), which can be deployed within the operating system of the first virtual device. The memory mapping pool includes mapped memory, which refers to the first system memory that has undergone direct memory access mapping; mapped memory is used during data pass-through. Specifically, the pass-through device needs to utilize a corresponding amount of mapped memory when performing DMA operations. Furthermore, the sum of the amount of mapped memory (N1) managed by the memory mapping pool and the amount of first system memory (N2) managed by the memory manager equals the amount of allocated system memory (N); N, N1, and N2 are all greater than 0. That is, of all the system memory allocated to the first virtual device, a portion of the system memory is not subject to DMA mapping; this portion is the first system memory and is managed by the memory manager. Another portion of the system memory undergoes DMA mapping; this portion is mapped memory and is managed by the memory mapping pool. The memory managed by the memory manager and 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 DMA mapping is performed, but is managed by the memory mapping pool; the mapped memory managed by the memory mapping pool can be regarded as dedicated system memory, specifically for allocation to the pass-through device; when the mapped memory managed by the memory mapping pool is demapped by DMA, it is no longer managed by the memory mapping pool, but is managed by the memory manager.
[0089] Since only a portion of the first system memory in the first virtual device with the pass-through device undergoes DMA mapping in advance, it is unnecessary to keep all system memory allocated to the first virtual device in a pinned state. On the one hand, idle system memory in the first virtual device can be directly reclaimed, shortening the memory reclamation processing path, improving memory reclamation efficiency, and thus improving memory resource utilization. On the other hand, pre-completing DMA mapping of a portion of the system memory allows for the pre-preparation of the mapped memory required for DMA operations. This means that mapped memory can be immediately obtained when there is a need for data pass-through processing, instead of triggering DMA mapping only when the actual DMA operation is performed. This avoids the time consumption caused by the long front-end and back-end interaction path of DMA mapping, improving the processing efficiency of data pass-through and greatly reducing the performance loss caused by dynamic DMA mapping.
[0090] Based on the above description, the first virtual device, based on the included memory manager and memory mapping pool, can also execute the memory processing flow shown in S401-S404 below.
[0091] S401, obtain the first memory requirement corresponding to the target transparent device in the first virtual device.
[0092] The first virtual device includes M passthrough devices (denoted as PassThrough Devices), where M is a positive integer. The target passthrough device refers to one of the M passthrough devices that has a data passthrough requirement. This data passthrough requirement indicates that the target passthrough device needs to transfer target data between the first virtual device and the target physical device. The target data to be transferred can be data written to physical memory or data to be read from physical memory. In one implementation, the load information of the first virtual device also includes the first memory requirement corresponding to the target passthrough device. The first virtual device can obtain the first memory requirement corresponding to the target passthrough device from the load information. This first memory requirement refers to the amount of mapped memory required by the target passthrough device to perform data passthrough. For example, the target passthrough device needs 4MB of mapped memory to perform data passthrough.
[0093] S402, call the memory allocation interface provided by the first virtual device to obtain the mapped memory of the first memory requirement from the memory mapping pool in the first virtual device.
[0094] To reduce the performance impact of frequent dynamic DMA mapping, the first virtual device can capture the memory allocation interface provided by itself, ensuring that mapped memory requiring DMA operations is allocated from the DMA pool. The mapped memory managed by the DMA pool is obtained by pre-mapping a batch of first system memory using DMA. When any pass-through device has a data pass-through requirement, it means that the data pass-through needs to be executed by that pass-through device. During data pass-through, the first virtual device can call the memory allocation interface to obtain the corresponding amount of mapped memory from the DMA pool and allocate it to the pass-through device.
[0095] In one implementation, whether the first virtual device can obtain the required amount of mapped memory from the memory-mapped pool can be determined based on the relationship between the amount of unused mapped memory (i.e., idle mapped memory) in the memory-mapped pool and the first memory requirement. The first virtual device can monitor the remaining mapped memory in the memory-mapped pool within the first virtual device; if the monitored remaining mapped memory is less than the first memory requirement, obtaining the required amount of mapped memory is not supported; if the monitored remaining mapped memory is greater than or equal to the first memory requirement, obtaining the required amount of mapped memory is supported.
[0096] Specifically, since other pass-through devices may be performing DMA operations and using a certain amount of mapped memory in the first virtual device, or other pass-through devices may have completed their DMA operations and released the used mapped memory to the memory mapping pool, the amount of unused mapped memory in the memory mapping pool is dynamically changing. Mapped memory reserve refers to the amount of mapped memory in the memory mapping pool that is in a free state; the amount of mapped memory N1 managed by the memory mapping pool is the memory management amount, which is determined based on the memory management amount of the memory mapping pool and the amount of mapped memory used, i.e., mapped memory reserve = memory management amount - usage amount.
[0097] If the amount of idle mapped memory is less than the first memory requirement, it indicates that the amount of unused mapped memory in the memory mapping pool is insufficient. The memory mapping pool cannot provide enough free mapped memory for the target pass-through device, thus failing to obtain sufficient mapped memory from the memory mapping pool, and the first virtual device does not obtain the required amount of mapped memory. If the amount of idle mapped memory is greater than or equal to the first memory requirement, it indicates that the amount of unused mapped memory in the memory mapping pool is sufficient. The memory mapping pool can provide enough free mapped memory for the target pass-through device, and the required amount of mapped memory can be obtained from the memory mapping pool. Based on whether the required amount of mapped memory is obtained from the memory mapping pool, the following steps S403 or S404 can be executed.
[0098] S403, if the mapped memory of the first memory requirement is obtained, the mapped memory of the first memory requirement is allocated to the target transparent transmission device, and the target transparent transmission device is invoked to perform a direct memory access operation based on the mapped memory of the first memory requirement, so as to transmit the target data between the first virtual device and the target physical device.
[0099] Specifically, the target pass-through device performs DMA operations. During DMA operations, a buffer is needed to store data during transmission. The mapped memory of the first memory requirement is allocated to the target pass-through device. Specifically, a buffer is constructed using the mapped memory of the first memory requirement for the target pass-through device. This allows the target pass-through device to perform DMA operations on this buffer without going through the CPU of the first virtual device, enabling data transfer between the first virtual device and the target physical device. The mapped memory can be first system memory in a DMA-mapped state, ensuring that the memory allocated to the target pass-through device is in a DMA-mapped state, eliminating the need to perform DMA mapping on memory allocated from the memory mapping pool. The mapped memory's state can be either idle or used, depending on whether it is occupied. Mapped memory of the first memory requirement obtained from the memory mapping pool is in an idle state. After the mapped memory of the first memory requirement is allocated to the target pass-through device, its state changes to used. It is evident that when there is sufficient mapped memory in the memory-mapped pool and there is a need for data pass-through, the required amount of mapped memory can be obtained, ensuring the smooth execution of DMA operations and improving the efficiency of data pass-through.
[0100] S404 If the mapped memory for the first memory requirement is not obtained, determine whether the memory manager meets the memory allocation conditions, and if the memory manager meets the memory allocation conditions, allocate the first system memory that can be allocated in the memory manager to the memory mapping pool.
[0101] If the required amount of mapped memory is not obtained from the memory mapping pool, it indicates that the amount of idle mapped memory in the memory mapping pool is insufficient. Therefore, it is necessary to first check whether the memory manager has any available first system memory, and after performing DMA mapping on the first system memory, it can be handed over to the memory mapping pool for management. In a specific implementation, the determination of whether the memory manager meets the memory allocation conditions can include the following steps (1)-(3).
[0102] Step (1) Determine the target allocation amount based on the remaining mapped memory in the memory mapping pool of the first virtual device and the first memory requirement.
[0103] The difference between the remaining mapped memory and the initial memory requirement is used to obtain the memory difference. The absolute value of this memory difference is then determined as the target allocation amount. This target allocation amount indicates the difference in mapped memory required to perform the DMA operation.
[0104] Step (2) Obtain the first memory allocation margin corresponding to the memory manager in the first virtual device.
[0105] The first memory allocation margin refers to the remaining amount of first system memory in the memory manager that supports direct memory access mapping (DMA). In specific implementations, a portion of the first system memory managed by the memory manager may be pre-allocated to critical services in the first virtual device. This portion of the first system memory carries a corresponding service tag and cannot be allocated to other services. Therefore, the first virtual device can query the amount of allocatable first system memory from the idle first system memory in the memory manager based on the service tag carried by the first system memory. The allocatable first system memory supports DMA mapping. This first memory allocation margin is used to compare its size 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.
[0106] Step (3) If the first memory allocation margin is greater than or equal to the target allocation amount, then the memory manager is determined to meet the memory allocation conditions.
[0107] If the initial memory allocation margin is greater than or equal to the target allocation amount, it indicates that the memory manager has sufficient idle initial system memory available for allocation to the memory-mapped pool. Therefore, it can be determined that the memory manager meets the memory allocation conditions, and initial system memory can be allocated in batches from the memory manager. Conversely, if the initial memory allocation margin is less than the target allocation amount, it can be determined that the memory manager does not meet the memory allocation conditions. In this case, it can wait for other pass-through devices to release mapped memory to the mapped memory pool, or wait for other processes to release initial system memory so that the memory manager has sufficient memory available for allocation. Here, "other devices" refers to pass-through devices other than the target pass-through device that are currently using mapped memory.
[0108] Based on the above steps (1)-(3), the memory manager satisfies the memory allocation conditions as follows: 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 amount of first system memory allocated from the memory manager to the memory-mapped pool for management. In another implementation, the memory manager satisfies the memory allocation conditions as follows: the first memory allocation margin is greater than zero, that is, as long as there is free first system memory in the memory manager, then the first system memory can be allocated from the memory manager to the memory-mapped pool. When the first memory allocation margin is less than the target allocation amount, it is necessary to wait for other transparent devices to release the mapped memory to the memory-mapped pool, or for the used first system memory to be released to the memory manager (for example, the page cache is released to the memory manager after using up the first system memory).
[0109] The memory manager satisfies the memory allocation condition if: the first memory allocation margin 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 that can be allocated in the memory manager to the memory mapping pool, it can allocate the first system memory that can be allocated in the memory manager to the memory mapping pool according to the target allocation amount. Thus, the first system memory in the memory manager with the target allocation amount can be allocated to the memory mapping pool. Specifically, the process can begin by obtaining the first system memory from the memory manager according to the target allocation amount, and then performing DMA mapping (mmap) on the first system memory with the target allocation amount to obtain the mapped memory with the target allocation amount. This mapped memory with the target allocation amount is managed by the memory mapping pool.
[0110] A communication connection is established between the first virtual device and the recycling module on the operating system side of the target physical device. During DMA mapping, the physical address of the first system memory allocated to the first virtual device can be obtained. This physical address is then sent to the recycling module in the target physical device, enabling the recycling module to establish a mapping relationship between the physical address (GPA, i.e., the Guest OS physical address) of the first system memory allocated to the first virtual device and its corresponding physical address (HPA, i.e., the Host OS physical address) in the target physical device. The physical address of the first virtual device is obtained by converting its virtual address (Guest Virtual Address, GVA). The physical address of the first virtual device is first converted to the virtual address (Host Virtual Address, HPA) of the target physical device, and then converted back to the physical address of the target physical device. The mapping page table in the target physical device records the DMA mapping relationship; therefore, the mapping page can be updated based on the establishment of the mapping relationship between the corresponding physical addresses. After the recycling module is established, it can send a first completion instruction to the first virtual device. The first virtual device can receive the first completion instruction sent by the recycling module and obtain the target amount of mapped memory. That is, the memory manager can release the management of the target amount of first system memory, and the memory mapping pool can manage the target amount of first system memory after DMA mapping. In other words, the target amount of mapped memory is managed by the memory mapping pool.
[0111] Furthermore, after allocating a portion of the first system memory to the mapped memory pool from the memory manager in batches, the first virtual device can re-detect the memory allocation surplus in the memory-mapped pool. If the detected memory allocation surplus is sufficient to allocate to the target pass-through device, the memory allocation interface is invoked again to retrieve the first memory requirement's mapped memory from the memory-mapped pool. That is, after the first system memory is allocated, the memory allocation interface is invoked again to retrieve the first memory requirement's mapped memory from the memory-mapped pool.
[0112] In one embodiment, if the memory manager does not meet the memory allocation conditions, the system can wait for the first system memory being used to be released, for example, by setting a preset waiting time and then re-determining whether the memory manager meets the memory allocation conditions after the preset waiting time has elapsed.
[0113] In another embodiment, if the first virtual device includes multiple pass-through devices, if the memory manager does not meet the memory allocation conditions, it can be determined whether other pass-through devices in the first virtual device are using mapped memory. Therefore, it can wait for other pass-through devices to release the mapped memory before determining whether the memory mapping pool has sufficient mapped memory to support allocation. The number M of pass-through devices in the first virtual device is greater than 1. After any pass-through device completes a direct memory access operation based on mapped memory, the used mapped memory is released to the memory mapping pool, and the state of the mapped memory released to the memory mapping pool changes from a used state to an idle state. Based on this: if the memory manager does not meet the memory allocation conditions, and other pass-through devices among the M pass-through devices are performing data pass-through, then at least wait for other pass-through devices to release the used mapped memory to the memory mapping pool. Here, "other pass-through devices" refers to any pass-through device among the M pass-through devices other than the target pass-through device, and the amount of idle mapped memory in the memory mapping pool increases as other pass-through devices release mapped memory. Once the amount of idle mapped memory in the memory-mapped pool reaches the first memory requirement, the first virtual device can re-invoke the memory allocation interface to obtain the first required amount of mapped memory from the memory-mapped pool.
[0114] In one implementation, if the first memory allocation margin of the memory manager is non-zero, then since the memory manager also has a small amount of allocatable first system memory, besides waiting for other pass-through devices to release their used mapped memory to the memory mapping pool, the first system memory in the memory manager's first memory allocation margin can also be allocated to the memory mapping pool. The amount of idle mapped memory in the memory mapping pool increases with the allocation of first system memory. For example, the first memory requirement of pass-through device P1 is 4MB, but there is only 2MB in the memory mapping pool. Pass-through device P2 is using 1MB of mapped memory to perform DMA mapping, and the memory manager can only allocate 1MB. Therefore, we can: ① allocate 1MB of first system memory from the memory manager, and after performing DMA mapping, allocate this 1MB of first system memory to the memory mapping pool; ② wait for pass-through device P2 to release 1MB of mapped memory. In this way, the amount of unused mapped memory in the memory mapping pool reaches the first memory requirement of 4MB.
[0115] Based on the memory processing in steps S401-S404 above, the following can be provided: Figure 5 The flowchart illustrates an exemplary process for dynamic memory adjustment. First, the target pass-through device allocates the required mapped memory from the DMA pool via a memory allocation interface. Then, it determines whether the allocation is supported. If supported, the corresponding amount of mapped memory is allocated to the target pass-through device, which then performs direct memory access mapping (DMA mapping) based on the allocated mapped memory. Conversely, if not supported, it determines whether the memory manager meets the memory allocation conditions. If so, first system memory is allocated in batches from the memory manager to the memory pool; otherwise, it waits for at least one of the following: waiting for other pass-through devices to release mapped memory, or waiting for the used first system memory to be released.
[0116] It is understandable that the above steps S401-S404 and Figure 2 / Figure 3 The processes shown can be independent of each other. That is, when the target physical device reclaims the first system memory from the memory manager in the first virtual device, the first virtual device can also allocate mapped memory from the memory mapping pool for the pass-through device to use, and the pass-through device performs DMA operations based on the acquired mapped memory.
[0117] The memory processing method provided in this application embodiment can support memory over-allocation of virtual devices with pass-through devices. Since the operating system of the first virtual device performs DMA mapping in batches in advance when allocating memory to the DMA pool, and when reclaiming memory 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 de-DMA mapped in advance. In this way, memory over-allocation of virtual devices with pass-through devices can be effectively supported, so that the memory of the virtual device can be dynamically allocated.
[0118] Please see Figure 6 This is a schematic flowchart illustrating a memory processing method provided in an exemplary embodiment of this application. The memory processing method can be implemented by a first virtual device (such as...). Figure 1 The first virtual device in the system is used to execute the operation. In the case where the first virtual device includes a mapped memory pool and a memory manager, the first system memory of the target memory amount is specified to support allocation to at least one service, such as the startup of an application; any service is represented as the target service. There is a runtime requirement for the target service in the first virtual device. The first virtual device can also execute the following steps S601-S603.
[0119] S601, receives a running request for the target service, and allocates first system memory from the memory manager in the first virtual device according to the running request for the target service.
[0120] The target service refers to any one of at least one service. A run request for the target service instructs the execution of the target service, and the first system memory required by the target service is allocated from the memory manager. This run request for the target service can be initiated based on the target object's operation on the target application or automatically initiated by the first virtual device. Based on the run request, the corresponding amount of first system memory required by the target service can be allocated from the memory manager. However, if the memory manager may not have enough free first system memory to allocate to the target service, allocation will fail, and the target service will not be able to run. Therefore, it is necessary to determine whether the required amount of first system memory can be allocated to the target service. If the memory manager has sufficient first system memory to allocate to the target service, then the required amount of first system memory can be allocated from the memory manager to the target service, and the target service will run based on the allocated first system memory.
[0121] In one implementation, the execution request for the target service includes a second memory requirement corresponding to the target service. Based on this, determining whether the first system memory required by the target service can be allocated may include the following steps ①-③.
[0122] ① Obtain the second memory requirement corresponding to the target service from the execution requests for the target service. This second memory requirement refers to the amount of first system memory needed by the target service during its execution. For example, if the target service is a data processing task of an application, the second memory requirement is 2MB, meaning that 2MB of free system memory is needed to store the data of this data processing task.
[0123] ② Obtain the second memory allocation margin corresponding to the memory manager. This second memory allocation margin refers to the remaining first system memory in the memory manager that can be allocated to the target service. In one specific implementation, if other services are running in the first virtual device, these services will occupy a portion of the first system memory. Therefore, the remaining first system memory in the memory manager that can be allocated to the target service can be determined based on the target memory amount n1 and the amount of first system memory occupied by the other running services n2. That is, the second memory allocation margin = n1 - n2. Here, n1 and n2 are numbers greater than zero. In another specific implementation, if no other services are running in the first virtual device, then the target memory amount n1 can be determined as the second memory allocation margin.
[0124] ③ Compare the second memory allocation margin with the second memory requirement. If the second memory allocation margin is less than the second memory requirement, it is determined that no memory has been allocated. By comparing the second memory allocation margin and the second memory requirement, it can be determined whether sufficient first system memory can be allocated from the memory manager in the first virtual device to ensure the normal operation of the target service. If the second memory allocation margin is less than the second memory requirement, it indicates that the memory manager does not support allocating sufficient first system memory for the target service, thus determining that the required amount of first system memory has not been allocated. In this case, it is possible to check whether there is any excess free mapped memory in the memory pool to be released, or to wait for the release of the used first system memory. Conversely, if the second memory allocation margin is greater than or equal to the second memory requirement, it indicates that the memory manager supports allocating sufficient first system memory for the target service, and the required amount of first system memory can be allocated. Based on the first system memory allocated from the memory manager, the target service can run.
[0125] The above ①-③, by comparing the amount of memory that can be allocated in the memory manager with the amount of memory required by the target service for the first system, can accurately determine whether it is necessary to adjust the amount of memory in the first system managed by the memory manager based on the second memory requirement in the service request.
[0126] S602 If no memory is allocated, determine whether the memory-mapped pool meets the memory release conditions.
[0127] In the actual implementation, if the corresponding amount of first system memory is not allocated from the memory manager, then we can wait for other processes in the memory manager to release the first system memory. At the same time, we can check whether the memory mapping pool meets the memory release conditions, so that there is extra mapped memory that can be demapped and released to the memory manager, thereby increasing the amount of first system memory available in the memory manager.
[0128] In one implementation, determining whether a memory-mapped pool meets the memory release conditions can include the following steps 1-4.
[0129] Step 1: Obtain the free memory and the preset reserve amount corresponding to the memory mapping pool. Free memory refers to the mapped memory in the memory mapping pool that is currently idle. The first virtual device includes at least one pass-through device, each with data pass-through functionality. The preset memory reserve amount is determined based on the number of pass-through devices in the first virtual device, or specified by the target object. The target object refers to an object with operational permissions to 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 this preset memory reserve amount can be positively correlated with the number of pass-through devices; the more pass-through devices, the larger the preset memory reserve amount, and vice versa. By using the preset reserve amount, a minimum amount of mapped memory can be retained in the memory mapping pool, thereby ensuring the basic operation of the pass-through device.
[0130] Step 2: Compare the amount of free memory with the preset memory reserve. By comparing the amount of free memory in the memory-mapped pool with the preset memory reserve, it can be determined whether the memory-mapped pool can release excess mapped memory while retaining the minimum amount of free mapped memory.
[0131] Step 3: If the amount of free memory is greater than the preset memory reservation amount, then the memory-mapped pool meets the memory release condition. If the amount of free memory is greater than the preset memory reservation amount, it means that there is excess free mapped memory in the memory-mapped pool that can be released, thus confirming that the memory-mapped pool meets the memory release condition.
[0132] Step 4: If the amount of free memory is less than or equal to the preset memory reservation amount, then it is determined that the memory mapping pool does not meet the memory release conditions.
[0133] If the amount of free memory is less than or equal to the preset memory reservation amount, it means that there is no extra free mapped memory in the memory mapping pool that can be released. Therefore, it can be determined that the memory mapping pool has not met the memory release condition, and we can wait for other transparent devices to release the mapped memory back to the memory mapping pool.
[0134] In another implementation, the determination of whether the memory-mapped pool meets the memory release condition can include the following: obtaining the amount of free memory corresponding to the memory-mapped pool; if the amount of free memory is greater than zero, then the memory-mapped pool meets the memory release condition; if the amount of free memory is less than or equal to zero, then the memory-mapped pool meets the memory release condition.
[0135] S603: If the memory-mapped pool meets the memory release conditions, determine the target release amount and release the mapped memory in the memory-mapped pool to the memory manager according to the target release amount.
[0136] In one implementation, the memory release condition for a memory-mapped pool is met when the amount of free memory in the pool is greater than the preset reserve amount. If the amount of free memory is greater than the preset reserve amount, it means that there is excess free mapped memory in the memory-mapped pool that can be released. Therefore, when determining the target release amount, it can be determined based on: the amount of free memory in the memory-mapped pool and the preset reserve amount. Specifically, the difference between the amount of free memory and the preset reserve amount can be calculated to obtain the memory difference, i.e., the amount of free memory minus the preset reserve amount. Then, the memory difference is determined as the target release amount; or, the product of the memory difference and a preset release ratio can be determined as the target release amount. This preset release ratio is a value less than 1, and it is used to further control the amount of mapped memory released. It can be seen that the target release amount refers to the amount of mapped memory in the memory-mapped pool that exceeds the preset reserve amount. This portion of mapped memory can be released to the memory manager without affecting the requirements of the pass-through device.
[0137] In another implementation, the memory release condition of the memory-mapped pool is met when the amount of free memory corresponding to the memory-mapped pool is greater than zero. The amount of free memory corresponding to the memory-mapped pool can be directly determined as the target release amount.
[0138] The first virtual device can obtain the target amount of mapped memory from the memory-mapped pool. Since the target amount of mapped memory is obtained by performing DMA mapping on the first system memory, the DMA mapping needs to be unmapped before it is released to the memory manager. Therefore, the target amount of mapped memory can be unmapped to obtain the target amount of first system memory. Then, the memory address of the target amount of first system memory is added to the free list in the memory manager, so that the target amount of first system memory is managed by the memory manager.
[0139] In one implementation, a communication connection is established between the first virtual device and the reclamation module in the target physical device. During demapping, the first virtual device can obtain the physical address of the target amount of mapped memory in the first virtual device and send this physical address (i.e., GPA, GuestOS physical address) to the reclamation module of the target physical device. This allows the reclamation module in the target physical device to release the mapping relationship between the physical address of the target amount of mapped memory in the first virtual device and its 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 DMA mapping relationships. During demapping, the reclamation module can delete the mapping relationship of the corresponding physical address in the mapping page. After the reclamation module completes its setup, it can send a second completion instruction to the first virtual device. The first virtual device receives this instruction and obtains the target amount of first system memory. In other words, the memory mapping pool can release the management of the target amount of mapped memory, and the memory manager can manage the target amount of first system memory.
[0140] Based on the steps shown in S601-S603, the following can be provided: Figure 7 This is a schematic diagram illustrating an exemplary process for dynamic memory adjustment. Figure 7 As shown, upon receiving a request to run a target service, the system first checks if the memory manager has sufficient memory, specifically whether the free first system memory in the memory manager can support the operation of the target service. If so, it allocates first system memory from the memory manager to the target service and runs it. If not, it waits for the used first system memory to be released. Simultaneously, it checks if the memory mapping pool meets the memory release conditions. If not, it waits for other pass-through devices to release mapped memory to the memory mapping pool. If so, the memory mapping pool releases free mapped memory to the memory manager. Therefore, when the memory manager in the first virtual device is insufficient, if the DMA Pool has unused memory, it can also release a portion of the memory to the memory manager in batches. The DMA Pool enables dynamic adjustment between DMA mapped memory and first system memory.
[0141] Based on the above Figure 2 , Figure 4 as well as Figure 6 The embodiments shown can provide, for example Figure 8 The memory processing interaction flowchart shown illustrates the specific interaction processes involved in memory processing, implemented based on the virtual machine operating system and the host operating system. Figure 8As shown, the virtual machine operating system (GuestOS) includes a memory-mapped pool (DMA Pool), a pass-through device, a memory manager, and a memory reclamation algorithm module. The host operating system (HostOS) includes a memory reclamation module. The interaction flow between these modules is represented by numerical values. Flow "0" and flow "6" correspond to... Figure 2 The memory reclamation process is shown. Process "0" includes: reclaiming memory from the virtual machine operating system to the memory manager using the memory reclamation algorithm module. Process "6" refers to reclaiming memory from the GuestOS to the HostOS using the memory reclamation module. Since memory not in the DMA Pool has been unmapped from DMA, it can be directly released in the HostOS. Process "1" corresponds to... Figure 6 The memory processing flow is as follows: When the virtual machine's general memory manager is insufficient, if there is unused memory in the DMA Pool, a portion of that memory is released into the memory manager in batches. Flow "2" can correspond to... Figure 4 The memory processing flow is shown below. That is, when the virtual machine's DMA Pool is insufficient, if the memory manager has free memory, it will allocate a portion of memory to the DMA Pool in batches. Figure 2 and Figure 4 All of these involve dynamic memory adjustment logic and process "5". Specifically, before releasing memory to the memory manager, the memory DMA mapping needs to be unmapped; before allocating to the DMA Pool, memory DMA mapping (mmap) needs to be performed. The DMA mapping (mmap) / unmapping (unmap) operation is performed by the DMA Pool communicating with the "reclamation module" on the HostOS side, passing the GuestOS's GPA information that needs to be mapped or unmapped to the HostOS, and then the "reclamation module" completes the mapping or unmapping action. Processes "3" and "4" correspond to... Figure 4The memory processing flow shown includes the following steps: Step "3": When the PassThrough Device driver needs to allocate memory (for data transfer), it allocates memory from the DMAPool, ensuring that the memory allocated from the DMA Pool is already in a DMA-mapped state. Step "4": When the PassThrough Device driver finishes using the memory, it releases the memory directly to the DMA Pool. It is evident that in the above interaction flow, the amounts of DMA-mapped memory and the actual usage of the first system memory can be adjusted, without requiring the first virtual device to complete DMA mapping of all memory at creation. Furthermore, it can resolve performance issues caused by dynamic memory DMA mapping. Specifically, the DMAPool implementation pre-maps a batch of memory and then performs batch mapping (expanding the Pool) or batch unmapping (shrinking the Pool) of the DMA Pool memory based on actual demand, thereby reducing the performance impact of dynamic memory DMA mapping.
[0142] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of a memory processing device provided in an exemplary embodiment of this application. The memory processing device can be disposed in the computer device provided in the embodiment of this application. Figure 8 The memory processing device shown can be a computer program (including program code) running on a computer device, and the memory processing device can be used to execute... Figure 2 , Figure 4 or Figure 6 Some or all of the steps in the method embodiments shown. Please refer to [link / reference]. Figure 9 The memory processing device may include the following units:
[0143] The acquisition unit 901 is used to acquire the load information of the first virtual device during its operation. The load information includes the usage information of the first system memory. The first virtual device runs in the target physical device. The first system memory is the system memory allocated to the first virtual device by the target physical device. The first system memory is managed by the memory manager in the first virtual device and is not subject to direct memory access mapping. The memory manager supports pre-allocating a portion of the first system memory to perform direct memory access mapping for data pass-through between the first virtual device and the target physical device.
[0144] The processing unit 902 is configured to determine the target amount to be reclaimed based on the usage information of the first system memory when the usage information of the first system memory meets the memory reclamation conditions; and reclaim the first system memory that is eligible for reclamation in the first virtual device to the memory manager in the first virtual device according to the target amount to be reclaimed.
[0145] The transceiver unit 903 is used to send a memory reclamation instruction to the target physical device. The memory reclamation instruction is used to instruct the target physical device to reclaim the first system memory from the memory manager in the first virtual device.
[0146] In one embodiment, the usage information of the first system memory includes at least one of the following: the memory usage of the first system memory; the I / O interface latency corresponding to the first system memory; the memory allocation time of the first system memory; the usage information of the first system memory satisfies the memory reclamation condition by at least one of the following: the memory usage of the first system memory is less than or equal to a first preset usage; the I / O interface latency corresponding to the first system memory is less than or equal to a first preset latency; the memory allocation time of the first system is less than or equal to a preset allocation time.
[0147] In one embodiment, the processing unit 902 is further configured to: detect a first amount of first system memory in an idle state in the memory manager of the first virtual device; if the first amount of memory reaches a preset amount of memory, trigger the step of sending a memory reclamation instruction to the target physical device.
[0148] In one embodiment, if the first memory amount reaches a preset memory amount, the processing unit 902 is further configured to: aggregate the first system memory reclaimed to the memory manager according to the preset memory amount to obtain at least one memory block; wherein, the memory reclamation instruction is used to instruct the target physical device to reclaim at least one memory block from the memory manager in the first virtual device.
[0149] In one embodiment, the load information of the first system memory further includes the demand information of the first system memory and the reference reclamation amount of the first system memory, wherein the reference reclamation amount refers to the amount of first system memory that can support the reclamation of the first system memory; the processing unit 902 is specifically used to: determine the reclamation ratio of the first system memory based on the usage information and the demand information of the first system memory; and determine the target reclamation amount according to the reclamation ratio of the first system memory and the reference reclamation amount of the first system memory.
[0150] In one embodiment, a second virtual device also runs in the target physical device; if the second virtual device has memory usage requirements, 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.
[0151] In one embodiment, data pass-through is performed by a pass-through device in a first virtual device; the first virtual device also includes a memory mapping pool for managing mapped memory, which refers to first system memory that has been mapped by direct memory access and is used during data pass-through.
[0152] The acquisition unit 901 is further configured to: acquire the first memory requirement corresponding to the target pass-through device in the first virtual device; wherein, the first virtual device includes M pass-through devices, M is a positive integer; the target pass-through device refers to one of the M pass-through devices that has a data pass-through requirement, and the first memory requirement refers to the amount of mapped memory required by the target pass-through device to perform data pass-through.
[0153] The acquisition unit 901 is also used to: call the memory allocation interface provided by the first virtual device to obtain the mapped memory of the first memory requirement from the memory mapping pool in the first virtual device;
[0154] The processing unit 902 is further configured to: if the mapped memory for the first memory requirement is not obtained, determine whether the memory manager meets the memory allocation conditions, and if the memory manager meets the memory allocation conditions, allocate the first system memory that can be allocated in the memory manager to the memory mapping pool.
[0155] In one embodiment, the acquisition unit 901 is configured to: monitor the remaining mapped memory corresponding to the memory mapping pool in the first virtual device; wherein, the remaining mapped memory refers to the amount of mapped memory in the memory mapping pool that is in an idle state; if the remaining mapped memory is detected to be less than the first memory requirement, then the acquisition of the mapped memory required for the first memory requirement is not supported; if the remaining mapped memory is detected to be greater than or equal to the first memory requirement, then the acquisition of the mapped memory required for the first memory requirement is supported.
[0156] In one embodiment, the processing unit 902 is configured to: determine the target allocation amount based on the mapped memory balance corresponding to the memory mapping pool in the first virtual device and the first memory requirement; the acquisition unit 901 is configured to acquire the first memory allocation balance corresponding to the memory manager in the first virtual device; the first memory allocation balance refers to the memory balance of the first system memory in the memory manager that supports the execution of direct memory access mapping; the processing unit 902 is configured to determine that the memory manager meets the memory allocation conditions if the first memory allocation balance is greater than or equal to the target allocation amount.
[0157] In one embodiment, M is greater than 1. After any transparent transmission device completes a direct memory access operation based on the mapped memory, the mapped memory used is released to the memory mapping pool. The processing unit 902 is further configured to: if the memory manager does not meet the memory allocation conditions and other transparent transmission devices among the M transparent transmission devices are performing data transparent transmission, then wait at least for other transparent transmission devices to release the mapped memory used to the memory mapping pool. The amount of mapped memory in the memory mapping pool that is in an idle state increases as other transparent transmission devices release the mapped memory. The acquisition unit 901 is further configured to: after the amount of mapped memory in the memory mapping pool that is in an idle state reaches the first memory requirement, re-call the memory allocation interface to obtain the first required amount of mapped memory from the memory mapping pool.
[0158] In one embodiment, a communication connection is established between the first virtual device and the recycling module in the target physical device; the memory manager satisfies the memory allocation condition by meaning 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 used for: 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 a 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 mapped memory of the target allocation amount, which is managed by the memory mapping pool.
[0159] In one embodiment, the first virtual device further includes a memory mapping pool for managing mapped memory, which refers to first system memory that has undergone direct memory access mapping; the first system memory of the target memory amount is designated to support allocation to at least one service; the transceiver unit 903 is further configured to: receive a run request for the target service, and allocate first system memory from the memory manager in the first virtual device according to the run request for the target service; wherein, the target service refers to any one of the at least one service;
[0160] The processing unit 902 is further configured to: if no memory is allocated, determine whether the memory mapping pool meets the memory release conditions; if the memory mapping pool meets the memory release conditions, determine the target release amount, and release the mapped memory in the memory mapping pool to the memory manager according to the target release amount.
[0161] In one embodiment, the running request for the target service includes a second memory requirement of the target service; the acquisition unit 901 is further configured to: acquire the second memory requirement corresponding to the target service from the running request for the target service, the second memory requirement referring to the amount of first system memory that the target service needs to use during operation; and acquire the second memory allocation margin corresponding to the memory manager, the second memory allocation margin referring to the memory margin in the memory manager that supports allocation to the first system memory of the target service;
[0162] The processing unit 902 is further configured to: compare 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, then determine that no memory has been allocated.
[0163] In one embodiment, the acquisition unit 901 is further configured to: acquire the amount of free memory corresponding to the memory mapping pool and the preset memory reservation amount corresponding to the memory mapping pool; wherein, the amount of free memory refers to the mapped memory in the memory mapping pool that is in an idle state; the preset memory reservation amount is determined based on the number of transparent devices in the first virtual device, or is specified by the target object;
[0164] The processing unit 902 is also used to: compare the amount of free memory with the amount of preset memory reservation; if the amount of free memory is greater than the amount of preset memory reservation, then determine that the memory-mapped pool meets the memory release conditions.
[0165] In one embodiment, a communication connection is established between the first virtual device and the recycling module in the target physical device; the processing unit 902 is specifically configured to: obtain the physical address of the mapped memory of the target amount to be released in the first virtual device; send the physical address of the mapped memory of the target amount to be released in the first virtual device to the recycling module in the target physical device, so that the recycling module can release the mapping relationship between the physical address of the mapped memory of the target amount to be released in the first virtual device and the corresponding physical address in the target physical device; receive a second completion instruction sent by the recycling module to obtain the first system memory of the target amount to be released, wherein the first system memory of the target amount to be released is managed by the memory manager.
[0166] It is understood that the specific functions of each unit of the memory processing apparatus described in the embodiments of this application can be specifically implemented according to the methods in the above method embodiments, and the specific implementation process can be referred to the relevant descriptions in the above method embodiments, which will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated here either.
[0167] An exemplary embodiment of this application also provides a structural schematic diagram of a computer device, which can be found in [reference needed]. Figure 10The computer device may include a processor 1001, an input device 1002, an output device 1003, and a memory 1004. The processor 1001, input device 1002, output device 1003, and memory 1004 are connected via a bus. The memory 1004 is used to store a computer-readable storage medium, which includes a computer program. The processor 1001 is used to execute the computer program stored in the memory 1004 to perform the following operations: during the operation of the first virtual device, acquiring load information of the first virtual device, the load information including the usage information of the first system memory; the first virtual device runs in the target physical device, the first system memory being: system memory allocated to the first virtual device by the target physical device; the first system memory being managed by the memory manager in the first virtual device and not subject to direct memory access mapping; the memory manager supporting the pre-allocation of a portion of the first system memory for direct memory access mapping to facilitate data pass-through between the first virtual device and the target physical device; when the usage information of the first system memory meets the memory reclamation conditions, determining the target reclamation amount based on the usage information of the first system memory; according to the target reclamation amount, reclaiming the first system memory in the first virtual device that is eligible for reclamation to the memory manager in the first virtual device; sending a memory reclamation instruction to the target physical device, the memory reclamation instruction instructing the target physical device to reclaim the first system memory from the memory manager in the first virtual device.
[0168] In one embodiment, the usage information of the first system memory includes at least one of the following: the memory usage of the first system memory; the I / O interface latency corresponding to the first system memory; the memory allocation time of the first system memory; the usage information of the first system memory satisfies the memory reclamation condition by at least one of the following: the memory usage of the first system memory is less than or equal to a first preset usage; the I / O interface latency corresponding to the first system memory is less than or equal to a first preset latency; the memory allocation time of the first system is less than or equal to a preset allocation time.
[0169] In one embodiment, the processor 1001 is further configured to: detect a first amount of first system memory that is in an idle state in the memory manager of the first virtual device; if the first amount of memory reaches a preset amount of memory, trigger the step of sending a memory reclamation instruction to the target physical device.
[0170] In one embodiment, if the first memory amount reaches a preset memory amount, the processor 1001 is further configured to: aggregate the first system memory reclaimed to the memory manager according to the preset memory amount to obtain at least one memory block; wherein, the memory reclamation instruction is used to instruct the target physical device to reclaim at least one memory block from the memory manager in the first virtual device.
[0171] In one embodiment, the load information of the first system memory further includes the demand information of the first system memory and the reference reclamation amount of the first system memory, wherein the reference reclamation amount refers to the amount of first system memory that can support the reclamation of the first system memory; the processor 1001 is specifically used to: determine the reclamation ratio of the first system memory based on the usage information and the demand information of the first system memory; and determine the target reclamation amount according to the reclamation ratio of the first system memory and the reference reclamation amount of the first system memory.
[0172] In one embodiment, a second virtual device also runs in the target physical device; if the second virtual device has memory usage requirements, 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.
[0173] In one embodiment, data pass-through is performed by a pass-through device in a first virtual device; the first virtual device also includes a memory mapping pool, which manages mapped memory, where mapped memory refers to first system memory that has been mapped by direct memory access, and the mapped memory is used during the data pass-through process; the processor 1001 is further configured to: obtain a first memory requirement corresponding to a target pass-through device in the first virtual device; wherein, the first virtual device includes M pass-through devices, where M is a positive integer; the target pass-through device refers to one of the M pass-through devices that has a data pass-through requirement, and the first memory requirement refers to the amount of mapped memory required by the target pass-through device to perform data pass-through; call the memory allocation interface provided by the first virtual device to obtain the mapped memory of the first memory requirement from the memory mapping pool in the first virtual device; if the mapped memory of the first memory requirement is not obtained, determine whether the memory manager meets the memory allocation conditions, and if the memory manager meets the memory allocation conditions, allocate the first system memory that can be allocated in the memory manager to the memory mapping pool.
[0174] In one embodiment, the processor 1001 is configured to: monitor the remaining mapped memory corresponding to the memory mapping pool in the first virtual device; wherein, the remaining mapped memory refers to the amount of mapped memory in the memory mapping pool that is in an idle state; if the remaining mapped memory is detected to be less than the first memory requirement, then obtaining the mapped memory required for the first memory requirement is not supported; if the remaining mapped memory is detected to be greater than or equal to the first memory requirement, then obtaining the mapped memory required for the first memory requirement is supported.
[0175] In one embodiment, the processor 1001 is configured to: determine a target allocation amount based on the mapped memory balance corresponding to the memory mapping pool in the first virtual device and a first memory requirement; obtain a first memory allocation balance corresponding to the memory manager in the first virtual device; the first memory allocation balance refers to the memory balance of the first system memory in the memory manager that supports direct memory access mapping; if the first memory allocation balance is greater than or equal to the target allocation amount, then determine that the memory manager meets the memory allocation conditions.
[0176] In one embodiment, M is greater than 1, and after any transparent transmission device completes a direct memory access operation based on the mapped memory, the mapped memory used is released to the memory mapping pool; the processor 1001 is further configured to: if the memory manager does not meet the memory allocation conditions, and other transparent transmission devices among the M transparent transmission devices are performing data transparent transmission, then wait at least for other transparent transmission devices to release the mapped memory used to the memory mapping pool; the amount of mapped memory in the memory mapping pool that is in an idle state increases as other transparent transmission devices release the mapped memory; after the amount of mapped memory in the memory mapping pool that is in an idle state reaches the first memory requirement, the memory allocation interface is called again to obtain the first required amount of mapped memory from the memory mapping pool.
[0177] In one embodiment, a communication connection is established between the first virtual device and the recycling module in the target physical device; the memory manager satisfies the memory allocation condition by means that the first memory allocation margin corresponding to the memory manager is greater than or equal to the target allocation amount; the processor 1001 is specifically used to: obtain the 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 recycling module in the target physical device, so that the recycling 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 the corresponding physical address in the target physical device; receive the first completion instruction sent by the recycling module to obtain the mapped memory of the target allocation amount, and the mapped memory of the target allocation amount is managed by the memory mapping pool.
[0178] In one embodiment, the first virtual device further includes a memory mapping pool for managing mapped memory, which refers to first system memory that has undergone direct memory access mapping; the first system memory of the target memory amount is designated to support allocation to at least one service; the processor 1001 is further configured to: receive a run request for the target service, and allocate first system memory from the memory manager in the first virtual device according to the run request for the target service; wherein, the target service refers to any one of the at least one service; if no memory is allocated, determine whether the memory mapping pool meets the memory release condition; if the memory mapping pool meets the memory release condition, determine the target release amount, and release the mapped memory in the memory mapping pool to the memory manager according to the target release amount.
[0179] In one embodiment, the execution request for the target service includes a second memory requirement of the target service; the processor 1001 is further configured to: obtain the second memory requirement corresponding to the target service from the execution request for the target service, the second memory requirement referring to the amount of first system memory required by the target service during execution; obtain the second memory allocation margin corresponding to the memory manager, the second memory allocation margin referring to the memory margin in the memory manager that supports allocation to the first system memory of the target service; compare 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 no memory has been allocated.
[0180] In one embodiment, the processor 1001 is further configured to: obtain the amount of free memory corresponding to the memory mapping pool and the preset memory reservation amount corresponding to the memory mapping pool; wherein, the amount of free memory refers to the mapped memory in the memory mapping pool that is in an idle state; the preset memory reservation amount is determined based on the number of transparent devices in the first virtual device, or is specified by the target object; compare the size of the amount of free memory and the preset memory reservation amount; if the amount of free memory is greater than the preset memory reservation amount, then determine that the memory mapping pool meets the memory release condition.
[0181] In one embodiment, a communication connection is established between the first virtual device and the recycling module in the target physical device; the processor 1001 is specifically configured to: obtain the physical address of the mapped memory of the target amount to be released in the first virtual device; send the physical address of the mapped memory of the target amount to be released in the first virtual device to the recycling module in the target physical device, so that the recycling module can release the mapping relationship between the physical address of the mapped memory of the target amount to be released in the first virtual device and the corresponding physical address in the target physical device; receive a second completion instruction sent by the recycling module to obtain the first system memory of the target amount to be released, wherein the first system memory of the target amount to be released is managed by a memory manager.
[0182] It should be understood that the computer device described in the embodiments of this application can execute the memory processing method described in the corresponding embodiments above, and can also execute the memory processing device described in the corresponding embodiments above, which will not be repeated here. In addition, the beneficial effects of using the same method will not be repeated here either.
[0183] Furthermore, it should be noted that this application also provides a computer-readable storage medium storing a computer program, which includes program instructions. When a processor executes these program instructions, it can execute the aforementioned... Figure 2 , Figure 4 and Figure 6 The methods described in the corresponding embodiments are therefore not repeated here.
[0184] According to one aspect of this application, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, enabling the computer device to perform the aforementioned... Figure 2 , Figure 4 and Figure 6 The methods described in the corresponding embodiments are therefore not repeated here.
[0185] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0186] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Those skilled in the art will understand that all or part of the processes for implementing the above embodiments and equivalent variations made in accordance with the claims of this application are still within the scope of this application.
Claims
1. A memory processing method, characterized in that, The method includes: During the operation of the first virtual device, load information of the first virtual device is acquired, including the usage information of the first system memory; the first virtual device runs in the target physical device, and the first system memory is the system memory allocated to the first virtual device by the target physical device; the first system memory is managed by the memory manager in the first virtual device and is not subject to direct memory access mapping; the memory manager supports pre-allocating a portion of the first system memory to perform direct memory access mapping for data pass-through between the first virtual device and the target physical device; When the memory usage information of the first system meets the memory reclamation conditions, the target reclamation amount is determined based on the memory usage information of the first system. According to the target reclamation amount, the first system memory that supports reclamation in the first virtual device is reclaimed to the memory manager in the first virtual device; A memory reclamation instruction is sent to the target physical device, the memory reclamation instruction being used to instruct the target physical device to reclaim the first system memory from the memory manager in the first virtual device.
2. The method as described in claim 1, characterized in that, The usage information of the first system memory includes at least one of the following: the amount of memory used by the first system memory; the I / O interface latency corresponding to the first system memory; and the memory allocation time of the first system memory. The memory usage information of the first system memory satisfies the memory reclamation condition if at least one of the following is true: the memory usage of the first system memory is less than or equal to a first preset usage; the I / O interface latency corresponding to the first system memory is less than or equal to a first preset latency; or the memory allocation time of the first system is less than or equal to a preset allocation time.
3. The method as described in claim 1 or 2, characterized in that, The method further includes: Detect the first amount of first system memory that is in an idle state in the memory manager of the first virtual device; If the first memory amount reaches the preset memory amount, then the step of sending a memory reclamation instruction to the target physical device is triggered.
4. The method as described in claim 3, characterized in that, If the first memory amount reaches the preset memory amount, the method further includes: The first system memory reclaimed to the memory manager is aggregated according to the preset memory amount to obtain at least one memory block; wherein, the memory reclamation 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.
5. The method as described in claim 1, characterized in that, The load information of the first system memory also includes the demand information of the first system memory and the reference reclamation amount of the first system memory, wherein the reference reclamation amount refers to the amount of first system memory that can support the reclamation of the first system memory; Determining the target amount of data to be reclaimed based on the memory usage information of the first system includes: Based on the memory usage information and memory demand information of the first system, determine the memory reclamation ratio of the first system. The target recovery amount is determined based on the recovery ratio of the first system memory and the reference recovery amount of the first system memory.
6. The method as described in claim 1, characterized in that, The target physical device also runs a second virtual device; if the second virtual device has memory usage requirements, the first system memory reclaimed from the memory manager in the first virtual device is allocated by the target physical device to the second virtual device.
7. The method as described in claim 1, characterized in that, The data pass-through is performed by a pass-through device in the first virtual device; the first virtual device further includes a memory mapping pool, which manages mapped memory, wherein the mapped memory refers to first system memory that has been mapped using direct memory access, and the mapped memory is used during the data pass-through process; the method further includes: Obtain the first memory requirement corresponding to the target pass-through device in the first virtual device; wherein, the first virtual device includes M pass-through devices, M is a positive integer; the target pass-through device refers to one of the M pass-through devices that has a data pass-through requirement, and the first memory requirement refers to the amount of mapped memory required by the target pass-through device to perform data pass-through; Call the memory allocation interface provided by the first virtual device to obtain the mapped memory for the first memory requirement from the memory mapping pool in the first virtual device; If the mapped memory for the first memory requirement is not obtained, it is determined whether the memory manager meets the memory allocation conditions. If the memory manager meets the memory allocation conditions, the first system memory that can be allocated in the memory manager is allocated to the memory mapping pool.
8. The method as described in claim 7, characterized in that, The method further includes: Monitor the remaining mapped memory corresponding to the memory mapping pool in the first virtual device; wherein, the remaining mapped memory refers to the amount of mapped memory in the memory mapping pool that is in an idle state; If the remaining mapped memory is detected to be less than the first memory requirement, then obtaining the mapped memory required for the first memory requirement is not supported. If the remaining mapped memory is detected to be greater than or equal to the first memory requirement, then the mapped memory of the first memory requirement can be obtained.
9. The method as described in claim 7, characterized in that, The method further includes: The target allocation amount is determined based on the remaining mapped memory in the memory mapping pool of the first virtual device and the first memory requirement. Obtain the first memory allocation margin corresponding to the memory manager in the first virtual device; the first memory allocation margin refers to the memory margin of the first system memory in the memory manager that supports the execution of direct memory access mapping; If the first memory allocation margin is greater than or equal to the target allocation amount, then the memory manager is determined to meet the memory allocation conditions.
10. The method as described in claim 7, characterized in that, When M is greater than 1, after any transparent transmission device completes a direct memory access operation based on the mapped memory, the mapped memory used is released to the memory mapping pool. The method further includes: If the memory manager does not meet the memory allocation conditions, and other transparent devices among the M transparent devices are performing data transparent transmission, then at least wait for the other transparent devices to release the mapped memory they use to the memory mapping pool; the amount of mapped memory in the memory mapping pool that is in an idle state increases as the other transparent devices release the mapped memory. Once the amount of idle mapped memory in the memory mapping pool reaches the first memory requirement, the memory allocation interface is called again to obtain the first required amount of mapped memory from the memory mapping pool.
11. The method according to any one of claims 7-10, characterized in that, A communication connection is established between the first virtual device and the recycling module in the target physical device; the memory manager satisfies the memory allocation condition if the first memory allocation margin corresponding to the memory manager is greater than or equal to the target allocation amount. The step of allocating the first system memory supported for allocation in the memory manager to the memory-mapped pool includes: Obtain the physical address of the first system memory containing the target allocation amount in the first virtual device; The physical address of the first system memory of the target allocation in the first virtual device is sent to the recycling module in the target physical device, so that the recycling module establishes a mapping relationship between the physical address of the first system memory of the target allocation in the first virtual device and the corresponding physical address in the target physical device; Upon receiving the first completion instruction sent by the recycling module, the target amount of mapped memory is obtained, and the target amount of mapped memory is managed by the memory mapping pool.
12. The method as described in claim 1, characterized in that, The first virtual device also includes a memory mapping pool, which is used to manage mapped memory, and the mapped memory refers to the first system memory that has been mapped by direct memory access. The first system memory of the target memory amount is designated to support allocation to at least one service; the method further includes: The system receives a run request for a target service and allocates first system memory from the memory manager in the first virtual device according to the run request for the target service; wherein the target service refers to any one of at least one service. If no memory is allocated, determine whether the memory mapping pool meets the memory release conditions; If the memory mapping pool meets the memory release conditions, a target release amount is determined, and the mapped memory in the memory mapping pool is released to the memory manager according to the target release amount.
13. The method as described in claim 12, characterized in that, The execution request for the target service includes a second memory requirement for the target service; the method further includes: The second memory requirement corresponding to the target service is obtained from the operational requirements of the target service. The second memory requirement refers to the amount of first system memory that the target service needs to use during operation. Obtain the second memory allocation margin corresponding to the memory manager, where the second memory allocation margin refers to the memory margin in the memory manager that supports allocation to the first system memory of the target service; Compare the second memory allocation margin with the second memory requirement; If the second memory allocation margin is less than the second memory requirement, then it is determined that no memory has been allocated.
14. The method as described in claim 12, characterized in that, The method further includes: Obtain the amount of free memory corresponding to the memory mapping pool and the preset memory reservation amount corresponding to the memory mapping pool; wherein, the amount of free memory refers to the mapped memory in the memory mapping pool that is in an idle state; the preset memory reservation amount is determined based on the number of transparent devices in the first virtual device, or is specified by the target object; Compare the amount of free memory with the amount of preset memory reserved; If the amount of free memory is greater than the preset memory retention amount, then the memory mapping pool is determined to meet the memory release conditions.
15. The method according to any one of claims 12-14, characterized in that, A communication connection is established between the first virtual device and the recycling module in the target physical device; the step of releasing the mapped memory in the memory mapping pool to the memory manager according to the target release amount includes: Obtain the physical address of the target release amount's mapped memory in the first virtual device; The physical address of the target release amount's mapped memory in the first virtual device is sent to the recycling module in the target physical device, so that the recycling module can release the mapping relationship between the physical address of the target release amount's mapped memory in the first virtual device and the corresponding physical address in the target physical device; The system receives a second completion instruction from the recycling module and obtains a first system memory of the target release amount, which is managed by the memory manager.
16. A memory processing device, characterized in that, The device includes: The acquisition unit is configured to acquire load information of the first virtual device during its operation, the load information including the usage information of the first system memory; the first virtual device runs in a target physical device, the first system memory being the 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 subject to direct memory access mapping; the memory manager supports pre-allocating a portion of the first system memory to perform direct memory access mapping for data pass-through between the first virtual device and the target physical device; The processing unit is configured to, when the usage information of the first system memory meets the memory reclamation conditions, determine the target reclamation amount based on the usage information of the first system memory; and reclaim the first system memory in the first virtual device that is eligible for reclamation to the memory manager in the first virtual device according to the target reclamation amount. A transceiver unit is configured to send a memory reclamation instruction to the target physical device, the memory reclamation instruction being used to instruct the target physical device to reclaim first system memory from the memory manager in the first virtual device.
17. A computer device, characterized in that, include: A processor is used to execute computer programs; A computer-readable storage medium storing a computer program, which, when executed by the processor, performs the memory processing method as described in any one of claims 1-15.
18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, performs the memory processing method as described in any one of claims 1-15.
19. A computer program product, characterized in that, The computer program product includes a computer program or computer instructions, which are executed by a processor to implement the memory processing method as described in any one of claims 1-15.