Device memory management method, computer device and storage medium

By constructing a mapping relationship between non-contiguous memory partitions and logical devices in CXL devices, the memory fragmentation problem is solved, enabling efficient memory utilization and cross-device sharing, and improving the efficiency and security of memory management.

CN120780616BActive Publication Date: 2025-11-21CORE TREND (ZHUHAI) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511260995.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-05
Publication Date
2025-11-21
Estimated Expiration
2045-09-05

AI Technical Summary

Technical Problem

In CXL devices, frequent memory allocation and deallocation lead to memory fragmentation, resulting in decreased memory utilization and an inability to meet large-capacity allocation demands.

Method used

By obtaining memory partition requests, confirming the occupancy status of physical memory blocks, forming non-contiguous memory partitions, generating a mapping relationship between memory partitions and physical memory blocks, and establishing a mapping relationship between memory partitions and logical devices, cross-device memory sharing and optimized memory management are achieved.

Benefits of technology

Reduce memory fragmentation, improve memory utilization, enable cross-device memory sharing, enhance memory usage efficiency, and improve data access security through permission management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120780616B_ABST
    Figure CN120780616B_ABST
Patent Text Reader

Abstract

The application provides a device memory management method, a computer device and a storage medium. The method comprises the following steps: when a memory partition request is obtained, the occupancy state of all physical memory blocks is confirmed; a corresponding number of idle physical memory blocks are obtained to form a memory partition according to the memory partition capacity information of the memory partition request, and a memory block configuration table of the mapping relationship between the memory partition and the corresponding physical memory block is generated, wherein the physical memory block has a fixed capacity, and the physical addresses of all physical memory blocks in the memory partition are discontinuous; a mapping relationship table of the memory partition and at least one logical device is established; and when a host computer accesses the memory partition through the logical device, the memory partition is accessed according to the mapping relationship table and the memory block configuration table. The device memory management method can reduce memory fragmentation and improve memory use efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory management technology, specifically to a device memory management method, a computer device using the device memory management method, and a computer-readable storage medium using the device memory management method. Background Technology

[0002] In the CXL (Compute Express Link) protocol, to enable a CXL device to be used simultaneously by multiple hosts, it needs to be connected to a CXL switch. The CXL switch connects multiple hosts through multiple uplink ports and connects to the same CXL device through downlink ports. The configuration of the CXL switch enables these hosts to access the same CXL device.

[0003] During the operation of a CXL device, when a logical device within the CXL device needs to use memory, the software requests and allocates memory for that logical device. When the logical device no longer needs the memory, it can release and reclaim the memory for future use. However, frequent memory allocation and deallocation can easily lead to a large amount of memory fragmentation within the CXL device. Even with available memory, to achieve advantages such as random access, caching, prefetching, vectorization friendliness, simple page tables, pointer arithmetic, and statically determined structure layout, memory allocation typically requires contiguous physical addresses between memory blocks. Therefore, fragmented memory blocks cannot meet the demands of large-capacity allocations, resulting in decreased memory utilization. For example, as... Figure 1 As shown, after multiple allocations and releases, memory fragments are formed. The maximum number of physical memory blocks that are contiguous is 4. If more than 4 memory blocks need to be allocated, the allocation requirement cannot be met.

[0004] Therefore, more optimized memory management methods need to be considered. Summary of the Invention

[0005] The primary objective of this invention is to provide a device memory management method that can reduce memory fragmentation and improve memory utilization efficiency.

[0006] A second objective of this invention is to provide a computer device that can reduce memory fragmentation and improve memory utilization efficiency.

[0007] A third objective of this invention is to provide a computer-readable storage medium that can reduce memory fragmentation and improve memory utilization efficiency.

[0008] In order to achieve the above-mentioned first object, the device memory management method provided by the application comprises the following steps: when a memory partition request is obtained, the occupation state of the current physical memory block is confirmed; according to the memory partition capacity information of the memory partition request, a corresponding number of idle physical memory blocks are obtained to form a memory partition, and a memory block configuration table of the mapping relationship between the memory partition and the corresponding physical memory block is generated, wherein the physical memory block has a fixed capacity, and the physical addresses of all physical memory blocks in the memory partition are discontinuous; a mapping relationship table of the memory partition and at least one logical device is established; when the host computer accesses the memory partition through the logical device, the memory partition is accessed according to the mapping relationship table and the memory block configuration table.

