Page replacement method for NAND flash memory and related device

By calculating the health score of NAND flash memory pages and using dynamic grading thresholds to identify and replace pages with bad page trends, the problem of low reliability in bad page management in existing technologies is solved, achieving higher storage reliability and capacity utilization.

CN122431948APending Publication Date: 2026-07-21SHENZHEN QUANHUIDA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN QUANHUIDA TECH CO LTD
Filing Date
2026-04-28
Publication Date
2026-07-21

Smart Images

  • Figure CN122431948A_ABST
    Figure CN122431948A_ABST
Patent Text Reader

Abstract

The application provides a page replacement method of NAND flash memory, which comprises the following steps: obtaining the number of corrected bit errors of each page in each read operation, maintaining a record containing the cumulative value of the number of bit errors, the number of erasing and writing times and the retention time for each page; calculating the health score value of each page based on the cumulative value of the number of bit errors, the number of erasing and writing times and the retention time; determining the page to be replaced based on the health score value and the preset dynamic grading threshold value, wherein the dynamic grading threshold value is obtained by dynamically grading the health score values of all array pages; and actively migrating the valid data of the page to be replaced to the reserved healthy replacement page within the preset correctable period, and updating the logical-to-physical address mapping table. Through health assessment of each page, the page with a bad page trend is determined as the page to be replaced, the valid data of the page to be replaced is actively migrated to the reserved healthy replacement page within the correctable period, and the reliability of bad page management is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data management technology, and in particular to a page replacement method and related equipment for NAND flash memory. Background Technology

[0002] Memory is a crucial component in computers, and NAND flash memory is currently the mainstream storage medium in products such as solid-state drives (SSDs), embedded storage (eMMC / UFS), and USB flash drives. With the multi-layer stacking of 3D NAND technology (such as 128 layers, 176 layers, 232 layers) and the increase in the number of bits per cell (QLC, PLC), the raw bit error rate (RBER) of NAND flash memory has increased significantly, and page errors have become more frequent and unpredictable.

[0003] Current NAND flash memory bad page management technologies typically mark and replace bad pages only after an Uncorrectable Error (UE) occurs. At this point, the data on the page may be permanently lost, and the entire block may be marked as bad, resulting in wasted storage capacity. This reactive approach cannot meet the demands of high-reliability storage. Therefore, a more reliable page replacement solution is urgently needed. Summary of the Invention

[0004] This invention provides a page replacement method for NAND flash memory, aiming to solve the problem of low reliability in bad page management of traditional NAND flash memory. By measuring the number of corrected bit errors on each page, a health assessment is performed on each page. Using a health score and a dynamic grading threshold, pages with a bad page trend are identified as pages to be replaced. Within the correctable period, valid data on the pages to be replaced is proactively migrated to reserved healthy replacement pages. This allows data replacement before bad pages occur, thereby improving the reliability of bad page management.

[0005] In a first aspect, embodiments of the present invention provide a page replacement method for NAND flash memory, the page replacement method for NAND flash memory comprising the following steps: Get the corrected bit error count for each page in each read operation, and maintain a record for each page containing the cumulative bit error count, number of erase / write cycles, and retention time; Calculate a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. Based on the health score and the preset dynamic grading threshold, the page to be replaced is determined. The dynamic grading threshold is obtained by dynamically grading the health score of all pages in the array. Within a preset correctable period, the valid data of the page to be replaced is actively migrated to the reserved healthy replacement page, and the logical-to-physical address mapping table is updated.

[0006] Optionally, the calculation of a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time includes: Calculate a basic health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. Extract the average number of bit errors, the maximum number of bit errors, and the trend of bit error count for each page; The basic health score is adjusted based on the changing trend to obtain the health score for each page.

[0007] Optionally, adjusting the basic health score based on the changing trend to obtain a health score for each page includes: Determine the trend type of the changing trend of the number of bit errors, where the trend type includes accelerating increase, uniform increase, decelerating increase, stable or decreasing; When the trend of change is accelerating upward, a downward adjustment is applied to the baseline health score; When the trend is decelerating upward or stable, no adjustment is applied or only a small downward adjustment is applied; When the trend is downward, an upward adjustment is applied to the baseline health score.

[0008] Optionally, the dynamic grading threshold is obtained by dynamically grading based on the health score values ​​of the entire array of pages, including: Collect the health score values ​​of all pages in the entire array, and calculate the central tendency statistic and dispersion statistic of the health score values; Based on the central tendency statistic and dispersion statistic, the health score range is dynamically divided into multiple continuous level ranges, and the boundary value of each level range is used as the dynamic grading threshold.

[0009] Optionally, determining the page to be replaced based on the health score and a preset dynamic grading threshold includes: The lowest level interval is identified from the plurality of consecutive level intervals as the replacement interval; Compare the health score of each page with the upper boundary of the replacement interval; Pages with a health score below the upper boundary are identified as pages to be replaced.

[0010] Optionally, within a preset correctable period, the valid data of the page to be replaced is actively migrated to a reserved healthy replacement page, including: Initiate the background migration operation within the preset correctable period; The background migration operation is executed in parallel with the read and write requests of the upper-layer host, and the original page to be replaced remains readable during the migration process. Verification will be performed after all data has been written to the health replacement page.

[0011] Optionally, before actively migrating the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, the method further includes: Get the maximum correctable threshold of the error correction coding for the current page; Calculate the growth trend of the number of bit errors based on the historical data of the number of bit errors on this page; Based on the growth trend, predict whether the number of bit errors in the page within a predetermined number of read operations in the future exceeds the maximum correctable capability threshold; The time interval or the number of read operations predicted to be no more than the maximum correctable capability threshold is determined as the correctable period; The upper limit of the correctable period is constrained by the error tolerance margin implied by the health score value corresponding to the upper boundary of the replacement interval in the dynamic grading threshold.

[0012] Secondly, embodiments of the present invention also provide a page replacement device for NAND flash memory, the page replacement device for NAND flash memory comprising: The first acquisition module is used to acquire the number of corrected bit errors for each page in each read operation, and maintain a record for each page containing the cumulative number of bit errors, the number of erase / write operations, and the retention time. The first processing module is used to calculate a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. The second processing module is used to determine the page to be replaced based on the health score value and the preset dynamic grading threshold. The dynamic grading threshold is obtained by dynamically grading the health score values ​​of all pages in the array. The page replacement module is used to actively migrate the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, and update the logical to physical address mapping table.

[0013] Thirdly, embodiments of the present invention provide an electronic device, characterized in that it includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in the page replacement method for NAND flash memory provided in the embodiments of the invention.

[0014] Fourthly, embodiments of the present invention provide a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps in the page replacement method for NAND flash memory provided in the embodiments of the invention.

