A method, system, apparatus and medium for garbage collection of multi-core CPU memory
By recording the amount of data written and generating trigger signals through the protocol layer CPU, and combining this with real-time calculations by the FTL layer CPU, the problem of the FTL layer being unable to perceive IO characteristics in a timely manner is solved, enabling accurate garbage collection of multi-core CPU memory and improving memory performance.
Patent Information
- Application Number
- CN202511285697.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-10
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-09-10
AI Technical Summary
In the existing garbage collection control framework for multi-core CPU memory, the FTL layer cannot detect the I/O characteristics of upper-layer applications in a timely manner, resulting in excessive or insufficient garbage collection. This makes it unable to adapt to the dynamic load characteristics of concurrent writes from multiple cores, thus affecting memory performance.
The protocol layer CPU records the amount of data written to the target and generates a garbage collection trigger signal when the write threshold is reached. The FTL layer CPU calculates the amount and time of garbage collection targets in real time to achieve timely garbage collection control.
It improves the accuracy and timeliness of garbage collection, adapts to the dynamic load characteristics of multi-core concurrent writes, and enhances memory performance.
Smart Images

Figure CN120762925B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, system, apparatus and medium for garbage collection of multi-core CPU memory. Background Technology
[0002] In existing technologies, within the garbage collection control framework of multi-core CPU memory, the protocol layer CPU is only responsible for receiving commands from the host, parsing and organizing them, and writing to the FTL (Flash Translation Layer) interface. The FTL layer cannot promptly perceive the I / O (Input / Output) characteristics of the upper-layer application, which can easily lead to over-collection or under-collection, and cannot adapt to the dynamic load characteristics of concurrent writing on multiple cores. Furthermore, using the amount of data written by the FTL layer as the trigger condition for garbage collection results in a trigger delay, preventing timely garbage collection and thus affecting memory performance. Summary of the Invention
[0003] In view of this, the purpose of this invention is to provide a garbage collection method, system, device and medium for multi-core CPU memory, which can improve the accuracy of garbage collection, adapt to the dynamic load characteristics of multi-core concurrent writing, and trigger garbage collection in a timely manner to improve memory performance.
[0004] In a first aspect, embodiments of the present invention provide a garbage collection method for a multi-core CPU memory, comprising:
[0005] Obtain the request instructions from the host;
[0006] The protocol layer CPU requests a target cache range according to the request instruction, whereby the protocol layer CPU represents the CPU core corresponding to the protocol layer.
[0007] The target data sent by the host is written into the target cache range, and the target data writing volume is recorded by the protocol layer CPU. The target data writing volume represents the amount of target data written into the target cache range.
[0008] When the target write data volume is greater than or equal to the write threshold, the protocol layer CPU generates a garbage collection trigger signal, stops requesting the target cache interval, and sets the garbage collection time according to the garbage target collection quantity. The write threshold and the garbage target collection quantity are calculated in real time by the FTL layer CPU, and the FTL layer CPU represents the CPU core corresponding to the FTL layer.
[0009] The garbage collection trigger signal is sent to the FTL layer CPU to enable the FTL layer CPU to start garbage collection and monitor the garbage collection status in real time.
[0010] If the waste recycling status indicates that the amount of waste recycled is greater than or equal to the target amount of waste recycled, or the waste recycling time is greater than or equal to the target waste recycling time, then waste recycling is terminated.
[0011] In some optional embodiments, the step of writing the target data sent by the host into the target cache range and recording the amount of target data written through the protocol layer CPU includes:
[0012] During the process of writing the target data into the target cache range:
[0013] The protocol layer CPU monitors the amount of garbage targets to be recycled in real time. When the amount of garbage targets to be recycled is greater than zero, the amount of data written to the targets is recorded.
[0014] In some optional embodiments, the FTL layer CPU calculates the target amount of garbage to be recycled in real time, including:
[0015] The protocol layer CPU transmits the first ratio of the remaining number of free blocks to the total number of blocks, the second ratio of the number of used blocks in SLC storage units to the total number of blocks, and the write rate gradient of each CPU core to the FTL layer CPU in real time.
[0016] The FTL layer CPU calculates the target amount of garbage to be recycled in real time based on the first ratio, the second ratio, and the write rate gradient.
[0017] In some optional embodiments, the FTL layer CPU calculates the target garbage collection quantity in real time based on the first ratio, the second ratio, and the write rate gradient, including:
[0018] Obtain the first weight of the first ratio and the second weight of the second ratio;
[0019] The health of the remaining available blocks is calculated based on the first ratio, the first weight, the second ratio, and the second weight.
[0020] A third weight is determined based on the health score and a preset correspondence table, wherein the preset correspondence table indicates the correspondence between the health score and the third weight, and the health score is negatively correlated with the third weight.
[0021] The target amount of garbage to be recycled is calculated in real time based on the third weight and the write rate gradient.
[0022] In some optional embodiments, the write threshold is calculated in real time by the FTL layer CPU, including:
[0023] The health status is calculated when the FTL layer CPU detects a change in the type of a storage block and the number of free blocks is less than a preset number of free blocks.
[0024] If the health level is less than or equal to the health threshold, the write threshold is calculated based on the health level and the third weight.
[0025] In some optional embodiments, the calculation of the write rate gradient includes:
[0026] When the protocol layer CPU detects that the write threshold is greater than zero, it records the first time when the target data is started being written, and begins to record the target write data volume.
[0027] If the target amount of data to be written is greater than or equal to the writing threshold, stop writing the target data and record the second time at which writing the target data stops;
[0028] The write rate gradient is calculated based on the first time, the second time, and the target amount of data written.
[0029] In some optional embodiments, after starting to record the amount of target data written when the number of garbage targets to be recycled is greater than zero, the method further includes:
[0030] If the target amount of data to be written is less than the write threshold, the protocol layer CPU sends a first inter-core communication message to the FTL layer CPU so that the FTL layer CPU can write data.
[0031] If the target amount of data to be written is greater than or equal to the write threshold:
[0032] The protocol layer CPU sends a second inter-core communication message to the FTL layer CPU, so that the FTL layer CPU ends the data writing and sends an end message to the protocol layer CPU;
[0033] The protocol layer CPU sends a garbage collection trigger signal carrying the target garbage collection time to the FTL layer CPU, so that the FTL layer CPU shuts down the module shared with other CPU cores;
[0034] When garbage collection is exited, the target data volume is cleared to zero, and modules shared with other CPU cores are enabled.
[0035] Secondly, embodiments of the present invention provide a garbage collection system for a multi-core CPU memory, comprising:
[0036] The first module is used to obtain the host's request instructions;
[0037] The second module is used to control the protocol layer CPU to request a target cache range according to the request instruction, wherein the protocol layer CPU represents the CPU core corresponding to the protocol layer;
[0038] The third module is used to write the target data sent by the host into the target cache range, and to record the target data writing amount through the protocol layer CPU, wherein the target data writing amount represents the number of target data written into the target cache range;
[0039] The fourth module is used to generate a garbage collection trigger signal, stop applying for the target cache interval, and set the garbage collection time according to the garbage target collection quantity when the target write data volume is greater than or equal to the write threshold. The write threshold and the garbage target collection quantity are calculated in real time by the FTL layer CPU, and the FTL layer CPU represents the CPU core corresponding to the FTL layer.
[0040] The fifth module is used to send the garbage collection trigger signal to the FTL layer CPU so that the FTL layer CPU can start garbage collection and monitor the garbage collection status in real time.
[0041] The sixth module is used to exit waste collection when the waste collection status indicates that the amount of waste collected is greater than or equal to the target amount of waste collected or the waste collection time is greater than or equal to the target waste collection time.
[0042] Thirdly, embodiments of the present invention provide a garbage collection device for a multi-core CPU memory, the device comprising:
[0043] At least one processor;
[0044] At least one memory for storing at least one program;
[0045] When the at least one program is executed by the at least one processor, the at least one processor performs the method as described above.
[0046] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to perform the method described above.
[0047] Implementing the embodiments of the present invention has the following beneficial effects: The embodiments of the present invention provide a garbage collection method for a multi-core CPU memory, comprising: obtaining a request instruction from a host; controlling a protocol layer CPU to request a target cache interval according to the request instruction, wherein the protocol layer CPU represents the CPU core corresponding to the protocol layer; writing target data sent by the host into the target cache interval, and recording the target written data amount through the protocol layer CPU, wherein the target written data amount represents the number of target data written into the target cache interval; when the target written data amount is greater than or equal to a write threshold, the protocol layer CPU generates a garbage collection trigger signal, stops requesting the target cache interval, and sets a target garbage collection time according to the target garbage collection amount, wherein the write threshold and the target garbage collection amount are calculated in real time by an FTL layer CPU, wherein the FTL layer CPU represents the CPU core corresponding to the FTL layer; sending the garbage collection trigger signal to the FTL layer CPU to enable the FTL layer CPU to start garbage collection, and monitoring the garbage collection status in real time; and exiting garbage collection when the garbage collection status indicates that the garbage collection amount is greater than or equal to the target garbage collection amount or the garbage collection time is greater than or equal to the target garbage collection time. The protocol layer CPU records the target write data volume and generates a garbage collection trigger signal in real time when the target write data volume reaches the write threshold, ensuring the timeliness and accuracy of garbage collection. Furthermore, the FTL layer CPU calculates the write threshold and the target garbage collection quantity in real time, thereby automatically adjusting the write threshold and the target garbage collection quantity based on the dynamic load characteristics of multi-core concurrent writes or garbage collection pressure, thus ensuring the accuracy of garbage collection and improving memory performance. Therefore, this application can improve the accuracy of garbage collection, adapt to the dynamic load characteristics of multi-core concurrent writes, and trigger garbage collection in a timely manner, thereby improving memory performance. Attached Figure Description
[0048] Figure 1 This is a flowchart illustrating the steps of a garbage collection method for a multi-core CPU memory provided in an embodiment of the present invention;
[0049] Figure 2 This is a structural block diagram of a garbage collection system for a multi-core CPU memory provided in an embodiment of the present invention;
[0050] Figure 3 This is a structural block diagram of a garbage collection device for a multi-core CPU memory provided in an embodiment of the present invention. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0052] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, or the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0053] This invention provides a garbage collection method for a multi-core CPU memory, comprising: obtaining a request instruction from a host; controlling a protocol layer CPU to request a target cache region according to the request instruction, wherein the protocol layer CPU represents the CPU core corresponding to the protocol layer; writing target data sent by the host into the target cache region, and recording the target written data amount through the protocol layer CPU, wherein the target written data amount represents the number of target data written into the target cache region; when the target written data amount is greater than or equal to a write threshold, the protocol layer CPU generates a garbage collection trigger signal, stops requesting the target cache region, and sets a target garbage collection time according to the target garbage collection amount, wherein the write threshold and the target garbage collection amount are calculated in real time by an FTL layer CPU, wherein the FTL layer CPU represents the CPU core corresponding to the FTL layer; sending the garbage collection trigger signal to the FTL layer CPU to enable the FTL layer CPU to start garbage collection, and monitoring the garbage collection status in real time; and exiting garbage collection when the garbage collection status indicates that the garbage collection amount is greater than or equal to the target garbage collection amount or the garbage collection time is greater than or equal to the target garbage collection time. The protocol layer CPU records the target write data volume and generates a garbage collection trigger signal in real time when the target write data volume reaches the write threshold, ensuring the timeliness and accuracy of garbage collection. Furthermore, the FTL layer CPU calculates the write threshold and the target garbage collection quantity in real time, thereby automatically adjusting the write threshold and the target garbage collection quantity based on the dynamic load characteristics of multi-core concurrent writes or garbage collection pressure, thus ensuring the accuracy of garbage collection and improving memory performance. Therefore, this application can improve the accuracy of garbage collection, adapt to the dynamic load characteristics of multi-core concurrent writes, and trigger garbage collection in a timely manner, thereby improving memory performance.
[0054] like Figure 1 As shown in the figure, this embodiment of the invention provides a garbage collection method for a multi-core CPU memory, including the following steps.
[0055] S100, Obtain the host's request instruction.
[0056] Specifically, the storage system of this application receives instruction signals from the host through a hardware interface and converts them into operations (such as writing, reading, and erasing) that the storage system can execute through protocol parsing. The host includes the main control chip and server motherboard that interact with the storage system, and is not specifically limited; the storage system of this application includes non-volatile memory systems such as UFS (Universal Flash Storage), SSD (Solid State Disk), and EMMC (Embedded MultiMediaCard).
[0057] S200. According to the request instruction, the protocol layer CPU requests the target cache range, where the protocol layer CPU represents the CPU core corresponding to the protocol layer.
[0058] Specifically, the protocol layer CPU (the CPU core corresponding to the protocol layer) controls the allocation of buffer space based on the host's request instructions. The protocol layer CPU dynamically allocates matching buffer resources based on information such as the data volume and address range in the request instructions, ensuring that the data sent by the host can be efficiently stored and passed to the FTL layer.
[0059] S300: Write the target data sent by the host into the target cache range, and record the target data writing amount through the protocol layer CPU. The target data writing amount represents the number of target data written into the target cache range.
[0060] Specifically, the protocol layer CPU sends cache address information (such as the starting physical address and length of the target cache) to the interface controller. The interface controller establishes a direct data transmission link between the host and the cache according to the protocol specification. The host transmits the target data to the storage device through the hardware interface. The interface controller writes the data byte by byte into the target cache according to the address specified by the protocol layer. After the data transmission is completed, the interface controller generates a transmission completion signal with a data checksum attached. After receiving the signal, the protocol layer CPU verifies the data in the buffer: if the verification passes, it confirms that the data has been completely written to the buffer and proceeds to the next step; if the verification fails, it sends a data retransmission request to the host through the interface layer and clears the current buffer to wait for retransmission.
[0061] After the data is written and verified, the protocol layer CPU marks the buffer as ready, indicating that the data can be read by the FTL layer; at the same time, it records the logical address information corresponding to the buffer, so that the FTL layer can subsequently map the data to the NAND physical address.
[0062] The protocol layer CPU immediately updates the write volume statistics the moment the data verification passes and the write to the buffer is confirmed: if the amount of data written this time is S (e.g., 32KB), then ( (This is the cumulative value from the previous record); the recording granularity is accurate to the byte or block (e.g., counting in 4KB blocks for easy alignment with NAND page size, but the specific value is not limited). The target amount of data written is monitored in real time by the write volume monitoring module on the protocol layer CPU.
[0063] In some optional embodiments, the step of writing the target data sent by the host into the target cache range and recording the amount of target data written through the protocol layer CPU includes:
[0064] During the process of writing the target data into the target cache range:
[0065] The protocol layer CPU monitors the amount of garbage targets to be recycled in real time. When the amount of garbage targets to be recycled is greater than zero, the amount of data written to the targets is recorded.
[0066] Specifically, the garbage collection target number (GC_DN) is dynamically adjusted by the FTL layer CPU. The protocol layer CPU monitors the GC_DN status in real time, which can be synchronized with the data write rhythm (e.g., monitored once after each data block is received) or periodically polled (e.g., every 10...). Query the GC_DN value in the shared memory of the FTL layer. If GC_DN=0: it means that GC (Garbage Collection) does not need to be triggered at present, and the protocol layer CPU does not record WDN (or clears the existing WDN value). If GC_DN>0: it means that the system has entered the GC preparation state and needs to start counting the amount of data written to determine whether to trigger GC. At this time, the WDN counter is activated, and the target amount of data written begins to be recorded.
[0067] S400, when the target write data volume is greater than or equal to the write threshold, the protocol layer CPU generates a garbage collection trigger signal, stops applying for the target cache interval, and sets the garbage target collection time according to the garbage target collection quantity. The write threshold and the garbage target collection quantity are calculated in real time by the FTL layer CPU, and the FTL layer CPU represents the CPU core corresponding to the FTL layer.
[0068] Specifically, when the target write data volume (WDN) reaches the write threshold (i.e., GC_DN) calculated in real time by the FTL layer CPU, the protocol layer CPU generates a trigger signal to start GC, stops cache allocation of target cache areas to avoid resource conflicts, and sets the GC time (garbage target reclamation time) to ensure reclamation efficiency. Among them, the write threshold (GC_DN) and the amount of garbage target to be reclaimed are calculated in real time by the FTL layer CPU.
[0069] In some optional embodiments, the FTL layer CPU calculates the target amount of garbage to be recycled in real time, including:
[0070] S410. The protocol layer CPU transmits the first ratio of the remaining number of free blocks to the total number, the second ratio of the number of used blocks in the SLC storage unit to the total number, and the write rate gradient of each CPU core to the FTL layer CPU in real time.
[0071] S420, the FTL layer CPU calculates the target amount of garbage to be recycled in real time based on the first ratio, the second ratio and the write rate gradient.
[0072] Specifically, the protocol layer CPU collects and transmits a first ratio, a second ratio, and the write rate gradient of each CPU core to the FTL layer CPU in real time. The first ratio represents the proportion of remaining free blocks in the flash memory to the total number of blocks, reflecting the overall storage space availability. The second ratio represents the proportion of used blocks in an SLC (Single-Level Cell) storage unit to its total number of blocks, reflecting the utilization of high-speed storage resources. The write rate gradient of each CPU core represents the current data write rate of each CPU core, reflecting the load fluctuation during multi-core concurrent writes. These parameters are transmitted in real time through a low-latency shared memory channel, ensuring that the FTL layer CPU obtains the latest system status. Based on the received first ratio, second ratio, and write rate gradient of each CPU core, the FTL layer CPU calculates the target number of garbage collection targets.
[0073] In some optional embodiments, the FTL layer CPU calculates the target garbage collection quantity in real time based on the first ratio, the second ratio, and the write rate gradient, including:
[0074] S421. Obtain the first weight of the first ratio and the second weight of the second ratio;
[0075] S422. Calculate the health of the remaining available blocks based on the first ratio, the first weight, the second ratio, and the second weight;
[0076] S423. Determine a third weight based on the health score and a preset correspondence table, wherein the preset correspondence table indicates the correspondence between the health score and the third weight, and the health score is negatively correlated with the third weight;
[0077] S424. The number of garbage targets to be recycled is calculated in real time based on the third weight and the write rate gradient.
[0078] Specifically, the first weight reflects the importance of the first ratio (the percentage of free blocks remaining) in assessing storage status; the second weight reflects the importance of the second ratio (the percentage of SLC blocks used). The first and second weights can be dynamically adjusted according to the system's priority on space adequacy and cache performance, and their specific values are not limited here.
[0079] Based on the first ratio, the second ratio, and their corresponding weights, a health score reflecting the overall storage health status is calculated: the health score is a comprehensive rating of free block sufficiency and SLC cache availability, calculated using the following formula: Health Score ( As the first weight, As the second weight, The first ratio, (This is the second ratio). Specifically, the numerical relationship between health and each parameter is shown in Table 1:
[0080] Table 1. Health Status and Test Data for Each Parameter
[0081]
[0082] A third weight is determined to adjust the recycling intensity using a pre-defined mapping table (the mapping relationship between health level and third weight). In the pre-defined table, health level and third weight are negatively correlated; high health level corresponds to a low third weight, indicating that large-scale recycling is not necessary; low health level corresponds to a high third weight, requiring strengthened recycling. The target recycling quantity is... ( As the third weight, (This is the write rate gradient).
[0083] In some optional embodiments, the write threshold is calculated in real time by the FTL layer CPU, including:
[0084] S430. If the FTL layer CPU detects a change in the type of a storage block and the number of free blocks is less than a preset number of free blocks, the health status is calculated.
[0085] S440. If the health level is less than or equal to the health threshold, the write threshold is calculated based on the health level and the third weight.
[0086] Specifically, the FTL layer CPU only initiates the calculation of the write threshold when the type of the storage block changes and the number of free blocks is less than the preset number of free blocks.
[0087] A change in storage block type was detected: This means that the state of some physical blocks in the flash memory has changed (such as a valid block that originally stored valid data becoming a block to be reclaimed containing invalid pages due to data updates or deletions). This indicates that there are more invalid blocks in the system and there is a need for reclamation.
[0088] The number of free blocks is less than the preset number of free blocks: The number of free blocks that can be directly used for new data writing is lower than the system's preset safe free block threshold (such as 10% of the total number of blocks), indicating that space is tight and free blocks need to be replenished through garbage collection.
[0089] After detecting a change in the type of storage blocks and that the number of free blocks is less than the preset number of free blocks, the FTL layer CPU calculates the health of the overall storage system. The FTL layer CPU compares the calculated health with a preset health threshold (e.g., 30%): if the health is greater than the health threshold, it means that the storage system is in good condition (sufficient free blocks and a lot of available SLC cache space), and there is no need to set the write threshold immediately (at this time, GC_DN remains at 0, and garbage collection is not triggered); if the health is less than or equal to the health threshold, it means that the storage system is in poor condition (space is tight or SLC cache is insufficient), and the write threshold needs to be calculated immediately, thus obtaining the write threshold based on the health and the third weight.
[0090] In some optional embodiments, the calculation of the write rate gradient includes:
[0091] S450: When the protocol layer CPU detects that the write threshold is greater than zero, record the first time when the target data is started to be written, and start recording the target data write volume;
[0092] S460. If the target amount of data to be written is greater than or equal to the writing threshold, stop writing the target data and record the second time when writing the target data stops.
[0093] S470. The write rate gradient is calculated based on the first time, the second time, and the target write data volume.
[0094] Specifically, when the protocol layer CPU detects that the write threshold (GC_DN) > 0 (i.e., the system has entered a state that requires monitoring GC triggering), it immediately executes the following: record the first moment, accurately recording the moment when writing the target data begins ( The target data write volume statistics are started, and the target data write volume in the cache range is accumulated (i.e., WDN starts counting from 0), and the total write volume in this stage is tracked in real time.
[0095] As data continues to be written, when the protocol layer CPU detects that the target written data volume (WDN) is greater than or equal to the write threshold (GC_DN) (i.e., the condition for triggering GC is met), it immediately terminates the writing and recording of this phase; stops writing target data, pauses receiving and writing new target data to avoid the continuous accumulation of data affecting the accuracy of statistics; and records a second time, accurately recording the moment when writing stops (e.g., ...). This serves as the end timestamp for the writing of this stage.
[0096] Based on the first time recorded in the first two steps ( ), second time ( ) and target write data volume (WDN), calculate the write rate gradient for this stage ( ): .
[0097] In some optional embodiments, after starting to record the amount of target data written when the number of garbage targets to be recycled is greater than zero, the method further includes:
[0098] S480. If the target amount of data to be written is less than the writing threshold, the protocol layer CPU sends a first inter-core communication message to the FTL layer CPU so that the FTL layer CPU can write data.
[0099] Specifically, when the target write data volume (WDN) is less than the write threshold (GC_DN), normal data writing continues. At this point, the conditions for triggering GC have not yet been met, and the protocol layer CPU sends the first inter-core communication message (such as a data write continuation instruction) to the FTL layer CPU. The core function of this message is to notify the FTL layer that the current write volume is still within a safe range and the target data in the protocol layer cache should continue to be written to the NAND flash memory.
[0100] S481, if the target write data volume is greater than or equal to the write threshold:
[0101] The protocol layer CPU sends a second inter-core communication message to the FTL layer CPU, so that the FTL layer CPU ends the data writing and sends an end message to the protocol layer CPU;
[0102] S482. The protocol layer CPU sends a garbage collection trigger signal carrying the target garbage collection time to the FTL layer CPU, so that the FTL layer CPU shuts down the module shared with other CPU cores;
[0103] S483. When exiting garbage collection, clear the target data volume to zero and enable the module shared with other CPU cores.
[0104] Specifically, when the target write data volume (WDN) is greater than or equal to the write threshold (GC_DN), GC is initiated and resources are controlled. At this point, the GC triggering condition is met, and the protocol layer CPU sends a second-core inter-core communication message (such as a data write termination instruction) to the FTL layer CPU, informing it that the GC threshold has been reached and new data writing must stop. Upon receiving the message, the FTL layer CPU completes the currently ongoing NAND write operation, no longer receives new cached data from the protocol layer, and returns a write completion confirmation message to the protocol layer CPU, marking the formal end of the data write phase.
[0105] After receiving the write completion confirmation message, the protocol layer CPU sends a garbage collection trigger signal to the FTL layer CPU, carrying the target garbage collection time (GC timeout T). This signal not only notifies the FTL layer to start GC, but also requires it to shut down modules shared with other CPU cores (such as shared NAND controllers, global caches, bus interfaces, etc.). This prevents read and write operations of other CPU cores from occupying shared resources (such as NAND bandwidth) during GC execution, ensuring that GC can exclusively use resources to complete efficiently and reduce collection time.
[0106] When the FTL layer CPU completes GC (reaching the set amount of data to be collected or the timeout period T) and exits the garbage collection process: the protocol layer CPU clears the target written data volume (WDN) to zero, resets the count state, and prepares for the next GC trigger condition judgment; the protocol layer CPU or the FTL layer CPU opens the modules that were previously closed and shared with other CPU cores, restores the access permissions of multiple cores to shared resources, and enables the storage system to re-enter the normal multi-tasking processing state, supporting new host data write requests.
[0107] S500: Send the garbage collection trigger signal to the FTL layer CPU so that the FTL layer CPU can start garbage collection and monitor the garbage collection status in real time.
[0108] Specifically, when the protocol layer CPU sends a garbage collection trigger signal carrying the garbage target collection time (T), the FTL layer CPU first parses the key information in the signal (including the number of garbage targets to be collected, the timeout time T, etc.), and then starts the garbage collection process: according to the preset collection strategy, it begins to execute GC operations. At the same time, the FTL layer CPU monitors the execution status of garbage collection in real time, and the monitoring dimensions include:
[0109] Recycling progress: Real-time statistics of the number of blocks (or pages) that have been recycled, calculation of the current progress, and comparison with the preset target number of garbage to be recycled;
[0110] Time consumption: Record the cumulative time after GC starts and compare it with the garbage target collection time T in the trigger signal to ensure that it does not exceed the timeout threshold;
[0111] Abnormal status: Monitor whether bad blocks (unable to write valid data), ECC check errors (data corruption) or other abnormalities occur during the data migration process, and whether the erase operation times out (NAND chip response delay).
[0112] During monitoring, the FTL layer CPU will report the status to the protocol layer CPU through inter-core communication (e.g., sending an update every 10% of the recycling progress). If the recycling progress stalls, the cumulative duration exceeds T, or a serious anomaly prevents it from continuing, the FTL layer CPU will immediately terminate GC, send a GC interrupt signal to the protocol layer CPU along with the reason for the anomaly, so that the system can take degraded strategies (e.g., reducing the amount of recycling, prioritizing host I / O).
[0113] S600: If the waste recycling status indicates that the amount of waste recycled is greater than or equal to the target amount of waste recycled or the waste recycling time is greater than or equal to the target waste recycling time, then exit waste recycling.
[0114] Specifically, if the actual number of garbage collected in real time (the number of invalid blocks that have been successfully erased and converted into free blocks) is greater than or equal to the target number of garbage blocks to be collected, it indicates that the preset garbage collection task has been completed. If the cumulative execution time of garbage collection from start to finish is greater than or equal to the target garbage collection time carried by the protocol layer CPU (i.e., GC timeout time T), even if the actual number of garbage collected has not fully met the target, it must be forcibly terminated to avoid excessive GC consumption of NAND bandwidth and CPU resources, which could lead to blocking of subsequent host IO requests and ensure system response timeliness.
[0115] Implementing the embodiments of the present invention has the following beneficial effects: The embodiments of the present invention provide a garbage collection method for a multi-core CPU memory, comprising: obtaining a request instruction from a host; controlling a protocol layer CPU to request a target cache interval according to the request instruction, wherein the protocol layer CPU represents the CPU core corresponding to the protocol layer; writing target data sent by the host into the target cache interval, and recording the target written data amount through the protocol layer CPU, wherein the target written data amount represents the number of target data written into the target cache interval; when the target written data amount is greater than or equal to a write threshold, the protocol layer CPU generates a garbage collection trigger signal, stops requesting the target cache interval, and sets a target garbage collection time according to the target garbage collection amount, wherein the write threshold and the target garbage collection amount are calculated in real time by an FTL layer CPU, wherein the FTL layer CPU represents the CPU core corresponding to the FTL layer; sending the garbage collection trigger signal to the FTL layer CPU to enable the FTL layer CPU to start garbage collection, and monitoring the garbage collection status in real time; and exiting garbage collection when the garbage collection status indicates that the garbage collection amount is greater than or equal to the target garbage collection amount or the garbage collection time is greater than or equal to the target garbage collection time. The protocol layer CPU records the target write data volume and generates a garbage collection trigger signal in real time when the target write data volume reaches the write threshold, ensuring the timeliness and accuracy of garbage collection. Furthermore, the FTL layer CPU calculates the write threshold and the target garbage collection quantity in real time, thereby automatically adjusting the write threshold and the target garbage collection quantity based on the dynamic load characteristics of multi-core concurrent writes or garbage collection pressure, thus ensuring the accuracy of garbage collection and improving memory performance. Therefore, this application can improve the accuracy of garbage collection, adapt to the dynamic load characteristics of multi-core concurrent writes, and trigger garbage collection in a timely manner, thereby improving memory performance.
[0116] Secondly, referring to Figure 2 This invention provides a garbage collection system for multi-core CPU memory, comprising:
[0117] The first module is used to obtain the host's request instructions;
[0118] The second module is used to control the protocol layer CPU to request a target cache range according to the request instruction, wherein the protocol layer CPU represents the CPU core corresponding to the protocol layer;
[0119] The third module is used to write the target data sent by the host into the target cache range, and to record the target data writing amount through the protocol layer CPU, wherein the target data writing amount represents the number of target data written into the target cache range;
[0120] The fourth module is used to generate a garbage collection trigger signal, stop applying for the target cache interval, and set the garbage collection time according to the garbage target collection quantity when the target write data volume is greater than or equal to the write threshold. The write threshold and the garbage target collection quantity are calculated in real time by the FTL layer CPU, and the FTL layer CPU represents the CPU core corresponding to the FTL layer.
[0121] The fifth module is used to send the garbage collection trigger signal to the FTL layer CPU so that the FTL layer CPU can start garbage collection and monitor the garbage collection status in real time.
[0122] The sixth module is used to exit waste collection when the waste collection status indicates that the amount of waste collected is greater than or equal to the target amount of waste collected or the waste collection time is greater than or equal to the target waste collection time.
[0123] It is evident that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0124] Thirdly, referring to Figure 3 This invention provides a garbage collection device for a multi-core CPU memory, comprising:
[0125] At least one processor;
[0126] At least one memory for storing at least one program;
[0127] When at least one program is executed by at least one processor, the at least one processor implements the method described above.
[0128] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0129] Fourthly, this application also discloses a computer program product or computer program stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the methods or systems described above. Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0130] It is understood that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as processors, such as central processing units, digital information processors, or microprocessors executing software, or as hardware, or as integrated circuits, such as application-specific integrated circuits. Such software can be distributed on computer-readable media, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data information such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0131] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.
Claims
1. A garbage collection method for a multi-core CPU memory, characterized in that, include: Obtain the request instructions from the host; The protocol layer CPU requests a target cache range according to the request instruction, whereby the protocol layer CPU represents the CPU core corresponding to the protocol layer. The target data sent by the host is written into the target cache range, and the target data writing volume is recorded by the protocol layer CPU. The target data writing volume represents the amount of target data written into the target cache range. When the target write data volume is greater than or equal to the write threshold, the protocol layer CPU generates a garbage collection trigger signal, stops requesting the target cache interval, and sets the garbage collection time according to the garbage target collection quantity. The write threshold and the garbage target collection quantity are calculated in real time by the FTL layer CPU, and the FTL layer CPU represents the CPU core corresponding to the FTL layer. The garbage collection trigger signal is sent to the FTL layer CPU to enable the FTL layer CPU to start garbage collection and monitor the garbage collection status in real time. If the waste recycling status indicates that the amount of waste recycled is greater than or equal to the target amount of waste recycled, or the waste recycling time is greater than or equal to the target waste recycling time, then waste recycling is terminated.
2. The method according to claim 1, characterized in that, The step of writing the target data sent by the host into the target cache range and recording the amount of target data written through the protocol layer CPU includes: During the process of writing the target data into the target cache range: The protocol layer CPU monitors the amount of garbage targets to be recycled in real time. When the amount of garbage targets to be recycled is greater than zero, the amount of data written to the targets is recorded.
3. The method according to claim 1, characterized in that, The FTL layer CPU calculates the target amount of garbage to be recycled in real time, including: The protocol layer CPU transmits the first ratio of the remaining number of free blocks to the total number of blocks, the second ratio of the number of used blocks in SLC storage units to the total number of blocks, and the write rate gradient of each CPU core to the FTL layer CPU in real time. The FTL layer CPU calculates the target amount of garbage to be recycled in real time based on the first ratio, the second ratio, and the write rate gradient.
4. The method according to claim 3, characterized in that, The FTL layer CPU calculates the target garbage collection quantity in real time based on the first ratio, the second ratio, and the write rate gradient, including: Obtain the first weight of the first ratio and the second weight of the second ratio; The health of the remaining available blocks is calculated based on the first ratio, the first weight, the second ratio, and the second weight. A third weight is determined based on the health score and a preset correspondence table, wherein the preset correspondence table indicates the correspondence between the health score and the third weight, and the health score is negatively correlated with the third weight. The target amount of garbage to be recycled is calculated in real time based on the third weight and the write rate gradient.
5. The method according to claim 4, characterized in that, The write threshold is calculated in real time by the FTL layer CPU, including: The health status is calculated when the FTL layer CPU detects a change in the type of a storage block and the number of free blocks is less than a preset number of free blocks. If the health level is less than or equal to the health threshold, the write threshold is calculated based on the health level and the third weight.
6. The method according to claim 4, characterized in that, The calculation of the write rate gradient includes: When the protocol layer CPU detects that the write threshold is greater than zero, it records the first time when the target data is started being written, and begins to record the target write data volume. If the target amount of data to be written is greater than or equal to the writing threshold, stop writing the target data and record the second time when writing the target data stops; The write rate gradient is calculated based on the first time, the second time, and the target amount of data written.
7. The method according to claim 2, characterized in that, After starting to record the amount of data written to the target when the number of garbage targets to be recycled is greater than zero, the method further includes: If the target amount of data to be written is less than the write threshold, the protocol layer CPU sends a first inter-core communication message to the FTL layer CPU so that the FTL layer CPU can write data. If the target amount of data to be written is greater than or equal to the write threshold: The protocol layer CPU sends a second inter-core communication message to the FTL layer CPU, so that the FTL layer CPU ends the data writing and sends an end message to the protocol layer CPU; The protocol layer CPU sends a garbage collection trigger signal carrying the target garbage collection time to the FTL layer CPU, so that the FTL layer CPU shuts down the module shared with other CPU cores; When garbage collection is exited, the target data volume is cleared to zero, and modules shared with other CPU cores are enabled.
8. A garbage collection system for a multi-core CPU memory, characterized in that, include: The first module is used to obtain the host's request instructions; The second module is used to control the protocol layer CPU to request a target cache range according to the request instruction, wherein the protocol layer CPU represents the CPU core corresponding to the protocol layer; The third module is used to write the target data sent by the host into the target cache range, and to record the target data writing amount through the protocol layer CPU, wherein the target data writing amount represents the number of target data written into the target cache range; The fourth module is used to generate a garbage collection trigger signal, stop applying for the target cache interval, and set the garbage collection time according to the garbage target collection quantity when the target write data volume is greater than or equal to the write threshold. The write threshold and the garbage target collection quantity are calculated in real time by the FTL layer CPU, and the FTL layer CPU represents the CPU core corresponding to the FTL layer. The fifth module is used to send the garbage collection trigger signal to the FTL layer CPU so that the FTL layer CPU can start garbage collection and monitor the garbage collection status in real time. The sixth module is used to exit waste collection when the waste collection status indicates that the amount of waste collected is greater than or equal to the target amount of waste collected or the waste collection time is greater than or equal to the target waste collection time.
9. A garbage collection device for a multi-core CPU memory, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method as described in any one of claims 1-7.
10. A computer-readable storage medium storing a processor-executable program, characterized in that, The processor-executable program, when executed by the processor, is used to perform the method as described in any one of claims 1-7.
Citation Information
Patent Citations
Solid state disk garbage collection method and device based on multi-core CPU
CN111045956A
Dynamically adjusted garbage collection workload
US20210073121A1