[0009] As can be seen from the above scheme, in the device memory management method of the application, when a memory partition request is received, the occupation state of all physical memory blocks is confirmed, and according to the capacity required by the memory partition, a corresponding number of idle physical memory blocks (whether the physical addresses are continuous or not) are directly selected to form a memory partition, and the mapping relationship between the memory partition and the physical block is recorded through the memory block configuration table, so that the scattered idle physical memory blocks are fully utilized, the memory fragmentation is reduced, and the memory utilization is improved. At the same time, the mapping relationship table of the memory partition and at least one logical device is established, so that the host computer can access the memory partition through the logical device.

[0010] In a further scheme, the step of confirming the occupation state of the current physical memory block comprises: confirming the occupation state of the local physical memory block and / or the external physical memory block in the interconnected external device.

[0011] As can be seen from the above scheme, by confirming the occupation state of the local physical memory block and / or the external physical memory block in the interconnected external device, the use of the local physical memory block and the external physical memory block in the interconnected external device can be known, so as to facilitate cross-device memory partitioning.

[0012] In a further scheme, the step of obtaining a corresponding number of idle physical memory blocks to form a memory partition according to the memory partition capacity information of the memory partition request comprises: obtaining idle local physical memory blocks and / or idle external physical memory blocks to form a memory partition.

[0013] As can be seen from the above scheme, when constructing a memory partition, idle local physical memory blocks and / or idle external physical memory blocks can be obtained to form a memory partition, which can reduce the fragmentation of local memory and also realize cross-device memory sharing and improve the utilization of memory.

[0014] In a further scheme, the step of establishing a mapping relationship table of the memory partition and at least one logical device comprises: establishing a mapping relationship of the memory partition and a local logical device and / or establishing a mapping relationship of the memory partition and an external logical device in an external device.

[0015] Therefore, when the mapping relationship table of the memory partition and the logical device is established, the mapping relationship of the memory partition and the local logical device and / or the mapping relationship of the memory partition and the external logical device in the external device can be established, so that the local logical device can access the memory partition and the external logical device, and the shared memory partition can be shared across devices.

[0016] In a further scheme, when the mapping relationship table of the memory partition and the at least one logical device is established, the method further includes: setting the access permission of the logical device to the memory partition.

[0017] Therefore, by setting the access permission of the logical device to the memory partition, when the host computer initiates access through the logical device, in addition to locating the physical memory through the mapping relationship table and the memory block configuration table, it is additionally required to check whether the permission of the logical device matches the operation type, thereby improving the security of data access.

[0018] In a further scheme, after the mapping relationship table of the memory partition and the at least one logical device is established, the method further includes: if any physical memory block in the same memory partition is in a frequently accessed state, migrating the data of the physical memory block to an idle physical memory block in the memory partition.

[0019] Therefore, in the same memory partition, a certain local physical memory block can be frequently accessed due to its high speed, which can easily cause bus congestion and drag the overall performance when frequently accessed. Therefore, by migrating the data of the hot physical memory block to an idle physical memory block in the same partition, the access frequency of each physical block can be balanced, and excessive busyness of a single block can be avoided.

[0020] In a further scheme, after the step of obtaining the corresponding number of idle physical memory blocks to form the memory partition according to the memory partition capacity information requested by the memory partition, the method further includes: counting the reference count of the mapping relationship and the unmapping relationship between the memory partition and the logical device, wherein the reference count is increased by one when the mapping relationship is established once, and the reference count is decreased by one when the mapping relationship is removed once; and when the reference count is zero, releasing the memory partition so that all the physical memory blocks of the memory partition are in an idle state.

[0021] Therefore, by counting the reference count of the mapping relationship and the unmapping relationship between the memory partition and the logical device, when the reference count is zero, the memory partition is released, so that the manual release operation is not required, the counter is used to automatically determine whether the partition is in an idle state, and the permanent occupation of the memory block caused by the abnormal exit of the logical device, the manual removal of the mapping relationship, and the like is avoided, thereby improving the reuse efficiency of the physical memory block.

[0022] In a further scheme, the memory partition is mapped to more than two logical devices; and before the host computer accesses the memory partition through the logical device, the method further includes: confirming that the memory partition is in an idle state.

[0023] Therefore, the step of confirming that the memory partition is in an idle state before the host computer accesses the logical device can solve the conflict of concurrent access of multiple devices and ensure the consistency of shared memory data and the operation safety.

[0024] To achieve the second object of the present application, the present application provides a computer device comprising a processor and a memory, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the steps of the device memory management method.

