Resource management method and device based on combination of Slab distributor and Buddy system

By combining the Slab allocator with the Buddy system, efficient management of MTT resources was achieved, solving the problems of fragmentation and lookup overhead in index resource management, and improving resource utilization and system performance.

CN121092467AActive Publication Date: 2025-12-09YIHUA TECHNOLOGY (BEIJING) CO LTD

Patent Information

Application Number
CN202511236682.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-01
Publication Date
2025-12-09
Estimated Expiration
2045-09-01

AI Technical Summary

Technical Problem

In existing technologies, MTT index resource management has difficulty in effectively maintaining continuous free areas, resulting in frequent memory gaps, which affects the efficiency of large-block resource allocation. Furthermore, the multi-level table lookup mechanism increases hardware table lookup overhead and reduces cache hit rate.

Method used

By combining the Slab allocator with the Buddy system, a linked list structure divided by powers of 2 is constructed to quickly allocate contiguous index intervals and merge adjacent intervals after release. The Slab allocator manages index units of fixed size, reducing internal fragmentation.

Benefits of technology

It improves MTT resource utilization and system response speed, reduces external fragmentation, and enhances hardware access efficiency, making it suitable for high-performance computing and low-latency communication scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121092467A_ABST
    Figure CN121092467A_ABST
Patent Text Reader

Abstract

The invention provides a resource management method and device based on combination of a Slab distributor and a Buddy system, and relates to the technical field of computers.The method comprises the steps that firstly, the Buddy system composed of a plurality of linked lists (recording the initial position of an index interval, the interval length and the use state) is constructed; the method comprises the following steps: distributing continuous index intervals from a Buddy system to construct a Slab cache region; when a resource request is received, searching and distributing available index units in the Slab cache region through the Slab distributor; if not, calling the Buddy system to distribute a new continuous index interval, and constructing a new Slab cache region based on the interval; and after the index units are released, if all the index units in the corresponding Slab cache region are released, returning the index interval corresponding to the Slab cache region to the Buddy system. While the MTT resources are quickly allocated and recycled, fragments are effectively reduced, and the resource utilization rate and the system response speed are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a resource management method and device based on combination of Slab allocator and Buddy system. BACKGROUND

[0002] In remote direct memory access (RDMA) technology, Memory Translation Table (MTT) is a key structure for managing virtual address to physical address mapping, and efficient management of its index resources is crucial to system performance.

[0003] In the prior art, MTT index resources are usually managed by bitmap, which is simple to implement, but it is difficult to effectively maintain continuous free areas during resource allocation, resulting in frequent memory holes and affecting the efficiency of large resource allocation. In addition, some improved schemes attempt to use a multi-level table lookup mechanism to reduce fragmentation, but this approach introduces additional hardware table lookup overhead, reduces cache hit rate, and affects access efficiency, especially in high concurrency and low latency scenarios.

[0004] Therefore, how to ensure fast allocation and recycling of MTT resources while effectively reducing fragmentation, improving resource utilization and system response speed has become a technical problem to be solved. SUMMARY

[0005] The purpose of the present application is to provide a resource management method and device based on combination of Slab allocator and Buddy system to alleviate the above technical problems in the prior art.

[0006] In a first aspect, the present application provides a resource management method based on combination of Slab allocator and Buddy system, comprising: constructing a Buddy system composed of multiple linked lists, the linked lists being used to record the start position, interval length and usage state of index intervals, and the index intervals being divided according to powers of 2; allocating continuous index intervals from the Buddy system to construct Slab cache areas, each Slab cache area including a management header and multiple index units of fixed size; when a resource request is received, searching and allocating available index units in the Slab cache area through the Slab allocator; when there is no available index unit in the Slab cache area, calling the Buddy system to allocate a new continuous index interval, and constructing a new Slab cache area based on the interval; After releasing the index unit, if all index units in the corresponding slab cache area are released, the index interval corresponding to the slab cache area is returned to the buddy system, and it is determined whether the index interval can be merged with adjacent index intervals.

[0007] In an optional embodiment, the buddy system is hierarchically managed by the size of the index interval, and each linked list corresponds to an index interval of a power of 2 size.

