Memory resource allocation method and device, storage medium and program product
By determining the NTB link and memory fragmentation level in a dual-controller storage system, memory resources are allocated to the NTB links directly or in a pre-allocated manner. This solves the reliability issue of memory resource allocation in a multi-NTB link environment, improving the allocation success rate and system stability.
Patent Information
- Application Number
- CN202511223054.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-08-29
AI Technical Summary
In a multi-NTB link environment, how to ensure the reliability of memory resource allocation and reduce the probability of resource waste and allocation failure.
By determining the target NTB link of a dual-controller storage system, the temporary memory resource size required by the NTB port, and the memory fragmentation level of the storage controller, memory resources are allocated to each NTB link using direct allocation or pre-allocation. Dynamic memory allocation functions and fault recovery mechanisms are used to improve allocation reliability.
It improves the reliability of memory resource allocation, reduces resource waste, improves the efficiency and stability of memory management, and ensures data security and efficient system operation.
Smart Images

Figure CN120743553A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a memory resource allocation method, device, storage medium, and program product. Background Art
[0002] In high-reliability storage systems, a dual-controller architecture is a core design for ensuring business continuity and data redundancy. Within this architecture, non-transport bridge (NTB) technology plays a crucial role. It connects two independent storage controllers via a physical backplane link, establishing a high-speed, low-latency interconnect. This NTB link is the lifeline for key functions such as dual-controller mirroring, cache synchronization, and heartbeat monitoring. It ensures that if one controller fails, the other controller can seamlessly take over, thus ensuring data security and service continuity. It is the cornerstone of high availability for the entire storage device.
[0003] However, with increasing demands for storage performance, supporting multiple NTB links has become standard for advanced devices, posing a significant resource allocation challenge. Each NTB port requires exclusive access to a large, physically contiguous temporary memory resource to function properly. In a multi-NTB environment, the system must simultaneously allocate this resource to multiple NTB ports, dramatically increasing the probability of failure. Therefore, ensuring reliable resource allocation across multiple NTB links in massive data scenarios is a pressing technical challenge. Summary of the Invention
[0004] The present application provides a memory resource allocation method, device, storage medium, and program product to at least ensure the reliability of multi-NTB link resource allocation.
[0005] In a first aspect, the present application provides a memory resource allocation method, comprising:
[0006] Determining at least one target non-transparent bridge link in a dual-controller storage system, where the dual-controller storage system includes a local storage controller and a remote storage controller;
[0007] Determine the size of temporary memory resources required by a non-transparent bridge port in any target non-transparent bridge link in at least one target non-transparent bridge link when the non-transparent bridge is driven;
[0008] Determine the memory fragmentation level of the local storage controller;
[0009] Memory resources are allocated to at least one target non-transparent bridge link according to the size of temporary memory resources required by at least one non-transparent bridge port and the memory fragmentation level of the local storage controller.
[0010] In a second aspect, the present application provides a memory resource allocation device, comprising:
[0011] A first determining module is configured to determine at least one target non-transparent bridge link in a dual-controller storage system, where the dual-controller storage system includes a local storage controller and a remote storage controller;
[0012] The second determining module is used to determine the size of temporary memory resources required by the non-transparent bridge port in any target non-transparent bridge link in at least one target non-transparent bridge link when the non-transparent bridge is driven;
[0013] A third determining module is used to determine the memory fragmentation level of the local storage controller;
[0014] The resource allocation module is used to allocate memory resources to at least one target non-transparent bridge link according to the size of temporary memory resources required by at least one non-transparent bridge port and the memory fragmentation degree of the local storage controller.
[0015] In a third aspect, the present application provides an electronic device comprising: a memory for storing a computer program; and a processor for implementing the steps of any one of the above-mentioned memory resource allocation methods when executing the computer program.
[0016] In a fourth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program implements the steps of any of the above-mentioned memory resource allocation methods when executed by a processor.
[0017] In a fifth aspect, the present application also provides a computer program product, comprising a computer program, which implements the steps of any of the above-mentioned memory resource allocation methods when executed by a processor.
[0018] The present application provides a memory resource allocation method, device, storage medium, and program product, which allocate memory resources to each NTB link according to the actual memory resource requirements of each NTB link and the actual degree of memory fragmentation of the local storage controller in a dual-controller storage system, thereby improving the reliability of memory resource allocation and reducing resource waste. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 A schematic diagram of an application environment architecture provided in an embodiment of the present application;
[0021] Figure 2 Schematic diagram of the memory resource allocation method provided in this embodiment of the application Figure 1 ;
[0022] Figure 3 Schematic diagram of the memory resource allocation method provided in this embodiment of the application Figure 2 ;
[0023] Figure 4 Schematic diagram of the memory resource allocation method provided in this embodiment of the application Figure 3 ;
[0024] Figure 5 A schematic diagram of the structure of a memory resource allocation device provided in an embodiment of the present application;
[0025] Figure 6 This is a schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION
[0026] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of this application.
[0027] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0028] The memory resource allocation method provided in this application allocates memory resources to each NTB link according to the actual memory resource requirements of each NTB link and the actual degree of memory fragmentation of the local storage controller in the dual-controller storage system, which can improve the reliability of memory resource allocation and reduce resource waste.
[0029] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0030] In conjunction with the specific application environment architecture or specific hardware architecture on which the execution of the storage resource allocation method depends, the specific application environment architecture or specific hardware architecture is described herein. Figure 1 , Figure 1 This is a schematic diagram of an application environment architecture provided by an embodiment of the present application. An input / output (IO) system 100 includes a server 101 and a storage device 102. Server 101 can be directly connected to storage device 102 via a network cable or other means. Storage device 102 can be equipped with an external accelerator card (ACC) or have its own onboard NTB engine. Using an external ACC or a built-in NTB engine can accelerate data transmission and processing.
[0031] It should be noted that Figure 1 This is only a schematic diagram of an application scenario and does not constitute a limitation on the application scenario of the technical solution provided in this application. For example, the number of servers 101 and storage devices 102 can also be multiple.
[0032] The dual-controller storage system in the embodiment of the present application may refer to Figure 1 The storage device 102 in.
[0033] Figure 2 Schematic diagram of the memory resource allocation method provided in this embodiment of the application Figure 1 ,like Figure 2 As shown, the following steps are included.
[0034] S201: Determine at least one target NTB link in a dual-controller storage system.
[0035] Dual-controller storage system: An intelligent storage device with two independent storage controllers. These two controllers do not operate in a simple master-slave relationship, but rather work together to manage a shared disk shelf, providing continuous and reliable data storage services for front-end servers (hosts). The two storage controllers can be connected via an NTB link.
[0036] NTB link: A high-speed, point-to-point communication channel between two independent computer devices (such as storage controllers) connected by two NTB ports and a physical link (such as a Peripheral Component Interconnect Express (PCIe) cable or backplane trace).
[0037] NTB port: It is an intelligent physical interface that implements the NTB function. The main functions of the NTB port include: (1) Address translation: When the local central processing unit (CPU) wants to access the memory of the other end, the NTB port will convert the local address into an address that can be recognized by the physical address space of the other end in real time. (2) Data isolation: The NTB port can implement data isolation, ensuring data security and independence between different PCIe domains. (3) Data transmission: The NTB port can achieve high-speed data transmission and support various high-speed data transmission applications.
[0038] The execution subject of the embodiment of the present application can be a storage controller in a dual-controller storage system, or a memory resource allocation device set in the storage controller. The memory resource allocation device can be implemented by software or by a combination of software and hardware.
[0039] The dual-control storage system includes a local storage controller and a remote storage controller. The local storage controller refers to the storage controller that implements the technical solution of the present application in the dual-control storage system, and the remote storage controller refers to the other storage controller of the two storage controllers in the dual-control storage system except the local storage controller.
[0040] The target NTB link may refer to an NTB link configured with an NTB adapter.
[0041] In a possible implementation, at least one target NTB link may be determined as follows: M NTB links are determined based on the connection status of NTB-related hardware links in the dual-controller storage system, where M is a positive integer; and at least one target NTB link is determined from the M NTB links based on whether corresponding NTB adapters exist for the M NTB links.
[0042] NTB-related hardware can refer to an external ACC or a built-in NTB engine.
[0043] For any one of the M NTB links, if a corresponding NTB adapter exists for the NTB link, the NTB link is determined as a target NTB link.
[0044] Determining the target NTB link in this way can reduce the waste of memory resources.
[0045] S202: Determine the size of temporary memory resources required by the NTB port in any target NTB link in at least one target NTB link during NTB driving.
[0046] NTB driver: A software component in the operating system kernel that manages and operates NTB hardware devices. It acts as a bridge between the hardware and upper-layer applications or system functions.
[0047] Although an NTB link includes two NTB ports, since this application is directed to a single storage controller, the number of NTB ports on a single storage controller for an NTB link is one. That is, on a single storage controller, each NTB link corresponds to one NTB port.
[0048] The sizes of temporary memory resources required by different NTB ports may be the same or different.
[0049] In a possible implementation, for any NTB port, the size of temporary memory resources required by the NTB port may be determined based on the data structure that the NTB driver needs to manage and the underlying NTB hardware function / register layout.
[0050] For example, the temporary memory resources required by the NTB port in an NTB link may refer to workspace memory resources of the NTB port.
[0051] S203: Determine the memory fragmentation level of the local storage controller.
[0052] For example, you can use storage management software or the command line interface to view the memory fragmentation level of the local storage controller.
[0053] For example, the degree of memory fragmentation may be determined by the number of each memory resource block in the free memory block list. This application does not limit the method for determining the degree of memory fragmentation of the local storage controller.
[0054] S204: Allocate memory resources to at least one target NTB link according to the size of temporary memory resources required by at least one NTB port and the memory fragmentation level of the local storage controller.
[0055] A memory resource allocation method can be determined based on the memory fragmentation level of the local storage controller. The memory resource allocation methods include direct allocation and pre-allocation. Memory resources are allocated to at least one target NTB link based on the memory resource allocation method and the size of temporary memory resources required by at least one NTB port.
[0056] The direct allocation method means that if the memory fragmentation of the local storage controller is low, that is, if the local storage controller has a large number of large-size memory resource blocks (the memory resources in the large-size memory resource blocks are continuous and idle), then memory resources can be directly allocated to each target NTB link based on the size of the temporary memory resources required by the NTB port in each target NTB link. The size of the memory resources allocated to each target NTB link is the same as the size of the temporary memory resources required by the NTB port in the target NTB link. The size of the memory resources in the large-size memory resource blocks is larger than the size of the temporary memory resources required by the NTB port in each target NTB link.
[0057] A large number of large-size memory resource blocks can be represented by the ratio of all large-size memory resource blocks to the available memory resources of the local storage controller. For example, if the ratio of all large-size memory resource blocks to the available memory resources of the local storage controller is greater than or equal to 60%, it can be indicated that a large number of large-size memory resource blocks exist.
[0058] The pre-allocation method involves pre-allocating memory resource blocks if the local storage controller has a high degree of memory fragmentation (i.e., a small number of large memory resource blocks (i.e., a large number of small memory resource blocks)). The pre-allocated memory resource blocks are smaller than the temporary memory resource size required by the NTB port in each target NTB link. For any target NTB link, multiple pre-allocated contiguous memory resource blocks are searched based on the temporary memory resource size required by the NTB port of the target NTB link. These pre-allocated contiguous memory resource blocks occupy a whole contiguous block of memory resources, and the memory resource size occupied by these pre-allocated contiguous memory resource blocks is the same as the temporary memory resource size required by the NTB port. The memory resources occupied by these pre-allocated contiguous memory resource blocks are then allocated to the NTB link. This pre-allocation method can filter out some small memory resource blocks in the local storage controller, thereby improving the timeliness of memory resource allocation.
[0059] The small number of large-size memory resource blocks can be represented by the ratio of all large-size memory resource blocks to the available memory resources of the local storage controller. For example, if the ratio of all large-size memory resource blocks to the available memory resources of the local storage controller is less than or equal to 20%, it can be indicated that there are a small number of large-size memory resource blocks.
[0060] The memory resource allocation method is determined based on the memory fragmentation level of the local storage controller, improving the timeliness and success rate of memory resource allocation. By properly selecting the allocation method, the efficiency and stability of kernel memory management can be significantly improved. In addition, since all allocation methods are based on demand, the memory resource allocation method of this application also improves the reliability of allocation and reduces memory resource waste.
[0061] exist Figure 2 Based on the embodiment shown, the following Figure 3 How to allocate memory resources for at least one target NTB link according to the size of temporary memory resources required by at least one NTB port and the memory fragmentation level of the local storage controller is described in detail.
[0062] Figure 3 Schematic diagram of the memory resource allocation method provided in this embodiment of the application Figure 2 ,like Figure 3 As shown, the following steps are included.
[0063] S301: Determine the size of a pre-allocated memory resource block and the maximum number of pre-allocated memory resource blocks according to the memory fragmentation degree of a local storage controller.
[0064] Based on the different degrees of memory fragmentation of the local storage controller, different sizes and / or maximum numbers of pre-allocated memory resource blocks can be determined. In other words, the sizes of the pre-allocated memory resource blocks determined by different degrees of memory fragmentation of the local storage controller can be different, and the maximum number of pre-allocated memory resource blocks can be the same; or, the sizes of the pre-allocated memory resource blocks determined by different degrees of memory fragmentation of the local storage controller can be the same, and the maximum number of pre-allocated memory resource blocks can be different; or, the sizes and maximum number of the pre-allocated memory resource blocks determined by different degrees of memory fragmentation of the local storage controller can be different.
[0065] All pre-allocated memory resource blocks may be of the same size.
[0066] For example, the size of the pre-allocated memory resource block may be 128 KB, and the maximum number of the pre-allocated memory resource blocks may be 800.
[0067] S302. Pre-allocate the available memory resources of the local storage controller through a dynamic memory allocation function according to the size of the pre-allocated memory resource block, and obtain at least one resource block set and at least one pointer array corresponding to the at least one resource block set. For any one resource block set in the at least one resource block set, the resource block set includes N memory resource blocks, and the pointer array corresponding to the resource block set includes N elements, where the N elements are kernel virtual addresses corresponding to the N memory resource blocks, and the N elements are arranged in ascending order according to the size of the kernel virtual address value, and N is an integer greater than 1 and less than or equal to the maximum number of pre-allocated memory resource blocks.
[0068] The dynamic allocation function may refer to a function for allocating continuous physical memory resources. For example, the dynamic allocation function may be a kernel memory allocation (kmalloc) function.
[0069] The available memory resources of the local storage controller are composed of multiple discontinuous memory resources.
[0070] The number of resource block sets is less than or equal to the number of target NTB links. Memory resources may be allocated to one or more NTB links from memory resources corresponding to one resource block set.
[0071] For example, if the number of resource block sets is 1 and the number of target NTB links is 2, memory resources are allocated to the two NTB links from the memory resources corresponding to the one resource block set. If the number of resource block sets is 2 and the number of target NTB links is 2, memory resources are allocated to the one NTB link from the memory resources corresponding to the one resource block set. If the number of resource block sets is 2 and the number of target NTB links is 3, memory resources are allocated to the one NTB link from the memory resources corresponding to the one resource block set, and memory resources are allocated to the two NTB links from the memory resources corresponding to another resource block set.
[0072] For any one resource block set in at least one resource block set, the above process is specifically as follows: according to the size of the pre-allocated memory resource block, the available memory resources of the local storage controller are pre-allocated through the dynamic memory allocation function, each pre-allocation can obtain a memory resource block, obtain the kernel virtual address of the memory resource block, and place the kernel virtual address of the memory resource block in the pointer array corresponding to the resource block set (or assign the kernel virtual address value of the memory resource block to the first element after all valid elements in the corresponding pointer array). After placing the kernel virtual address of the memory resource block in the pointer array, the valid elements in the pointer array are arranged in ascending order according to the size of the kernel virtual address value, that is, the elements with smaller memory virtual address values are arranged in front of the pointer array, and the elements with larger memory virtual address values are arranged behind the pointer array.
[0073] The kernel virtual address corresponding to the memory resource block may refer to the starting virtual address of the memory resource block.
[0074] It should be noted that a corresponding pointer array can be created in advance for each resource block set. Before resource allocation, the pointer array can be an empty set, or the pointer array can include multiple elements, but the value of each element is a preset value, such as 0.
[0075] A valid element in the pointer array refers to an element whose element value is a kernel virtual address value, and an invalid element may refer to an element whose element value is a preset value (eg, 0).
[0076] For example, the initial pointer array is {0, 0, 0, 0, 0, 0, 0, 0}. After preallocation three times, the pointer array is {0×1000, 0×2000, 0×3000, 0, 0, 0, 0, 0}. The first three elements of the pointer array are valid elements, and the first element after all valid elements is the fourth element in the pointer array.
[0077] The elements in the pointer array can also be called pointers, and the kernel virtual address value can also be called pointer value.
[0078] If the dynamic allocation function is kmalloc and the allocation flag is the kernel memory (GFP_KERNEL) allocation flag, pre-allocation can be performed within the available kernel memory of the local storage controller, meaning that the pre-allocation range is unlimited.
[0079] S303 . Allocate memory resources for any target NTB link among the at least one target NTB link according to the size of temporary memory resources required by the NTB port in the target NTB link, at least one resource block set, and at least one pointer array.
[0080] The size of the memory resource allocated to the target NTB link is the same as the size of the temporary memory resource required by the NTB port in the target NTB link.
[0081] exist Figure 3 In the illustrated embodiment, some small-sized memory resource blocks in the local storage controller can be screened out through pre-allocation, thereby improving the timeliness of memory resource allocation.
[0082] exist Figure 3 Based on the embodiment shown, for any one of the at least one target NTB link, the following is combined with Figure 4A detailed description is given of how to allocate memory resources for the target NTB link according to the size of temporary memory resources required by the NTB port in the target NTB link, the at least one resource block set, and the at least one pointer array.
[0083] Figure 4 Schematic diagram of the memory resource allocation method provided in this embodiment of the application Figure 3 ,like Figure 4 As shown, the following steps are included.
[0084] S401: Determine a candidate kernel virtual address.
[0085] A kernel virtual address may be randomly selected as the candidate kernel virtual address; or the kernel virtual address indicated by the first element in the pointer array may be used as the candidate kernel virtual address; or the candidate kernel virtual address may be determined based on the recorded log.
[0086] The candidate kernel virtual address is an element in the at least one pointer array.
[0087] S402 : Determine the number of resource blocks Q required by the NTB port according to the size of temporary memory resources required by the NTB port in the target NTB link and the size of the pre-allocated memory resource block, where Q is a positive integer.
[0088] The size of the temporary memory resource required by the NTB port in the target NTB link is divided by the size of the pre-allocated memory resource block, and the resulting divisor is the number of resource blocks Q required by the NTB port.
[0089] For example, if the size of the temporary memory resource required by the NTB port in the target NTB link is 1 Mb and the size of the pre-allocated memory resource block is 128 Kb, then the number of resource blocks Q required by the NTB port is 8.
[0090] S403: Determine a pointer array including the candidate kernel virtual address in the at least one pointer array as a target pointer array.
[0091] S404: Determine a resource block set corresponding to the target pointer array in at least one resource block set as a target resource block set.
[0092] S405: Determine the element in the target pointer array whose kernel virtual address is the same as the candidate kernel virtual address as the target element.
[0093] S406. Starting with the target element, traverse the target pointer array until Q elements with continuously increasing kernel virtual address values are found, and the kernel virtual address indicated by the first element of the Q elements is aligned with the boundary of the temporary memory resources required by the NTB port in the target NTB link.
[0094] The Q elements whose kernel virtual address values increase continuously may mean that between any two adjacent elements of the Q elements, the kernel virtual address value indicated by the previous element = the kernel virtual address value indicated by the next element + the size of the pre-allocated memory resource block.
[0095] For example, if the size of the pre-allocated memory resource block is 128 KB and the size of the temporary memory resource required by the NTB port in the target NTB link is 1 MB, then Q is 8, and the kernel virtual address indicated by the first element of the 8 elements is aligned with the boundary of the temporary memory resource required by the NTB port in the target NTB link, which means that the kernel virtual address indicated by the first element of the 8 elements is an integer multiple of 1 MB (0×100000).
[0096] The above steps are specifically as follows: a counter (config) is used to record the number of elements whose kernel virtual address values are continuously increasing in the current search, starting from the starting element, determining whether the starting element is aligned with the boundary of the temporary memory resource required by the NTB port in the target NTB link, and if so, checking whether the kernel virtual address of the starting element and the next element are continuously increasing (that is, whether the kernel virtual address value indicated by the starting element is equal to the sum of the kernel virtual address value indicated by the next element and the size of the pre-allocated memory resource block). If so, the counter is incremented by 1; otherwise, the counter is set to 0; and determining whether the next element is aligned with the boundary of the temporary memory resource required by the NTB port in the target NTB link, and if so, the next element is regarded as the new starting element, and checking whether the kernel virtual address of the starting element and the next element are continuously increasing, and so on, until the counter reaches 7 (because counting starts from 0, 8 consecutive blocks), indicating that 8 consecutive memory resource blocks have been found, and returning the starting virtual address of these 8 memory resource blocks (that is, returning the kernel virtual address indicated by the first element of the 8 elements). If the entire pointer data is traversed and no eight elements with continuously increasing kernel virtual addresses are found, null is returned.
[0097] Since the maximum number of pre-allocated memory resource blocks limits the range of memory resources to be searched, the timeliness of memory resource allocation can be guaranteed.
[0098] In a possible implementation, the search information may be recorded in a log, where the search information includes a search result and the number of elements searched, and the search result includes a search failure or a search success.
[0099] The number of elements to be searched is equal to the number of resource blocks to be searched.
[0100] This log can be used to determine candidate kernel virtual addresses for other target NTB links.
[0101] In a possible implementation, if Q elements with continuously increasing kernel virtual address values are not found in the target pointer array, the memory resources corresponding to the target resource block set are released.
[0102] In addition, if, when traversing the target pointer array, the pointer points to a memory resource outside the memory resource corresponding to the target pointer array (ie, the pointer is invalid or a memory out-of-bounds occurs), the memory resource corresponding to the target resource block set is released.
[0103] By dynamically releasing memory resources, we can avoid the waste of memory resources caused by static pre-allocation and increase the flexibility of memory resource allocation.
[0104] In a possible implementation, if the memory resource allocation of any target NTB link in at least one target NTB link fails, a fault recovery operation is performed to redistribute the memory resources; wherein the fault recovery operation includes restarting the system operation; and reallocating resources for the target NTB link based on the redistributed memory resources and the size of the temporary memory resources required by the NTB port in the target NTB link. The process of reallocating resources can be referred to Figure 3 The illustrated embodiment and Figure 4 Steps S401 to S406 in the illustrated embodiment are not described in detail here.
[0105] For example, the number of fault repair operations may be 3. This application does not limit the specific number of fault repair operations.
[0106] Fault repair operations can reduce the probability of memory resource allocation failure under multiple NTB links, and detect and repair potential faults in advance, effectively improving the reliability of storage devices, ensuring data security and efficient system operation.
[0107] In one possible implementation, if memory resource allocation for any target NTB link among at least one target NTB link fails, data unrelated to the NTB in the local storage controller is transparently compressed to obtain redistributed memory resources; and resources are reallocated to the target NTB link based on the redistributed memory resources and the size of temporary memory resources required by the NTB port in the target NTB link.
[0108] By transparently compressing data not related to the NTB, some memory resources can be released, resulting in redistributed memory resources. This can reduce the probability of memory resource allocation failure under multiple NTB links, and detect and repair potential faults in advance, effectively improving the reliability of storage devices, ensuring data security and efficient system operation.
[0109] S407 : Determine Q memory resource blocks in the target resource block set according to the kernel virtual address indicated by the first element of the Q elements and the size of temporary memory resources required by the NTB port in the target NTB link.
[0110] S408: Allocate the memory occupied by the Q memory resource blocks to the target NTB link.
[0111] In other words, the kernel virtual address indicated by the first of the Q elements is assigned to the temporary memory resources required by the NTB port in the target NTB link as the starting virtual address of the temporary memory resources required by the NTB port in the target NTB link (for example, the memory_start pointer is assigned to workspace_charp). Based on this starting virtual address and the size of the temporary memory resources required by the NTB port in the target NTB link, a contiguous block of memory resources is determined and allocated to the target NTB link. During the allocation process, the starting virtual address can also be converted to a physical address (for example, workspace_charp is converted to phy_addr based on page << PAGE_SHIFT, and the page count is updated using pgalloc_kmallocpageinccount).
[0112] exist Figure 4 In the illustrated embodiment, required memory resources can be quickly found through pre-allocation, thereby improving the timeliness of memory resource allocation.
[0113] It should be noted that Figure 4 The memory resource allocation shown is not Figure 3 After the pre-allocation method shown is completed, resource memory resource allocation can be performed at the same time as pre-allocation. For example, if the number of pre-allocated memory resource blocks is greater than or equal to Q, then Figure 4 In the memory resource allocation method shown, if Q elements with continuously increasing kernel virtual address values are not found, pre-allocation continues until Q elements with continuously increasing kernel virtual address values are found or the number of pre-allocated memory resource blocks reaches the maximum number. Furthermore, the method of the present application is applicable to storage controllers of any manufacturer and / or model.
[0114] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0115] Figure 5This is a schematic diagram of the structure of the memory resource allocation device provided in the embodiment of the present application. Figure 5 As shown, the memory resource allocation device 500 includes: a first determination module 501 , a second determination module 502 , a third determination module 503 and a resource allocation module 504 .
[0116] A first determining module 501 is configured to determine at least one target non-transparent bridge link in a dual-controller storage system, where the dual-controller storage system includes a local storage controller and a remote storage controller.
[0117] The second determining module 502 is configured to determine the size of temporary memory resources required by a non-transparent bridge port in any target non-transparent bridge link in at least one target non-transparent bridge link when the non-transparent bridge is driven;
[0118] A third determining module 503 is configured to determine a degree of memory fragmentation of the local storage controller;
[0119] The resource allocation module 504 is configured to allocate memory resources to at least one target non-transparent bridge link according to the size of temporary memory resources required by at least one non-transparent bridge port and the memory fragmentation level of the local storage controller.
[0120] In a possible implementation, the resource allocation module 504 is specifically configured to:
[0121] Determine the size of the pre-allocated memory resource block and the maximum number of the pre-allocated memory resource blocks according to the degree of memory fragmentation;
[0122] Pre-allocating available memory resources of the local storage controller using a dynamic memory allocation function according to the size of the memory resource block to obtain at least one resource block set and at least one pointer array corresponding to each of the at least one resource block set, wherein for any one of the at least one resource block set, the resource block set includes N memory resource blocks, and the pointer array corresponding to the resource block set includes N elements, where the N elements are kernel virtual addresses corresponding to the N memory resource blocks, and the N elements are arranged in ascending order according to the size of the kernel virtual address values, where N is an integer greater than 1 and less than or equal to a maximum number;
[0123] For any one of the at least one target non-transparent bridge link, memory resources are allocated to the target non-transparent bridge link according to the size of temporary memory resources required by the non-transparent bridge port in the target non-transparent bridge link, at least one resource block set, and at least one pointer array.
[0124] In a possible implementation, the resource allocation module 504 is specifically configured to:
[0125] Determine candidate kernel virtual addresses;
[0126] Determine the number of resource blocks Q required by the non-transparent bridge port according to the size of the temporary memory resource and the size of the memory resource block, where Q is a positive integer;
[0127] determining a pointer array including the candidate kernel virtual address in the at least one pointer array as a target pointer array;
[0128] Determine a resource block set corresponding to the target pointer array in at least one resource block set as a target resource block set;
[0129] Determine the element in the target pointer array whose kernel virtual address is the same as the candidate kernel virtual address as the target element;
[0130] Starting with the target element, traverse the target pointer array until Q elements with successively increasing kernel virtual address values are found, and the kernel virtual address indicated by the first element of the Q elements is aligned with the boundary of the temporary memory resource;
[0131] Determine Q memory resource blocks in the target resource block set according to the kernel virtual address indicated by the first element of the Q elements and the size of the temporary memory resource;
[0132] Allocate the memory occupied by Q memory resource blocks to the target non-transparent bridge link.
[0133] In a possible implementation, the memory resource allocation apparatus 500 further includes a recording module 505 configured to:
[0134] Search information is recorded in the log, including the search result and the number of elements found. The search result includes search failure or search success.
[0135] In a possible implementation, the memory resource allocation apparatus 500 further includes a releasing module 506 configured to:
[0136] If Q elements with continuously increasing kernel virtual address values are not found in the target pointer array, the memory resources corresponding to the target resource block set are released.
[0137] In a possible implementation, the memory resource allocation apparatus 500 further includes a fault recovery module 507 configured to:
[0138] If the memory resource allocation of any target non-transparent bridge link in at least one target non-transparent bridge link fails, performing a fault recovery operation to redistribute the memory resources; wherein the fault recovery operation includes a system restart operation;
[0139] Resources are reallocated for the target non-transparent bridge link according to the reallocated memory resources and the size of the temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link.
[0140] In a possible implementation, the memory resource allocation apparatus 500 further includes a fault recovery module 507 configured to:
[0141] If the memory resource allocation of any target non-transparent bridge link in at least one target non-transparent bridge link fails, transparently compressing the data in the local storage controller that is not related to the non-transparent bridge to obtain redistributed memory resources;
[0142] Resources are reallocated for the target non-transparent bridge link according to the reallocated memory resources and the size of the temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link.
[0143] In a possible implementation, the first determining module 501 is specifically configured to:
[0144] Determine M non-transparent bridge links based on the connection status of non-transparent bridge-related hardware links in the dual-controller storage system, where M is a positive integer.
[0145] At least one target non-transparent bridge link is determined among the M non-transparent bridge links according to whether corresponding non-transparent bridge adapters exist for the M non-transparent bridge links.
[0146] In a possible implementation, the first determining module 501 is specifically configured to:
[0147] For any non-transparent bridge link among the M non-transparent bridge links, if the non-transparent bridge link has a corresponding non-transparent bridge adapter, the non-transparent bridge link is determined as a target non-transparent bridge link.
[0148] For the description of the features in the embodiment corresponding to the memory resource allocation apparatus 500 , reference can be made to the relevant description of the embodiment corresponding to the memory resource allocation method, which will not be described in detail here.
[0149] Figure 6 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 6 As shown, the electronic device 600 provided in this embodiment includes: at least one processor 601 and a memory 602. Optionally, the electronic device 600 further includes a communication component 603. The processor 601, the memory 602 and the communication component 603 are connected by a wire.
[0150] During the specific implementation process, at least one processor 601 executes the computer-executable instructions stored in the memory 602, so that the at least one processor 601 executes the above-mentioned embodiment of the memory resource allocation method.
[0151] The specific implementation process of the processor 601 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.
[0152] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.
[0153] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.
[0154] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.
[0155] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above-mentioned memory resource allocation method embodiments when running.
[0156] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0157] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned memory resource allocation method embodiments are implemented.
[0158] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned memory resource allocation method embodiments are implemented.
[0159] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0160] The above is a detailed introduction to a memory resource allocation method provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core ideas of the present application. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A memory resource allocation method, characterized in that: include: Determining at least one target non-transparent bridge link in a dual-controller storage system, wherein the dual-controller storage system includes a local storage controller and a remote storage controller; Determine the size of temporary memory resources required by a non-transparent bridge port in any one of the at least one target non-transparent bridge links when the non-transparent bridge is driven; Determining a degree of memory fragmentation of the local storage controller; Memory resources are allocated to the at least one target non-transparent bridge link according to the size of temporary memory resources required by at least one of the non-transparent bridge ports and the degree of memory fragmentation.
2. The method according to claim 1, characterized in that The allocating memory resources to the at least one target non-transparent bridge link according to the size of the temporary memory resources required by the at least one non-transparent bridge port and the degree of memory fragmentation includes: Determining the size of the pre-allocated memory resource block and the maximum number of the pre-allocated memory resource blocks according to the degree of memory fragmentation; pre-allocating available memory resources of the local storage controller according to the size of the memory resource block through a dynamic memory allocation function to obtain at least one resource block set and at least one pointer array corresponding to each of the at least one resource block set; for any one of the at least one resource block set, the resource block set includes N memory resource blocks, the pointer array corresponding to the resource block set includes N elements, the N elements are kernel virtual addresses corresponding to the N memory resource blocks, the N elements are arranged in ascending order according to the size of the kernel virtual address values, and N is an integer greater than 1 and less than or equal to the maximum number; For any one of the at least one target non-transparent bridge links, memory resources are allocated to the target non-transparent bridge link based on the size of temporary memory resources required by the non-transparent bridge port in the target non-transparent bridge link, the at least one resource block set and the at least one pointer array.
3. The method according to claim 2, characterized in that The allocating memory resources to the target non-transparent bridge link according to the size of temporary memory resources required by the non-transparent bridge port in the target non-transparent bridge link, the at least one resource block set, and the at least one pointer array includes: Determine candidate kernel virtual addresses; Determining the number of resource blocks Q required by the non-transparent bridge port according to the size of the temporary memory resource and the size of the memory resource block, where Q is a positive integer; Determine a pointer array including the candidate kernel virtual address in the at least one pointer array as a target pointer array; Determine the resource block set corresponding to the target pointer array in the at least one resource block set as the target resource block set; Determine an element in the target pointer array whose kernel virtual address is the same as the candidate kernel virtual address as a target element; Starting with the target element, traverse the target pointer array until Q elements with successively increasing kernel virtual address values are found, and the kernel virtual address indicated by the first element of the Q elements is aligned with the boundary of the temporary memory resource; Determining Q memory resource blocks in the target resource block set according to the kernel virtual address indicated by the first element of the Q elements and the size of the temporary memory resource; Allocate the memory occupied by the Q memory resource blocks to the target non-transparent bridge link.
4. The method according to claim 3, characterized in that The method further comprises: Search information is recorded in a log, where the search information includes a search result and the number of elements searched, and the search result includes a search failure or a search success.
5. The method according to claim 3, characterized in that The method further comprises: If Q elements with continuously increasing kernel virtual address values are not found in the target pointer array, the memory resources corresponding to the target resource block set are released.
6. The method according to claim 5, characterized in that The method further comprises: If the memory resource allocation of any target non-transparent bridge link among the at least one target non-transparent bridge link fails, performing a fault recovery operation to redistribute the memory resources; wherein the fault recovery operation includes restarting the system; Resources are reallocated for the target non-transparent bridge link according to the redistributed memory resources and the size of temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link.
7. The method according to claim 5, characterized in that The method further comprises: If memory resource allocation of any target non-transparent bridge link among the at least one target non-transparent bridge link fails, transparently compressing data in the local storage controller that is not related to the non-transparent bridge to obtain redistributed memory resources; Resources are reallocated for the target non-transparent bridge link according to the redistributed memory resources and the size of temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link.
8. The method according to any one of claims 1 to 7, characterized in that The determining of at least one target non-transparent bridge link in the dual-controller storage system includes: Determining M non-transparent bridge links according to a connection status of non-transparent bridge-related hardware links in the dual-controller storage system, where M is a positive integer; The at least one target non-transparent bridge link is determined among the M non-transparent bridge links according to whether corresponding non-transparent bridge adapters exist for the M non-transparent bridge links.
9. The method according to claim 8, characterized in that The determining the at least one target non-transparent bridge link among the M non-transparent bridge links according to whether corresponding non-transparent bridge adapters exist for the M non-transparent bridge links includes: For any non-transparent bridge link among the M non-transparent bridge links, if a corresponding non-transparent bridge adapter exists for the non-transparent bridge link, the non-transparent bridge link is determined as a target non-transparent bridge link.
10. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the memory resource allocation method according to any one of claims 1 to 9 when executing the computer program.
Citation Information
Patent Citations
Distributed display system and method
CN109976686A
Data synchronization method, device and equipment and storage medium
CN111813707A
System and method of High-Speed Data Communication Frame For Cloud Gaming Data Storage and Retrieval
CN112422606A
Memory resource calling optimization method and system
CN119356850A
Cross-domain communication method, electronic equipment and medium
CN120389978A