A memory block data write method, device and memory controller

CN116450033BActive Publication Date: 2026-10-30WUHAN UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310083951.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-14
Publication Date
2026-10-30
Estimated Expiration
2043-01-14

AI Technical Summary

Benefits of technology

[0042]与现有技术相比,本发明提供的存储器块数据写入方法、装置和存储器控制器,首先对存储器内存块进行区域划分,获得多个存储子区域;然后获取待写入压缩数据,随后根据所述待写入压缩数据的数据量与多个存储子区域的剩余空间的大小关系、以及所述数据量与预设的阈值之间的大小关系,确定所述待写入压缩数据的数据放置策略;最后根据所述数据放置策略,将所述待写入压缩数据写入所述存储器内存块对应的区域中。本发明考虑待写入压缩数据与存储器剩余空间的大小及剩余空间所在区域位置,通过数据放置策略将待写入压缩数据写入存储器块内不同的区域,缓解了局部磨损现象,延长了存储器寿命。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116450033B_ABST
    Figure CN116450033B_ABST
Patent Text Reader

Abstract

The application discloses a memory block data writing method and device and a memory controller. The method comprises the following steps: dividing a memory block into multiple sub-regions; obtaining to-be-written compressed data; determining a data placement strategy of the to-be-written compressed data according to the size relationship between the data amount of the to-be-written compressed data and the residual space of the multiple sub-regions and the size relationship between the data amount and a preset threshold; and writing the to-be-written compressed data into the corresponding region of the memory block according to the data placement strategy. The application solves the technical problem that the data writing of the memory block is concentrated in one place, which causes local wear of the memory block and affects the service life of the memory block.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of non-volatile storage technology, and more specifically to a method, apparatus and memory controller for writing data to a memory block. Background Technology

[0002] Due to their non-volatile and large-capacity characteristics, NVM (Non-Volatile Memory) devices have been increasingly deployed on various levels of memory, including main memory and cache. However, their limited lifespan remains a major issue for large-scale data centers. Existing technologies can extend NVM lifespan by reducing write operations or bit flips to decrease write volume or by using compression algorithms to save NVM space. To comprehensively investigate the impact of compression on NVM performance, preliminary experimental studies were conducted on bit flips involved in several typical compression algorithms. Analysis revealed that because compressed data is typically stored in a fixed shrinkage area, more bit flips usually occur in the compressed region of the memory block. This leads to uneven wear within the block, i.e., localized wear, which significantly reduces NVM lifespan.

[0003] Since an entire memory block is considered damaged once the wear at any single location reaches its limit, many locations within the block may not yet have reached their wear limits, meaning a significant portion of the block's capacity remains unused. Current wear leveling algorithms that rely on flipping write locations cannot effectively handle the wear leveling of overlapping portions after writes to the beginning and end of the memory. Therefore, it is necessary to extend block lifespan by reducing localized wear, allowing the memory to provide its full capacity for a longer period. Summary of the Invention

[0004] The purpose of this invention is to overcome the above-mentioned technical deficiencies and provide a memory block data writing method, apparatus and memory controller to solve the technical problem in the prior art where the data writing of memory blocks is concentrated in one place, resulting in local wear of the memory block and thus affecting the service life of the memory block.

[0005] To achieve the above-mentioned technical objectives, the present invention adopts the following technical solution:

[0006] In a first aspect, the present invention provides a method for writing data to a memory block, comprising:

[0007] The memory block is divided into regions to obtain multiple storage sub-regions;

[0008] Get the compressed data to be written;

[0009] Based on the relationship between the amount of compressed data to be written and the remaining space of multiple storage sub-regions, and the relationship between the amount of data and a preset threshold, the data placement strategy for the compressed data to be written is determined.

[0010] According to the data placement strategy, the compressed data to be written is written to the area corresponding to the memory block of the memory.

[0011] In some embodiments, obtaining multiple storage sub-regions includes:

[0012] Based on the data writing granularity, the memory block of the memory is divided into multiple storage sub-regions of equal size.

[0013] In some embodiments, the data placement strategy includes:

[0014] Determine the relationship between the amount of data to be written for compression and the preset threshold.

[0015] If the amount of data is greater than the threshold, the compressed data to be written is written to the memory at a preset initial writing position.

[0016] If the amount of data is less than the threshold, then determine the relationship between the amount of data and the remaining space of the multiple storage sub-regions;