[0025] To achieve the third object of the present application, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a controller to implement the steps of the device memory management method. BRIEF DESCRIPTION OF DRAWINGS

[0026] Figure 1 is a schematic diagram of the existing memory allocation.

[0027] Figure 2 is a flowchart of an embodiment of the device memory management method of the present application.

[0028] Figure 3 is a schematic diagram of the relationship among the physical memory blocks, the memory partitions and the logical devices in an embodiment of the device memory management method of the present application.

[0029] Figure 4 is a flowchart of the step of obtaining a corresponding number of idle physical memory blocks to form a memory partition according to the memory capacity of the memory partition in an embodiment of the device memory management method of the present application.

[0030] The present application will be further described below in combination with the drawings and embodiments. DETAILED DESCRIPTION

[0031] The device memory management method of the present application is an application program applied in a computer device for managing the device memory.

[0032] Embodiment of the device memory management method:

[0033] As shown in Figure 2 the present embodiment, when the device memory management method is working, it first executes step S1 to determine whether a memory partition request is obtained. When it is necessary to allocate memory for a host computer or a task process, a memory partition request can be sent to obtain the memory partition required by the host computer or the task process. The memory partition request can be obtained when the host computer requests or when the task process is executed.

[0034] When the memory partition request is acquired, step S2 is performed to confirm the occupation state of the current physical memory block. The occupation state includes two types of "allocated" and "free", "allocated" means that it has been used by a process or system, and "free" means that it has not been allocated, as shown in Figure 1 The occupation state can be obtained by reading the existing memory block configuration table. For example, the device memory is assumed to be 2T, and the device memory is divided into 8192 physical memory blocks with a fixed size of 256M. An 8192-bit memory block configuration is used to maintain whether each physical memory block is allocated to the memory partition, so the occupation state of the physical memory block can be obtained by reading the memory block configuration table.

[0035] In this embodiment, the step of confirming the occupation state of the current physical memory block includes confirming the occupation state of the local physical memory block and / or the external physical memory block in the interconnected external device. By confirming the occupation state of the local physical memory block and / or the external physical memory block in the interconnected external device, the use of the local physical memory block and the external physical memory block in the interconnected external device can be known, so as to perform cross-device memory partitioning. For example, in a system in which multiple CXL devices are interconnected and communicate, in order to jointly partition the memories of the multiple CXL devices and improve the use efficiency of the memories, when performing memory partitioning, in addition to confirming the local physical memory block, the use of the external physical memory block in the external device can also be confirmed, the occupation state of the global physical memory block is confirmed, so as to further allocate the memory block.

[0036] After confirming the occupation state of the current physical memory block, step S3 is performed to obtain a corresponding number of free physical memory blocks to form a memory partition according to the memory partition capacity information of the memory partition request, and generate a memory block configuration table of the memory partition and the corresponding physical memory block. The physical memory block has a fixed capacity, and the physical addresses of all physical memory blocks in the memory partition are non-continuous. The non-continuous limitation means that it is not required that the physical addresses of all physical memory blocks in the memory partition are continuous.

[0037] After obtaining the memory partition request, the memory capacity requirement of the memory partition can be parsed according to the memory partition request, and the number of required physical memory blocks is calculated. The physical memory block has a fixed capacity, and the size of the physical memory block can be configured according to the system requirement, such as 32KB, 64KB, 2MB, etc. For each to-be-created memory partition, the number of physical memory blocks to be allocated is calculated according to the memory capacity requirement and the size of the physical memory block (rounded up): the number of required blocks = memory capacity requirement ÷ physical block size. For example, assuming that the physical block size is 4KB and the memory capacity requirement is 10KB, then 10KB ÷ 4KB = 2.5, and the number of physical memory blocks is 3 after rounding up. After obtaining the number of physical memory blocks to be allocated, the memory block configuration table is traversed to filter the continuous or discontinuous idle physical memory blocks for the to-be-created memory partition.

[0038] In an optional embodiment, if there are "the number of continuous idle physical memory blocks ≥ the number of physical memory blocks to be allocated" in the memory block configuration table, then the continuous physical memory blocks are preferentially selected to form the memory partition; if there are not enough continuous physical memory blocks, then the non-continuous idle physical memory blocks are allocated to form the memory partition.