[0015] In this embodiment of the invention, the number of corrected bit errors for each page in each read operation is obtained, and a record containing the cumulative number of bit errors, the number of erase / write operations, and the retention time is maintained for each page. A health score for each page is calculated based on the cumulative number of bit errors, the number of erase / write operations, and the retention time. Pages to be replaced are determined based on the health score and a preset dynamic grading threshold, which is obtained by dynamically grading the health scores of all pages in the array. Within a preset correctable period, the valid data of the pages to be replaced is proactively migrated to a reserved healthy replacement page, and the logical-to-physical address mapping table is updated. By using the number of corrected bit errors for each page to perform a health assessment, and using the health score and the dynamic grading threshold, pages with a bad page trend are identified as pages to be replaced. Proactively migrating the valid data of the pages to be replaced to the reserved healthy replacement page within the correctable period allows for data replacement before bad pages occur, thereby improving the reliability of bad page management.

[0016] Other beneficial effects of this application will be described in detail in the following detailed description section. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart of a page replacement method for NAND flash memory provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a page replacement device for NAND flash memory provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0019] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0020] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0021] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0022] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0023] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0024] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0025] like Figure 1 As shown, Figure 1This is a flowchart of a page replacement method for NAND flash memory provided in an embodiment of the present invention. The page replacement method for NAND flash memory includes the following steps: 101. Obtain the corrected bit error count for each page in each read operation, and maintain a record for each page containing the cumulative bit error count, the number of erase / write cycles, and the retention time.

[0026] 102. Calculate the health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time.

[0027] 103. Based on the health score and the preset dynamic grading threshold, the page to be replaced is determined.

[0028] The dynamic grading threshold is obtained by dynamically grading the health score of the entire array of pages.

[0029] 104. Within a preset correctable period, the valid data of the page to be replaced is actively migrated to the reserved healthy replacement page, and the logical-to-physical address mapping table is updated.

[0030] In this embodiment of the invention, a record is created for each page when it is first used or when each page is first written to. Initially, the cumulative bit error count is set to 0, the erase / write count is set to the current erase / write count of the block to which the page belongs, and the retention time is set to 0. All records are stored in the metadata area within the controller.

[0031] When the host initiates a read operation or a background maintenance task performs a read operation, the flash memory controller reads page data from the flash memory chip, and the ECC module performs error detection and correction on the data. After correction is complete, the ECC module outputs the number of bit errors corrected in this read operation. The controller obtains this value and associates it with the corresponding physical page.

[0032] The controller calculates the retention time (current time minus the page's last write time) for this read operation based on the current system time or a counter. Then, it performs the following updates on the target page's record: the number of bit errors corrected in this operation is added to the cumulative bit error count; if the page's erase / write count changes due to the erase of its block, the erase / write count is updated synchronously (this can be queried periodically through the block management module or triggered by an event); and the retention time field is updated to the current value. After the record update is complete, it can be used for subsequent health score calculations.

[0033] To prevent data loss in the event of power failure, records can be periodically backed up to a reserved area of ​​the flash memory (such as the system block). Incremental checkpointing can also be used to reduce write overhead.

[0034] Construct a scoring function and design a mathematical function. ,in, This is the cumulative number of bit errors. This refers to the number of erase / write cycles. For retention time. The function satisfies, The higher the score, the better the health rating. The smaller the value (indicating less healthy). Specifically, the above data function can be a linear weighted sum: ,in These are the normalized cumulative number of bit errors, the number of erase / write cycles, and the retention time, respectively; it can also be a machine learning model: a regression function obtained through offline training.

[0035] For each page, read the current cumulative bit error count, erase / write count, and retention time from the records maintained in step one. It should be noted that the erase / write count and retention time may be shared across all pages within the same block, but the cumulative bit error count for each page is independent.

[0036] Substitute the three parameters mentioned above into the scoring function to calculate the health score for the page. The score can be normalized to a range of 0-100 for easier subsequent classification. After calculation, the health score can be stored in the page record, or it can be calculated in real time without being stored.

[0037] Health scores can be calculated incrementally after each read operation, or they can be calculated in batches periodically by background inspection tasks. To reduce computational overhead, a lazy calculation strategy can be adopted, calculating the scores of all pages only when a replacement decision is needed.

[0038] When a replacement decision is needed (e.g., at fixed time intervals, or when a sharp increase in the number of errors on certain pages is detected), collect the health score of all current pages. If the number of pages is large, sampling or partitioning can be used for collection.

[0039] Based on the collected set of health scores, statistical methods are used to divide them into multiple consecutive level intervals. The division method can be equal-width binning: dividing the health score into several intervals equally from the minimum to the maximum value; it can also be equal-frequency binning: ensuring that the number of pages in each interval is approximately equal; or it can be based on the mean and standard deviation: for example, dividing scores below a certain threshold into intervals. The pages are classified as the lowest level. The output is a set of thresholds. ,in This is the lower boundary of the highest level. This is the lower boundary of the lowest level.

[0040] Each page's health score is compared to a grading threshold to identify pages belonging to the lowest tier (i.e., the worst health status). A replacement threshold is then set. For example, taking the upper boundary of the lowest level range. All health score values. Pages with low ratings are marked as pages to be replaced. Alternatively, only a few pages with the lowest ratings from the lowest tier can be selected to avoid migrating too many at once. The list of physical addresses of the pages to be replaced can be stored in a processing queue for use in subsequent migration steps.

[0041] For each page to be replaced, it is necessary to estimate the number of read operations or the time window remaining before reaching an uncorrectable error. The correctable period can be estimated by considering historical error growth trends and the maximum correctable capacity of ECC. In this embodiment, the correctable period is a pre-set safety value, such as within the next 1000 read operations or within the next 7 days.

[0042] Within a defined correctable period, the controller initiates a background migration task. An idle healthy page can be allocated from a reserved pool of healthy replacement pages. The selection criteria for a healthy replacement page can include the highest health score, the lowest number of write attempts, or the shortest retention time.

[0043] Read valid data from the page to be replaced (i.e., the user data currently stored at that logical address). Write the read data to the newly allocated healthy replacement page. Verify that the write was correct (through readback comparison or ECC check).

[0044] After the data is successfully written to the health replacement page, the logical-to-physical address mapping table is modified, updating the logical address entries that originally pointed to the page to be replaced to the physical address that points to the new page. Simultaneously, the page to be replaced is marked as invalid or awaiting erasure.

[0045] Once the data in the page to be replaced has been migrated and the mapping updated, the page no longer contains valid data. It can be added to the free block pool and reclaimed during subsequent block erasure. It should be noted that page replacement does not immediately erase the data to avoid impacting performance.

[0046] In one possible implementation, during the migration process, if a host initiates a read or write request to the logical address being migrated, the controller needs to employ an appropriate synchronization mechanism (such as returning the old page data during reads until the mapping update is complete, and directly writing the new page and updating the mapping during writes). This is typically implemented as an atomic operation to ensure data consistency.

[0047] After the migration is complete, record the replacement event (including the original page address, new page address, reason for replacement, migration time, etc.) in the system log for subsequent performance analysis and fault diagnosis.

[0048] In this embodiment of the invention, the number of corrected bit errors for each page in each read operation is obtained, and a record containing the cumulative number of bit errors, the number of erase / write operations, and the retention time is maintained for each page. A health score for each page is calculated based on the cumulative number of bit errors, the number of erase / write operations, and the retention time. Pages to be replaced are determined based on the health score and a preset dynamic grading threshold, which is obtained by dynamically grading the health scores of all pages in the array. Within a preset correctable period, the valid data of the pages to be replaced is proactively migrated to a reserved healthy replacement page, and the logical-to-physical address mapping table is updated. By using the number of corrected bit errors for each page to perform a health assessment, and using the health score and the dynamic grading threshold, pages with a bad page trend are identified as pages to be replaced. Proactively migrating the valid data of the pages to be replaced to the reserved healthy replacement page within the correctable period allows for data replacement before bad pages occur, thereby improving the reliability of bad page management.

[0049] It is understood that in the specific implementation of this application, data such as device data, business data, user data, operation behavior data, training data, and test data are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required. Furthermore, the collection, use, and processing of related data, as well as the training, deployment, and invocation of algorithm models, must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0050] Optionally, the step of calculating the health score of each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time includes: calculating a basic health score of each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time; extracting the average number of bit errors, the maximum number of bit errors, and the trend of bit error changes for each page; and adjusting the basic health score based on the trend of changes to obtain the health score of each page.