[0008] In an optional embodiment, the management header records the free index item linked list pointer, the usage state of the slab, and the number of allocated index units.

[0009] In an optional embodiment, the method further comprises: When the slab allocator allocates an index unit, an available index unit is directly taken from the free linked list, and the allocated count of the management header is updated.

[0010] In an optional embodiment, when the index interval is returned to the buddy system, the method further comprises: It is determined whether the index interval and its adjacent buddy interval are adjacent and free, and if so, they are merged into a larger index interval, and the linked list structure is updated.

[0011] In an optional embodiment, the number and size of the slab cache area are dynamically adjusted according to the resource usage of the system during operation.

[0012] In an optional embodiment, the method is applied to the management of MTT resources in an RDMA device, wherein the MTT resources are used to store mapping information of virtual addresses to physical addresses.

[0013] In a second aspect, the present application provides a resource management device based on the combination of a slab allocator and a buddy system, comprising: A first construction module is configured to construct a buddy system composed of a plurality of linked lists, the linked lists being used to record the start position, interval length and usage state of the index interval, and the index interval being divided according to powers of 2; A second construction module is configured to allocate continuous index intervals from the buddy system to construct slab cache areas, and each slab cache area includes a management header and a plurality of index units of a fixed size; A search module is configured to search and allocate available index units in the slab cache area through the slab allocator when a resource request is received; A calling module is configured to call the buddy system to allocate a new continuous index interval when there is no available index unit in the slab cache area, and to construct a new slab cache area based on the interval; The releasing module is configured to, after releasing the index unit, return the index interval corresponding to the slab cache area to the buddy system if all index units in the corresponding slab cache area are released, and determine whether the index interval can be merged with adjacent index intervals.

[0014] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, the memory storing computer executable instructions capable of being executed by the processor, and the processor executes the computer executable instructions to implement the resource management method based on the combination of the slab allocator and the buddy system according to any one of the preceding embodiments.

[0015] In a fourth aspect, the present application provides a computer readable storage medium, the computer readable storage medium storing computer executable instructions, and the computer executable instructions, when invoked and executed by a processor, cause the processor to implement the resource management method based on the combination of the slab allocator and the buddy system according to any one of the preceding embodiments.

[0016] The resource management method and device based on the combination of the slab allocator and the buddy system provided by the present application implement an efficient resource management method by combining the slab allocator and the buddy system: the buddy system adopts a linked list structure divided by powers of 2, which can quickly allocate continuous index intervals and effectively merge adjacent intervals after release, thereby significantly reducing external fragmentation; the slab allocator manages fixed-size index units in continuous intervals, which improves the allocation and recycling efficiency and reduces internal fragmentation. Through the cooperative work of the buddy system and the slab allocator, the efficiency of resource allocation is ensured, and the dynamic adaptability of the system under different loads is enhanced. The method effectively improves the MTT resource utilization rate and hardware access efficiency, and is suitable for high-performance computing and low-latency communication scenarios. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the specific embodiments or prior art of the present application, the drawings needed in the description of the specific embodiments or prior art will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.

[0018] Figure 1 A flowchart of a resource management method based on the combination of a slab allocator and a buddy system provided by an embodiment of the present application; Figure 2 A schematic diagram of an index unit provided by an embodiment of the present application; Figure 3A structural diagram of a resource management device based on a combination of a Slab allocator and a Buddy system is provided for an embodiment of the present application. Figure 4 A structural diagram of an electronic device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0019] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in connection with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.

[0020] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative labor are within the scope of protection of the present application.

[0021] It should be noted that: similar reference numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0022] Term explanation: 1、Buddy system: Buddy System is a memory allocation and recycling strategy, mainly used to manage variable size memory blocks.

[0023] 2、Slab: Slab mechanism is a memory allocation strategy used to efficiently manage and allocate fixed-size memory blocks. Each Slab consists of multiple Entries (memory blocks, also known as memory units), and each Entry is usually the same size.

[0024] 3、MTT: MTT is a structure used to manage virtual address to physical address mapping. In RDMA (Remote Direct Memory Access) technology, MTT is used to store and manage device memory address mapping to ensure that remote hosts can access the specified physical memory region.