[0039] In this embodiment, the step of obtaining the corresponding number of idle physical memory blocks to form the memory partition according to the memory partition capacity information of the memory partition request includes: obtaining the idle local physical memory blocks and / or the idle external physical memory blocks to form the memory partition. When constructing the memory partition, the idle local physical memory blocks and / or the idle external physical memory blocks are obtained to form the memory partition, which can reduce the fragmentation of the local memory and also realize the cross-device memory sharing and improve the memory usage. For example, as shown in FIG. 1, when constructing the memory partition C, the local physical memory blocks a and y in the device 2 can be obtained to form the memory partition C. When constructing the memory partition B, the local physical memory blocks 0, 1, 2, b and x, and the external physical memory block n in the device 1 can be obtained to form the memory partition B. Preferably, when obtaining the corresponding number of idle physical memory blocks to form the memory partition, the physical addresses of the physical memory blocks are obtained in ascending order. The physical memory blocks on different devices are selected in a preset priority order. Figure 3

[0040] After obtaining the corresponding number of idle physical memory blocks to form the memory partition according to the memory partition capacity information of the memory partition request, the memory block configuration table of the mapping relationship between the memory partition and the corresponding physical memory block can be generated. After each partition is allocated with the physical block, the corresponding relationship between the partition identifier and the occupied physical memory block needs to be recorded, for example, the mapping relationship between the memory partition and the physical memory block is as follows: the memory partition 1 corresponds to the physical addresses of the physical memory blocks 2, 3 and 4; the memory partition 2 corresponds to the physical addresses of the physical memory blocks 5 and 6; and the memory partition 3 corresponds to the physical addresses of the physical memory blocks 9 and 10. ​

[0041] After obtaining the corresponding number of free physical memory blocks to form a memory partition based on the memory partition capacity information requested in the memory partition request, step S4 is executed to establish a mapping table between the memory partition and at least one logical device. Establishing a mapping table between memory partitions and logical devices clarifies the association between memory partitions and logical devices (such as abstract devices like processes, files, and virtual devices), thereby enabling targeted allocation and management of memory resources.

[0042] In this embodiment, the step of establishing a mapping table between a memory partition and at least one logical device includes: establishing a mapping relationship between the memory partition and a local logical device and / or establishing a mapping relationship between the memory partition and an external logical device in the external devices. When establishing the mapping table between the memory partition and the logical device, a mapping relationship between the memory partition and a local logical device can be established, and / or a mapping relationship between the memory partition and an external logical device in the external devices can be established. This enables the local logical device to access the memory partition and the external logical device, allowing cross-device sharing of the shared memory partition. The information of the local mapping and the external mapping is integrated and recorded using a unified mapping table.

[0043] Local logical devices refer to entities running on the local system (such as local processes, system services, local virtual devices, etc.). Their mapping relationships are directly managed by the local operating system. Based on the memory requirements of the local logical device, a matching memory partition is selected from the allocated local memory partitions and an association is established. External logical devices refer to entities running on interconnected external devices (such as remote server processes, GPU kernels, processing units of smart network cards, etc.). Their mapping relationships need to be established through inter-device communication protocols. Information about external logical devices is obtained through the communication interfaces of external devices (such as PCIe drivers, CXL network protocols, device management APIs, etc.). Based on the memory requirements of the external logical device, a mapping relationship is established between the local memory partition and the external logical device, or vice versa.

[0044] For example, such as Figure 3 In the system shown, memory partition C in device 2 is mapped to the local logical device LLDj corresponding to port i. Memory partition B in device 2 is mapped to the external logical device ELDk corresponding to port 0 in device 1. In addition, memory partition B is also mapped to the local logical devices LLD0 corresponding to port 0 and port 1 in device 2.

[0045] In the embodiment, when the mapping relationship table of the memory partition and the at least one logical device is established, the access permission of the logical device to the memory partition is also set. When the mapping relationship table of the memory partition and the logical device is established, the access permission of the logical device to the memory partition is set, which can effectively ensure the safe access and isolation of the memory resource. According to the security requirement of the memory operation, the access permission of the logical device to the memory partition is usually divided into the following categories (which can be combined for use): read permission, allowing the logical device to read the data in the memory partition; write permission, allowing the logical device to modify the data in the memory partition; shared permission, allowing the logical device to share the access right of the memory partition with other devices; exclusive permission, limiting the memory partition to be accessed only by the current logical device (excluding other devices).