[0051] In this embodiment of the invention, for each page, the cumulative value of bit errors C (accumulated since the first use or the last replacement) is read from its record; the number of erase / write operations E (the erase / write count of the block to which the page belongs); and the retention time R (the time elapsed since the last write, usually in seconds or hours).

[0052] Because the three indicators have different dimensions and ranges, normalization is required to make their impact on the scores comparable. Normalization can be achieved using: Max-Min Normalization: Alternatively, quantile normalization based on historical distribution can be used; or, clipping normalization can be performed using a pre-defined upper limit threshold. For example, the upper limit for cumulative errors can be set to twice the maximum correctable ECC capability, the upper limit for erase / write cycles can be set to the nominal lifetime in the flash memory specification, and the upper limit for retention time can be set to the maximum time required for data retention.

[0053] Substitute the three normalized indicators into the preset scoring function. After calculation, the baseline health score is retained or converted to a floating-point number or an integer (0-100). The baseline score can be temporarily stored in the page's records or stored together with the final score.

[0054] For each page, after each read operation, the number of bit errors corrected in this operation is recorded. Add to a fixed-length First-In-First-Out (FIFO) queue. Queue length. The value can be set according to system memory and precision requirements; typical values ​​are 10, 32, or 64. Queue Q stores the most recent... The number of read operation errors is the basis for subsequent statistics.

[0055] For all error values ​​in the queue Sum and divide by queue length (If the queue is not full, the actual number will be used for calculation): Average number of bit errors It reflects the recent average degradation level of the page and is not sensitive to random fluctuations.

[0056] Traverse the queue and find the maximum value: Maximum number of bit errors It reflects the worst instantaneous state of the page, which is of great significance for predicting sudden degradation.

[0057] To extract trends, linear regression can be used: Using the read operation sequence number (or timestamp) as the independent variable Number of errors Calculate the regression slope k, where k is the dependent variable: The sign and magnitude of the slope directly indicate the direction and strength of the trend. If... The number of errors increases; if , decrease; if ,smooth.

[0058] Alternatively, the sliding difference method can be used: Calculate the difference between the two most recent error counts, and then average the multiple differences. For example, Divide by the number of intervals.

[0059] Time series models can also be used: For example, use exponential smoothing to predict the next value and compare it with historical averages.

[0060] Map the calculated trend quantification value (such as slope k) to a qualitative type, if And second-order difference (Or a series of consecutive first-order differences increasing) is considered an accelerating upward trend. If Furthermore, since the first-order difference is stable, it is determined to be a uniform upward motion. If However, the first-order difference decreases, indicating a decelerating upward movement. If The condition is determined to be stable. If The result was determined to be a decline.

[0061] in and The preset threshold can be adjusted according to the characteristics of flash memory. Alternatively, a machine learning classifier can be used, taking multiple statistical features (mean, variance, first-order difference mean, second-order difference mean) as input, and outputting the trend type.

[0062] The calculated average number of errors, maximum number of errors, and trend type (or slope value) are stored in the page record for further adjustments.

[0063] Determine the adjustment amount based on the identified trend type. For an accelerating upward trend, this is the most dangerous, indicating a rapid deterioration in page health. A downward adjustment (negative value) should be applied, lowering the health score and causing the page to be marked for replacement earlier. The magnitude of the adjustment can be proportional to the acceleration of the trend (second difference) or the degree to which the current slope exceeds a threshold. For example: ,in This is the proportionality coefficient.

[0064] A steady increase indicates a moderate trend, requiring a moderate reduction in the score. The adjustment can be a small negative value, or no adjustment at all (depending on the system's aggressiveness). For example: ,in The coefficient is less than that under the condition of accelerated rise.

[0065] A decelerating upward trend indicates slower growth and reduced risk. A minor downward adjustment can be applied, or no adjustment may be made. For example, if the deceleration is significant, no adjustment may be necessary.

[0066] "Stable" indicates a stable trend with no additional risk. No adjustments are applied. ).

[0067] A decline indicates a favorable trend, and the page may be recovering (e.g., due to lower temperature or read interference during refresh). An upward adjustment (positive value) should be applied to improve the health score and postpone unnecessary replacements. The adjustment amount should be proportional to the absolute value of the decline slope, but an upper limit should be set to avoid masking fundamental wear and tear. For example: And not exceeding the maximum upward adjustment range (e.g., 5%).

[0068] Add the adjustment amount to the baseline health score. superior: Ensure the final health score The value must fall within a reasonable range (e.g., 0 to 100). If it exceeds the boundary, it is truncated to the boundary value.

[0069] In one possible implementation, to improve the accuracy of the adjustment, a correction based on the average number of errors can be added to the trend adjustment described above: if the average number of errors exceeds a certain high threshold, an additional small downward adjustment is applied even if the trend is stable. If the maximum number of errors approaches the ECC capability threshold, an additional downward adjustment is applied. These auxiliary adjustments can be integrated into the trend adjustment amount or used as independent adjustment items.

[0070] Will This score serves as the page's health rating, used for calculating dynamic grading thresholds and identifying pages to be replaced. The final score can also be stored in the page record for future reference.

[0071] Adjustment coefficient It can adaptively adjust based on system runtime history. For example, if insufficient downward adjustment previously caused uncorrectable errors to appear prematurely on the page, then the adjustment can be improved. If excessive upward adjustment leads to untimely replacement, then the efficiency will be reduced. .

[0072] Optionally, adjusting the basic health score value based on the changing trend to obtain a health score value for each page includes: determining the trend type of the changing trend of the number of bit errors, where the trend type includes accelerating increase, uniform increase, decelerating increase, stable, or decreasing; when the changing trend is accelerating increase, applying a downward adjustment to the basic health score value; when the changing trend is decelerating increase or stable, not applying an adjustment or applying a small downward adjustment; and when the changing trend is decreasing, applying an upward adjustment to the basic health score value.