[0025] In RDMA devices, MTT is responsible for managing virtual address to physical address mapping, and software usually uses bitmap to record the allocation of MTT resources. However, the traditional bitmap scheme has the following problems: Cave problem: bitmap can only manage MTT index, while hardware can only access MTT based on start index and entrycount; Fragmentation problem: when releasing MTT resources, fragmentation may occur in the bitmap, making it difficult to allocate large MTT resources.

[0026] To solve the fragmentation problem, some technical solutions use a multi-level lookup table to manage mtt entries. This solution can reduce the generation of fragments to some extent, but it will increase the overhead of hardware lookup table. Given the key feature of MTT as a high-frequency access resource, using a multi-level table will result in uneven data distribution and thus reduce cache hit rate, affecting data access efficiency.

[0027] Therefore, based on the above, the embodiment of the present application provides a resource management method based on the combination of Slab allocator and Buddy system, as shown in Figure 1 The method mainly includes the following steps: Step S110, a Buddy system composed of multiple linked lists is constructed, the linked list is used to record the start position, interval length and usage state of the index interval, and the index interval is divided according to the power of 2.

[0028] In the system initialization phase, a Buddy system-based index resource pool is first constructed, which specifically includes resource pool data structure construction, linked list node information and initialization processing. Specifically: The resource pool data structure construction refers to first establishing multiple linked list structures, and each linked list is used to manage a specific size of index interval. In specific implementation, the mtt index item is abstracted as a resource as shown in Figure 2 Each index item has its own subscript, and the index interval can be divided according to the power of 2, for example, the interval of 1, 2, 4, 8, 16 and the like continuous index items, this example is only illustrative, and is not specifically limited.

[0029] The linked list node information refers to that each linked list node records the start position, interval length and usage state of the index interval, wherein the usage state includes idle or occupied.

[0030] The initialization process is to divide the entire index space into multiple intervals of the power of 2 according to the total number of available MTT resources of the system, and insert these intervals into the linked list of the corresponding level.

[0031] Step S120, a continuous index interval is allocated from the Buddy system to construct a Slab cache area, and each Slab cache area includes a management header and multiple fixed-size index units.

[0032] On the basis of the Buddy system, a Slab cache area is constructed to manage MTT index items of fixed size, i.e. Slab cache area division is performed. Specifically, in the Slab cache area division, a continuous index interval is allocated from the Buddy system and divided into several sub-intervals as Slab cache areas. Each Slab cache area includes a management header and a plurality of index units of fixed size.

[0033] In an optional embodiment, the management header records the free index item list pointer, the usage state of the Slab, and the number of allocated index units. Corresponding to the above Slab cache area, the management header records the state of the Slab cache area, the free index list pointer, the allocated index count, and the like metadata.

[0034] Step S130, upon receiving a resource request, the Slab allocator is used to search and allocate available index units in the Slab cache area.

[0035] Upon receiving a resource request, the Slab allocator is first used for preferential allocation, i.e. the Slab allocator is first used to search whether there is a free index unit in the corresponding Slab cache area.

[0036] If there is a free unit, an index unit is taken out from the free list and the management data is updated.

[0037] Step S140, when there is no available index unit in the Slab cache area, a new continuous index interval is allocated by the Buddy system, and a new Slab cache area is constructed based on the interval.

[0038] If no available index unit is found in the current Slab cache area after searching, the Buddy system is called to allocate a new continuous index interval. Further, a new Slab cache area is constructed based on the newly allocated index interval, and an allocation operation is performed.

[0039] Step S150, after releasing an index unit, if all index units in the corresponding Slab cache area are released, the index interval corresponding to the Slab cache area is returned to the Buddy system, and it is determined whether it can be merged with the adjacent index interval.

[0040] After the index resource is released, the following processes are performed: Release to Slab cache area: the released index unit is returned to the free list of the corresponding Slab cache area, and the allocated count is updated; Slab recycling judgment: if all index units in a Slab cache area are released, the index interval corresponding to the Slab cache area is returned to the Buddy system; Interval merging operation: In the Buddy system, it is determined whether the interval can be merged with the adjacent Buddy interval (also known as the buddy interval). If it can be merged, it is merged into a larger interval, and the linked list structure is updated.

