TWI886005B - Memory management method and data storage system - Google Patents
Memory management method and data storage system Download PDFInfo
- Publication number
- TWI886005B TWI886005B TW113128347A TW113128347A TWI886005B TW I886005 B TWI886005 B TW I886005B TW 113128347 A TW113128347 A TW 113128347A TW 113128347 A TW113128347 A TW 113128347A TW I886005 B TWI886005 B TW I886005B
- Authority
- TW
- Taiwan
- Prior art keywords
- block
- physical
- total number
- locked
- critical value
- Prior art date
Links
Images
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
- Memory System (AREA)
Abstract
Description
本發明是有關於一種記憶體管理方法與資料儲存系統。The present invention relates to a memory management method and a data storage system.
隨著科技的進步,人們對於存儲裝置的性能表現的要求也越來越高。一般來說,記憶體裝置(例如快閃記憶體裝置)是透過輪替的方式來使用內部的實體區塊。例如,當主機系統欲將資料存入記憶體裝置時,記憶體控制器可從記憶體裝置中挑選一個閒置區塊來儲存資料。當主機系統欲刪除記憶體裝置中的資料時,記憶體控制器可將當前存儲有該資料的實體頁標記為無效,並等待適當時機對包含該實體頁的實體區塊進行整體抹除,以利於後續重新存入新資料至該實體區塊。With the advancement of technology, people have higher and higher requirements for the performance of storage devices. Generally speaking, memory devices (such as flash memory devices) use internal physical blocks in a rotating manner. For example, when the host system wants to store data in the memory device, the memory controller can select an idle block from the memory device to store the data. When the host system wants to delete the data in the memory device, the memory controller can mark the physical page currently storing the data as invalid, and wait for the right time to erase the physical block containing the physical page as a whole, so as to facilitate the subsequent re-storage of new data to the physical block.
然而,在現有技術中,一旦記憶體裝置中的某一個實體區塊中的實體頁曾經響應於特定類型的操作指令而被標記為無效,則記憶體裝置會在下一次處於閒置狀態時,主動對該實體區塊進行垃圾回收(Garbage Collection, GC),以盡可能快速地抹除主機系統所欲清除的資料。但是,這樣的操作方式也存在缺陷。例如,當某一實體區塊中絕大多數的實體頁仍然處於有效狀態(即存儲有效資料)時,記憶體裝置需要花費相對較多的系統資源(例如電力及時間)來對該實體區塊進行垃圾回收,導致系統資源浪費。此外,過度頻繁地對實體區塊進行垃圾回收,也可能無謂地增加寫入放大(Write Amplification, WAF),從而縮短記憶體裝置的使用壽命。However, in the prior art, once the physical pages in a physical block in a memory device have been marked as invalid in response to a specific type of operation instruction, the memory device will actively perform garbage collection (GC) on the physical block the next time it is in an idle state, so as to erase the data that the host system wants to clear as quickly as possible. However, this operation method also has defects. For example, when the vast majority of physical pages in a physical block are still in a valid state (i.e., storing valid data), the memory device needs to spend relatively more system resources (such as power and time) to perform garbage collection on the physical block, resulting in a waste of system resources. In addition, excessively frequent garbage collection of physical blocks may also unnecessarily increase write amplification (WAF), thereby shortening the life of the memory device.
本發明提供一種記憶體管理方法與資料儲存系統,可改善上述問題,並可在盡可能不影響記憶體裝置的性能表現的前提下,有效延長記憶體裝置的使用壽命。The present invention provides a memory management method and a data storage system, which can improve the above-mentioned problems and effectively extend the service life of the memory device without affecting the performance of the memory device as much as possible.
本發明的實施例提供一種記憶體管理方法,其用於記憶體裝置,所述記憶體管理方法:從主機系統取得操作指令;根據所述操作指令將所述記憶體裝置中的第一實體頁標記為無效,並將所述記憶體裝置中包含所述第一實體頁的第一實體區塊設定為鎖定區塊;判斷所述記憶體裝置中的閒置區塊的總數是否小於第一臨界值;若所述閒置區塊的所述總數小於所述第一臨界值,判斷屬於所述鎖定區塊的任一實體區塊是否符合解鎖條件;若屬於所述鎖定區塊的所述第一實體區塊符合所述解鎖條件,將所述第一實體區塊釋放為所述閒置區塊;判斷所述記憶體裝置中的所述閒置區塊的所述總數是否小於第二臨界值,其中所述第二臨界值小於所述第一臨界值;若所述閒置區塊的所述總數小於所述第二臨界值,執行垃圾回收操作;以及若所述閒置區塊的所述總數不小於所述第二臨界值,不執行所述垃圾回收操作。The embodiment of the present invention provides a memory management method for a memory device, wherein the memory management method: obtains an operation instruction from a host system; marks a first physical page in the memory device as invalid according to the operation instruction, and sets a first physical block in the memory device containing the first physical page as a locked block; determines whether the total number of idle blocks in the memory device is less than a first critical value; if the total number of idle blocks is less than the first critical value, determines whether any physical block belonging to the locked block is invalid; whether the first physical block belonging to the locked block meets the unlocking condition; if the first physical block belonging to the locked block meets the unlocking condition, releasing the first physical block as the idle block; determining whether the total number of the idle blocks in the memory device is less than a second critical value, wherein the second critical value is less than the first critical value; if the total number of the idle blocks is less than the second critical value, performing a garbage collection operation; and if the total number of the idle blocks is not less than the second critical value, not performing the garbage collection operation.
本發明的實施例另提供一種資料儲存系統,其包括主機系統與記憶體裝置。所述記憶體裝置耦接至所述主機系統。所述主機系統用以提供操作指令,並且所述記憶體裝置用以:根據所述操作指令將所述記憶體裝置中的第一實體頁標記為無效,並將所述記憶體裝置中包含所述第一實體頁的第一實體區塊設定為鎖定區塊;判斷所述記憶體裝置中的閒置區塊的總數是否小於第一臨界值;若所述閒置區塊的所述總數小於所述第一臨界值,判斷屬於所述鎖定區塊的任一實體區塊是否符合解鎖條件;若屬於所述鎖定區塊的所述第一實體區塊符合所述解鎖條件,將所述第一實體區塊釋放為所述閒置區塊;判斷所述記憶體裝置中的所述閒置區塊的所述總數是否小於第二臨界值,其中所述第二臨界值小於所述第一臨界值;若所述閒置區塊的所述總數小於所述第二臨界值,執行垃圾回收操作;以及若所述閒置區塊的所述總數不小於所述第二臨界值,不執行所述垃圾回收操作。The embodiment of the present invention further provides a data storage system, which includes a host system and a memory device. The memory device is coupled to the host system. The host system is used to provide an operation instruction, and the memory device is used to: mark a first physical page in the memory device as invalid according to the operation instruction, and set a first physical block in the memory device containing the first physical page as a locked block; determine whether the total number of idle blocks in the memory device is less than a first critical value; if the total number of idle blocks is less than the first critical value, determine whether any physical block belonging to the locked block meets the unlocking condition. ; if the first physical block belonging to the locked block meets the unlocking condition, releasing the first physical block as the idle block; determining whether the total number of the idle blocks in the memory device is less than a second critical value, wherein the second critical value is less than the first critical value; if the total number of the idle blocks is less than the second critical value, performing a garbage collection operation; and if the total number of the idle blocks is not less than the second critical value, not performing the garbage collection operation.
基於上述,在從主機系統取得操作指令後,記憶體裝置中的第一實體頁可根據此操作指令而被標記為無效。同時,記憶體裝置中包含第一實體頁的第一實體區塊可被設定為鎖定區塊。在記憶體裝置的運行期間,記憶體裝置可自動判斷閒置區塊的總數是否小於第一臨界值。若閒置區塊的總數小於第一臨界值,記憶體裝置可優先判斷屬於鎖定區塊的任一實體區塊是否符合解鎖條件。若屬於鎖定區塊的第一實體區塊符合解鎖條件,記憶體裝置可自動將第一實體區塊釋放為閒置區塊,以增加閒置區塊的數量。另一方面,記憶體裝置可同步判斷閒置區塊的總數是否小於第二臨界值。特別是,第二臨界值可小於第一臨界值。若閒置區塊的總數小於第二臨界值,記憶體裝置可自動在背景執行垃圾回收操作,以進一步增加閒置區塊的數量。然而,若閒置區塊的總數不小於第二臨界值,則垃圾回收操作可不被執行。藉此,可改善傳統上記憶體裝置可能會過度頻繁地執行垃圾回收操作而縮短記憶體裝置的使用壽命的問題,並可在盡可能不影響記憶體裝置的性能表現的前提下,有效延長記憶體裝置的使用壽命。Based on the above, after obtaining the operation instruction from the host system, the first physical page in the memory device can be marked as invalid according to the operation instruction. At the same time, the first physical block in the memory device including the first physical page can be set as a locked block. During the operation of the memory device, the memory device can automatically determine whether the total number of idle blocks is less than the first critical value. If the total number of idle blocks is less than the first critical value, the memory device can preferentially determine whether any physical block belonging to the locked block meets the unlocking condition. If the first physical block belonging to the locked block meets the unlocking condition, the memory device may automatically release the first physical block as an idle block to increase the number of idle blocks. On the other hand, the memory device may simultaneously determine whether the total number of idle blocks is less than a second threshold value. In particular, the second threshold value may be less than the first threshold value. If the total number of idle blocks is less than the second threshold value, the memory device may automatically perform a garbage collection operation in the background to further increase the number of idle blocks. However, if the total number of idle blocks is not less than the second threshold value, the garbage collection operation may not be performed. In this way, the problem that the conventional memory device may perform garbage collection operations too frequently and shorten the service life of the memory device can be improved, and the service life of the memory device can be effectively extended without affecting the performance of the memory device as much as possible.
圖1是根據本發明的實施例所繪示的資料儲存系統的示意圖。請參照圖1,資料儲存系統10包括主機系統11與記憶體裝置12。主機系統11可將資料儲存至記憶體裝置12中,或從記憶體裝置12中讀取資料。例如,主機系統11為可實質地與記憶體裝置12配合以儲存資料的任意系統,例如,智慧型手機、平板電腦、筆記型電腦、桌上型電腦、工業用電腦、伺服器、遊戲機或設置於特定載體(例如車輛、飛機或船艦等)的電腦等。此外,記憶體裝置12則可為隨身碟、記憶卡、固態硬碟(Solid State Drive, SSD)、安全數位(Secure Digital, SD)卡、小型快閃(Compact Flash, CF)卡或嵌入式儲存裝置等各式非揮發性記憶體裝置。FIG1 is a schematic diagram of a data storage system according to an embodiment of the present invention. Referring to FIG1 , the
在一實施例中,主機系統11包括處理器111與連接界面112。處理器111可包括中央處理單元(Central Processing Unit, CPU)、圖形處理單元(Graphic Processing Unit, GPU)、神經網路處理單元(Neural network Processing Unit, NPU)或是其他可程式化之一般用途或特殊用途的微處理器、數位訊號處理器(Digital Signal Processor, DSP)、可程式化控制器、特殊應用積體電路(Application Specific Integrated Circuits, ASIC)、可程式化邏輯裝置(Programmable Logic Device, PLD)或其他類似裝置或這些裝置的組合。處理器111用以控制主機系統11的整體或部分運作。在以下實施例中,對處理器111的操作說明可等同於對主機系統11的操作說明。In one embodiment, the
連接界面112耦接至處理器111並用以將訊號(包含資料或指令)傳輸至記憶體裝置12或從記憶體裝置12接收訊號。在一實施例中,主機系統11還包含任何實務上所需的硬體裝置,例如電源管理電路、網路界面卡、鍵盤(或觸控板)、螢幕及/或揚聲器等等。The
在一實施例中,記憶體裝置12包括連接界面121、記憶體控制器122及記憶體模組123。連接界面121用以連接主機系統11的連接界面112並經由連接界面112與主機系統11通訊。在一實施例中,連接界面112與121符合NVM Express (NVMe)界面規範。在一實施例中,連接界面112與121亦可以符合序列先進附件(Serial Advanced Technology Attachment, SATA)、並列先進附件(Parallel Advanced Technology Attachment, PATA)、高速周邊零件互連(Peripheral Component Interconnect Express, PCI Express)或通用序列匯流排(Universal Serial Bus, USB)等各式連接界面標準。In one embodiment, the
記憶體控制器122耦接至連接界面121與記憶體模組123。記憶體控制器122用以控制記憶體裝置12的整體運作。例如,記憶體控制器122可根據來自主機系統11的指令來存取或控制記憶體模組123。例如,記憶體控制器122可根據來自主機系統11的指令在記憶體模組123中進行資料的寫入、讀取與抹除等操作。在一實施例中,記憶體控制器122包括快閃記憶體控制器。在以下實施例中,對記憶體控制器122的操作說明可等同於對記憶體裝置12的操作說明。The
記憶體模組123用以儲存主機系統11所寫入的資料。例如,記憶體模組123可包括單階胞(Single Level Cell, SLC)NAND型快閃記憶體模組(即,一個記憶胞可儲存1個位元的快閃記憶體模組)、多階胞(Multi Level Cell, MLC)NAND型快閃記憶體模組(即,一個記憶胞可儲存2個位元的快閃記憶體模組)、三階胞(Triple Level Cell, TLC)NAND型快閃記憶體模組(即,一個記憶胞可儲存3個位元的快閃記憶體模組)、四階胞(Quad Level Cell, QLC)NAND型快閃記憶體模組(即,一個記憶胞可儲存4個位元的快閃記憶體模組)、其他類型的快閃記憶體模組或具有相同或相似特性的非揮發性記憶體模組。此外,記憶體模組123中的記憶胞是以臨界電壓的改變來儲存資料。The
在一實施例中,處理器111可提供操作指令給記憶體裝置12。例如,此操作指令可透過主機系統11與記憶體裝置12之間的連線傳送至記憶體裝置12。例如,此連線可透過在主機系統11與記憶體裝置12之間執行交握(handshake)操作而建立。關於如何執行交握操作屬於本技術領域的現有技術,在此不多加贅述。In one embodiment, the
在一實施例中,所述操作指令指示刪除或抹除屬於至少一邏輯地址(亦稱為第一邏輯地址)的資料。第一邏輯地址映射至記憶體模組123中的至少一實體頁(亦稱為第一實體頁)。例如,此操作指令包括Trim指令或具有類似功能的指令。In one embodiment, the operation instruction indicates to delete or erase data belonging to at least one logical address (also referred to as the first logical address). The first logical address is mapped to at least one physical page (also referred to as the first physical page) in the
在一實施例中,記憶體控制器122可從主機系統11取得所述操作指令。例如,記憶體控制器122可透過所述連線從主機系統11取得所述操作指令。In one embodiment, the
在一實施例中,根據所述操作指令,記憶體控制器122可將第一實體頁標記為無效。在一實施例中,將第一實體頁標記為無效的操作可等同於或替換為將儲存於第一實體頁中的資料標記為無效(invalid)資料的操作。In one embodiment, according to the operation instruction, the
在一實施例中,根據所述操作指令,記憶體控制器122可將記憶體模組123中包含第一實體頁的實體區塊(亦稱為第一實體區塊)設定為鎖定區塊。須注意的是,在將第一實體區塊設定為鎖定區塊後,第一實體區塊將處於鎖定狀態,且暫不參與針對記憶體模組123的垃圾回收(Garbage Collection, GC)操作。In one embodiment, according to the operation instruction, the
在一實施例中,在觸發針對記憶體模組123的垃圾回收操作後,記憶體模組123中被設定為鎖定區塊的實體區塊(即處於鎖定狀態的實體區塊)將不會被回收(例如被回收作為新的閒置區塊)。或者,從另一角度而言,在觸發針對記憶體模組123的垃圾回收操作後,記憶體模組123中只有未被設定為鎖定區塊的實體區塊(即未處於鎖定狀態的實體區塊)可以被回收(例如被回收作為新的閒置區塊)。In one embodiment, after triggering the garbage collection operation for the
圖2是根據本發明的實施例所繪示的根據來自主機系統的操作指令將第一實體頁標記為無效的示意圖。請參照圖1與圖2,假設第一實體區塊為實體區塊21。實體區塊21包括多個實體頁201(1)~201(n)。FIG2 is a schematic diagram showing how a first physical page is marked as invalid according to an operation instruction from a host system according to an embodiment of the present invention. Referring to FIG1 and FIG2 , it is assumed that the first physical block is a
記憶體控制器122可從主機系統11取得操作指令22。例如,操作指令22可指示刪除或抹除屬於第一邏輯位址的資料,且第一邏輯位址映射至實體區塊21中的實體頁201(i)。根據操作指令22,記憶體控制器122可將實體區塊21中的實體頁201(i)標記為無效(等同於將儲存於實體頁201(i)中的資料標記為無效資料)。The
另一方面,響應於操作指令22,記憶體控制器122可將實體區塊21設定為鎖定區塊。此時,實體區塊21處於鎖定狀態。特別是,在將實體區塊21設定為鎖定區塊後,直到實體區塊21被解除鎖定(即實體區塊21非處於鎖定狀態)之前,實體區塊21將不會參與針對記憶體模組123的垃圾回收操作。換言之,在將實體區塊21解除鎖定後,非處於鎖定狀態的實體區塊21可參與所述垃圾回收操作。On the other hand, in response to the
在一實施例中,透過將基於所述操作指令而被部分標記為無效的第一實體區塊設定為鎖定區塊,可在非必要情況下,避免對第一實體區塊執行不必要的垃圾回收操作,從而減少無謂地浪費系統資訊並減少寫入放大(Write Amplification, WAF)。藉此,可在盡可能不影響記憶體裝置12的性能表現的前提下,有效延長記憶體裝置12的使用壽命。In one embodiment, by setting the first physical block partially marked as invalid based on the operation instruction as a locked block, unnecessary garbage collection operations can be avoided for the first physical block when it is not necessary, thereby reducing unnecessary waste of system information and reducing write amplification (WAF). In this way, the service life of the
在一實施例中,記憶體控制器122可持續接收一或多個操作指令22,並逐步將實體頁201(1)~201(n)標記為無效。在一實施例中,實體頁201(1)~201(n)的至少其中之一亦可基於記憶體控制器122所執行的其他操作而被標記為無效,在此不逐一贅述。In one embodiment, the
在一實施例中,記憶體控制器122可持續監測記憶體模組123中的閒置區塊的總數。例如,閒置區塊是指記憶體模組123中沒有存儲任何有效資料的實體區塊。在一實施例中,閒置區塊是指記憶體模組123中被關聯至閒置池(free pool)的實體區塊。在一實施例中,閒置區塊(例如被關聯至閒置池的實體區塊)可被抹除。但是,須注意的是,所述閒置區塊不包含當前屬於鎖定區塊的任何實體區塊。In one embodiment, the
以圖2為例,假設當前實體區塊21屬於鎖定區塊。在此情況下,即便實體區塊21中的所有實體頁201(1)~201(n)皆已被標記為無效(等同於實體頁201(1)~201(n)皆未儲存有效資料),當前屬於鎖定區塊(即處於鎖定狀態)的實體區塊21仍不被視為閒置區塊。然而,在一實施例中,在將實體區塊21解除鎖定後,實體區塊21可被切換或決定為閒置區塊並可被關聯至閒置池。Taking FIG. 2 as an example, assume that the current
在一實施例中,記憶體控制器122可判斷記憶體模組123中的閒置區塊的總數是否小於一個臨界值(亦稱為第一臨界值)。若記憶體模組123中的閒置區塊的總數小於第一臨界值,記憶體控制器122可進一步判斷屬於鎖定區塊的任一實體區塊是否符合特定條件(亦稱為解鎖條件)。例如,所述解鎖條件包括屬於鎖定區塊的單一實體區塊中的所有實體頁皆被標記為無效(等同於屬於鎖定區塊的單一實體區塊中的所有實體頁皆未儲存有效資料)。In one embodiment, the
在一實施例中,在記憶體模組123中的閒置區塊的總數小於第一臨界值的情況下,若記憶體控制器122判定屬於鎖定區塊的某一實體區塊符合所述解鎖條件,記憶體控制器122可將此實體區塊從鎖定狀態切換為非鎖定狀態並將此實體區塊釋放為(新的)閒置區塊。例如,被釋放為閒置區塊的實體區塊可被關聯至閒置池並可被抹除。In one embodiment, when the total number of idle blocks in the
在一實施例中,在記憶體模組123中的閒置區塊的總數小於第一臨界值的情況下,記憶體控制器122可判斷屬於鎖定區塊的第一實體區塊中的所有實體頁是否皆被標記為無效。若第一實體區塊中的所有實體頁皆被標記為無效,記憶體控制器122可判定第一實體區塊符合解鎖條件。然而,若第一實體區塊中的所有實體頁非皆被標記為無效,記憶體控制器122可判定第一實體區塊不符合解鎖條件。In one embodiment, when the total number of idle blocks in the
以圖2為例,在一實施例中,在記憶體模組123中的閒置區塊的總數小於第一臨界值的情況下,若當前屬於鎖定區塊的實體區塊21中的所有實體頁201(1)~201(n)皆已被標記為無效(等同於實體頁201(1)~201(n)皆未儲存有效資料),則記憶體控制器122可判定實體區塊21符合解鎖條件並解除對實體區塊21的鎖定。然後,記憶體控制器122可將實體區塊21釋放為(新的)閒置區塊。例如,在將實體區塊21釋放為(新的)閒置區塊後,實體區塊21可被關聯至閒置池並可被抹除。然而,在一實施例中,若當前屬於鎖定區塊的實體區塊21中的至少一實體頁仍為有效(即實體區塊21中的至少一實體頁仍有儲存有效資料),則記憶體控制器122可判定實體區塊21不符合解鎖條件。Taking FIG. 2 as an example, in one embodiment, when the total number of idle blocks in the
在一實施例中,在記憶體模組123中的閒置區塊的總數小於第一臨界值的情況下,透過將符合解鎖條件釋放為閒置區塊,可增加當下記憶體模組123中的閒置區塊的總數。在一實施例中,透過將符合解鎖條件釋放為閒置區塊以增加當下記憶體模組123中的閒置區塊的總數,可延緩垃圾回收操作的執行及/或減少垃圾回收操作的執行頻率。In one embodiment, when the total number of idle blocks in the
在一實施例中,若屬於鎖定區塊的所有實體區塊皆不符合所述解鎖條件,則記憶體控制器122可不將屬於鎖定區塊的任一實體區塊釋放為閒置區塊。換言之,若屬於鎖定區塊的所有實體區塊皆不符合所述解鎖條件,記憶體控制器122可維持此些實體區塊的鎖定狀態且不對此些實體區塊進行解鎖或釋放。In one embodiment, if all physical blocks belonging to the locked block do not meet the unlocking condition, the
在一實施例中,若記憶體模組123中的閒置區塊的總數不小於(例如大於或等於)第一臨界值,則記憶體控制器122可不將屬於鎖定區塊的任一實體區塊釋放為閒置區塊。藉此,同樣可在非必要情況下,避免對第一實體區塊執行不必要的垃圾回收操作,從而減少無謂地浪費系統資訊並減少寫入放大(WAF)。藉此,可在不影響記憶體裝置12的性能表現的前提下,有效延長記憶體裝置12的使用壽命。In one embodiment, if the total number of idle blocks in the
在一實施例中,記憶體控制器122還可判斷記憶體模組123中的閒置區塊的總數是否小於另一臨界值(亦稱為第二臨界值)。特別是,第二臨界值可小於第一臨界值。例如,假設第一臨界值為“10”,則第二臨界值可為“5”。然而,第一臨界值與第二臨界值皆可根據實務需求調整,只要滿足第二臨界值小於第一臨界值的規範即可。In one embodiment, the
在一實施例中,若記憶體模組123中的閒置區塊的總數小於第二臨界值,記憶體控制器122可執行垃圾回收操作。換言之,響應於記憶體模組123中的閒置區塊的總數小於第二臨界值,垃圾回收操作可被觸發。在垃圾回收操作中,記憶體控制器122可從記憶體模組123中選擇至少一實體區塊作為來源區塊並從記憶體模組123(例如閒置池)中選擇至少一實體區塊作為目標區塊。記憶體控制器122可從來源區塊中讀取並收集有效資料並將所收集的有效資料集中儲存至目標區塊中。在將屬於目標區塊的某一實體區塊中的所有的有效資料都搬移或複製到來源區塊後,此實體區塊可被釋放為閒置區塊並可關聯至閒置池。同時,此實體區塊(即閒置區塊)可被抹除並且等待被寫入新資料。然而,若記憶體模組123中的閒置區塊的總數不小於第二臨界值,記憶體控制器122可不執行垃圾回收操作。In one embodiment, if the total number of idle blocks in the
圖3是根據本發明的實施例所繪示的根據記憶體模組中的閒置區塊的總數針對記憶體模組中的鎖定區塊執行不同類型的管理操作的示意圖。請參照圖1至圖3,在一實施例中,若記憶體模組123中的閒置區塊的總數不小於(例如大於或等於)臨界值THR(1)(即第一臨界值),記憶體控制器122可不釋放記憶體模組123中的任何鎖定區塊。在一實施例中,在記憶體模組123中的閒置區塊的總數不小於臨界值THR(1)的情況下,透過將記憶體模組123中的部分實體區塊維持於鎖定狀態,可減少非必要的垃圾回收操作之執行。FIG3 is a schematic diagram showing different types of management operations for locked blocks in a memory module according to the total number of idle blocks in the memory module according to an embodiment of the present invention. Referring to FIG1 to FIG3 , in one embodiment, if the total number of idle blocks in the
在一實施例中,若記憶體模組123中的閒置區塊的總數小於臨界值THR(1),記憶體控制器122可釋放記憶體模組123中符合解鎖條件的鎖定區塊。在一實施例中,在記憶體模組123中的閒置區塊的總數小於臨界值THR(1)的情況下,透過釋放記憶體模組123中符合解鎖條件的鎖定區塊,可增加記憶體模組123中的閒置區塊的總數,從而同樣可延緩或減少非必要的垃圾回收操作之執行。In one embodiment, if the total number of idle blocks in the
在一實施例中,若記憶體模組123中的閒置區塊的總數進一步減少至小於臨界值THR(2)(即第二臨界值),則記憶體控制器122可觸發並執行垃圾回收操作。透過執行垃圾回收操作來釋放出新的閒置區塊,可維持記憶體裝置12正常運作。In one embodiment, if the total number of idle blocks in the
在一實施例中,處理器111可提供設定指令給記憶體裝置12。例如,此設定指令可透過主機系統11與記憶體裝置12之間的連線傳送至記憶體裝置12。此設定指令用以設定(包含調整或更新)第一臨界值。In one embodiment, the
在一實施例中,記憶體控制器122可從主機系統11取得此設定指令。記憶體控制器122可根據此設定指令來設定(包含調整或更新)第一臨界值。例如,此設定指令可帶有對應於第一臨界值的設定資訊。在獲得此設定指令後,記憶體控制器122可根據此設定指令中的設定資訊來設定(包含調整或更新)第一臨界值。In one embodiment, the
在一實施例中,記憶體控制器122可監測鎖定區塊的總數。記憶體控制器122可將與鎖定區塊有關的數量信息提供給主機系統11。例如,此數量信息可反映鎖定區塊的總數。在一實施例中,在接收到此數量信息後,處理器111可根據此數量信息來提供所述設定指令。In one embodiment, the
在一實施例中,第一臨界值可正相關於鎖定區塊的總數。在一實施例中,響應於鎖定區塊的總數增加(例如增加至高於第一預設數量),處理器111可透過所述設定指令,指示記憶體控制器122提高第一臨界值。另一方面,在一實施例中,響應於鎖定區塊的總數減少(例如減少至低於第二預設數量,且第二預設數量可少於第一預設數量),處理器111可透過所述設定指令,指示記憶體控制器122減少第一臨界值。In one embodiment, the first threshold value may be positively correlated with the total number of locked blocks. In one embodiment, in response to the total number of locked blocks increasing (e.g., increasing to a value higher than a first preset number), the
在一實施例中,透過適當地調整第一臨界值,可更佳地在維持實體區塊的鎖定與增加閒置區塊之間取得平衡。例如,在一實施例中,在鎖定區塊的總數逐漸增加(例如增加至高於第一預設數量)的情況下,透過提高第一臨界值,可提前觸發對於符合條件的鎖定區塊的解鎖。藉此,可在已經採用鎖定區塊來減少垃圾回收操作的情況下,適度增加或維持記憶體模組123中的閒置區塊的總數。另一方面,在一實施例中,在鎖定區塊的總數減少(例如減少至低於第二預設數量)的情況下,透過降低第一臨界值,可延後觸發對於符合條件的鎖定區塊的解鎖。藉此,可避免因鎖定區塊被過度釋放,而喪失了將部分實體區塊鎖定以減少執行非必要的垃圾回收操作的初衷。In one embodiment, by appropriately adjusting the first critical value, a better balance can be achieved between maintaining the locking of physical blocks and increasing the number of idle blocks. For example, in one embodiment, when the total number of locked blocks gradually increases (e.g., increases to a value higher than a first preset number), by increasing the first critical value, unlocking of locked blocks that meet the conditions can be triggered in advance. In this way, the total number of idle blocks in the
圖4是根據本發明的實施例所繪示的記憶體管理方法的流程圖。請參照圖4,在步驟S401中,從主機系統取得操作指令。在步驟S402中,根據所述操作指令將記憶體裝置中的第一實體頁標記為無效,並將記憶體裝置中包含第一實體頁的第一實體區塊設定為鎖定區塊。在步驟S403中,判斷記憶體裝置中的閒置區塊的總數是否小於第一臨界值。若閒置區塊的總數不小於第一臨界值,可回到步驟S401。FIG. 4 is a flow chart of a memory management method according to an embodiment of the present invention. Referring to FIG. 4 , in step S401, an operation instruction is obtained from a host system. In step S402, a first physical page in a memory device is marked as invalid according to the operation instruction, and a first physical block in the memory device containing the first physical page is set as a locked block. In step S403, it is determined whether the total number of idle blocks in the memory device is less than a first critical value. If the total number of idle blocks is not less than the first critical value, the process returns to step S401.
若閒置區塊的總數小於第一臨界值,在步驟S404中,判斷屬於鎖定區塊的任一實體區塊是否符合解鎖條件。若屬於鎖定區塊的某一實體區塊符合解鎖條件,在步驟S405中,將符合解鎖條件的實體區塊釋放為閒置區塊。在步驟S405之後,可進入圖5的步驟S501。此外,若屬於鎖定區塊的所有實體區塊皆不符合解鎖條件,也可在步驟S404之後進入圖5的步驟S501。If the total number of idle blocks is less than the first critical value, in step S404, it is determined whether any physical block belonging to the locked block meets the unlocking condition. If a physical block belonging to the locked block meets the unlocking condition, in step S405, the physical block meeting the unlocking condition is released as an idle block. After step S405, the process may proceed to step S501 of FIG. 5 . In addition, if all physical blocks belonging to the locked block do not meet the unlocking condition, the process may proceed to step S501 of FIG. 5 after step S404.
圖5是根據本發明的實施例所繪示的記憶體管理方法的流程圖。請參照圖5,在步驟S501中,判斷記憶體裝置中的閒置區塊的總數是否小於第二臨界值,其中第二臨界值小於第一臨界值。若閒置區塊的總數小於第二臨界值,在步驟S502中,執行垃圾回收操作。然而,若閒置區塊的總數不小於第二臨界值,在步驟S503中,不執行垃圾回收操作。FIG5 is a flow chart of a memory management method according to an embodiment of the present invention. Referring to FIG5, in step S501, it is determined whether the total number of idle blocks in the memory device is less than a second critical value, wherein the second critical value is less than the first critical value. If the total number of idle blocks is less than the second critical value, in step S502, a garbage collection operation is performed. However, if the total number of idle blocks is not less than the second critical value, in step S503, a garbage collection operation is not performed.
然而,圖4與圖5中各步驟已詳細說明如上,在此便不再贅述。值得注意的是,圖4與圖5中各步驟可以實作為多個程式碼或是電路,本發明不加以限制。此外,圖4與圖5的方法可以搭配以上範例實施例使用,也可以單獨使用,本發明不加以限制。However, each step in FIG. 4 and FIG. 5 has been described in detail above, and will not be repeated here. It is worth noting that each step in FIG. 4 and FIG. 5 can be implemented as multiple program codes or circuits, and the present invention is not limited thereto. In addition, the methods in FIG. 4 and FIG. 5 can be used in conjunction with the above exemplary embodiments, or can be used alone, and the present invention is not limited thereto.
綜上所述,本發明的實施例提出的記憶體管理方法與資料儲存系統,可將記憶體模組中基於來自主機系統的特定類型的操作指令而被部分標記為無效的實體區塊設定為鎖定區塊。藉此,可在非必要情況下,避免對部分實體區塊執行不必要的垃圾回收操作,從而減少無謂地浪費系統資訊並減少寫入放大(WAF)。此外,根據記憶體模組中的閒置區塊的總數,部分符合解鎖條件的鎖定區塊可被解鎖,而成為新的閒置區塊。藉此,本發明的實施例提出的記憶體管理方法與資料儲存系統,可在盡可能不影響記憶體裝置的性能表現的前提下,有效延長記憶體裝置的使用壽命。In summary, the memory management method and data storage system proposed in the embodiment of the present invention can set the physical blocks in the memory module that are partially marked as invalid based on a specific type of operation instruction from the host system as locked blocks. In this way, it is possible to avoid unnecessary garbage collection operations on some physical blocks when it is not necessary, thereby reducing unnecessary waste of system information and reducing write amplification (WAF). In addition, according to the total number of idle blocks in the memory module, some locked blocks that meet the unlocking conditions can be unlocked and become new idle blocks. Thus, the memory management method and data storage system proposed in the embodiment of the present invention can effectively extend the service life of the memory device without affecting the performance of the memory device as much as possible.
雖然本發明已以實施例揭露如上,然其並非用以限定本發明,任何所屬技術領域中具有通常知識者,在不脫離本發明的精神和範圍內,當可作些許的更動與潤飾,故本發明的保護範圍當視後附的申請專利範圍所界定者為準。Although the present invention has been disclosed as above by the embodiments, they are not intended to limit the present invention. Any person with ordinary knowledge in the relevant technical field can make some changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be defined by the scope of the attached patent application.
10:資料儲存系統 11:主機系統 111:處理器 112:連接界面 12:記憶體裝置 121:連接界面 122:記憶體控制器 123:記憶體模組 21: 實體區塊 201(1)~201(n): 實體頁 22: 操作指令 THR(1), THR(2): 臨界值 S401~S405, S501~S503:步驟 10: Data storage system 11: Host system 111: Processor 112: Connection interface 12: Memory device 121: Connection interface 122: Memory controller 123: Memory module 21: Physical block 201(1)~201(n): Physical page 22: Operation instruction THR(1), THR(2): Critical value S401~S405, S501~S503: Steps
圖1是根據本發明的實施例所繪示的資料儲存系統的示意圖。 圖2是根據本發明的實施例所繪示的根據來自主機系統的操作指令將第一實體頁標記為無效的示意圖。 圖3是根據本發明的實施例所繪示的根據記憶體模組中的閒置區塊的總數針對記憶體模組中的鎖定區塊執行不同類型的管理操作的示意圖。 圖4是根據本發明的實施例所繪示的記憶體管理方法的流程圖。 圖5是根據本發明的實施例所繪示的記憶體管理方法的流程圖。 FIG. 1 is a schematic diagram of a data storage system according to an embodiment of the present invention. FIG. 2 is a schematic diagram of marking a first physical page as invalid according to an operation instruction from a host system according to an embodiment of the present invention. FIG. 3 is a schematic diagram of performing different types of management operations on locked blocks in a memory module according to the total number of idle blocks in the memory module according to an embodiment of the present invention. FIG. 4 is a flow chart of a memory management method according to an embodiment of the present invention. FIG. 5 is a flow chart of a memory management method according to an embodiment of the present invention.
S401~S405:步驟 S401~S405: Steps
Claims (12)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW113128347A TWI886005B (en) | 2024-07-30 | 2024-07-30 | Memory management method and data storage system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW113128347A TWI886005B (en) | 2024-07-30 | 2024-07-30 | Memory management method and data storage system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| TWI886005B true TWI886005B (en) | 2025-06-01 |
| TW202605594A TW202605594A (en) | 2026-02-01 |
Family
ID=97227534
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| TW113128347A TWI886005B (en) | 2024-07-30 | 2024-07-30 | Memory management method and data storage system |
Country Status (1)
| Country | Link |
|---|---|
| TW (1) | TWI886005B (en) |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20110283049A1 (en) * | 2010-05-12 | 2011-11-17 | Western Digital Technologies, Inc. | System and method for managing garbage collection in solid-state memory |
| TW201737089A (en) * | 2014-11-10 | 2017-10-16 | 慧榮科技股份有限公司 | Data storage device and operating method |
| TW201928678A (en) * | 2017-12-20 | 2019-07-16 | 慧榮科技股份有限公司 | Data storage device and operating method for dynamically executing garbage collection |
-
2024
- 2024-07-30 TW TW113128347A patent/TWI886005B/en active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20110283049A1 (en) * | 2010-05-12 | 2011-11-17 | Western Digital Technologies, Inc. | System and method for managing garbage collection in solid-state memory |
| US9026716B2 (en) * | 2010-05-12 | 2015-05-05 | Western Digital Technologies, Inc. | System and method for managing garbage collection in solid-state memory |
| TW201737089A (en) * | 2014-11-10 | 2017-10-16 | 慧榮科技股份有限公司 | Data storage device and operating method |
| TW201928678A (en) * | 2017-12-20 | 2019-07-16 | 慧榮科技股份有限公司 | Data storage device and operating method for dynamically executing garbage collection |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8819358B2 (en) | Data storage device, memory system, and computing system using nonvolatile memory device | |
| US10372619B2 (en) | Data backup method, data recovery method and storage controller | |
| US11210226B2 (en) | Data storage device and method for first processing core to determine that second processing core has completed loading portion of logical-to-physical mapping table thereof | |
| US20120131263A1 (en) | Memory storage device, memory controller thereof, and method for responding host command | |
| TWI698749B (en) | A data storage device and a data processing method | |
| TWI697009B (en) | Write control method, associated data storage device and controller thereof | |
| TWI726314B (en) | A data storage device and a data processing method | |
| US11036429B2 (en) | Memory control method, memory storage device and memory control circuit unit to determine a source block using interleaving information | |
| CN112068782B (en) | Memory management method, memory storage device and memory control circuit unit | |
| US10339045B2 (en) | Valid data management method and storage controller | |
| CN112988068B (en) | Memory control method, memory storage device and memory controller | |
| TW201935232A (en) | Memory management method and storage controller using the same | |
| TWI886005B (en) | Memory management method and data storage system | |
| CN118796119B (en) | Memory management method and memory device | |
| TWI747191B (en) | Data storage device and data processing method | |
| US11307786B2 (en) | Data storage devices and data processing methods | |
| CN118747059A (en) | Memory management method and storage device | |
| CN118689402A (en) | Data consolidation method and storage device | |
| TWI768829B (en) | Parameter adjusting method for a memory device and a memory storage system | |
| TWI790568B (en) | Work status control method for memory device and data storage system | |
| US11249898B1 (en) | Data merge method, memory storage device and memory control circuit unit | |
| CN116578228A (en) | Storage System | |
| CN115079928B (en) | Jumping data clearing method and data storage system | |
| CN117632038B (en) | Wear leveling method, memory storage device and memory control circuit unit | |
| TW202125206A (en) | Memory management method and memory device |