[0073] In this embodiment of the invention, the most recent error is extracted from the page's historical error queue. The number of bit errors corrected after the next read operation forms an ordered sequence. The subscript indicates the order of read operations. As the earliest, (This is the latest version).

[0074] Calculate the change in the number of errors between two consecutive read operations: First-order difference sequence This reflects the rate of change in the number of errors. If most... A positive value indicates an overall upward trend; a negative value indicates a downward trend; fluctuations around zero indicate stability.

[0075] Based on the first-order difference, calculate the difference between adjacent first-order differences: Second-order difference sequence It reflects the rate of change of the velocity of change (i.e., acceleration). A positive second-order difference indicates that the velocity of change is increasing (accelerating upwards), while a negative second-order difference indicates that the velocity of change is decreasing (decelerating upwards or decelerating downwards).

[0076] Based on the statistical characteristics of the first-order and second-order differences, the trend type is determined according to preset rules.

[0077] Accelerated Ascent: Mean of First Difference (Overall increase); Mean of second difference (The rate of increase accelerates); or, the values ​​of the most recent first differences show an increasing trend (e.g., the last 3 first differences). (Increasing sequentially). Additionally, the slope of the linear regression can be calculated. and quadratic coefficient If quadratic regression In and This was also determined to be an accelerated rise.

[0078] Uniformly increasing: Mean of the first difference The absolute value of the second difference Very small (close to zero), or the standard deviation of the first difference is very small (indicating that the rate of change is basically constant); the sequence grows approximately linearly after noise removal.

[0079] Decelerating Ascent: Mean of First Difference The mean of the second difference (The rate of increase slows down); or, the most recent first-order difference is significantly smaller than the earlier first-order difference.

[0080] Stationarity: The mean of the absolute values ​​of the first-order differences Less than a certain stability threshold (e.g., less than 5% of the maximum number of errors); the difference between the maximum and minimum values ​​of the error sequence is small (e.g., less than 20% of the maximum number of errors); linear regression slope (Absolute value approaches zero).

[0081] Decline: Mean of the first difference (Overall decrease); Second-order differences can be positive or negative, without special restrictions.

[0082] If the sequence length is insufficient (e.g., the newly written page has not yet accumulated enough read operation records), the trend type can be temporarily withheld, and it can be conservatively treated as a stable or uniform increase. If the data noise is too high, causing the type determination to be unstable, a smoothing filter (such as a moving average) can be used before making a determination.

[0083] When the trend type is determined to be "rapid increase," a downward adjustment is applied to the baseline health score. The magnitude of the adjustment should reflect the severity of the acceleration and can be calculated based on the average of the second-order differences or the magnitude of the acceleration. ,in This is a preset scaling factor. Alternatively, a fixed downward adjustment amount (e.g., -10) can be set, or the adjustment can be based on the increase in the most recent differential (e.g., slight acceleration -5, moderate acceleration -10, severe acceleration -15). After adjustment, the final health score should be significantly lower than the base score, causing the page to fall into a lower level in the dynamic grading, thus making it a preferred page for replacement.

[0084] When the trend is determined to be a steady upward trend, you can choose not to apply any adjustment or apply a small downward adjustment. Specifically, choosing a conservative strategy (prioritizing data safety) involves applying a small downward adjustment, for example... ,in A very small positive number (e.g., 1% to 2% of the base score). Alternatively, a balancing strategy: no adjustment is applied. The researchers believe that the uniform rate of increase has already been reflected in the basic score through indicators such as the number of erases and rewrites.

[0085] When the trend type is determined to be a decelerating upward trend, the risk is relatively low because the rate of error growth is slowing down. Typically, no adjustment is applied, or only a very small downward adjustment (or zero) is applied compared to a uniform upward trend. For example, one could set... If the deceleration is very significant (e.g., the second-order difference is a large negative value), it can be ignored and will not lower the score.

[0086] When the trend type is determined to be stable, the page is in a stable state with no additional risk. No adjustments are applied. The final health score is equal to the baseline health score.

[0087] When the trend is determined to be downward, a decrease in the number of errors on the page indicates that its condition has recovered. An upward adjustment should be applied to improve the health score and postpone unnecessary replacements. The magnitude of the adjustment is proportional to the absolute value of the downward slope. in This is a preset proportional coefficient, and the adjusted score should not exceed the maximum value (e.g., 100). To prevent over-optimism, an upper limit can be set for the upward adjustment, such as not exceeding 10% of the base score or an absolute value not exceeding 5 points.

[0088] In one possible implementation, all adjustments should be consistent in scale with respect to the baseline health score. If the baseline score ranges from 0 to 100, the adjustments should also be between -100 and 100. After applying the adjustment, if the final score is below 0, it is set to 0; if it is above 100, it is set to 100. To ensure score stability, the maximum absolute value of a single adjustment can be limited (e.g., not exceeding 15 points).

[0089] Add the baseline health score to the adjustment amount to obtain the final health score: in Determined based on trend type (can be negative, zero, or positive). The final score is used for dynamic grading and page replacement identification.

[0090] In one possible implementation, the trend type, base score, adjustment amount, final score, and adjustment timestamp for each page can be recorded. These logs can help analyze flash memory degradation patterns and adaptively adjust adjustment factors (such as...). , wait).

[0091] Optionally, the dynamic grading threshold is obtained by dynamically grading the health score values ​​of all pages in the array, including: collecting the health score values ​​of all pages in the array, calculating the central tendency statistic and dispersion statistic of the health score values; dynamically dividing the health score value interval into multiple continuous level intervals based on the central tendency statistic and dispersion statistic, and using the boundary value of each level interval as the dynamic grading threshold.

[0092] In this embodiment of the invention, the set of pages covered by this hierarchical classification is first defined as all user pages of the entire flash memory chip, but it can also be limited to a superblock group, channel, or namespace as needed. The entire array range should remain unchanged until the next full array refresh (e.g., triggered by a timer or event).

[0093] Iterate through each page in the entire array and read the current health score value from the page record. If the health score value of some pages has not yet been calculated (e.g., a newly written page), you can temporarily use the default value (such as the highest health score) or trigger a calculation.

[0094] Pages marked as having bad blocks, being unused, or having been erased can be excluded from the statistics or assigned a special health score (such as a maximum value). Exclusion is recommended to avoid affecting the distribution of normal pages.

[0095] Store all collected health score values ​​in an array or list, denoted as . ,in This represents the total number of pages in the array. This array forms the basis for subsequent statistical calculations.

[0096] Based on the system's preset configuration, select one or more central tendency statistics for calculation. The following uses the mean and / or median as examples: Mean (μ): The mean reflects the overall health level. When the distribution of health scores is roughly symmetrical, the mean is considered to be representative.

[0097] Median (M): for an array Sort in ascending order, if If the number is odd, the median is the value at the middle position; if the number is even, the median is the average of the two middle values. The median is not sensitive to outliers (such as extremely low or extremely high scores) and is suitable for situations with a skewed distribution.