[0041] By combining the Buddy system with the Slab allocator, a hierarchical MTT index resource management method is constructed. Through this hierarchical management mode, the problems of low resource management efficiency and serious fragmentation in the prior art are solved. Not only is the efficient scheduling of resources achieved, but also the fast allocation of fixed-size resource items is guaranteed, significantly improving the overall response speed and stability of the system. The specific beneficial effects are as follows: 1. Improve resource allocation and recycling efficiency Buddy system fast allocation: The Buddy system is based on 2 power interval division and linked list management, which can quickly locate the continuous index block that meets the request size, avoiding the overhead of bit-by-bit search in traditional bitmap method.

[0042] Slab allocator fast response: The Slab allocator maintains a fixed-size index unit cache, so that frequent resource allocation and release operations almost do not produce additional overhead, significantly improving the response speed.

[0043] 2. Reduce fragmentation and improve resource utilization Buddy system reduces external fragmentation: The Buddy system combines adjacent intervals after release into larger intervals through the interval merging mechanism, effectively reducing external fragmentation caused by resource release.

[0044] Slab allocator reduces internal fragmentation: The Slab mechanism manages fixed-size objects, avoiding internal fragmentation caused by inconsistent object sizes in traditional allocation methods.

[0045] 3. Improve system dynamic adaptability and scalability Hierarchical structure supports multi-level granularity management: The Buddy system is responsible for dynamic management of large resources, and the Slab allocator is responsible for fast allocation of fine-grained resources. The combination of the two forms a multi-level resource management architecture that adapts to resource needs in different scenarios.

[0046] Flexible expansion capability: When the Slab cache area cannot meet the request, the Buddy system is automatically called to apply for new resources, ensuring that the system can still run stably under high load.

[0047] 4. Improve hardware access efficiency Cache hit rate optimization: Since the Slab mechanism ensures the continuity of resources and the Buddy system controls the distribution pattern of resources, MTT index access is more concentrated, improving cache hit rate and reducing hardware table lookup delay.

[0048] Reducing multi-level table lookup overhead: compared with the multi-level table structure in the prior art, the scheme avoids multiple table lookup operations, improves hardware access efficiency, and is suitable for high-performance computing and low-latency scenarios such as RDMA.

[0049] For ease of understanding, the following describes in detail the specific implementation of the resource management method provided by the embodiments of the application based on the combination of the Slab allocator and the Buddy system.

[0050] The above-described linked list of the Buddy system provided by the embodiments of the application is hierarchically managed according to the size of the index interval, and each linked list corresponds to an index interval of a power-of-2 size. This hierarchical management mechanism enables the system to efficiently find, allocate, and merge resources of different granularities.

[0051] Specifically, when the system is initialized, the index interval is divided into multiple levels according to powers of 2 according to the total MTT index space size (for example, 256 index items in total), for example, 1, 2, 4, 8, 16, 32, 64, 128, 256, and the like, different sizes of contiguous index intervals. Each level corresponds to a linked list for managing all available free intervals at this level.

[0052] A specific example is described as follows: Suppose that the system has a total of 256 MTT index items (numbered 0-255), and the system constructs the following level linked list structure: The 0th level linked list: manages intervals of size 1 (i.e., a single index item), a total of 256; The 1st level linked list: manages intervals of size 2, a total of 128; The 2nd level linked list: manages intervals of size 4, a total of 64; ... The 8th level linked list: manages intervals of size 256, only 1 (i.e., the entire index space).

[0053] When the system receives a request to allocate 10 contiguous MTT index items, the Buddy system will round up the request size to the nearest power of 2 (i.e., 16), and then find whether there is a free 16 contiguous index interval in the 4th level linked list. If so, allocate the interval; if not, take out an interval of 32 index items from a higher level (such as the 5th level), and split it into two intervals of 16 index items, use one of them for allocation, and insert the other one into the 4th level linked list as a free resource.

[0054] In the resource release phase, the system checks whether the "buddy" of the release interval is also in the idle state. For example, if the interval [0~15] is released, its "buddy" interval is [16~31], if the interval is also idle, the two will be merged into an interval of 32 index items, and inserted into the 5th level linked list, thereby realizing the automatic arrangement and efficient reuse of resources.