[0017] If the amount of data is less than the remaining space, the compressed data to be written will be directly written to the memory.

[0018] If the amount of data is greater than the remaining space, the compressed data to be written will be written to the memory starting from the location of the remaining space.

[0019] In some embodiments, after determining the data placement strategy for the compressed data to be written, the method further includes tag management of the compressed data to be written according to the data placement strategy, wherein the tag management includes:

[0020] The encoded information of the data to be written to the compression system is marked to obtain encoded tags;

[0021] The starting position of the compressed data to be written to storage is marked to obtain the starting address label;

[0022] The end position of the compressed data to be written to storage is marked to obtain the end address label;

[0023] According to the data placement strategy, a preset counter is used to count and statistically analyze different placement strategies to obtain statistical results, and the placement position when writing data is adjusted according to the statistical results.

[0024] In some embodiments, the determination of the relationship between the amount of data to be written and the preset threshold is performed. If the amount of data is zero, the corresponding label of the data to be written is updated.

[0025] In some embodiments, the step of tagging the compressed data to be written according to the data placement strategy includes:

[0026] When the data placement strategy is to write the compressed data to be written to the memory at a preset initial write position, the start address label is the end position of the previous compressed data, and the end address label is the region where the end of the compressed data to be written is located.

[0027] When the data placement strategy is to write the compressed data to be written to the memory starting from the location of the remaining space, the starting address label is the difference between the data writing granularity and the data volume, and the ending address label is the high address of the memory;

[0028] When the data placement strategy is to update the corresponding label of the compressed data to be written, the start address label and the end address label are both the end position of the previous compressed data.

[0029] In some embodiments, the step of using a preset counter to count and statistically analyze different placement strategies according to the data placement strategy, and obtaining statistical results, includes:

[0030] If the amount of data is less than the threshold, then determine whether the preset counter has reached the counting threshold;

[0031] If the counting threshold is reached, the compressed data to be written is written into a location in the memory that can accommodate the compressed data to be written.

[0032] In some embodiments, after tagging the compressed data to be written, the tag and address corresponding to the written data are identified, and the written data is identified.

[0033] Secondly, the present invention also provides a memory block data writing device, comprising:

[0034] The region partitioning module is used to partition the memory blocks of the storage device into multiple storage sub-regions;

[0035] The acquisition module is used to acquire the compressed data to be written.

[0036] The placement strategy determination module is used to determine the data placement strategy of the compressed data to be written based on the relationship between the amount of data to be written and the remaining space of multiple storage sub-regions, and the relationship between the amount of data and a preset threshold.

[0037] The writing module is used to write the compressed data to be written into the area corresponding to the memory block of the memory according to the data placement strategy.

[0038] Thirdly, the present invention also provides a memory controller for writing data into the storage space of a non-volatile memory, the memory controller comprising: a cache interface, a memory interface, and a memory management circuit;

[0039] The cache interface is used for electrical connection to the last-level cache;

[0040] The memory interface is used for electrical connection to the non-volatile memory;

[0041] The memory management circuit is electrically connected to the cache interface and the memory interface. When the memory management circuit is executed, it implements the steps in the memory block data writing method described above.

[0042] Compared with existing technologies, the memory block data writing method, apparatus, and memory controller provided by this invention first divide the memory block into regions to obtain multiple storage sub-regions; then, it acquires the compressed data to be written; subsequently, based on the relationship between the amount of the compressed data to be written and the remaining space in the multiple storage sub-regions, and the relationship between the amount of data and a preset threshold, it determines a data placement strategy for the compressed data to be written; finally, according to the data placement strategy, it writes the compressed data to be written into the corresponding region of the memory block. This invention considers the size of the compressed data to be written and the remaining space in the memory, as well as the location of the remaining space, and writes the compressed data to be written into different regions within the memory block through a data placement strategy, thereby mitigating local wear and extending the memory's lifespan. Attached Figure Description

[0043] Figure 1 This is a flowchart of an embodiment of the memory block data writing method provided by the present invention;

[0044] Figure 2 This is a flowchart of an embodiment of step S103 in the memory block data writing method provided by the present invention;

[0045] Figure 3 This is a flowchart of an embodiment of the application of the counter and placement strategy in the memory block data writing method provided by the present invention;