[0098] You can choose to use the mean or median as a statistic of central tendency, or you can calculate both for later use.

[0099] Based on the preset configuration, select one or more dispersion statistics. The following uses standard deviation and / or interquartile range as examples: Standard deviation (σ): Standard deviation reflects the average deviation of health scores from the mean. A larger standard deviation indicates more varied page health status; a smaller standard deviation indicates a more consistent overall health level.

[0100] Interquartile Range (IQR): Calculates the 25th percentile. and the 75th percentile ,but The interquartile range is robust to outliers and can reflect the distribution width of the middle 50% of the page.

[0101] The calculated central tendency statistics (such as μ or M) and dispersion statistics (such as σ or IQR) are stored in system variables for further use. These statistics will be recalculated with each dynamic hierarchical update.

[0102] Determine the number of grade ranges It can be a preset fixed value (e.g., 3, 5, 10), or it can be dynamically adjusted according to the number of pages in the entire array or the dispersion of the health score distribution. Typical values ​​are 3 to 5, which are easy to understand intuitively (e.g., danger, warning, normal, good, excellent).

[0103] Lower limit of the effective range The minimum value of the entire array health score can be taken. Or, the absolute lower limit set by the system (e.g., 0). Upper limit Take the maximum value Or, the absolute upper and lower limits set by the system (such as 100). Using absolute upper and lower limits can avoid the grading intervals being too narrow due to extreme values.

[0104] Based on the statistics of central tendency and dispersion, a partitioning method based on the mean and standard deviation can be used (applicable to approximately normal distributions): Assuming that health scores follow a normal distribution (or approximately), the intervals can be divided as follows: Lowest level: below .

[0105] Second lowest level: arrive .

[0106] Intermediate level: arrive .

[0107] Higher level: arrive .

[0108] Highest level: Higher than .

[0109] in For preset coefficients (e.g.) The boundary value obtained in this way is the dynamic grading threshold.

[0110] Alternatively, the division can be based on the median and interquartile range (robust to skewed distributions): Use the median and interquartile range : Lowest level: below .

[0111] Second lowest level: arrive .

[0112] Intermediate level: arrive .

[0113] Second highest level: arrive .

[0114] Highest level: Higher than .

[0115] Alternatively, equal-frequency partitioning (quantile partitioning) can be used: sort all array pages in ascending order of health score, and then divide them into equal parts. The groups are divided into groups, each containing approximately the same number of pages. The dividing point between each group is the dynamic grading threshold. This can be done without relying on distribution assumptions, directly based on the actual distribution density, ensuring a balanced number of pages within each grading interval. Specific steps: right Sorting yields an ordered sequence.

[0116] Calculate the number of pages that each level should contain. .

[0117] Take the first The health score of each page is used as the boundary value.

[0118] Boundary value sequences divide the interval into A continuous interval.

[0119] Alternatively, equal-width partitioning can be used: dividing the effective range Evenly divided into There are three equal-width intervals, each with a width of [missing value]. .

[0120] Of all the rating intervals, the interval corresponding to the lowest health score (i.e., the first interval) is defined as the replacement interval. The upper boundary of this interval... The page to be replaced in claim 1 is identified (pages with a health score below this boundary are considered to be replaced). Other intervals are used for monitoring and classification, but do not directly trigger replacement.

[0121] The calculated boundary values ​​(an increasing sequence) of all level intervals are output as the dynamic grading threshold and stored in the controller's memory for subsequent page replacement identification. For example, for 5 levels, the output... These represent the upper (or lower) boundaries of the levels from lowest to highest. Typically, only the upper boundaries of the replacement interval need to be stored. It can be used for replacement decisions, but storing all the hierarchical thresholds is helpful for statistics and analysis.

[0122] The dynamic grading threshold is not fixed all at once, but needs to be recalculated periodically or triggered by events (such as after a certain amount of time, after a certain number of page replacements, or when a significant change in the health score distribution is detected). The above steps are repeated during updates to achieve dynamic adaptation of the threshold.

[0123] Optionally, determining the page to be replaced based on the health score and a preset dynamic grading threshold includes: identifying the lowest grade interval from the plurality of consecutive grade intervals as the replacement interval; comparing the health score of each page with the upper boundary of the replacement interval; and determining the page whose health score is lower than the upper boundary as the page to be replaced.

[0124] In this embodiment of the invention, the number of grade intervals can be obtained. (e.g., 3, 5, or 10); the sequence of boundary values ​​for each level interval, for example... ,in This is the minimum value (or lower limit of the system) of the health score. This is the maximum value (or the system limit). This represents the internal boundary.

[0125] Therefore, the first Each level range can be represented as (or closed interval, depending on the definition), where The lowest level range, This is the highest level range.

[0126] According to the interval numbering rules, the lowest level interval is... The interval is denoted as: Alternatively, based on the order of health score values, directly select the interval with the smallest left endpoint among all intervals. Pages within this interval have the lowest health score and are closest to failure.

[0127] The lowest-level interval identified is marked as the replacement interval. The upper boundary of this interval... (That is, the first dynamic grading threshold) will serve as the benchmark for subsequent comparisons. The replacement interval can contain zero, one, or more pages (at least one page, unless all pages in the array have identical health scores).

[0128] Replace the upper boundary value of the interval The data is stored in the controller for use in step 5.2. It can also record information such as the number of pages and the width of the interval for monitoring and logging.

[0129] For each page in the entire array (or only traverse the currently active pages to save computational overhead), obtain the final health score for that page. .

[0130] Read (That is, the upper boundary of the lowest level range). Compare the page's health score with the upper boundary of the replacement range: if If so, the page is determined to be below the top boundary. If the value is not lower than the top boundary, then the page is determined to be not lower than the top boundary.

[0131] If the health score is exactly equal to the upper boundary According to the definition of intervals (usually the lowest level interval is left-closed and right-open, that is, it includes the lower boundary but does not include the upper boundary), pages that are equal to the upper boundary belong to the adjacent higher level interval, so they should not be judged as pages to be replaced.

[0132] For all satisfying The page is marked as a page to be replaced. This can be done by setting a flag in the page record or by adding the page address to the replacement queue.

[0133] Collect all marked pages to form a set of pages to be replaced. This set corresponds to all pages within the lowest rating range (it may also include some pages with ratings below the lower boundary, but the lower boundary is usually the minimum value, so the set is equivalent to the entire lowest rating range).