[0046] After the mapping relationship table of the memory partition and the at least one logical device is established, step S5 is performed to determine whether the host computer accesses the memory partition through the logical device. After the mapping relationship table of the memory partition and the logical device is established, the logical device can be exposed to the host computer through the corresponding port, and at least one logical device can be bound to one port. For example, Figure 3 In the example, the port 1 of the device 2 is bound to m logical devices LLD0 to LLDm, and the logical device corresponding to the port 1 can be exposed to the host computer 1 through the port 1. When the host computer needs to access the memory partition, the access can be realized through the logical device. When the access request to the memory partition is obtained, it is determined through analysis whether the access request to the memory partition is initiated by the host computer and whether the access is performed through the logical device with which the mapping relationship has been established.

[0047] If the host computer does not access the memory partition through the logical device, step S5 is continuously performed to perform continuous detection. When the host computer accesses the memory partition through the logical device, step S6 is performed to access the memory partition according to the mapping relationship table and the memory block configuration table. When it is confirmed that the host computer accesses the memory partition, the mapping relationship table and the memory block configuration table corresponding to the logical device are obtained to access the memory partition. The mapping relationship table provides the association link among the host computer, the logical device and the memory partition, and clearly defines the permission range of the access and the device ownership. The memory block configuration table provides the mapping details of the memory partition and the physical memory block, and clearly defines the physical block number and the allocation state of the partition, thereby providing the physical address basis for the actual data read and write.

[0048] In one embodiment, the memory partition is mapped with two or more logical devices; before the host accesses the memory partition through the logical device, the host further comprises: confirming that the memory partition is in an idle state. Wherein, the memory partition in an idle state means that there is no any logical device performing "write operation" or "exclusive read operation" on the memory partition, and the memory partition is not locked, such as system operation of migration, repair, etc. When the memory partition is mapped with two or more logical devices, i.e. multiple logical devices share the memory partition, before the host accesses the memory partition through the logical device, the idle state of the memory partition needs to be confirmed to avoid data conflict caused by multiple logical devices reading and writing the partition at the same time.

[0049] In an optional embodiment, after the mapping relationship table of the memory partition and at least one logical device is established, it further comprises: if any physical memory block in the same memory partition is in a frequent access state, migrating the data of the physical memory block to an idle physical memory block in the memory partition. In the same memory partition, a certain local physical memory block may be frequently accessed due to its high speed, which may cause bus congestion and drag the overall performance. Therefore, by migrating the data of the hot physical memory block to an idle physical memory block in the same partition, the access frequency of each physical block can be balanced to avoid excessive busy of a single block. The access amount per unit time of each physical memory block is counted according to a set period (such as every 30 seconds), and physical memory blocks exceeding the threshold value are screened out, such as a physical memory block accessed 1200 times per second, which is determined as a hot physical memory block. Then, it is checked from the memory block configuration table whether there is an idle physical memory block in the memory partition. If there is, the hot physical memory block can be migrated to the idle physical memory block. If there is no idle physical memory block, the migration can be temporarily not performed or a partition expansion operation can be triggered.

[0050] In another optional embodiment, referring to Figure 4 After the step S3, the corresponding number of idle physical memory blocks are obtained according to the memory partition capacity information requested by the memory partition to form the memory partition, the step S11 is further performed to count the reference count of the mapping relationship and the unmapping relationship between the memory partition and the logical device, wherein the reference count is increased by one when the mapping relationship is established once, and the reference count is decreased by one when the mapping relationship is removed once. By counting the reference count of the mapping relationship between the memory partition and the logical device, the usage frequency of the memory partition can be obtained by tracking the number of times of establishing and removing the mapping relationship, which provides a basis for memory resource recycling, conflict avoidance, etc.

[0051] After the reference count is obtained, the step S12 is performed to determine whether the reference count is zero. When the reference count is zero, it means that the current memory partition is in an idle state, i.e. no logical device is connected.

[0052] If the reference count is not zero, the step S12 is continued to perform the continuous detection. When the reference count is zero, the step S13 is executed to release the memory partition, so that all the physical memory blocks of the memory partition are in the idle state. When the reference count is zero, the memory partition is released, and the automatic judgment of the memory partition in the useless state by the counter is not dependent on the manual release operation, the permanent occupation of the memory block caused by the abnormal exit of the logical device, the unmanual release of the mapping relationship and the like is avoided, and the reuse efficiency of the physical memory block is improved.