[0046] Figure 4 This is a schematic diagram of an embodiment of the memory block data writing device provided by the present invention. Detailed Implementation

[0047] 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.

[0048] The methods, apparatus, and memory controllers involved in this invention are used to write data into the storage space of non-volatile memory. Figure 1 A memory block data writing method provided in this embodiment of the invention includes:

[0049] S101. Divide the memory block into regions to obtain multiple storage sub-regions;

[0050] S102. Obtain the compressed data to be written;

[0051] S103. Determine the data placement strategy for the compressed data to be written based on the relationship between the amount of data to be written and the remaining space of multiple storage sub-regions, and the relationship between the amount of data and a preset threshold.

[0052] S104. According to the data placement strategy, the compressed data to be written is written to the area corresponding to the memory block of the memory.

[0053] In this embodiment, the memory block is first divided into regions to obtain multiple storage sub-regions. Then, compressed data to be written is acquired. Subsequently, based on the relationship between the amount of compressed data to be written and the remaining space in the multiple storage sub-regions, as well as the relationship between the amount of data and a preset threshold, a data placement strategy for the compressed data to be written is determined. Finally, according to the data placement strategy, the compressed data to be written is written to the corresponding region of the memory block. This invention considers the size of the compressed data to be written and the remaining space in the memory, as well as the location of the remaining space. By using a data placement strategy to write the compressed data to be written to different regions within the memory block, it alleviates local wear and extends the memory's lifespan.

[0054] It should be noted that the memory involved in the embodiments of the present invention is an NVM memory. During the data writing process, the data is first compressed in the compression engine to form compressed data, then the data placement strategy determines how to place the data, and finally the data is sent to the write buffer and the NVM array to complete the write operation.

[0055] In some embodiments, obtaining multiple storage sub-regions includes:

[0056] Based on the data writing granularity, the memory block of the memory is divided into multiple storage sub-regions of equal size.

[0057] In this embodiment, the data is divided into equally sized regions. The storage location of the compressed data to be written is determined by the remaining storage in each region. Specifically, the number of regions depends on the granularity of the write operation and can be adjusted according to the required write size.

[0058] In one specific embodiment, if the granularity is 4, the physical memory block is divided into 4 regions. Assuming the address range of the memory block to be written is from "0x00000000" to "0x00000040" (64 bytes), then the size of each region is 16 bytes. The logical numbers of the four regions are denoted as "00", "01", "10", and "11", respectively.

[0059] In some embodiments, please refer to Figure 2 The data placement strategy includes:

[0060] S201. Determine the relationship between the amount of data to be written and the preset threshold.

[0061] S202. If the amount of data is greater than the threshold, the compressed data to be written is written to the memory at a preset initial writing position.

[0062] S203. If the amount of data is less than the threshold, then determine the relationship between the amount of data and the remaining space of the multiple storage sub-regions;

[0063] S204. If the amount of data is less than the remaining space, the compressed data to be written is directly written into the memory.

[0064] S205. If the amount of data is greater than the remaining space, the compressed data to be written is written to the memory starting from the location of the remaining space.

[0065] In this embodiment, the compression engine provides the compressed data size and compares the data to be written with the remaining memory space. The remaining space is calculated by subtracting the end position of the data from the granularity, and then multiplying the result by the region size. The region size is calculated by dividing the memory block size by the granularity. Shift operations can replace multiplication and division operations.

[0066] It should be noted that the amount of data to be written to the compressed data is specifically the ratio of the actual size of the compressed data to be written to the size of the storage sub-region, and the threshold is the storage sub-region block size * (granularity - 1) / granularity.

[0067] In some embodiments, after determining the data placement strategy for the compressed data to be written, the method further includes tag management of the compressed data to be written according to the data placement strategy, wherein the tag management includes:

[0068] The encoded information of the data to be written to the compression system is marked to obtain encoded tags;

[0069] The starting position of the compressed data to be written to storage is marked to obtain the starting address label;

[0070] The end position of the compressed data to be written to storage is marked to obtain the end address label;

[0071] According to the data placement strategy, a preset counter is used to count and statistically analyze different placement strategies to obtain statistical results, and the placement position when writing data is adjusted according to the statistical results.

[0072] In this embodiment, various states of compressed data are set through tag management, and encoded tags, start address tags, end address tags, and counters are used to indicate the writing of compressed data and assist in reading and writing.