[0134] If the number of pages within the lowest health rating range is too large (e.g., exceeding the system's single migration capacity limit), further filtering can be performed. For example, select only a certain number of pages with the lowest health rating (e.g., the top N); or select only pages with ratings lower than [a certain threshold]. The page (of which) (A small threshold).

[0135] The list of pages to be replaced is passed to the proactive migration step for subsequent data migration and mapping table updates. Simultaneously, information such as the time of the replacement decision, the number of pages replaced, and the average health score can be recorded for system monitoring and adaptive adjustments.

[0136] Optionally, within a preset correctable period, the valid data of the page to be replaced is actively migrated to a reserved healthy replacement page, including: initiating a background migration operation within the preset correctable period; the background migration operation is executed in parallel with the read and write requests of the upper-layer host, and the original page to be replaced remains readable during the migration process; and verification is performed after the data is completely written to the healthy replacement page.

[0137] In this embodiment of the invention, for each page to be replaced, its remedial period is estimated (e.g., 500 remaining safe read operations, or 7 days remaining safe time). The remedial period is stored in the page record or associated with the list of pages to be replaced.

[0138] To ensure the migration is completed within the correctable period, it can be started sufficiently early before the period ends. The most aggressive approach is to start the migration immediately after a page is marked as a replacement page. Alternatively, a start offset can be set based on the length of the correctable period and the estimated migration time: for example, starting the migration just before the correctable period ends (allowing for migration time multiplied by a safety margin). A background scheduler can also be used to process replacement pages in order of priority during idle time, with priority proportional to the urgency of the correctable period (remaining time or remaining reads).

[0139] Trigger a background migration task, which executes in a separate background thread or callback function. The migration task is added to the background job queue, and the scheduler determines when to start execution based on the current host load and migration urgency. Upon startup, record the migration start timestamp and update the page status to "Migration in Progress".

[0140] Background migration operations need to coordinate with host read / write requests. An interrupt-based preemptive scheduling approach can be used, where migration operations run with low priority. When a host request arrives, the migration operation is paused, the host request is processed, and migration resumes upon completion. This ensures that host requests always have priority.

[0141] Alternatively, time-slicing rotation can be used to break the migration operation into multiple small steps (such as reading a portion of a page each time or programming a small piece of data each time), inserting a migration step between each host command.

[0142] Multi-channel parallelism can also be used. If the flash controller has multiple independent channels, the migration operation can be assigned to an idle channel, while the host request uses other channels to achieve parallelism.

[0143] Throughout the migration process, the original page to be replaced cannot be erased, overwritten, or marked as invalid. The migration task only reads the original page data and does not perform any erase or write operations. The mapping table entries of the original page remain unchanged for the time being (still pointing to the original physical address). The status flags of the original page (such as valid / invalid) remain valid. In this way, if the host initiates a read request during the migration process, the system can read the original page data through normal address translation.

[0144] If a write request is made to a logical address being migrated, special handling is required to avoid data inconsistency. Alternatively, new data can be written directly to the new health replacement page (instead of the original page), updating the mapping table, while canceling or adjusting the current migration task. Or, write requests can be allowed to overwrite data on the original page, but the migration task should detect the data change and reread the latest data.

[0145] In one possible implementation, when the target logical address of the host write request is detected to be the same as the address being migrated, the current migration task is immediately aborted, the host data is written to the reserved healthy replacement page, the mapping table is updated, the original page is marked as invalid, and then the migration is reassessed (in fact, the newly written page may be in good health and does not need to be migrated).

[0146] The background migration task completely reads the data from the original page to be replaced and then writes it to the healthy replacement page allocated from the reservation pool. The write operation uses NAND flash memory programming commands to ensure data alignment along page boundaries. If the data in the original page spans multiple logical sectors, it needs to be copied sector by sector or the entire page at once.

[0147] After writing is complete, verification is performed to ensure the data is error-free. The data just written can be read from the health replacement page and compared byte-by-byte with the original page data (or a copy stored in the buffer). If they are completely identical, verification passes. Alternatively, the health replacement page can be read to check if the ECC module reports any errors. If there are no errors or the errors are within correctable limits, the data is considered valid. The programming status returned by the flash memory chip can also be read to confirm the absence of programming failure flags (such as write error bits). Furthermore, the checksum of the original data (such as CRC32) can be pre-calculated, and after writing, the checksum can be calculated by reading the new page data; if they match, the verification passes.

[0148] If validation fails (e.g., due to data inconsistency or programming errors), it indicates a potential problem with the healthy replacement page (such as bad blocks). In this case, the currently used healthy replacement page can be released (either marked as bad blocks or re-added to the reserve pool's list of pages to be checked). Another healthy replacement page can then be reassigned from the reserve pool.

[0149] If the retries fail multiple times (e.g., 3 times), an error should be reported, and other error recovery strategies (such as using RAID or backup) should be considered.

[0150] After successful verification, confirming that the data has been correctly written to the healthy replacement page, the logical-to-physical address mapping table is updated, mapping the original logical address to the physical address of the new healthy replacement page. The original page to be replaced is marked as invalid or awaiting reclamation and will no longer be used for read operations (but can be retained for debugging). The information of the original page to be replaced (if it belongs to a reclaimable block) is recorded in the garbage collection queue. The migration task status is updated to complete, and the migration time and verification results are recorded.

[0151] After the migration is complete, release the temporary buffer resources occupied by the migration task. Simultaneously, remove the healthy replacement page from the reservation pool (as it has already been used), and replenish the reserved pages as needed (e.g., erase and initialize new reserved pages from the free block). Finally, update the system log to record this migration event for subsequent analysis and performance optimization.

[0152] Optionally, before actively migrating the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, the method further includes: obtaining the maximum correctable capability threshold of the error correction coding of the current page; calculating the growth trend of the number of bit errors based on the historical data of the number of bit errors of the page; predicting whether the number of bit errors of the page will exceed the maximum correctable capability threshold within a predetermined number of read operations based on the growth trend; and determining the time interval or the interval of the number of read operations predicted to not exceed the maximum correctable capability threshold as the correctable period; wherein, the upper limit of the correctable period is constrained by the error tolerance margin implied by the health score value corresponding to the upper boundary of the replacement interval in the dynamic grading threshold.

[0153] If dynamic ECC is supported (e.g., using lower-strength ECC early in the page lifecycle to improve performance and switching to higher-strength ECC later), then the currently effective threshold needs to be obtained. Typically, the ECC capability threshold for each page is fixed, determined by factory configuration or wear leveling strategy.

[0154] Get Stored in page records or cached in memory for later prediction.

[0155] Read the most recent errors from the page's history error queue. The number of bit errors corrected after the next read operation forms an ordered sequence. The subscript indicates the order of read operations. (To be up-to-date). Ensure the sequence length is sufficient (e.g., ...). Otherwise, no prediction will be made for the time being, and a conservative estimate will be adopted (such as setting the correctable period to the minimum value).

[0156] Based on the typical variation pattern of the number of errors with the number of read operations, a mathematical model is selected to fit the growth trend. Possible models include: Linear model: ,in Counts read operations.

[0157] Exponential model: (Applicable to accelerated degradation).

[0158] Power-law model: .

[0159] The choice of model can be dynamically determined based on the characteristics of historical data (such as first-order difference and second-order difference), or a linear model can be used to simplify calculations.

[0160] Using least squares or other regression methods, the historical sequence is fitted to a selected model to obtain the model parameters. For example, for a linear model, the slope is calculated. and intercept : in For the first The sequence number of the read operation (or the cumulative number of reads).

[0161] Growth trends can be represented by slope The error increment per unit of read operation can be expressed as the error growth rate per unit of time (if time is the horizontal axis).

[0162] Set a prediction window size (A predetermined number of read operations), for example Or it can be set according to system policy. It can be a fixed value, or it can be based on the current number of errors on the page. Dynamic distance adjustment: the smaller the distance, The smaller it should be.

[0163] Take the latest value from the historical sequence Based on the selected growth model, it is predicted that in The number of errors after the first read operation. The possible growth models are as follows: Linear model: ,in It represents the cumulative number of read operations since the last read operation.

[0164] Exponential model: .

[0165] Predicted values With ECC maximum correctable capability threshold If a comparison is made, Then the prediction is in The threshold will not be exceeded during the next read operation. If If so, the prediction will exceed the threshold.

[0166] To find the precise correctable period, a binary search or a method of progressively increasing the window can be used to find the period that satisfies the condition. The largest The largest This is the correctable period (in terms of the number of read operations).

[0167] You can choose to use either the number of read operations or the actual time as the unit. If you choose the number of read operations, the maximum safe window obtained will be used directly. If the unit is time, then the number of read operations needs to be converted into time, which requires knowing the average read access frequency of the page (which can be obtained by statistically analyzing historical read intervals).

[0168] If based on time The unit is [unit], and the average read operation interval of the page is [statistic]. ,but Alternatively, predictions can be made directly based on a time series fitting model (with time as the horizontal axis).

[0169] The calculated or The correctable period for this page is stored in the page record for use in migration scheduling. If the threshold may be exceeded within the prediction window, the correctable period is less than [a certain value]. If even an infinite number of read operations will not exceed the limit (e.g., error saturation), then the correctable period can be set to a maximum value (e.g., a system-defined upper limit).

[0170] Since prediction models contain errors, a safety factor can be introduced. (e.g., 0.7), shortening the correctable period to To allow for a safety margin.

[0171] Get the upper boundary of the replacement interval Using health scoring functions The inverse function (or approximate model) estimates when the health score equals At that time, the corresponding number of bit errors Since the health score is also affected by the number of erase / write cycles and retention time, we can simplify by assuming other parameters remain constant and only considering the number of errors. A more accurate method is to use an empirical formula: In fact, a table can be pre-defined through experiments: for a given number of erase / write cycles and retention time interval, the range of error counts corresponding to different health score values.

[0172] The number of errors on the current page is Then the error tolerance margin for: if It is already greater than If the remainder is negative, the page should already be in the replacement range.

[0173] Error tolerance margin An absolute safety limit is given, which cannot be exceeded even if errors grow at the fastest rate. Therefore, the correctable period forecast value Should meet: in This represents the maximum possible rate of error growth (such as the historical maximum slope or the physical limit). In practical implementations, the predicted rate can be directly constrained. No more than according to And the upper limit calculated from the typical slope. Another way is to use... As an alternative threshold for prediction, i.e., using As an upper limit for comparison. Because... The corresponding number of errors is usually less than (Because replacement is triggered before it becomes uncorrectable), the replacement interval boundary is actually used as a stricter constraint to ensure that the page is migrated before the health score drops below the replacement interval.

[0174] The correctable period will be obtained The smaller of the two constraints is used as the final correctable period. If the constraint limit is less than zero, migration is triggered immediately (correctable period is zero).

[0175] like Figure 2 As shown, this embodiment of the invention provides a page replacement device for NAND flash memory, the page replacement device for NAND flash memory comprising: The first acquisition module 201 is used to acquire the number of corrected bit errors for each page in each read operation, and maintain a record for each page containing the cumulative value of the number of bit errors, the number of erase / write operations, and the retention time. The first processing module 202 is used to calculate a health score value for each page based on the cumulative value of bit errors, the number of erase / write cycles, and the retention time. The second processing module 203 is used to determine the page to be replaced based on the health score value and the preset dynamic grading threshold, wherein the dynamic grading threshold is obtained by dynamically grading the health score values ​​of the entire array of pages. The page replacement module 204 is used to actively migrate the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, and update the logical to physical address mapping table.

[0176] Optionally, the first processing module 202 is further configured to calculate a basic health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time; extract the average number of bit errors, the maximum number of bit errors, and the trend of bit error changes for each page; and adjust the basic health score based on the trend of changes to obtain a health score for each page.

[0177] Optionally, the first processing module 202 is further configured to determine the trend type of the changing trend of the number of bit errors, wherein the trend type includes accelerating increase, uniform increase, decelerating increase, stable or decreasing; when the changing trend is accelerating increase, a downward adjustment is applied to the basic health score value; when the changing trend is decelerating increase or stable, no adjustment is applied or a small downward adjustment is applied; when the changing trend is decreasing, an upward adjustment is applied to the basic health score value.

[0178] Optionally, the dynamic grading threshold is obtained by dynamically grading the health score values ​​of all pages in the array, including: collecting the health score values ​​of all pages in the array, calculating the central tendency statistic and dispersion statistic of the health score values; dynamically dividing the health score value interval into multiple continuous level intervals based on the central tendency statistic and dispersion statistic, and using the boundary value of each level interval as the dynamic grading threshold.

[0179] Optionally, the second processing module 203 is further configured to identify the lowest level interval from the plurality of consecutive level intervals as a replacement interval; compare the health score value of each page with the upper boundary of the replacement interval; and determine the page whose health score value is lower than the upper boundary as the page to be replaced.

[0180] Optionally, the page replacement module 204 is also used to initiate a background migration operation within a preset correctable period; the background migration operation is executed in parallel with the read and write requests of the upper-layer host, and the original page to be replaced remains readable during the migration process; verification is performed after the data is completely written to the healthy replacement page.

[0181] Optionally, the device further includes: The second acquisition module is used to acquire the maximum correctable threshold of the error correction coding of the current page; The third processing module is used to calculate the growth trend of the number of bit errors based on the historical data of the number of bit errors on this page. The prediction module is used to predict, based on the growth trend, whether the number of bit errors in the page within a predetermined number of read operations in the future will exceed the maximum correctable capability threshold. The fourth processing module is used to determine the correctable period as the time interval or the interval of read operation counts predicted to be no more than the maximum correctable capability threshold. The upper limit of the correctable period is constrained by the error tolerance margin implied by the health score value corresponding to the upper boundary of the replacement interval in the dynamic grading threshold.

[0182] like Figure 3 As shown, embodiments of the present invention also provide an electronic device, including a processor, which can execute any of the above-described facility detection methods based on UAV infrared imaging.

[0183] Specifically, it includes a processor 301 and a memory 302, as well as a computer program stored on the memory 302 and capable of running on the processor 301, which performs a page replacement method for NAND flash memory, wherein: The processor 301 executes a calculator program for the page replacement method of the NAND flash memory stored in the memory 302, performing the following steps: Get the corrected bit error count for each page in each read operation, and maintain a record for each page containing the cumulative bit error count, number of erase / write cycles, and retention time; Calculate a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. Based on the health score and the preset dynamic grading threshold, the page to be replaced is determined. The dynamic grading threshold is obtained by dynamically grading the health score of all pages in the array. Within a preset correctable period, the valid data of the page to be replaced is actively migrated to the reserved healthy replacement page, and the logical-to-physical address mapping table is updated.

[0184] Optionally, the processor 301 performs the calculation of a health score value for each page based on the cumulative value of the number of bit errors, the number of erase / write cycles, and the retention time, including: Calculate a basic health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. Extract the average number of bit errors, the maximum number of bit errors, and the trend of bit error count for each page; The basic health score is adjusted based on the changing trend to obtain the health score for each page.

[0185] Optionally, the processor 301 performs the adjustment of the basic health score value based on the changing trend to obtain a health score value for each page, including: Determine the trend type of the changing trend of the number of bit errors, where the trend type includes accelerating increase, uniform increase, decelerating increase, stable or decreasing; When the trend of change is accelerating upward, a downward adjustment is applied to the baseline health score; When the trend is decelerating upward or stable, no adjustment is applied or only a small downward adjustment is applied; When the trend is downward, an upward adjustment is applied to the baseline health score.

[0186] Optionally, the dynamic grading threshold executed by processor 301 is obtained by dynamically grading based on the health score values ​​of the entire array of pages, including: Collect the health score values ​​of all pages in the entire array, and calculate the central tendency statistic and dispersion statistic of the health score values; Based on the central tendency statistic and dispersion statistic, the health score range is dynamically divided into multiple continuous level ranges, and the boundary value of each level range is used as the dynamic grading threshold.

[0187] Optionally, the processor 301 performs the process of determining the page to be replaced based on the health score and a preset dynamic grading threshold, including: The lowest level interval is identified from the plurality of consecutive level intervals as the replacement interval; Compare the health score of each page with the upper boundary of the replacement interval; Pages with a health score below the upper boundary are identified as pages to be replaced.

[0188] Optionally, the processor 301 performs the action of actively migrating the valid data of the page to be replaced to a reserved healthy replacement page within a preset correctable period, including: Initiate the background migration operation within the preset correctable period; The background migration operation is executed in parallel with the read and write requests of the upper-layer host, and the original page to be replaced remains readable during the migration process. Verification will be performed after all data has been written to the health replacement page.

[0189] Optionally, before actively migrating the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, the method executed by the processor 301 further includes: Get the maximum correctable threshold of the error correction coding for the current page; Calculate the growth trend of the number of bit errors based on the historical data of the number of bit errors on this page; Based on the growth trend, predict whether the number of bit errors in the page within a predetermined number of read operations in the future exceeds the maximum correctable capability threshold; The time interval or the number of read operations predicted to be no more than the maximum correctable capability threshold is determined as the correctable period; The upper limit of the correctable period is constrained by the error tolerance margin implied by the health score value corresponding to the upper boundary of the replacement interval in the dynamic grading threshold.

[0190] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the NAND flash memory page replacement method provided in this invention and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0191] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0192] The above description discloses only preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. Therefore, equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.

