A memory resource allocation method, device, storage medium and program product
By determining the NTB link and memory fragmentation level in a dual-controller storage system, and allocating memory resources to the NTB link using direct or pre-allocation methods, the reliability problem of memory resource allocation in a multi-NTB link environment is solved, achieving efficient and reliable memory resource management.
Patent Information
- Application Number
- CN202511223054.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-08-29
AI Technical Summary
In a multi-NTB link environment, how can we ensure the reliability of memory resource allocation and reduce resource waste and the probability of allocation failure?
By determining the target NTB link, the temporary memory resource size required by the NTB port, and the memory fragmentation degree of the storage controller in the dual-controller storage system, memory resources are allocated to each NTB link using direct allocation or pre-allocation methods. Combined with dynamic memory allocation functions and fault recovery mechanisms, the reliability and timeliness of memory resource allocation are improved.
It improves the reliability of memory resource allocation, reduces resource waste, ensures data security and efficient system operation, and reduces the probability of memory resource allocation failure under multi-NTB links.
Smart Images

Figure CN120743553B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a memory resource allocation method, device, storage medium, and program product. Background Technology
[0002] In high-reliability storage systems, a dual-controller architecture is a core design element 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 enabling critical functions such as dual-controller mirroring, cache synchronization, and heartbeat detection. It ensures that if one controller fails, the other can seamlessly take over operations, thereby guaranteeing data security and service continuity. It is the cornerstone of high availability for the entire storage device.
[0003] However, with the increasing demands for storage performance, supporting multiple NTB links has become standard in advanced devices, posing a significant challenge to system resource allocation. Each NTB port requires a large, physically contiguous block of temporary memory to function properly during NTB driver operation. In a multi-NTB link environment, the system needs to successfully allocate such resources to multiple NTB ports simultaneously, drastically increasing the probability of failure. Therefore, ensuring the reliability of multi-NTB link resource allocation in massive data scenarios is a critical technical problem that needs to be solved. Summary of the Invention
[0004] This 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] Firstly, this application provides a method for allocating memory resources, including:
[0006] Determine at least one target non-transparent bridge link in the dual-controller storage system, which includes the local storage controller and the peer storage controller.
[0007] Determine the size of temporary memory resources required for the non-transparent bridge port in at least one target non-transparent bridge link when driving a non-transparent bridge;
[0008] Determine the degree of memory fragmentation on the local storage controller;
[0009] Memory resources are allocated to at least one target non-transparent bridge link based on the size of the temporary memory resources required by at least one non-transparent bridge port and the degree of memory fragmentation of the local storage controller.
[0010] Secondly, this application provides a memory resource allocation device, comprising:
[0011] The first determining module is used to determine at least one target non-transparent bridge link in the dual-controller storage system, which includes a local storage controller and a peer storage controller.
[0012] The second determining module is used to determine the size of the temporary memory resources required by the non-transparent bridge port in any one of the target non-transparent bridge links when driving a non-transparent bridge;
[0013] The third determination module is used to determine the degree of memory fragmentation 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 based on the size of the temporary memory resources required by at least one non-transparent bridge port and the degree of memory fragmentation of the local storage controller.
[0015] Thirdly, this application provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described memory resource allocation methods when executing the computer program.
[0016] Fourthly, this application provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described memory resource allocation methods.
[0017] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described memory resource allocation methods.
[0018] This application provides a memory resource allocation method, device, storage medium, and program product that allocates memory resources to each NTB link according to the actual memory resource requirements of each NTB link and the actual memory fragmentation level of the local storage controller in a dual-controller storage system. This can improve the reliability of memory resource allocation and reduce resource waste. Attached Figure Description
[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 A schematic diagram of an application environment architecture provided in this application embodiment;
[0021] Figure 2 A flowchart illustrating the memory resource allocation method provided in the embodiments of this application. Figure 1 ;
[0022] Figure 3 A flowchart illustrating the memory resource allocation method provided in the embodiments of this application. Figure 2 ;
[0023] Figure 4 A flowchart illustrating the memory resource allocation method provided in the embodiments of this application. Figure 3 ;
[0024] Figure 5 This is a schematic diagram of the structure of the memory resource allocation device provided in the embodiments of this application;
[0025] Figure 6 A schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0027] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific 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 memory fragmentation of the local storage controller in the dual-controller storage system. This can improve the reliability of memory resource allocation and reduce resource waste.
[0029] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0030] This section describes the specific application environment architecture or hardware architecture upon which the storage resource allocation method depends. (References) Figure 1 , Figure 1 This is a schematic diagram of an application environment architecture provided in an embodiment of this application. The input / output (IO) system 100 includes a server 101 and a storage device 102. The server 101 can be directly connected to the storage device 102 via a network cable or the like. The storage device 102 can have an external accelerator card (ACC) or a built-in NTB engine. By using an external ACC or a built-in NTB engine, data transmission and processing can be accelerated.
[0031] It should be noted that, Figure 1 This is merely an illustrative diagram of one application scenario and does not constitute a limitation on the application scenarios of the technical solutions 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 this application embodiment may refer to... Figure 1 Storage device 102 in the middle.
[0033] Figure 2 A flowchart illustrating the memory resource allocation method provided in the embodiments of this application. Figure 1 ,like Figure 2 As shown, the steps include the following.
[0034] S201. Determine at least one target NTB link in the dual-controller storage system.
[0035] Dual-controller storage system: An intelligent storage device with two independent storage controllers. These two controllers are not in a simple master-slave relationship, but rather work collaboratively to manage a shared disk shelf, providing continuous and reliable data storage services to the front-end server (host). The two storage controllers can be connected via an NTB link.
[0036] NTB Link: A high-speed, point-to-point communication channel connecting two independent computer devices (such as storage controllers) through two NTB ports and a physical link (such as a Peripheral Component Interconnect Express (PCIe) cable or backplane cabling).
[0037] NTB Port: A smart physical interface that implements NTB functionality. The main functions of the NTB port include: (1) Address translation: When the local central processing unit (CPU) needs to access the memory of the peer, the NTB port will translate the local address into an address that can be recognized by the physical address space of the peer in real time. (2) Data isolation: The NTB port can realize data isolation to ensure the data security and independence between different PCIe domains. (3) Data transmission: The NTB port can realize high-speed data transmission and support various high-speed data transmission applications.
[0038] The execution entity in this application embodiment 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 in the dual-control storage system that executes the technical solution of this application, while the remote storage controller refers to the other storage controller in the dual-control storage system besides the local storage controller.
[0040] The target NTB link can refer to an NTB link that has been configured with an NTB adapter.
[0041] In one possible implementation, at least one target NTB link can be determined as follows: based on the connection status of NTB-related hardware links in the dual-controller storage system, determine M NTB links, where M is a positive integer; based on whether there is a corresponding NTB adapter for the M NTB links, determine at least one target NTB link among the M NTB links.
[0042] NTB-related hardware can refer to an external ACC or a built-in NTB engine.
[0043] Specifically, for any NTB link among the M NTB links, if there is a corresponding NTB adapter for that NTB link, then that NTB link is determined as the 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 the temporary memory resources required by the NTB port in any one of the target NTB links when driving the NTB.
[0046] NTB driver: A software component in the operating system kernel used to manage and operate NTB hardware devices. It acts as a bridge between the hardware and upper-level applications or system functions.
[0047] Although an NTB link includes two NTB ports, since this application targets a single storage controller, the number of NTB ports on a single storage controller is one. That is, on a single storage controller, each NTB link corresponds to one NTB port.
[0048] The amount of temporary memory resources required by different NTB ports can be the same or different.
[0049] In one possible implementation, for any NTB port, the size of the temporary memory resources required by the NTB port can be determined based on the data structures that the NTB driver needs to manage and the underlying NTB hardware functions / register layout.
[0050] For example, the temporary memory resources required by the NTB port in an NTB link can refer to the workspace memory resources of the NTB port.
[0051] S203. Determine the degree of memory fragmentation of the local storage controller.
[0052] For example, you can view the memory fragmentation level of the local storage controller through storage management software or command-line interface.
[0053] For example, the degree of memory fragmentation can be determined by the number of each memory resource block in the free memory block list. This application does not limit the method by which the local storage controller determines the degree of memory fragmentation.
[0054] S204. Allocate memory resources for at least one target NTB link based on the size of the temporary memory resources required by at least one NTB port and the degree of memory fragmentation of the local storage controller.
[0055] The memory resource allocation method can be determined based on the memory fragmentation level of the local storage controller. The memory resource allocation method includes direct allocation and pre-allocation. Based on the memory resource allocation method and the size of the temporary memory resources required by at least one NTB port, memory resources are allocated for at least one target NTB link.
[0056] The direct allocation method refers to the following: If the local storage controller has low memory fragmentation, meaning it contains a large number of large memory resource blocks (where the memory resources are contiguous 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 ports in that 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 ports in that target NTB link. Specifically, the size of the memory resources in the large memory resource blocks is greater than the size of the temporary memory resources required by the NTB ports in each target NTB link.
[0057] A large number of large memory resource blocks can be characterized by the proportion of all large memory resource blocks in the available memory resources of the local storage controller. For example, if the proportion of all large memory resource blocks in the available memory resources of the local storage controller is greater than or equal to 60%, it indicates the presence of a large number of large memory resource blocks.
[0058] The pre-allocation method refers to the following: If the local storage controller has a high degree of memory fragmentation, meaning there are a few large memory resource blocks (i.e., a large number of small memory resource blocks), then memory resource blocks can be pre-allocated. The size of the pre-allocated memory resource blocks is smaller than the size of the temporary memory resources required by the NTB ports in each target NTB link. For any target NTB link, based on the size of the temporary memory resources required by the NTB ports of that target NTB link, multiple pre-allocated contiguous memory resource blocks are found. These multiple pre-allocated contiguous memory resource blocks occupy a single contiguous block of memory, and the size of the memory resources occupied by these multiple pre-allocated contiguous memory resource blocks is the same as the size of the temporary memory resources required by the NTB port. The memory resources occupied by these multiple pre-allocated contiguous memory resource blocks are then allocated to that 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] A small number of large memory resource blocks can be characterized by the proportion of all large memory resource blocks in the available memory resources of the local storage controller. For example, if the proportion of all large memory resource blocks in the available memory resources of the local storage controller is less than or equal to 20%, it indicates that there are a small number of large memory resource blocks.
[0060] Based on the memory fragmentation level of the local storage controller, the memory resource allocation method is determined, improving the timeliness and success rate of memory resource allocation. By rationally selecting the allocation method, the efficiency and stability of kernel memory management can be significantly improved. In addition, since allocating on demand regardless of the allocation method, 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 illustrated embodiment, the following is combined with Figure 3 This document details how to allocate memory resources for at least one target NTB link based on the size of the temporary memory resources required by at least one NTB port and the degree of memory fragmentation of the local storage controller.
[0062] Figure 3 A flowchart illustrating the memory resource allocation method provided in the embodiments of this application. Figure 2 ,like Figure 3 As shown, the steps include the following.
[0063] S301. Based on the memory fragmentation level of the local storage controller, determine the size of the pre-allocated memory resource blocks and the maximum number of pre-allocated memory resource blocks.
[0064] Depending on the degree of memory fragmentation of different local storage controllers, different sizes and / or maximum numbers of pre-allocated memory resource blocks can be determined. In other words, the size of the pre-allocated memory resource blocks can be different, but the maximum number of pre-allocated memory resource blocks can be the same, depending on the degree of memory fragmentation of different local storage controllers; or, the size of the pre-allocated memory resource blocks can be the same, but the maximum number of pre-allocated memory resource blocks can be different, or the size and maximum number of pre-allocated memory resource blocks can be different, depending on the degree of memory fragmentation of different local storage controllers.
[0065] All pre-allocated memory resource blocks can be the same size.
[0066] For example, the size of a pre-allocated memory resource block can be 128Kb, and the maximum number of pre-allocated memory resource blocks can be 800.
[0067] S302. Based on the size of the pre-allocated memory resource blocks, the available memory resources of the local storage controller are pre-allocated using a dynamic memory allocation function to obtain at least one set of resource blocks and at least one pointer array corresponding to each set of resource blocks. For any one of the at least one set of resource blocks, the set of resource blocks includes N memory resource blocks, and the pointer array corresponding to the set of resource blocks includes N elements. The N elements are the 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. N is an integer greater than 1 and less than or equal to the maximum number of pre-allocated memory resource blocks.
[0068] Dynamic allocation functions can refer to functions used to allocate contiguous physical memory resources. For example, a dynamic allocation function can be the kernel memory allocation (kmalloc) function.
[0069] The available memory resources of the local storage controller consist of multiple non-contiguous memory blocks.
[0070] The number of resource block sets is less than or equal to the number of target NTB links. Memory resources can be allocated for one or more NTB links from the memory resources corresponding to a resource block set.
[0071] For example, if the number of resource block sets is 1 and the number of target NTB links is 2, then memory resources are allocated for 2 NTB links from the memory resources corresponding to that resource block set. If the number of resource block sets is 2 and the number of target NTB links is 2, then memory resources are allocated for one NTB link from the memory resources corresponding to that resource block set. If the number of resource block sets is 2 and the number of target NTB links is 3, then memory resources are allocated for one NTB link from the memory resources corresponding to that resource block set, and memory resources are allocated for two NTB links from the memory resources corresponding to the other resource block set.
[0072] For any one of the resource block sets in at least one resource block set, the above process is as follows: Based on the size of the pre-allocated memory resource block, the available memory resources of the local storage controller are pre-allocated through a dynamic memory allocation function. Each pre-allocation can obtain one memory resource block. The kernel virtual address of the memory resource block is obtained, and the kernel virtual address of the memory resource block is placed in the pointer array corresponding to the resource block set (or the kernel virtual address value of the memory resource block is assigned to the first element after all valid elements in the corresponding pointer array). After the kernel virtual address of the memory resource block is placed in the pointer array, the valid elements in the pointer array are sorted in ascending order according to the size of the kernel virtual address value, that is, the element with the smaller memory virtual address value is placed at the beginning of the pointer array, and the element with the larger memory virtual address value is placed at the end of the pointer array.
[0073] The kernel virtual address corresponding to a memory resource block can refer to the starting virtual address of that 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] In a pointer array, a valid element is an element whose value is a kernel virtual address, while an invalid element can be an element whose value is a preset value (such as 0).
[0076] For example, the initial pointer array is {0, 0, 0, 0, 0, 0, 0, 0}. After three pre-allocations, the pointer array becomes {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] Elements in a pointer array can also be called pointers, and kernel virtual address values can also be called pointer values.
[0078] If the dynamic allocation function is kmalloc, 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 there is no limit to the pre-allocation range.
[0079] S303. For any one of the at least one target NTB links, allocate memory resources for the target NTB link based on the size of the temporary memory resources required by the NTB port in the target NTB link, at least one set of resource blocks, and at least one array of pointers.
[0080] The amount of memory resources allocated to the target NTB link is the same as the amount of temporary memory resources required by the NTB ports in the target NTB link.
[0081] exist Figure 3 In the illustrated embodiment, pre-allocation can filter out some small-sized memory resource blocks in the local storage controller, thereby improving the timeliness of memory resource allocation.
[0082] exist Figure 3 Based on the illustrated embodiment, for any one of the at least one target NTB link, the following is combined with... Figure 4The document details how to allocate memory resources for the target NTB link based on the size of the temporary memory resources required by the NTB port in the target NTB link, the above-mentioned at least one set of resource blocks, and the above-mentioned at least one array of pointers.
[0083] Figure 4 A flowchart illustrating the memory resource allocation method provided in the embodiments of this application. Figure 3 ,like Figure 4 As shown, the steps include the following.
[0084] S401. Determine candidate kernel virtual addresses.
[0085] A kernel virtual address can be randomly selected as a candidate kernel virtual address; or, the kernel virtual address pointed to by the first element in the pointer array can be used as a candidate kernel virtual address; or, the candidate kernel virtual address can be determined based on the recorded log.
[0086] The candidate kernel virtual address is an element in at least one of the above pointer arrays.
[0087] S402. Based on the size of the temporary memory resources required by the NTB port in the target NTB link and the size of the pre-allocated memory resource blocks, determine the number of resource blocks Q required by the NTB port, where Q is a positive integer.
[0088] The divisor Q is the number of resource blocks Q required by the NTB port in the target NTB link, which is the size of the temporary memory resources required by the NTB port divided by the size of the pre-allocated memory resource blocks.
[0089] For example, if the temporary memory resource required by the NTB port in the target NTB link is 1Mb and the pre-allocated memory resource block size is 128Kb, then the number of resource blocks Q required by the NTB port is 8.
[0090] S403. Determine at least one pointer array that includes candidate kernel virtual addresses as the target pointer array.
[0091] S404. Determine the set of resource blocks in at least one set of resource blocks that corresponds to the target pointer array as the target resource block set.
[0092] S405. The element in the target pointer array whose kernel virtual address is the same as the candidate kernel virtual address is determined as the target element.
[0093] S406. Starting with the target element, traverse the target pointer array until you find Q elements whose kernel virtual address values are continuously increasing, 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 consecutively increasing kernel virtual address values can refer to any two adjacent elements where the kernel virtual address value indicated by the previous element equals the kernel virtual address value indicated by the next element plus the size of the pre-allocated memory resource block.
[0095] For example, if the size of the pre-allocated memory resource block is 128Kb and the size of the temporary memory resource required by the NTB port in the target NTB link is 1Mb, then Q is 8. The alignment of the kernel virtual address indicated by the first element of the 8 elements with the boundary of the temporary memory resource required by the NTB port in the target NTB link means that the kernel virtual address indicated by the first element of the 8 elements is an integer multiple of 1Mb (0×100000).
[0096] The specific steps are as follows: Use a counter (config) to record the number of consecutively incrementing kernel virtual address values of the currently searched elements. Starting from the starting element, determine whether the boundary of the starting element and the temporary memory resource required by the NTB port in the target NTB link are aligned. If so, check whether the kernel virtual address of the starting element and the next element are consecutively incrementing (i.e., 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, increment the counter by 1; otherwise, set the counter to 0. Then determine whether the boundary of the next element and the temporary memory resource required by the NTB port in the target NTB link are aligned. If so, treat the next element as a new starting element and check whether the kernel virtual address of the starting element and the next element are consecutively incrementing. Continue in this manner until the counter reaches 7 (because counting starts from 0, 8 consecutive blocks), indicating that 8 consecutive memory resource blocks have been found. Return the starting virtual address of these 8 memory resource blocks (i.e., return the kernel virtual address indicated by the first element among the 8 elements). If no consecutively increasing 8 elements of kernel virtual address are found after traversing the entire pointer data, then return null.
[0097] Since the maximum number of pre-allocated memory resource blocks limits the range of memory resources that can be searched, the timeliness of memory resource allocation can be guaranteed.
[0098] In one possible implementation, search information can be logged, including search results and the number of elements searched. Search results may include whether the search failed or succeeded.
[0099] The number of elements searched is equal to the number of resource blocks searched.
[0100] This log can be used to identify candidate kernel virtual addresses for other target NTB links.
[0101] In one possible implementation, if Q consecutively 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] Additionally, if, while traversing the target pointer array, a pointer points to a memory resource outside the memory resource corresponding to the target pointer array (i.e., the pointer becomes invalid or a memory out-of-bounds error occurs), then the memory resource corresponding to the target resource block set is released.
[0103] By dynamically releasing memory resources, the waste of memory resources caused by static pre-allocation can be avoided, and the flexibility of memory resource allocation can be increased.
[0104] In one possible implementation, if memory resource allocation fails for any one of the at least one target NTB link, a fault repair operation is performed to redistribute the memory resources. This fault repair operation includes restarting the system. Based on the redistributed memory resources and the size of the temporary memory resources required by the NTB ports in the target NTB links, resources are reallocated to the target NTB links. The resource reallocation process can be referred to... Figure 3 The illustrated embodiments and Figure 4 Steps S401 to S406 in the illustrated embodiment will not be repeated here.
[0105] For example, the number of fault repair operations can 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 can detect and repair potential faults in advance, effectively improving the reliability of storage devices and ensuring data security and efficient system operation.
[0107] In one possible implementation, if the memory resource allocation of any one of the at least one target NTB link fails, the 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 according to the redistributed memory resources and the size of the temporary memory resources required by the NTB port in the target NTB link.
[0108] By transparently compressing data unrelated to NTB, some memory resources can be freed up, resulting in redistributed memory resources. This reduces the probability of memory resource allocation failures across multiple NTB links, allows for early detection and repair of potential faults, effectively improves the reliability of storage devices, and ensures data security and efficient system operation.
[0109] S407. Based on the kernel virtual address indicated by the first element among the Q elements and the size of the temporary memory resources required by the NTB port in the target NTB link, determine Q memory resource blocks in the target resource block set.
[0110] S408. Allocate the memory occupied by Q memory resource blocks to the target NTB link.
[0111] In other words, the kernel virtual address indicated by the first element of the Q elements is assigned to the temporary memory resource required by the NTB port in the target NTB link, serving as the starting virtual address of the temporary memory resource required by the NTB port in the target NTB link (for example, assigning the memory_start pointer to workspace_charp). Based on this starting virtual address and the size of the temporary memory resource required by the NTB port in the target NTB link, a contiguous block of memory 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 counts are updated via pgalloc_kmallocpageinccount).
[0112] exist Figure 4 In the illustrated embodiment, the required memory resources can be quickly located through pre-allocation, thereby improving the timeliness of memory resource allocation.
[0113] It should be noted that, Figure 4 The memory resource allocation method shown is not in Figure 3 The pre-allocation method shown is performed after completion, and resource memory allocation can occur simultaneously with pre-allocation. For example, if the number of pre-allocated memory resource blocks is greater than or equal to Q, then execution can proceed. Figure 4 The memory resource allocation method shown in this application, if Q consecutively increasing kernel virtual address values are not found, continues pre-allocation until Q consecutively increasing kernel virtual address values are found or the number of pre-allocated memory resource blocks reaches the maximum. Furthermore, the method of this application is applicable to memory controllers from any manufacturer and / or model.
[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they 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 a memory resource allocation device provided in an embodiment of this application. Figure 5 As shown, the memory resource allocation device 500 includes: a first determining module 501, a second determining module 502, a third determining module 503, and a resource allocation module 504.
[0116] The first determining module 501 is used to determine at least one target non-transparent bridge link existing in the dual-controller storage system, the dual-controller storage system including the local storage controller and the peer storage controller;
[0117] The second determining module 502 is used to determine the size of the temporary memory resources required by the non-transparent bridge port in any one of the target non-transparent bridge links when driving a non-transparent bridge;
[0118] The third determining module 503 is used to determine the degree of memory fragmentation of the local storage controller;
[0119] Resource allocation module 504 is used to allocate memory resources for at least one target non-transparent bridge link based on the size of temporary memory resources required by at least one non-transparent bridge port and the degree of memory fragmentation of the local storage controller.
[0120] In one possible implementation, the resource allocation module 504 is specifically used for:
[0121] Based on the degree of memory fragmentation, determine the size of the pre-allocated memory resource blocks and the maximum number of pre-allocated memory resource blocks;
[0122] Based on the size of the memory resource blocks, the available memory resources of the local storage controller are pre-allocated using a dynamic memory allocation function, resulting in at least one set of resource blocks and at least one pointer array corresponding to each set of resource blocks. For any one of the at least one set of resource blocks, the set of resource blocks includes N memory resource blocks, and the pointer array corresponding to the set of resource blocks includes N elements. The N elements are the 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. N is an integer greater than 1 and less than or equal to the maximum number.
[0123] For any one of the at least one target non-transparent bridge links, allocate memory resources for the target non-transparent bridge link based on the size of the temporary memory resources required by the non-transparent bridge port in the target non-transparent bridge link, at least one set of resource blocks, and at least one array of pointers.
[0124] In one possible implementation, the resource allocation module 504 is specifically used for:
[0125] Determine candidate kernel virtual addresses;
[0126] The number of resource blocks Q required for the non-transparent bridge port is determined based on the size of the temporary memory resources and the size of the memory resource blocks, where Q is a positive integer;
[0127] The target pointer array is determined from at least one pointer array that includes candidate kernel virtual addresses;
[0128] Determine the target resource block set from at least one resource block set that corresponds to the target pointer array;
[0129] The element in the target pointer array whose kernel virtual address is the same as the candidate kernel virtual address is identified as the target element;
[0130] Starting with the target element, traverse the target pointer array until you find Q consecutively increasing kernel virtual address values, and the kernel virtual address pointed to by the first of the Q elements is aligned with the boundary of the temporary memory resource.
[0131] Based on the kernel virtual address indicated by the first element of the Q elements and the size of the temporary memory resources, determine the Q memory resource blocks in the target resource block set;
[0132] Allocate the memory occupied by Q memory resource blocks to the target non-transparent bridge link.
[0133] In one possible implementation, the memory resource allocation device 500 further includes a recording module 505, used for:
[0134] Information can be retrieved by logging the results. The retrieved information includes the search results and the number of elements searched. The search results include whether the search failed or succeeded.
[0135] In one possible implementation, the memory resource allocation device 500 further includes a release module 506, used for:
[0136] If Q consecutively increasing kernel virtual address values are not found in the target pointer array, then the memory resources corresponding to the target resource block set are released.
[0137] In one possible implementation, the memory resource allocation device 500 further includes a fault repair module 507, used for:
[0138] If memory resource allocation fails for any one of the at least one non-transparent bridge links, a fault repair operation is performed to redistribute the memory resources; the fault repair operation includes restarting the system.
[0139] Based on the redistributed memory resources and the size of the temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link, resources are reallocated to the target non-transparent bridge link.
[0140] In one possible implementation, the memory resource allocation device 500 further includes a fault repair module 507, used for:
[0141] If the memory resource allocation of any one of the at least one target non-transparent bridge links fails, the data in the local storage controller that is unrelated to the non-transparent bridge will be transparently compressed to obtain redistributed memory resources.
[0142] Based on the redistributed memory resources and the size of the temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link, resources are reallocated to the target non-transparent bridge link.
[0143] In one possible implementation, the first determining module 501 is specifically used for:
[0144] Based on the connection status of the non-transparent bridge related hardware links in the dual-controller storage system, determine M non-transparent bridge links, where M is a positive integer;
[0145] Based on whether there is a corresponding non-transparent bridge adapter for each of the M non-transparent bridge links, determine at least one target non-transparent bridge link among the M non-transparent bridge links.
[0146] In one possible implementation, the first determining module 501 is specifically used for:
[0147] For any one of the M non-transparent bridge links, if a corresponding non-transparent bridge adapter exists for the non-transparent bridge link, then the non-transparent bridge link is determined as the target non-transparent bridge link.
[0148] For a description of the features in the embodiment corresponding to the memory resource allocation device 500, please refer to the relevant description in the embodiment corresponding to the memory resource allocation method, which will not be repeated here.
[0149] Figure 6 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, memory 602, and communication component 603 are connected by a wire.
[0150] In a specific implementation, at least one processor 601 executes computer execution instructions stored in memory 602, causing at least one processor 601 to execute the above-described memory resource allocation method embodiment.
[0151] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0152] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed 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 device.
[0154] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0155] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described memory resource allocation method embodiments at runtime.
[0156] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0157] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described memory resource allocation method embodiments.
[0158] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described memory resource allocation method embodiments.
[0159] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for various specific applications, but such implementations should not be considered beyond the scope of this application.
[0160] The above provides a detailed description of a memory resource allocation method provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and its core ideas. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A memory resource allocation method, characterized in that, include: Determine at least one target non-transparent bridge link in the dual-controller storage system, which includes a local storage controller and a peer storage controller; Determine the size of the temporary memory resources required for the non-transparent bridge port in any one of the at least one target non-transparent bridge links when driving a non-transparent bridge; Determine the degree of memory fragmentation of the local storage controller; Based on the degree of memory fragmentation, a memory resource allocation method is determined. The memory resource allocation method includes a direct allocation method and a pre-allocation method. The proportion of large-size memory resources corresponding to the direct allocation method is greater than or equal to a first threshold, and the proportion of large-size memory resources corresponding to the pre-allocation method is less than or equal to a second threshold. The proportion of large-size memory resources is the proportion of all large-size memory resource blocks in the available memory resources of the local storage controller. The size of the memory resources in the large-size memory resource blocks is greater than the size of the temporary memory resources required by the non-transparent bridge port in any one of the at least one target non-transparent bridge links. The first threshold is greater than the second threshold. If the memory resource allocation method is the direct allocation method, then memory resources are allocated to the at least one target non-transparent bridge link according to the size of the temporary memory resources required by at least one of the non-transparent bridge ports; If the memory resource allocation method is the pre-allocation method, then memory resources are allocated to the at least one target non-transparent bridge link according to the size of the temporary memory resources required by at least one of the non-transparent bridge ports and the size of the pre-allocated memory resource block.
2. The method according to claim 1, characterized in that, The step of allocating memory resources for the at least one target non-transparent bridge link based on the size of the temporary memory resources required by at least one of the non-transparent bridge ports and the size of the pre-allocated memory resource blocks includes: Based on the degree of memory fragmentation, determine the size of the pre-allocated memory resource blocks and the maximum number of pre-allocated memory resource blocks; Based on the size of the memory resource blocks, the available memory resources of the local storage controller are pre-allocated using a dynamic memory allocation function to obtain at least one set of resource blocks and at least one pointer array corresponding to each of the at least one set of resource blocks. For any one of the at least one set of resource blocks, the set of resource blocks includes N memory resource blocks, and the pointer array corresponding to the set of resource blocks includes N elements. The N elements are the 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. 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 the 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 step of allocating memory resources for the target non-transparent bridge link based on the size of the temporary memory resources required by the non-transparent bridge ports 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; The number of resource blocks Q required for the non-transparent bridge port is determined based on the size of the temporary memory resource and the size of the memory resource block, where Q is a positive integer; The pointer array that includes the candidate kernel virtual address in the at least one pointer array is determined as the target pointer array; The resource block set corresponding to the target pointer array in the at least one resource block set is determined as the target resource block set; The element in the target pointer array whose kernel virtual address is the same as the candidate kernel virtual address is identified as the target element; 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 resource. Based on the kernel virtual address indicated by the first element of the Q elements and the size of the temporary memory resource, Q memory resource blocks are determined in the target resource block set; 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 includes: The information is retrieved by logging the search results, which include the search results and the number of elements searched. The search results include whether the search was successful or failed.
5. The method according to claim 3, characterized in that, The method further includes: If no Q consecutively increasing kernel virtual address values are found in the target pointer array, then 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 includes: If the memory resource allocation of any one of the at least one target non-transparent bridge links fails, a fault repair operation is performed to redistribute the memory resources; wherein, the fault repair operation includes a system restart operation; Based on the redistributed memory resources and the size of the temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link, resources are reallocated to the target non-transparent bridge link.
7. The method according to claim 5, characterized in that, The method further includes: If the memory resource allocation of any one of the at least one target non-transparent bridge links fails, the data in the local storage controller that is unrelated to the non-transparent bridge will be transparently compressed to obtain redistributed memory resources. Based on the redistributed memory resources and the size of the temporary memory resources required by the non-transparent bridge ports in the target non-transparent bridge link, resources are reallocated to the target non-transparent bridge link.
8. The method according to any one of claims 1 to 7, characterized in that, The determination of at least one target non-transparent bridge link existing in the dual-controller storage system includes: Based on the connection status of the non-transparent bridge related hardware links in the dual-controller storage system, M non-transparent bridge links are determined, where M is a positive integer; Based on whether there is a corresponding non-transparent bridge adapter for the M non-transparent bridge links, determine the at least one target non-transparent bridge link from the M non-transparent bridge links.
9. The method according to claim 8, characterized in that, The step of determining the at least one target non-transparent bridge link from the M non-transparent bridge links based on whether there is a corresponding non-transparent bridge adapter includes: For any one of the M non-transparent bridge links, if the non-transparent bridge link has a corresponding non-transparent bridge adapter, then the non-transparent bridge link is determined as the target non-transparent bridge link.
10. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the memory resource allocation method as described in any one of claims 1 to 9 when executing the computer program.
Citation Information
Patent Citations
Data synchronization method, device and equipment and storage medium
CN111813707A
Memory resource calling optimization method and system
CN119356850A