[0073] Specifically, the counter always uses 2 bits, and the value is set according to the situation. The `encode_tag` also always occupies 2 bits. The number of bits for `addr_tag` (start address tag) and `end_tag` (end address tag) depends on the granularity of `SlidW`. For cases with four regions, `addr_tag` and `end_tag` each occupy 2 bits. The modified tag information will be passed to the data placement module. During the condition check, it will determine whether the data is compressed based on the size of the written data. If the data is not compressed, i.e., the written data is 64 bytes, `encode_tag` is set to 00; otherwise, it is set to 01.

[0074] Furthermore, data placement is determined by the `addr_tag` and `encode_tag` calculated by tag management. When the encoding tag is set to 11, data is written backwards from the end of the memory block, meaning the first byte of data is written to the last byte of the memory block, and then data is written sequentially to the beginning bytes of the memory block until the data writing is complete. The leftmost bytes of the memory block do not need to be written. When the encoding tag is 10, this writing is simply skipped. When the encoding tag is 00 or 01, there are four states for `addr_tag` when there are four regions in the memory block. For state "00", new data is written from the beginning of the memory block. For the other three states, SlidW rotates the written data to the corresponding region of the memory block. When the write position is not between `addr_tag` and `end_tag`, the cell writing is skipped. Once the data position is determined, it is sent to the write buffer along with the tag information.

[0075] In some embodiments, the determination of the relationship between the amount of data to be written and the preset threshold is performed. If the amount of data is zero, the corresponding label of the data to be written is updated.

[0076] In this embodiment, when the amount of compressed data to be written is zero, it indicates that the data is empty, and the corresponding tag can be updated.

[0077] In some embodiments, the step of tagging the compressed data to be written according to the data placement strategy includes:

[0078] When the data placement strategy is to write the compressed data to be written to the memory at a preset initial write position, the start address label is the end position of the previous compressed data, and the end address label is the region where the end of the compressed data to be written is located.

[0079] When the data placement strategy is to write the compressed data to be written to the memory starting from the location of the remaining space, the starting address label is the difference between the data writing granularity and the data volume, and the ending address label is the high address of the memory;

[0080] When the data placement strategy is to update the corresponding label of the compressed data to be written, the start address label and the end address label are both the end position of the previous compressed data.

[0081] In this embodiment, different data placement strategies correspond to different tag information.

[0082] It should be noted that during the reading process, the memory controller first reads the data along with the tag. In the tag management mode, it identifies the address and tag information of the data, reorganizes the data, and then sends it to the decompression engine to restore the data and complete the reading.

[0083] In some embodiments, please refer to Figure 3 The step of using a preset counter to count and statistically analyze different placement strategies according to the data placement strategy, and obtaining statistical results, includes:

[0084] S301. If the amount of data is less than the threshold, then determine whether the preset counter has reached the counting threshold.

[0085] S302. If the counting threshold is reached, the compressed data to be written is written into a location in the memory that can accommodate the compressed data to be written.

[0086] In this embodiment, if the counter count threshold is set to 3, after the number of forward writes to the memory reaches 3, the next write will be performed from the reverse write to the memory. Each time a reverse write is performed, the counter count is decremented by 1.

[0087] In some embodiments, after tagging the compressed data to be written, the tag and address corresponding to the written data are identified, and the written data is identified.

[0088] In this embodiment, the storage information of the data written to the memory can be located through the tag, thereby realizing the reading of the data.

[0089] Based on the above-described memory block data writing method, this embodiment of the invention also provides a memory block data writing device 400. Please refer to [link to relevant documentation]. Figure 4 The memory block data writing device includes a region partitioning module 410, an acquisition module 420, a placement strategy determination module 430, and a writing module 440.

[0090] The region partitioning module 410 is used to partition the memory block of the memory to obtain multiple storage sub-regions;

[0091] Module 420 is used to acquire the compressed data to be written;

[0092] The placement strategy determination module 430 is used to determine the data placement strategy of the compressed data to be written based on the relationship between the amount of data to be written and the remaining space of multiple storage sub-regions, and the relationship between the amount of data and a preset threshold.

[0093] The writing module 440 is used to write the compressed data to be written into the area corresponding to the memory block of the memory according to the data placement strategy.

[0094] Based on the above memory block data writing method, the present invention also provides a memory controller for writing data into the storage space of a non-volatile memory, the memory controller comprising: a cache interface, a memory interface, and a memory management circuit;