[0055] Through the above hierarchical management mechanism, the system can quickly respond to resource requests of different sizes, effectively reduce resource fragmentation, and improve overall resource utilization and allocation efficiency.

[0056] Further, in an embodiment of the present application, the Slab allocator directly takes an available index unit from the free list when allocating an index unit, and updates the allocated count in the management header to realize fast and efficient resource allocation. The specific implementation process is as follows: Each Slab cache area includes a management header and multiple fixed-size index units. The management header records the state of the Slab, the free index list pointer, the allocated count, and the cache type to which the Slab belongs, and other metadata. The free index units are organized in a linked list manner, and each index unit header saves the pointer of the next free unit, forming a one-way linked list structure.

[0057] A specific example is described as follows: Suppose there is a Slab cache area in the system for managing MTT index units of size 1, and the Slab contains 16 index units (numbered 0~15). In the initialization phase, all units are in the idle state, and the free list is connected in turn 0→1→2→…→15, and the management header records that the current allocated count is 0.

[0058] When receiving an index allocation request, the Slab allocator first locates the corresponding Slab cache area, reads the free list pointer in the management header, takes the head node of the linked list (i.e. index unit 0), and removes it from the free list. Then update the allocated count in the management header to 1, and return the index unit for use.

[0059] If the allocation is requested again, the Slab allocator continues to take the next node from the free list until the free list is empty. At this time, the system will call the Buddy system to apply for a new continuous index interval, and construct a new Slab cache area to meet subsequent requests.

[0060] In the above manner, the Slab allocator can realize fast allocation and efficient management of fixed-size index units, significantly reduce allocation delay, and improve the overall response performance of the system.

[0061] In an optional embodiment, when returning the index interval to the Buddy system, it can be further determined whether the index interval is adjacent to its adjacent Buddy interval and both are in the idle state, if so, it is merged into a larger index interval, and the linked list structure is updated. In the specific implementation, each index interval is managed as a fixed size of 2 power length in the Buddy system. Each interval has a "buddy", that is, another interval with the same size and adjacent to it. The system determines whether two intervals are buddies of each other through a specific algorithm (such as the parity of the starting index and the interval size).

[0062] The following is an example: Suppose there are index ranges 0-255 in the system, and the interval size managed by the Buddy system is 16, that is, each interval contains 16 consecutive index items. There are currently two adjacent intervals: Interval A: starting index 0, length 16, state idle; Interval B: starting index 16, length 16, state also idle.

[0063] At this time, the system determines that the two intervals are "buddies" of each other, that is, they are the same size and physically adjacent, and both are in the idle state. Therefore, the system merges the two intervals into a larger interval, whose starting index is 0 and length is 32, and removes the two intervals from the original 16-size linked list and inserts the merged interval into the 32-size linked list.

[0064] In the subsequent resource allocation process, when there is a request for 32 index items, the merged interval can be directly taken from the linked list, thereby effectively reducing resource fragmentation and improving resource utilization and allocation efficiency.

[0065] Through the above mechanism, the application can automatically identify and merge adjacent idle intervals after the index interval is released, forming a larger continuous resource block, further optimizing the resource management performance. This whole process strictly defines the identification, state and link relationship of the index interval, realizes the dynamic allocation and recovery of a large range of index resources, ensures that the allocation strategy can be effectively adjusted in large-scale resource management, and reduces the scattered hole phenomenon.

[0066] Further, in an embodiment of the application, the number and size of the Slab cache area are dynamically adjusted according to the resource usage of the system during operation, thereby improving the flexibility and adaptability of resource management. The specific implementation process is as follows: Each slab cache area is used to manage MTT index units of a fixed size (such as 1, 2, 4, etc.). The system continuously monitors the usage of each slab cache area during operation, including indicators such as idle rate, allocation failure rate, etc. When a certain slab cache area frequently experiences resource shortages or is in a long-term low utilization state, the system will dynamically adjust the capacity or number of the slab cache area according to the preset strategy.