Claims

1. A method for page replacement in NAND flash memory, characterized in that, The page replacement method for the NAND flash memory includes the following steps: Get the corrected bit error count for each page in each read operation, and maintain a record for each page containing the cumulative bit error count, number of erase / write cycles, and retention time; Calculate a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. Based on the health score and the preset dynamic grading threshold, the page to be replaced is determined. The dynamic grading threshold is obtained by dynamically grading the health score of all pages in the array. Within a preset correctable period, the valid data of the page to be replaced is actively migrated to the reserved healthy replacement page, and the logical-to-physical address mapping table is updated.

2. The page replacement method for NAND flash memory as described in claim 1, characterized in that, The calculation of a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time includes: Calculate a basic health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. Extract the average number of bit errors, the maximum number of bit errors, and the trend of bit error count for each page; The basic health score is adjusted based on the changing trend to obtain the health score for each page.

3. The page replacement method for NAND flash memory as described in claim 2, characterized in that, The process of adjusting the basic health score value based on the changing trend to obtain a health score value for each page includes: Determine the trend type of the changing trend of the number of bit errors, where the trend type includes accelerating increase, uniform increase, decelerating increase, stable or decreasing; When the trend of change is accelerating upward, a downward adjustment is applied to the baseline health score; When the trend is decelerating upward or stable, no adjustment is applied or only a small downward adjustment is applied; When the trend is downward, an upward adjustment is applied to the baseline health score.