[0095] The cache interface is used for electrical connection to the last-level cache;

[0096] The memory interface is used for electrical connection to the non-volatile memory;

[0097] The memory management circuit is electrically connected to the cache interface and the memory interface. When the memory management circuit is executed, it implements the steps in the memory block data writing method described above.

[0098] The specific embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention. Any other corresponding changes and modifications made in accordance with the technical concept of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for writing data to a memory block, used to write data into the storage space of a non-volatile memory, characterized in that, The writing method includes: The memory block is divided into regions to obtain multiple storage sub-regions; Get the compressed data to be written; Based on the relationship between the amount of compressed data to be written and the remaining space of multiple storage sub-regions, and the relationship between the amount of data and a preset threshold, the data placement strategy for the compressed data to be written is determined. The data placement strategy includes: Determine the relationship between the amount of data to be written for compression and the preset threshold. If the amount of data is greater than the threshold, the compressed data to be written is written to the memory at a preset initial writing position. If the amount of data is less than the threshold, then determine the relationship between the amount of data and the remaining space of the multiple storage sub-regions; If the amount of data is less than the remaining space, the compressed data to be written will be directly written to the memory. If the amount of data is greater than the remaining space, the compressed data to be written will be written to the memory starting from the location of the remaining space. After determining the data placement strategy for the compressed data to be written, the method further includes: performing tag management on the compressed data to be written according to the data placement strategy; The tag management includes: The encoded information of the data to be written to the compression system is marked to obtain encoded tags; The starting position of the compressed data to be written to storage is marked to obtain the starting address label; The end position of the compressed data to be written to storage is marked to obtain the end address label; According to the data placement strategy, a preset counter is used to count and statistically analyze different placement strategies to obtain statistical results, and the placement position of the data during writing is adjusted according to the statistical results. The step of using a preset counter to count and statistically analyze different placement strategies according to the data placement strategy, and obtaining statistical results, includes: If the amount of data is less than the threshold, then determine whether the preset counter has reached the counting threshold; If the counting threshold is reached, the compressed data to be written is written into a location in the memory that can accommodate the compressed data to be written. The step of tagging the compressed data to be written according to the data placement strategy includes: When the data placement strategy is to write the compressed data to be written to the memory at a preset initial write position, the start address label is the end position of the previous compressed data, and the end address label is the region where the end of the compressed data to be written is located. When the data placement strategy is to write the compressed data to be written to the memory starting from the location of the remaining space, the starting address label is the difference between the data writing granularity and the data amount, and the ending address label is the high address of the memory. When the data placement strategy is to update the corresponding label of the compressed data to be written, the start address label and the end address label are both the end position of the previous compressed data; After tagging the compressed data to be written, the tag and address corresponding to the written data are identified, and the written data is identified. According to the data placement strategy, the compressed data to be written is written to the area corresponding to the memory block of the memory.

2. The memory block data writing method according to claim 1, characterized in that, The acquisition of multiple storage sub-regions includes: Based on the data writing granularity, the memory block of the memory is divided into multiple storage sub-regions of equal size.

3. The memory block data writing method according to claim 1, characterized in that, The method determines the relationship between the amount of data to be written and the preset threshold. If the amount of data is zero, the corresponding label of the data to be written is updated.

4. A memory block data writing device, characterized in that, The apparatus is used to perform the method according to any one of claims 1-3, comprising: The region partitioning module is used to partition the memory blocks of the storage device into multiple storage sub-regions; The acquisition module is used to acquire the compressed data to be written. The placement strategy determination module is used to determine the data placement strategy of the compressed data to be written based on the relationship between the amount of data to be written and the remaining space of multiple storage sub-regions, and the relationship between the amount of data and a preset threshold. The writing module is used to write the compressed data to be written into the area corresponding to the memory block of the memory according to the data placement strategy.

5. A memory controller for writing data to the storage space of a non-volatile memory, characterized in that, The memory controller includes: a cache interface, a memory interface, and a memory management circuit; The cache interface is used for electrical connection to the last-level cache; The memory interface is used for electrical connection to the non-volatile memory; The memory management circuit is electrically connected to the cache interface and the memory interface, and when the memory management circuit is executed, it implements the steps in the memory block data writing method as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Disk access method and device

    CN110515562A