[0067] The following is an example: Suppose there is a slab cache area in the system, which is used to manage MTT index units of size 1, and the initial configuration contains 16 index units (numbers 0-15) to meet frequent small-grained resource requests. During system operation, if it is monitored that the slab cache area frequently fails to allocate (i.e., the free list is empty), the system will determine that the current cache capacity is insufficient, and then trigger the expansion mechanism. The expansion mechanism refers to: calling the Buddy system to apply a new continuous index interval (such as 16 index units), constructing a new slab cache area based on the interval, and adding the new cache area to the management structure of the slab allocator, thereby improving the supply capacity of this type of resource.

[0068] Conversely, if a slab cache area is long-term idle (such as the usage rate is lower than a set threshold), the system will trigger the recycling mechanism to release the entire slab cache area back to the Buddy system and remove it from the management structure of the slab allocator to release resources for other uses.

[0069] Through the above dynamic adjustment mechanism, the resource configuration of the slab cache area can be flexibly adjusted according to the actual running state, thereby improving the system resource utilization and response performance.

[0070] The above method of the present application can be applied to the management of MTT resources in an RDMA device, wherein MTT (Memory Translation Table) is used to store mapping information from virtual address to physical address, and is a key data structure for remote memory access of the RDMA device.

[0071] In the process of RDMA communication, the user program specifies the memory region that can be accessed remotely by registering the memory region (Memory Region, MR), and the system needs to allocate a set of continuous MTT index items for each MR to describe the physical address mapping information of the memory region. Since the hardware requires MTT index items to be continuous, efficient MTT resource management is crucial to RDMA performance.

[0072] In a specific example, it is assumed that in a certain RDMA device, the system manages a total of 1024 MTT index items (numbered 0~1023) for supporting address mapping requests of multiple user MRs. When a user initiates a request for registering a memory region, the system needs to allocate a continuous MTT index interval for the user. The above method is used to realize efficient management of MTT resources, including: The buddy system constructs an index pool: the system constructs an index resource pool based on the buddy system in the initialization stage, divides the entire MTT index space into multiple intervals of power-of-2 size, and maintains multiple linked lists for managing the intervals.

[0073] The slab allocator manages fixed-size index units: for common small-granularity MTT requests (such as 4 index items), the system constructs a slab cache area from the continuous interval allocated by the buddy system, and each slab cache area manages fixed-size index units.

[0074] Dynamic resource allocation and recycling: when a user initiates an MR registration request, the slab allocator first searches for available index units in the corresponding cache area; if the cache area resource is insufficient, the buddy system is called to expand the resource; after the MR is released, the system recycles the index units and judges whether the entire slab cache area can be merged into the buddy system.

[0075] For example, user A initiates an MR registration request, requiring allocation of 12 continuous MTT index items. The system rounds up the request size to 16 (the nearest power of 2), calls the buddy system to find a 16-index-item interval, and allocates and records it in the address mapping table of the MR if found; if user A releases the MR later, the system returns the interval to the buddy system and judges whether it can be merged with adjacent intervals to reduce fragmentation.

[0076] Through the above mechanism, the application realizes efficient management of MTT resources in an RDMA device, significantly improves address mapping efficiency, resource utilization, and system stability, and is suitable for high-performance network communication and remote memory access scenarios.

[0077] In summary, the resource management method based on the combination of the slab allocator and the buddy system provided by the embodiments of the application realizes efficient management of MTT resources by combining the buddy system and the slab allocator. The buddy system effectively reduces external fragmentation and supports dynamic allocation of large blocks of resources, and the slab allocator improves the efficiency of small-granularity resource allocation and reduces internal fragmentation. The two work together to improve resource utilization, allocation and recycling speed, and system dynamic adaptability, especially suitable for high-performance scenarios such as RDMA, significantly optimizing memory management performance and hardware access efficiency.

