A memory allocation device, method, apparatus, and medium
By dividing DDR memory into resource pools and index pools of different granularity and forming PRP linked lists, the problems of fragmentation and low utilization in the existing technology are solved, and efficient and flexible allocation of memory space is achieved.
Patent Information
- Application Number
- CN202211001585.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-19
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2042-08-19
AI Technical Summary
The memory allocation method in the existing NVMe protocol leads to fragmentation of memory space and low utilization, and it is impossible to flexibly map and organize memory space.
Divide DDR memory into multiple resource pools, each resource pool corresponds to a different granularity, and sets up a corresponding memory index pool, obtain task information through the task decoding unit, and use the distribution engine to select the target index value from the index pool to form a PRP linked list.
It improves the efficiency of memory space utilization, can flexibly allocate memory space according to different task requirements, and improves the overall utilization of memory space.
Smart Images

Figure CN115344387B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technologies, and in particular, to a memory allocation device, method, equipment, and medium. Background Art
[0002] The Non-Volatile Memory Host Controller Interface Specification (NVMe) is a communication specification specifically for accessing non-volatile memory media attached via the PCIe bus. The combination of the NVMe protocol and the PCIe protocol utilizes the parallel characteristics of solid-state drives to improve the read and write speeds of NAND, achieving faster non-volatile storage. As Figure 1A shown, NVMe is a high-performance and highly scalable storage protocol used to connect a host and a memory system.
[0003] The functions of the NVMe interface protocol include: supporting 64K command queues, being able to send 64K commands for each queue using low CPU cycles, having a latency of approximately 2.8 microseconds, being able to communicate directly with the system CPU, NVMe being able to achieve more than one million IOPs, NVMe dividing the host-side memory into a set of pages, and the page size can be configured in a register. The NVMe protocol organizes memory pages in the form of a PRP linked list. Each PRP linked list is accessed through an entry address. As follows Figure 1B shown, the PRP linked list can have the following three existence forms: As shown in linked list A, the entry address points to a data index page, and no business data information is stored in the data index page, only the index values of each data page are stored. All data index pages in this linked list store the index values of data pages. As shown in linked list B, the entry address directly points to a data page, and the data page is directly used to store business data information. As shown in linked list N, at this time, the storage space required for service N is relatively large, and multi-level data index pages are needed for cascading. At this time, the last address of each data index page is used to store the entry address of the next data index page.
[0004] However, in the existing memory allocation method in the form of PRP, the memory is usually fragmented into the smallest particles, and then each smallest particle is organized to form a PRP linked list. The space formed by this method of organization is often discontinuous, and the utilization rate of the memory space is also relatively low. In addition, the memory organization method of NVMe has a form of SGL in addition to the form of PRP. However, whether it is PRP or SGL, essentially, they both describe a section of data space in the memory. This section of data space can be continuous or discrete. For PRP, a section of data space can only be mapped to a certain physical page. For SGL, it can be mapped to a continuous physical space of any size. It has greater flexibility and can describe a larger space, but it is a bit more complex compared to the PRP format. Summary of the Invention
[0005] In view of this, it is necessary to provide a memory allocation device, method, device and medium for the above technical problems.
[0006] According to the first aspect of the present invention, a memory allocation device is provided, and the device includes:
[0007] A partitioning unit, which is used to partition the DDR into multiple memory resource pools, where different memory resource pools correspond to different granularities;
[0008] A memory index pool corresponding to each memory resource pool one by one, and index values of each granule of the corresponding memory resource pool are stored in each memory index pool;
[0009] A task decoding unit, which is used to parse the task to be processed to obtain task information;
[0010] A distribution engine, which is used to select one as the target memory index pool from multiple memory index pools according to the task information, obtain a target index value matching the task information from the target memory index pool, and form a PRP linked list by using the target memory index pool and the target index value.
[0011] In some embodiments, the task decoding unit is further used for:
[0012] Obtain the memory space capacity required by the task to be processed;
[0013] And judge whether the task to be processed has a corresponding old PRP linked list;
[0014] In response to the task to be processed having no corresponding old PRP linked list, use the memory space capacity required by the task to be processed as the task information;
[0015] In response to the task to be processed having a corresponding old PRP linked list, use the old PRP linked list and the memory space capacity required by the task to be processed as the task information.
[0016] In some embodiments, in response to the memory space capacity required by the task to be processed being used as the task information, the distribution engine is further used for:
[0017] Judge whether the memory space capacity required by the task to be processed is equal to zero;
[0018] In response to the memory space capacity required by the task to be processed being equal to zero, create an empty PRP linked list;
[0019] In response to the memory space capacity required by the task to be processed not being equal to zero, create a PRP linked list based on the following rules:
[0020] Determine whether there is a memory resource pool with the same granularity as the memory space capacity required for the task to be processed;
[0021] In response to the existence, use the memory index pool corresponding to the memory resource pool with the same granularity as the memory space capacity required for the task to be processed as the target memory index pool, and use one index value in the target memory index pool as the target index value;
[0022] In response to the non-existence, use the memory index pool corresponding to the memory resource pool with available space greater than the memory space capacity required for the task to be processed and the largest granularity among multiple memory resource pools as the target memory index pool, and select an available index value from the target memory index pool as the target index value according to Formula 1;
[0023]
[0024] Recombine each target index value according to the following rules to generate a new index value;
[0025] Generate a CRC check code for the target index value;
[0026] Combine the valid flag, the resource pool to which it belongs, the target index value, and the CRC check code of the target index value to generate a new index value;
[0027] Combine all new index values to generate a PRP linked list corresponding to the task to be processed.
[0028] In some embodiments, in response to the old PRP linked list and the memory space capacity required for the task to be processed as the task information, the distribution engine is further configured to:
[0029] Calculate the difference between the memory space capacity required for the task to be processed and the space capacity corresponding to the old PRP linked list;
[0030] In response to the difference being greater than zero, select an available index value from the memory index pool corresponding to the old PRP linked list as the extended index value according to Formula 2 based on the difference;
[0031]
[0032] Recombine each extended index value according to the following rules to generate a new index value;
[0033] Generate a CRC check code for the extended index value;
[0034] Combine the valid flag, the resource pool to which it belongs, the extended index value, and the CRC check code of the extended index value to generate a new index value;
[0035] Add all new index values to the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
[0036] In some embodiments, in response to the difference being equal to zero, the distribution engine is further configured to:
[0037] Obtain the index values to be replaced in the old PRP linked list, and select available index values from the memory index pool corresponding to the old PRP linked list as padding index values for each index value to be replaced;
[0038] Recombine each padding index value according to the following rules to generate new index values;
[0039] Generate a CRC check code for the padding index value;
[0040] Combine the valid flag, the belonging resource pool, the padding index value, and the CRC check code of the padding index value to generate new index values;
[0041] Use the new index values of each padding index value to overwrite the corresponding index values to be replaced in the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
[0042] In some embodiments, the apparatus further includes:
[0043] A PRP linked list storage pool for storing the PRP linked list constructed by the distribution engine.
[0044] In some embodiments, the partitioning unit is further configured to:
[0045] Partition the DDR into three memory resource pools, and the granularities of the three memory resource pools are 4KB, 8KB, and 16KB respectively.
[0046] According to a second aspect of the present invention, there is provided a memory allocation method, the method including:
[0047] Partition the DDR into multiple memory resource pools, wherein different memory resource pools correspond to different granularities;
[0048] Set a memory index pool corresponding to each memory resource pool one by one, and store the index values of each granule of the corresponding memory resource pool in each memory index pool;
[0049] The task decoding unit parses the task to be processed to obtain task information;
[0050] The distribution engine selects one as the target memory index pool from multiple memory index pools according to the task information, obtains the target index value matching the task information from the target memory index pool, and constructs a PRP linked list by using the target memory index pool and the target index value.
[0051] According to a third aspect of the present invention, there is also provided a computer device, which includes:
[0052] At least one processor; and
[0053] A memory, where the memory stores a computer program that can run on the processor, and when the processor executes the program, it executes the foregoing memory allocation method.
[0054] According to a fourth aspect of the present invention, there is also provided a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it executes the foregoing memory allocation method.
[0055] The foregoing memory allocation device divides the memory space according to different granularities of sizes, and can provide a memory space matching different tasks, which can effectively improve the utilization efficiency of the memory space.
[0056] In addition, the present invention also provides a memory allocation method, a computer device, and a computer-readable storage medium, which can also achieve the above technical effects, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other embodiments according to these drawings without creative efforts.
[0058] Figure 1A It is a schematic diagram of a storage system of a traditional NVMe protocol;
[0059] Figure 1B It is a schematic diagram of a traditional NVMe PRP linked list structure;
[0060] Figure 2 It is a schematic diagram of the structure of a memory allocation device provided by an embodiment of the present invention;
[0061] Figure 3 It is a schematic diagram of a loopback RAM structure in a memory resource pool provided by another embodiment of the present invention;
[0062] Figure 4 It is a schematic diagram of a task decoding pipeline provided by an embodiment of the present invention;
[0063] Figure 5 It is a schematic diagram of the data format of a memory index value provided by an embodiment of the present invention;
[0064] Figure 6Another embodiment of the present invention provides a flowchart of the operation of a memory allocation device and a schematic diagram of the software interaction mechanism;
[0065] Figure 7A Schematic diagram of an empty linked list structure provided for an embodiment of the invention;
[0066] Figure 7B Schematic diagram of an extended linked list structure provided for an embodiment of the invention;
[0067] Figure 7C Schematic diagram of a filled linked list structure provided for an embodiment of the invention;
[0068] Figure 8 Flowchart of a memory allocation method provided for an embodiment of the present invention;
[0069] Figure 9 Internal structure diagram of a computer device in another embodiment of the present invention. Detailed implementation manners
[0070] To make the objectives, technical solutions, and advantages of the present invention clearer and more understandable, the following further elaborates on the embodiments of the present invention in detail with reference to specific embodiments and the accompanying drawings.
[0071] It should be noted that all the expressions using "first" and "second" in the embodiments of the present invention are used to distinguish two entities or parameters with the same name but different identities. It can be seen that "first" and "second" are only for the convenience of expression and should not be construed as limitations on the embodiments of the present invention. This will not be elaborated one by one in the subsequent embodiments.
[0072] In one embodiment, please refer to Figure 2 As shown, the present invention provides a memory allocation device. Specifically, the device includes:
[0073] A partitioning unit for partitioning the DDR into multiple memory resource pools, where different memory resource pools correspond to different granularities;
[0074] A memory index pool corresponding to each memory resource pool one by one, and the index values of each granule of the corresponding memory resource pool are stored in each memory index pool;
[0075] A task decoding unit for parsing the task to be processed to obtain task information;
[0076] A distribution engine for selecting one of the multiple memory index pools as the target memory index pool according to the task information, obtaining the target index value matching the task information from the target memory index pool, and forming a PRP linked list using the target memory index pool and the target index value.
[0077] The above-mentioned memory allocation device divides the memory space into different granularities, and can provide a matching memory space for different tasks, which can effectively improve the utilization efficiency of the memory space.
[0078] In some embodiments, the task decoding unit is further configured to:
[0079] Obtain the memory space capacity required for the task to be processed;
[0080] And determine whether the task to be processed has a corresponding old PRP linked list;
[0081] In response to the task to be processed not having a corresponding old PRP linked list, use the memory space capacity required for the task to be processed as the task information;
[0082] In response to the task to be processed having a corresponding old PRP linked list, use the old PRP linked list and the memory space capacity required for the task to be processed as the task information.
[0083] In some embodiments, in response to using the memory space capacity required for the task to be processed as the task information, the distribution engine is further configured to:
[0084] Determine whether the memory space capacity required for the task to be processed is equal to zero;
[0085] In response to the memory space capacity required for the task to be processed being equal to zero, create an empty PRP linked list;
[0086] In response to the memory space capacity required for the task to be processed not being equal to zero, create a PRP linked list based on the following rules:
[0087] Determine whether there is a memory resource pool with the same granularity as the memory space capacity required for the task to be processed;
[0088] In response to the existence, use the memory index pool corresponding to the memory resource pool with the same granularity as the memory space capacity required for the task to be processed as the target memory index pool, and use an index value in the target memory index pool as the target index value;
[0089] In response to the non-existence, use the memory index pool corresponding to the memory resource pool with the largest available space greater than the memory space capacity required for the task to be processed and the largest granularity among multiple memory resource pools as the target memory index pool, and select an available index value from the target memory index pool according to Formula 1 as the target index value;
[0090]
[0091] Reorganize each target index value according to the following rules to generate a new index value;
[0092] Generate a CRC check code for the target index value;
[0093] Combine the valid flag, the belonging resource pool, the target index value, and the CRC check code of the target index value to generate a new index value;
[0094] Combine all the new index values to generate a PRP linked list corresponding to the task to be processed.
[0095] In some embodiments, in response to the old PRP linked list and the memory space capacity required for the task to be processed as the task information, the distribution engine is further configured to:
[0096] Calculate the difference between the memory space capacity required for the task to be processed and the space capacity corresponding to the old PRP linked list;
[0097] In response to the difference being greater than zero, select available index values from the memory index pool corresponding to the old PRP linked list as extended index values according to Formula Two;
[0098]
[0099] Recombine each extended index value according to the following rules to generate a new index value;
[0100] Generate a CRC check code for the extended index value;
[0101] Combine the valid flag, the belonging resource pool, the extended index value, and the CRC check code of the extended index value to generate a new index value;
[0102] Add all the new index values to the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
[0103] In some embodiments, the distribution engine is further configured to:
[0104] In response to the difference being equal to zero, obtain the index values to be replaced in the old PRP linked list, and select available index values from the memory index pool corresponding to the old PRP linked list as padding index values for each index value to be replaced;
[0105] Recombine each padding index value according to the following rules to generate a new index value;
[0106] Generate a CRC check code for the padding index value;
[0107] Combine the valid flag, the belonging resource pool, the padding index value, and the CRC check code of the padding index value to generate a new index value;
[0108] Overwrite the corresponding index value to be replaced in the old PRP linked list with the new index value of each padding index value to generate a PRP linked list corresponding to the task to be processed.
[0109] In some embodiments, the apparatus further includes:
[0110] A PRP linked list storage pool for storing the PRP linked list constructed by the distribution engine.
[0111] In some embodiments, the partitioning unit is further configured to:
[0112] Partition the DDR into three memory resource pools with granularities of 4KB, 8KB, and 16KB respectively.
[0113] In yet another embodiment, for the convenience of understanding the solution of the present invention, the following takes an application to Figure 1A a storage system as an example to detail the main functions and working processes of each part of the memory allocation apparatus of the present invention. Please refer to again Figure 2 The memory allocation apparatus shown in the present invention includes the following parts:
[0114] (1) A software interface for communicating with the firmware, in which configuration registers and status registers required by the memory allocation apparatus are implemented. The software can control the execution mode of the apparatus through the configuration registers, and at the same time can obtain the internal hardware status of the apparatus through the status registers. For example, the size of each memory resource pool, the starting address, and so on.
[0115] (2) An interaction mechanism for communicating with the upstream and downstream engines of the service flow. After the apparatus completes the current task, it can notify the upstream or downstream engine of the execution status of the task by writing to the register.
[0116] (3) A storage device for the memory index pool, as Figure 3 shown, this storage device is implemented by means of a loopback RAM and is used to store the index values of different continuous space blocks of the memory resource pool in the DDR. For example, if the size of memory resource pool a is 16MB and the size of each continuous space block is 4KB, then 4K index values need to be stored in index pool a. The index values in index pool a are random and do not necessarily point to continuous spaces.
[0117] The memory resource pool exists in the DDR and can be any continuous space in the DDR. Different memory resource pools have different granularities, meaning that the memory space represented by each index value in the memory index pool is different. The memory index pool exists in the local loopback RAM. According to the starting address and size of each memory resource pool configured by the software, the index values are initialized. During the memory distribution process, the memory space to be allocated is read according to the head pointer of the loopback RAM and written into the PRP linked list. The number of memory resource pools initialized by the software determines the corresponding memory index pools established by the hardware. During memory allocation, each index pool manages its own resource pool, enabling the distribution engine to know the memory resource situation of the DDR.
[0118] (4) Task decoding unit. This device obtains the current task information from the task queue pool by getting the storage location of the current task and sends the task information to the distribution engine.
[0119] The parsed task information is sent to the distribution engine through the task decoding unit, and the two achieve data exchange through the handshake of valid and ready. As Figure 4 is a simple timing diagram for data exchange between the task decoding unit and the distribution engine. After the current CB decoding is successful and handed over to the distribution engine, the task decoding unit can decode the next task in parallel, thereby improving the utilization rate of the hardware.
[0120] (5) Distribution engine for memory data format. This engine obtains index values from the memory index pool according to the needs of the current task, constructs the PRP linked list, and stores the constructed PRP linked list in the PRP list storage pool.
[0121] The main function of the distribution engine is to create the PRP linked list format by taking different operation methods according to the control information of the current task and write the linked list into the linked list storage pool in the memory. Figure 5 is the format of the index value in the PRP linked list, which mainly has the following fields: The first field: a 1-bit valid flag indicating whether the address space represented by the index value is valid. The second field: a 5-bit resource pool ID recording which resource pool in the memory the index value points to. The third field: a 21-bit index value used to record the address offset of the resource pool. The fourth field: a CRC check code. After the format is constructed, a CRC check code is generated and filled into this field. After the distribution engine obtains the index value from the index pool, it constructs Figure 5 the index value format shown and then starts to construct the PRP linked list according to the current task.
[0122] (6) The main interface supporting a certain bus protocol can access other relevant modules in the SOC system through read and write controls.
[0123] It should be noted that both the execution of the hardware startup task and the exception handling operation are carried out through the mechanism of software-hardware interaction, such as Figure 6 As shown, the working process of the memory allocation device of the present invention can be mainly divided into the following steps:
[0124] Step 1: After the system is powered on, the firmware configures the internal registers, including the size and starting address of each memory pool, etc. After the configuration is completed, the flag bit of the register is written to start the hardware to work.
[0125] Step 2: Inside the hardware, the index values of the memory pools are initialized according to the sizes of the respective memory pools, and the index values are written into the memory index pool.
[0126] Step 3: Receive tasks from the upstream engine and form a PRP linked list according to the task requirements.
[0127] Step 4: After the PRP table is built, notify the downstream engine to start working.
[0128] During the operation of the memory allocation device, some exceptional situations may occur. We notify the software to intervene in the form of interrupt or event reporting. Figure 6 The intervention mechanisms of the software for different exceptional situations are described respectively in
[0129] The memory allocation device of the present invention supports the following several forms of linked list formation:
[0130] (1) Create an empty table, such as Figure 7A As shown, a method for creating an empty PRP linked list is provided. This method only creates the structure of the linked list without filling in any data page information. At this time, the available memory space of the linked list is 0.
[0131] (2) Create a new linked list. For the tasks in this mode, the distribution engine applies for memory space according to the actual business space size and forms a PRP linked list.
[0132] (3) Create an extended linked list, such as Figure 7B As shown, the distribution engine can obtain the space size of the old linked list, and then expand it on the basis of the original linked list according to the space size required by the new task. In this way, the actual space of the new business is the sum of the two after expansion.
[0133] (4) Fill the linked list, such as Figure 7C As shown, the distribution engine can obtain the index value information of the existing PRP linked list, replace the invalid index values with the newly formed valid index values, and do not change the structure of the PRP linked list.
[0134] The above-mentioned memory allocation device has at least the following beneficial technical effects: Based on the PRP data organization format of NVMe, the device can flexibly apply for and organize memory space particles according to the actual business flow requirements. First, the firmware divides the memory space into different particle sizes, such as 4KB, 8KB, and 16KB granularities, and notifies this device of the division method. Secondly, this device applies for spaces of different granularities according to the software configuration or the business requirements of the upstream hardware engine, and organizes the data format in the PRP format. Finally, it notifies the downstream engine that the space application is successful or notifies the CPU of the application failure through an interrupt. By forming larger memory spaces with different particles in the form of a PRP linked list, and at the same time providing two software and hardware interaction methods for exceptional situations, which can be intervened by software for processing, it has better stability and reliability.
[0135] In yet another embodiment, please refer to Figure 8 as shown, the present invention also provides a memory allocation method 100, and the method includes:
[0136] Step 101, divide the DDR into multiple memory resource pools, where different memory resource pools correspond to different granularities;
[0137] Step 102, set a memory index pool corresponding to each memory resource pool one by one, and store the index values of each particle of the corresponding memory resource pool in each memory index pool;
[0138] Step 103, the task decoding unit parses the task to be processed to obtain task information;
[0139] Step 104, the distribution engine selects one as the target memory index pool from multiple memory index pools according to the task information, obtains the target index value matching the task information from the target memory index pool, and constructs a PRP linked list using the target memory index pool and the target index value.
[0140] The above-mentioned memory allocation method divides the memory space into different particle sizes, and can provide a matching memory space for different tasks, which can effectively improve the utilization efficiency of the memory space.
[0141] In some embodiments, in step 103, the task decoding unit parses the task to be processed to obtain task information, including:
[0142] Obtain the memory space capacity required by the task to be processed;
[0143] And determine whether the task to be processed has a corresponding old PRP linked list;
[0144] In response to the pending task having no corresponding old PRP linked list, the memory space capacity required for the pending task is used as the task information;
[0145] In response to the pending task having a corresponding old PRP linked list, the old PRP linked list and the memory space capacity required for the pending task are used as the task information.
[0146] In some embodiments, in response to the memory space capacity required for the pending task being used as the task information, the foregoing step 104 includes:
[0147] Determine whether the memory space capacity required for the pending task is equal to zero;
[0148] In response to the memory space capacity required for the pending task being equal to zero, create an empty PRP linked list;
[0149] In response to the memory space capacity required for the pending task not being equal to zero, create a PRP linked list based on the following rules:
[0150] Determine whether there is a memory resource pool with the same granularity as the memory space capacity required for the pending task;
[0151] In response to the existence, use the memory index pool corresponding to the memory resource pool with the same granularity as the memory space capacity required for the pending task as the target memory index pool, and use one index value in the target memory index pool as the target index value;
[0152] In response to the non - existence, use the memory index pool corresponding to the memory resource pool with the largest available space greater than the memory space capacity required for the pending task and the largest granularity among multiple memory resource pools as the target memory index pool, and select an available index value from the target memory index pool according to Formula 1 as the target index value;
[0153]
[0154] Re - organize each target index value according to the following rules to generate a new index value;
[0155] Generate a CRC check code for the target index value;
[0156] Combine the valid flag, the belonging resource pool, the target index value, and the CRC check code of the target index value to generate a new index value;
[0157] Combine all the new index values to generate a PRP linked list corresponding to the pending task.
[0158] In some embodiments, in response to the old PRP linked list and the memory space capacity required for the pending task being used as the task information, the foregoing step 104 includes:
[0159] Calculate the difference between the memory space capacity required for the task to be processed and the space capacity corresponding to the old PRP linked list;
[0160] In response to the difference being greater than zero, select an available index value from the memory index pool corresponding to the old PRP linked list as the extended index value according to Formula Two;
[0161]
[0162] Recombine each extended index value according to the following rules to generate a new index value;
[0163] Generate a CRC check code for the extended index value;
[0164] Combine the valid flag, the resource pool to which it belongs, the extended index value, and the CRC check code of the extended index value to generate a new index value;
[0165] Add all the new index values to the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
[0166] In some implementations, in response to the difference being equal to zero, step 104 further includes:
[0167] Then obtain the index value to be replaced in the old PRP linked list, and select an available index value from the memory index pool corresponding to the old PRP linked list as the filling index value for each index value to be replaced;
[0168] Recombine each filling index value according to the following rules to generate a new index value;
[0169] Generate a CRC check code for the filling index value;
[0170] Combine the valid flag, the resource pool to which it belongs, the filling index value, and the CRC check code of the filling index value to generate a new index value;
[0171] Use the new index value of each filling index value to overwrite the corresponding index value to be replaced in the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
[0172] In some embodiments, the method further includes:
[0173] Set up a PRP linked list storage pool, and store the PRP linked list formed by the distribution engine in the PRP linked list storage pool.
[0174] In some embodiments, in step 101, divide the DDR into multiple memory resource pools, where different memory resource pools correspond to different granularities, including:
[0175] The DDR is divided into three memory resource pools, and the granularities of the three memory resource pools are 4KB, 8KB, and 16KB respectively.
[0176] According to another aspect of the present invention, there is provided a computer device, which may be a server. For the internal structure diagram, please refer to Figure 9 as shown. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the above-mentioned memory allocation method is implemented. Specifically, the method includes the following steps:
[0177] The DDR is divided into multiple memory resource pools, where different memory resource pools correspond to different granularities;
[0178] A memory index pool corresponding to each memory resource pool is set, and the index values of each granularity of the corresponding memory resource pool are stored in each memory index pool;
[0179] The task decoding unit parses the task to be processed to obtain task information;
[0180] The distribution engine selects one as the target memory index pool from multiple memory index pools according to the task information, obtains the target index value matching the task information from the target memory index pool, and forms a PRP linked list by using the target memory index pool and the target index value.
[0181] According to still another aspect of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned memory allocation method is implemented. Specifically, it includes performing the following steps:
[0182] The DDR is divided into multiple memory resource pools, where different memory resource pools correspond to different granularities;
[0183] A memory index pool corresponding to each memory resource pool is set, and the index values of each granularity of the corresponding memory resource pool are stored in each memory index pool;
[0184] The task decoding unit parses the task to be processed to obtain task information;
[0185] The distribution engine selects one of multiple memory index pools as the target memory index pool according to the task information, obtains a target index value that matches the task information from the target memory index pool, and forms a PRP linked list by using the target memory index pool and the target index value.
[0186] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0187] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0188] The above-described embodiments merely represent several implementation manners of the present application. Their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A memory allocation device, characterized in that, The device includes: a partitioning unit configured to partition the DDR into multiple memory resource pools, where different memory resource pools correspond to different granularities; a memory index pool corresponding to each memory resource pool one by one, and each memory index pool stores the index values of each granularity of the corresponding memory resource pool; a task decoding unit configured to parse the task to be processed to obtain task information; a distribution engine configured to select one of the multiple memory index pools as a target memory index pool according to the task information, obtain a target index value matching the task information from the target memory index pool, and form a PRP linked list by using the target memory index pool and the target index value; The distribution engine is further configured to: judge whether the memory space capacity required by the task to be processed is equal to zero according to the task information; if it is equal to zero, create an empty PRP linked list; if it is not equal to zero, judge whether there is a memory resource pool with the same granularity as the memory space capacity required by the task to be processed; if there is, use the memory index pool corresponding to the same memory resource pool as the target memory index pool, and use one index value in the target memory index pool as the target index value; if not, use the memory index pool corresponding to the memory resource pool with the available space greater than the memory space capacity required by the task to be processed and the largest granularity among the multiple memory resource pools as the target memory index pool, and select an available index value from the target memory index pool as the target index value according to Formula 1; Formula 1; generate a CRC check code for the target index value; combine the valid flag, the belonging resource pool, the target index value, and the CRC check code of the target index value to generate a new index value; combine all the new index values to generate a PRP linked list corresponding to the task to be processed.
2. The memory allocation device according to claim 1, wherein The task decoding unit is further configured to: obtain the memory space capacity required by the task to be processed; and judge whether the task to be processed has a corresponding old PRP linked list; in response to the task to be processed having no corresponding old PRP linked list, use the memory space capacity required by the task to be processed as the task information; in response to the task to be processed having a corresponding old PRP linked list, use the old PRP linked list and the memory space capacity required by the task to be processed as the task information.
3. The memory allocation device according to claim 2, wherein In response to using the old PRP linked list and the memory space capacity required by the task to be processed as the task information, the distribution engine is further configured to: calculate the difference between the memory space capacity required by the task to be processed and the space capacity corresponding to the old PRP linked list; in response to the difference being greater than zero, select available index values as extended index values from the memory index pool corresponding to the old PRP linked list according to Formula 2 based on the difference; Formula 2; recombine each extended index value according to the following rules to generate a new index value; generate a CRC check code for the extended index value; combine the valid flag, the belonging resource pool, the extended index value, and the CRC check code of the extended index value to generate a new index value; add all the new index values to the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
4. The memory allocation device according to claim 3, wherein In response to the difference being equal to zero, the distribution engine is further configured to: Obtain the index values to be replaced in the old PRP linked list, and select available index values from the corresponding memory index pool of the old PRP linked list as padding index values for each index value to be replaced; Recombine each padding index value according to the following rules to generate new index values; Generate a CRC check code for the padding index value; Combine the valid flag, the belonging resource pool, the padding index value, and the CRC check code of the padding index value to generate a new index value; Use the new index value of each padding index value to overwrite the corresponding index value to be replaced in the old PRP linked list to generate a PRP linked list corresponding to the task to be processed.
5. The memory allocation device according to any one of claims 1-4, characterized in that The apparatus further includes: A PRP linked list storage pool for storing the PRP linked list formed by the distribution engine.
6. The memory allocation device according to any one of claims 1-4, characterized in that, The partitioning unit is further configured to: Partition the DDR into three memory resource pools with granularities of 4KB, 8KB, and 16KB respectively.
7. A memory allocation method, characterized in that, The method includes: Partition the DDR into multiple memory resource pools, where different memory resource pools correspond to different granularities; Set a memory index pool corresponding to each memory resource pool, and store the index values of each granule of the corresponding memory resource pool in each memory index pool; The task decoding unit parses the task to be processed to obtain task information; The distribution engine selects one of the multiple memory index pools as the target memory index pool according to the task information, obtains the target index value matching the task information from the target memory index pool, and forms a PRP linked list using the target memory index pool and the target index value; The distribution engine is configured to: determine whether the memory space capacity required for the task to be processed is equal to zero according to the task information; if it is equal to zero, create an empty PRP linked list; if it is not equal to zero, determine whether there is a memory resource pool with the same granularity as the memory space capacity required for the task to be processed; if there is, use the memory index pool corresponding to the same memory resource pool as the target memory index pool, and use one index value in the target memory index pool as the target index value; if not, use the memory index pool corresponding to the memory resource pool with available space greater than the memory space capacity required for the task to be processed and the largest granularity among the multiple memory resource pools as the target memory index pool, and select an available index value from the target memory index pool as the target index value according to Formula 1; Formula 1; Generate a CRC check code for the target index value; Combine the valid flag, the belonging resource pool, the target index value, and the CRC check code of the target index value to generate a new index value; Combine all the new index values to generate a PRP linked list corresponding to the task to be processed.
8. A computer device, characterized in that, Includes: At least one processor; And A memory storing a computer program that can run in the processor, and when the processor executes the program, it executes the method according to claim 7.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it executes the method according to claim 7.
Citation Information
Patent Citations
Solid state disk cache management method, solid state disk cache controller and solid state disk
CN112650450A