[0053] As known from the above, in the device memory management method, when the memory partition request is received, the occupation state of all the physical memory blocks is confirmed, the number of matched idle physical memory blocks (whether the physical addresses are continuous or not) is directly selected according to the capacity required by the memory partition to form the memory partition, and the mapping relationship between the memory partition and the physical block is recorded through the memory block configuration table, so that the scattered idle physical memory blocks are fully utilized, the memory fragmentation is reduced, and the memory utilization rate is improved. Meanwhile, the mapping relationship table between the memory partition and at least one logical device is established, so that the host computer can access the memory partition through the logical device, and the memory partition shared by multiple devices is realized.

[0054] The computer device embodiment includes a controller, and the controller implements the steps in the device memory management method embodiment when executing the computer program.

[0055] The computer device of the embodiment includes a controller, and the controller implements the steps in the device memory management method embodiment when executing the computer program.

[0056] For example, the computer program can be divided into one or more modules, one or more modules are stored in the memory and executed by the controller to complete the present application. One or more modules can be a series of computer program instructions capable of completing a specific function, which is used to describe the execution process of the computer program in the computer device.

[0057] The computer device can include, but is not limited to, a controller, a memory. Those skilled in the art can understand that the computer device can include more or less components, or combine certain components, or different components, for example, the computer device can also include an input / output device, a network access device, a bus and the like.

[0058] For example, the controller can be a central processing unit (CPU), and can also be other general-purpose controllers, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose controller can be a microcontroller, or the controller can also be any conventional controller, etc. The controller is the control center of the computer device, and connects various parts of the computer device through various interfaces and lines.

[0059] The memory can be used to store computer programs and / or modules, and the controller realizes various functions of the computer device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. For example, the memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required for a function (such as a sound receiving function, a sound conversion to text function, etc.), etc.; and the data storage area can store data (such as audio data, text data, etc.) created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0060] Computer readable storage medium embodiment:

[0061] The modules of the computer device of the above embodiments, if realized in the form of software function units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above device memory management method embodiments can also be completed by instructing related hardware through a computer program, and the computer program can be stored in a computer readable storage medium. When the computer program is executed by the controller, the steps of the above device memory management method embodiments can be realized. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms, etc. The storage medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier wave signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction, for example, in some jurisdictions, according to legislation and patent practice, the computer readable medium does not include electric carrier wave signal and telecommunication signal.

[0062] It should be noted that the above is only the preferred embodiment of the present application, but the design concept of the application is not limited thereto, and any non-essential modification of the application made by using the concept also falls within the protection scope of the application.

Claims

1. A device memory management method, applied to a CXL device, characterized in that: include: When a memory partition request is received, the occupancy status of the local physical memory block and the external physical memory block in the interconnected external device is confirmed; Based on the memory partition capacity information requested by the memory partition, a corresponding number of free local physical memory blocks and free external physical memory blocks are obtained to form a memory partition, and a memory block configuration table mapping the memory partition to the corresponding physical memory blocks is generated. The physical memory blocks have a fixed capacity, and the physical addresses of all physical memory blocks in the memory partition are not contiguous. Establishing a mapping table between the memory partition and at least one logical device includes: establishing a mapping relationship between the memory partition and a local logical device and establishing a mapping relationship between the memory partition and an external logical device in the external device; The memory partition is mapped to two or more logical devices. When the host computer accesses the memory partition through the logical devices, it confirms that the memory partition is in an idle state and accesses the memory partition according to the mapping table and the memory block configuration table. The process of establishing a mapping table between the memory partition and at least one logical device further includes: if any physical memory block in the same memory partition is in a frequently accessed state, migrating the data of that physical memory block to an idle physical memory block in the memory partition.

2. The device memory management method according to claim 1, characterized in that: When establishing the mapping table between the memory partition and at least one logical device, the following steps are also included: Configure the access permissions of the logical device to the memory partition.

3. The device memory management method according to claim 1 or 2, characterized in that: After the step of obtaining the corresponding number of free physical memory blocks to form a memory partition based on the memory partition capacity information requested in the memory partition request, the method further includes: The reference counts for establishing and demapping relationships between the memory partition and the logical device are counted. Each time a mapping relationship is established, the reference count is incremented by one, and each time a mapping relationship is demapping, the reference count is decremented by one. When the reference count is zero, the memory partition is released, leaving all physical memory blocks in the memory partition in an idle state.

4. A computer device, comprising a processor and a memory, characterized in that: The memory stores a computer program that, when executed by the processor, implements the steps of the device memory management method as described in any one of claims 1 to 3.

5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the controller, it implements the steps of the device memory management method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method and device for expanding memory and related equipment

    CN115794669A

  • Cross-host memory sharing method, system, equipment and medium

    CN120371537A