[0078] Based on the above method embodiments, the application embodiments further provide a resource management device based on the combination of a Slab allocator and a Buddy system, as shown in Figure 3 The device mainly includes the following parts: A first construction module 310 is configured to construct a Buddy system composed of a plurality of linked lists, the linked lists being used to record the starting position, interval length and usage state of index intervals, and the index intervals being divided according to powers of 2. A second construction module 320 is configured to allocate continuous index intervals from the Buddy system to construct Slab cache areas, and each Slab cache area includes a management header and a plurality of index units of fixed size. A searching module 330 is configured to search and allocate available index units in the Slab cache areas through the Slab allocator when a resource request is received. A calling module 340 is configured to call the Buddy system to allocate new continuous index intervals and construct new Slab cache areas based on the intervals when there is no available index unit in the Slab cache areas. A releasing module 350 is configured to return the index intervals corresponding to the Slab cache areas to the Buddy system when all index units in the corresponding Slab cache areas are released, and determine whether the index intervals can be merged with adjacent index intervals.

[0079] In a feasible implementation, the linked lists of the Buddy system are managed in stages according to the size of the index intervals, and each linked list corresponds to an index interval of a power of 2 size.

[0080] In a feasible implementation, the management header records the free index item linked list pointer, the usage state of the Slab and the number of allocated index units.

[0081] In a feasible implementation, the device further includes a first updating module configured to: when the Slab allocator allocates index units, directly take an available index unit from the free linked list and update the allocated count of the management header.

[0082] In a feasible implementation, when the index intervals are returned to the Buddy system, the device further includes a second updating module configured to: determine whether the index intervals are adjacent to their adjacent Buddy intervals and are both in the free state, and if so, merge them into a larger index interval and update the linked list structure.

[0083] In a feasible implementation, the number and size of the Slab cache areas are dynamically adjusted according to the resource usage of the system during operation.

[0084] In an implementable embodiment, the method is applied to the management of MTT resources in an RDMA device, wherein the MTT resources are used to store mapping information of virtual addresses to physical addresses.

[0085] The resource management apparatus based on the combination of the Slab allocator and the Buddy system provided by the embodiments of the present application has the same implementation principle, technical effects and the foregoing method embodiments. For brief description, the embodiments of the resource management apparatus based on the combination of the Slab allocator and the Buddy system are not mentioned in the foregoing method embodiments, and the corresponding content can be referred to in the foregoing method embodiments.

[0086] The embodiments of the present application further provide an electronic device, as shown in the accompanying drawings, which is a structural schematic diagram of the electronic device, wherein the electronic device 100 comprises a processor 41 and a memory 40, the memory 40 stores computer executable instructions capable of being executed by the processor 41, and the processor 41 executes the computer executable instructions to implement any one of the foregoing resource management methods based on the combination of the Slab allocator and the Buddy system. Figure 4

[0087] In the embodiments shown in the accompanying drawings, the electronic device further comprises a bus 42 and a communication interface 43, wherein the processor 41, the communication interface 43 and the memory 40 are connected through the bus 42. Figure 4

[0088] The memory 40 can contain a high-speed random access memory (RAM) and can also include a non-volatile memory, for example, at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 43 (which can be wired or wireless), and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used. The bus 42 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 42 can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one bidirectional arrow is used in the accompanying drawings to represent the bus, but it does not mean that there is only one bus or only one type of bus. Figure 4

[0089] ​​​The processor 41 can be an integrated circuit chip with processing capability. In implementation process, each step of the above method can be completed by integrated logic circuit of hardware in the processor 41 or by instructions in the form of software. The processor 41 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor to execute, or be executed by a combination of hardware and software modules in the code processor. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register, or other mature storage medium in the art. The storage medium is located in the storage, and the processor 41 reads the information in the storage, and combines the hardware to complete the steps of the above-mentioned resource management method based on the combination of the Slab allocator and the Buddy system.

[0090] The embodiment of the present application further provides a computer readable storage medium, which stores computer executable instructions. When the computer executable instructions are called and executed by a processor, the computer executable instructions cause the processor to implement the above-mentioned resource management method based on the combination of the Slab allocator and the Buddy system. For specific implementation, refer to the foregoing method embodiments, which will not be described here.

[0091] The computer program product of the resource management method and device based on the combination of the Slab allocator and the Buddy system provided by the embodiment of the present application includes a computer readable storage medium storing program codes. The instructions included in the program codes can be used to execute the method in the foregoing method embodiments. For specific implementation, refer to the method embodiments, which will not be described here.

[0092] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present application.

[0093] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present application or the part of the present application that essentially contributes to the prior art or the part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0094] In the description of the present application, it should be noted that the terms "first", "second" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.