4. The page replacement method for NAND flash memory as described in claim 1, characterized in that, The dynamic grading threshold is obtained by dynamically grading the health score of the entire array of pages, including: Collect the health score values ​​of all pages in the entire array, and calculate the central tendency statistic and dispersion statistic of the health score values; Based on the central tendency statistic and dispersion statistic, the health score range is dynamically divided into multiple continuous level ranges, and the boundary value of each level range is used as the dynamic grading threshold.

5. The page replacement method for NAND flash memory as described in claim 4, characterized in that, The process of determining the page to be replaced based on the health score and a preset dynamic grading threshold includes: The lowest level interval is identified from the plurality of consecutive level intervals as the replacement interval; Compare the health score of each page with the upper boundary of the replacement interval; Pages with a health score below the upper boundary are identified as pages to be replaced.

6. The page replacement method for NAND flash memory as described in any one of claims 1 to 5, characterized in that, Actively migrate the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, including: Initiate the background migration operation within the preset correctable period; The background migration operation is executed in parallel with the read and write requests of the upper-layer host, and the original page to be replaced remains readable during the migration process. Verification will be performed after all data has been written to the health replacement page.

7. The page replacement method for NAND flash memory as described in any one of claims 1 to 5, characterized in that, Before actively migrating the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, the method further includes: Get the maximum correctable threshold of the error correction coding for the current page; Calculate the growth trend of the number of bit errors based on the historical data of the number of bit errors on this page; Based on the growth trend, predict whether the number of bit errors in the page within a predetermined number of read operations in the future exceeds the maximum correctable capability threshold; The time interval or the number of read operations predicted to be no more than the maximum correctable capability threshold is determined as the correctable period; The upper limit of the correctable period is constrained by the error tolerance margin implied by the health score value corresponding to the upper boundary of the replacement interval in the dynamic grading threshold.

8. A page replacement device for NAND flash memory, characterized in that, The page replacement device for the NAND flash memory includes: The first acquisition module is used to acquire the number of corrected bit errors for each page in each read operation, and maintain a record for each page containing the cumulative number of bit errors, the number of erase / write operations, and the retention time. The first processing module is used to calculate a health score for each page based on the cumulative number of bit errors, the number of erase / write cycles, and the retention time. The second processing module is used to determine the page to be replaced based on the health score value and the preset dynamic grading threshold. The dynamic grading threshold is obtained by dynamically grading the health score values ​​of all pages in the array. The page replacement module is used to actively migrate the valid data of the page to be replaced to the reserved healthy replacement page within a preset correctable period, and update the logical to physical address mapping table.

9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the page replacement method for NAND flash memory as claimed in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the page replacement method for NAND flash memory as described in any one of claims 1 to 7.