[0095] In the description of the present application, it should be noted that unless otherwise specified and limited, the terms "set", "install", "connect", "connect" should be understood in a broad sense, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium, or it can be connected inside two elements. For those skilled in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.

[0096] Finally, it should be pointed out that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A resource management method based on the combination of Slab allocator and Buddy system, characterized in that, The method comprises the following steps: a Buddy system composed of multiple linked lists is constructed, the linked lists are used to record the start position, interval length and use state of index intervals, and the index intervals are divided according to powers of 2; a Slab cache area is constructed by allocating continuous index intervals from the Buddy system, each Slab cache area comprises a management header and multiple index units of fixed size; when a resource request is received, a Slab allocator is used to search and allocate available index units in the Slab cache area; when there is no available index unit in the Slab cache area, the Buddy system is called to allocate a new continuous index interval, and a new Slab cache area is constructed based on the interval; after an index unit is released, if all index units in the corresponding Slab cache area are released, the index interval corresponding to the Slab cache area is returned to the Buddy system, and it is determined whether the index interval can be merged with adjacent index intervals.

2. The resource management method based on Slab allocator combined with Buddy system according to claim 1, characterized in that, The linked lists of the Buddy system are managed in a hierarchical manner according to the size of the index intervals, and each linked list corresponds to an index interval of a power of 2.

3. The method for resource management based on Slab allocator combined with Buddy system according to claim 1, characterized in that, The management header records a free index item linked list pointer, a Slab use state and a number of allocated index units.

4. The method for resource management based on Slab allocator combined with Buddy system according to claim 1, characterized in that, The method further comprises the following steps: When the Slab allocator allocates an index unit, an available index unit is directly taken from the free linked list, and the number of allocated index units in the management header is updated.

5. The method for resource management based on Slab allocator combined with Buddy system according to claim 1, characterized in that, When the index interval is returned to the Buddy system, the method further comprises the following steps: It is determined whether the index interval is adjacent to a Buddy interval adjacent thereto and both are in a free state, if yes, the index interval and the Buddy interval are merged into a larger index interval, and the linked list structure is updated.

6. The method for resource management based on Slab allocator combined with Buddy system according to claim 1, characterized in that, The number and size of the Slab cache areas are dynamically adjusted according to the resource use condition of the system during operation.

7. The method for resource management based on Slab allocator combined with Buddy system according to claim 1, characterized in that, The method is applied to the management of MTT resources in an RDMA device, wherein the MTT resources are used to store mapping information of virtual addresses to physical addresses.

8. A resource management apparatus based on a combination of Slab allocator and Buddy system, characterized in that, The method comprises the following steps: a first constructing module is configured to construct a Buddy system composed of multiple linked lists, the linked lists are used to record the start position, interval length and use state of index intervals, and the index intervals are divided according to powers of 2; a second constructing module is configured to construct a Slab cache area by allocating continuous index intervals from the Buddy system, each Slab cache area comprises a management header and multiple index units of fixed size; a searching module is configured to search and allocate available index units in the Slab cache area by using a Slab allocator when a resource request is received; a calling module is configured to call the Buddy system to allocate a new continuous index interval when there is no available index unit in the Slab cache area, and to construct a new Slab cache area based on the interval; a releasing module is configured to return the index interval corresponding to the Slab cache area to the Buddy system when all index units in the corresponding Slab cache area are released, and to determine whether the index interval can be merged with adjacent index intervals.

9. An electronic device, comprising: The computer readable storage medium stores computer executable instructions, which, when invoked and executed by the processor, cause the processor to implement the resource management method based on the Slab allocator combined with the Buddy system according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer executable instructions, which, when invoked and executed by the processor, cause the processor to implement the resource management method based on the Slab allocator combined with the Buddy system according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Memory management method and system

    CN108647150A

  • Data transmission method, system and device and storage medium

    CN116414582A

  • Kernel large-page memory optimization method

    CN117827430A

  • Address translation bypass cache management system for realizing address translation

    CN118012789A

  • Edge gateway storage optimization method and system based on partner algorithm

    CN118590457A

Cited By

  • Memory object management method, device and equipment and readable storage medium

    CN122132326A