Memory management method, electronic device, storage medium and computer program product
By integrating the energy consumption perception module and dynamic data migration strategy in the CXL controller, data transfer is carried out based on the hot and cold scores of the memory page and the storage medium type, the energy consumption waste and performance fluctuations of the low-power heterogeneous memory management technology under the CXL protocol are solved, and the effects of dynamic load adaptation and energy consumption management are achieved.
Patent Information
- Application Number
- CN202510331481.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2045-03-20
AI Technical Summary
Under the CXL protocol, low-power heterogeneous memory management technology has problems such as static power management, single media access strategy and insufficient protocol layer support, resulting in waste of energy consumption and performance fluctuations.
By integrating the energy-saving module and dynamic data migration strategy in the CXL controller, it is determined whether to transfer data based on the hot and cold scores of the memory page and the storage medium type, and data migration is carried out if the target storage medium supports it, or its operating mode is adjusted to support data transfer.
The combination of dynamic adjustment of data location according to load and static power consumption management is realized, reducing energy consumption, avoiding energy waste, and improving the energy efficiency ratio of memory management and the dynamic response capability of the system.
Smart Images

Figure CN119847772A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a memory management method, an electronic device, a storage medium, and a computer program product. Background Art
[0002] CXL (Computer Express Link) is a new open interconnection standard launched by Intel and many manufacturers for data centers, high-performance computers, AI and other fields. The current low-power heterogeneous memory management technology under the CXL protocol mainly relies on static allocation strategies and single media optimization, which has significant limitations. Fixed memory partitioning is usually used to divide DRAM and SCM / NVM into static capacity pools. The data location cannot be adjusted dynamically according to the load, resulting in low-frequency access data occupying high-power DRAM for a long time, causing more than 30% energy waste. The current technical solutions of the CXL protocol in the field of heterogeneous memory management have significant defects, which are mainly reflected in three aspects: static power management, single media access strategy and insufficient support at the protocol layer. Summary of the invention
[0003] The present application provides a memory management method, an electronic device, a storage medium and a computer program product to at least solve the technical problem in the related art that it is impossible to combine dynamic adjustment of data location according to load with static power consumption management to reduce energy consumption.
[0004] The present application provides a memory management method, including: Acquire memory data of a memory page in a memory module, acquire a hot / cold score of the memory data of the memory page, and set a hot / cold mark for the memory page according to the hot / cold score; Obtaining the type of the storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page; In response to transferring the memory data of the memory page, an address of a storage medium where the memory page is located and an address of a target storage medium are obtained, and it is determined whether a current operation mode of the target storage medium supports data transfer; In response to the current operating mode of the target storage medium supporting data transfer, the memory data of the memory page is migrated to the target storage medium according to the address of the target storage medium, otherwise the current operating mode of the target storage medium is converted to support data transfer.
[0005] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any one of the above memory management methods when executing the computer program: Acquire memory data of a memory page in a memory module, acquire a hot / cold score of the memory data of the memory page, and set a hot / cold mark for the memory page according to the hot / cold score; Obtaining the type of the storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page; In response to transferring the memory data of the memory page, an address of a storage medium where the memory page is located and an address of a target storage medium are obtained, and it is determined whether a current operation mode of the target storage medium supports data transfer; In response to the current operating mode of the target storage medium supporting data transfer, the memory data of the memory page is migrated to the target storage medium according to the address of the target storage medium, otherwise the current operating mode of the target storage medium is converted to support data transfer.
[0006] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of implementing any one of the above memory management methods are: Acquire memory data of a memory page in a memory module, acquire a hot / cold score of the memory data of the memory page, and set a hot / cold mark for the memory page according to the hot / cold score; Obtaining the type of the storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page; In response to transferring the memory data of the memory page, an address of a storage medium where the memory page is located and an address of a target storage medium are obtained, and it is determined whether a current operation mode of the target storage medium supports data transfer; In response to the current operating mode of the target storage medium supporting data transfer, the memory data of the memory page is migrated to the target storage medium according to the address of the target storage medium, otherwise the current operating mode of the target storage medium is converted to support data transfer.
[0007] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above memory management methods when executed by a processor: Acquire memory data of a memory page in a memory module, acquire a hot / cold score of the memory data of the memory page, and set a hot / cold mark for the memory page according to the hot / cold score; Obtaining the type of the storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page; In response to transferring the memory data of the memory page, an address of a storage medium where the memory page is located and an address of a target storage medium are obtained, and it is determined whether a current operation mode of the target storage medium supports data transfer; In response to the current operating mode of the target storage medium supporting data transfer, the memory data of the memory page is migrated to the target storage medium according to the address of the target storage medium, otherwise the current operating mode of the target storage medium is converted to support data transfer.
[0008] Through the present application, by setting hot and cold marks for memory pages according to hot and cold scores, memory data of different hot and cold levels can be distinguished, and by comparing with the type of storage medium where the memory page is located, it is determined whether to transfer the memory data of the memory page. By transferring the data to the storage medium that matches the hot and cold marks, energy consumption can be reduced and energy waste can be avoided. Before data transfer, the current operating mode of the target storage medium is determined to support data transfer, and the target storage medium is adjusted to an operating mode that supports data transfer. There is no need to keep all storage media in an operating mode that supports data transfer at all times, and the energy consumption of the operating mode of the storage medium can be kept at the lowest. Dynamic adjustment of data location according to load and static power consumption management can be combined to reduce energy consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0010] Figure 1 This is an application environment diagram of a memory management method in one embodiment of the present application; Figure 2 A flowchart of a memory management method in one embodiment of the present application; Figure 3 A flowchart of the steps of obtaining memory data of a memory page in a memory module, obtaining a hot / cold score of the memory data of the memory page, and setting a hot / cold mark for the memory page according to the hot / cold score in one embodiment of the present application; Figure 4 A flowchart of the steps of obtaining the type of storage medium where the memory page is located and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page in one embodiment of the present application; Figure 5A flowchart of an embodiment of the present application is provided for obtaining the address of the storage medium where the memory page is located and the address of the target storage medium in response to transferring the memory data of the memory page, and determining whether the current operation mode of the target storage medium supports the data transfer step; Figure 6 A flowchart of the steps of migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium in response to the current operation mode of the target storage medium supporting data transfer in one embodiment of the present application; Figure 7 This is a structural block diagram of a memory management device in one embodiment of the present application; Figure 8 This is a structural block diagram of a data migration engine in one embodiment of the present application; Fig. 9 This is a diagram of the internal structure of an electronic device in one embodiment of the present application. DETAILED DESCRIPTION
[0011] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0012] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0013] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0014] The current CXL protocol lacks dynamic analysis of multi-dimensional features such as access frequency and temporal locality, resulting in a high rate of false migration, which in turn increases system latency. At the protocol support level, the existing CXL 3.0 standard lacks native energy management fields, and manufacturers need to indirectly control the media status through private protocols, resulting in poor cross-platform compatibility. In addition, DRAM mode switching is achieved through multiple MMIO register reads and writes, which introduces additional latency and fails to provide real-time feedback on energy consumption status. In addition, traditional solutions have insufficient support for new media (such as ReRAM and MRAM), requiring customized drivers and hardware interfaces, long R&D cycles, and poor scalability.
[0015] In dynamic load scenarios, existing technologies are particularly inadequate. Sudden data access in AI training tasks causes DRAM to frequently switch power consumption modes, and static strategies are difficult to respond quickly, causing performance fluctuations. In general, existing solutions cannot meet the needs of green computing in terms of energy efficiency, real-time performance, and scalability, and innovative breakthroughs in software and hardware collaboration are urgently needed.
[0016] Specifically, the current technical solutions of the CXL protocol in the field of heterogeneous memory management have significant defects, which are mainly reflected in three aspects: static power consumption management, single media access strategy and insufficient protocol layer support.
[0017] (1) Limitations of static power management strategies Currently, fixed power consumption modes are used, and the power consumption state of memory media cannot be adjusted dynamically according to the load. Specific problems include energy waste: low-frequency access to data occupies high-power DRAM for a long time, resulting in low energy efficiency (TOPS / W). For example, in AI reasoning tasks, after the model parameters are loaded, they may only be frequently accessed during the initialization phase, and 80% of the data is idle during the subsequent reasoning process, but the traditional solution still retains it in DRAM, resulting in power waste.
[0018] There is also a lack of dynamic response and an inability to perceive real-time load changes. For example, sudden access requests (such as real-time data analysis) may cause DRAM to frequently enter / exit low-power mode, resulting in additional energy consumption overhead.
[0019] (2) Simplified media access strategy Existing technologies generally adopt a single medium optimization strategy, ignoring the differentiated characteristics of heterogeneous media, and over-reliance on DRAM leads to resource contention. The low power consumption characteristics of SCM / NVM are not fully utilized. Traditional solutions do not classify the hot and cold attributes of data, resulting in mixed storage of high-frequency access "hot data" and low-frequency "cold data". There is a lack of collaborative access mechanisms for DRAM, SCM, and NVM. It cannot effectively cooperate with the random access characteristics of DRAM, resulting in increased cross-media data transfer overhead.
[0020] (3) Insufficient support at the protocol layer The CXL protocol has weak native support for energy management. First, there is a lack of energy status feedback: the CXL 3.0 protocol does not define a standard field for reporting real-time power consumption status. In addition, it is difficult to expand control instructions. The existing CXL.io protocol lacks dedicated commands for power management and requires indirect control of the media status through multiple read and write operations.
[0021] like Figure 1 As shown, in order to avoid the serious problem of energy waste caused by low-frequency access data occupying high-power DRAM for a long time, resulting in low energy efficiency ratio (TOPS / W) of memory modules, this application reduces the delay of media switching and reduces memory energy consumption. By setting a CXL controller between the host (HOST CPU) and the memory module, the CXL controller includes a hot and cold score calculator, an energy management module and a data migration engine. The memory module includes DRAM, SCM (storage-class memory), and NVM (non-volatile memory), where the storage medium type of DRAM is high-bandwidth memory, the storage medium type of SCM (storage-class memory) is low-power medium, and the storage medium type of NVM (non-volatile memory) is large-capacity memory. This application is based on the low-power heterogeneous memory management technology of the Compute Express Link (CXL) protocol. By integrating the energy consumption perception module and dynamic data migration strategy in the CXL controller, the energy efficiency of heterogeneous media such as DRAM, SCM (storage-class memory), and NVM (non-volatile memory) is optimized, and it is suitable for high-density computing scenarios such as data centers and edge servers.
[0022] This application achieves software and hardware collaboration through hardware architecture optimization and protocol layer expansion to realize low-power heterogeneous memory management. The system architecture is divided into two levels: hardware layer and protocol layer.
[0023] Hardware layer: The host is interconnected with the CXL controller through the PCIE protocol; the CXL controller integrates a data migration engine and an energy management module, which are responsible for data hot and cold classification and energy management respectively; the CXL controller has external expansion links to connect different types of storage media, including three heterogeneous memory modules: DRAM / SCM / NVM, which are used to store different data types such as hot data (Hot), warm data (Warm) and cold data (Cold), and implement different energy management strategies.
[0024] Protocol layer: CXL.io protocol provides underlying device connection and device management functions, and adds new information control such as energy consumption status and data migration; CXL.cache protocol mainly solves the problem of multi-device cache consistency; CXL.memory protocol realizes elastic expansion of memory resources, adds detailed fields for energy consumption management, and sends energy consumption information to the memory module while completing data migration for memory module power consumption management. Extend the CXL.memory protocol, add energy consumption management TLP fields, do not affect the existing CXL.io / CXL.cache functions, add energy consumption management information in the process of completing dynamic expansion of memory resources, improve resource utilization and energy efficiency; Extend the CXL.io control interface to transmit control information such as energy consumption status and data migration, and synchronize basic information with the host and device.
[0025] like Figure 2 As shown, an embodiment of the present application provides a memory management method, comprising the following steps: S1. Obtain memory data of a memory page in a memory module, obtain a hot / cold score of the memory data of the memory page, and set a hot / cold mark for the memory page according to the hot / cold score; S2, obtaining the type of storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of storage medium and the hot and cold flags set for the memory page; S3, in response to transferring the memory data of the memory page, obtaining the address of the storage medium where the memory page is located and the address of the target storage medium, and determining whether the current operation mode of the target storage medium supports the data transfer; S4. In response to the current operation mode of the target storage medium supporting data transfer, the memory data of the memory page is migrated to the target storage medium according to the address of the target storage medium; otherwise, the current operation mode of the target storage medium is converted to support data transfer.
[0026] In this embodiment, hot and cold marks are set for memory pages according to hot and cold scores to distinguish memory data of different hot and cold levels, and whether to transfer the memory data of the memory page is determined by comparing with the type of storage medium where the memory page is located. By transferring the data to the storage medium matching the hot and cold marks, energy consumption can be reduced and energy waste can be avoided. Before data transfer, the current operating mode of the target storage medium is determined to support data transfer, and the target storage medium is adjusted to an operating mode that supports data transfer. There is no need to keep all storage media in an operating mode that supports data transfer at all times, and the energy consumption of the operating mode of the storage medium can be kept at the lowest. Dynamic adjustment of data location according to load and static power consumption management can be combined to reduce energy consumption.
[0027] The memory management method is applied to GPU server clusters and can serve various application scenarios with high concurrency and high computing power requirements, such as AI / HPC / cloud services.
[0028] like Figure 3 As shown, in this embodiment, obtaining memory data of a memory page in a memory module, obtaining a hot / cold score of the memory data of the memory page, and setting a hot / cold mark for the memory page according to the hot / cold score include: S11, obtaining the access frequency, temporal locality and task priority of the memory data of the memory page; S12, obtaining a hot / cold score of the memory data of the memory page according to the access frequency, temporal locality, and task priority of the memory data of the memory page; S13. Obtain types of hot and cold tags, where the hot and cold tags include hot data, warm data, and cold data, and mark the memory pages with hot and cold tags according to the hot and cold scores of the memory data of the memory pages.
[0029] In this embodiment, obtaining the hot / cold score of the memory data of the memory page according to the access frequency, temporal locality and task priority of the memory data of the memory page includes: Set temporal locality to a weight value that decreases over time based on an exponential decay model; Set weight coefficients for access frequency, temporal locality, and task priority; The access frequency, temporal locality, and task priority are multiplied by their corresponding weight coefficients and then summed to obtain the hot and cold scores of the memory data of the memory page.
[0030] Specifically, the formula for the hot and cold score of the memory data of the memory page is: Score=0.6*Freq+0.3*Recency+0.1*Priority.
[0031] Among them, Freq is the access frequency, which is the number of accesses within the statistical time window (T=1s), which is a 0-1 value; Recency is the temporal locality, which is based on the exponential decay model, and the weight decreases over time. In the exponential decay model, λ=0.1 (decay coefficient), and t is in milliseconds; Priority is the task priority, which is marked by the operating system or application (in the range of 0-1), such as real-time task = 1.0, batch task = 0.3.
[0032] This embodiment improves the LRU-K algorithm: expand the traditional LRU, record the last three access histories (K=3), and combine the weighted heat calculation to eliminate the candidate pages. The weight coefficients of access frequency, time locality, and task priority are set to 0.6, 0.3, and 0.1 respectively, and these weight coefficients can also be adjusted according to actual situations.
[0033] like Figure 4As shown, in this embodiment, obtaining the type of storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of storage medium and the hot and cold flags set for the memory page include: S21, obtaining a storage medium type in the memory module, where the storage medium type includes a high-bandwidth memory, a low-power medium, and a large-capacity memory; S22, obtaining the type of preset hot and cold marks of the memory data stored corresponding to the storage medium type, the memory data marked as hot data is stored in the high-bandwidth memory, the memory data marked as warm data is stored in the low-power medium, and the memory data marked as cold data is stored in the large-capacity storage device; S23. Obtain the type of preset hot and cold marks corresponding to the type of storage medium where the memory page is located, and determine whether the hot and cold marks marked by the memory data of the memory page are the same as the type of preset hot and cold marks corresponding to the type of storage medium where the memory page is located; if they are different, determine to transfer the memory data of the memory page; otherwise, determine not to transfer the memory data of the memory page.
[0034] It is understandable that the CXL controller has external expansion links to connect different types of storage media, and can obtain the storage media type in the memory module. The CXL controller has a dual-port DMA controller as a connection port, which supports concurrent transmission of DRAM and SCM / NVM with a bandwidth of 64GB / s. Among the storage media types in the memory module, the storage medium for high-bandwidth memory is DRAM, the storage medium for low-power media is SCM (storage-class memory), and the storage medium for large-capacity storage is NVM (non-volatile memory). In DRAM, memory data marked as hot data is stored, in SCM, memory data marked as warm data is stored, and in NVM, memory data marked as cold data is stored. By classifying and storing memory data according to hot and cold tags, warm data and cold data can be prevented from occupying high-bandwidth memory space, and cold data can be prevented from occupying low-power media space.
[0035] The characteristics of hot data are: high-frequency access (>100 times / second), recent use (last access time <10ms), and high-priority task association. The storage strategy for hot data is: keep it in DRAM and give priority to cache lines.
[0036] The characteristics of warm data are: medium access frequency (10-100 times / second), weak temporal locality (last access time 10ms-1s), and normal priority. The storage strategy for warm data is: temporarily stored in SCM and dynamically upgraded according to load pressure.
[0037] The characteristics of cold data are: low-frequency access (<10 times / second), long-term unused (last access time>1s), low priority or background tasks. The storage strategy for cold data is: migrate to NVM to release DRAM resources.
[0038] Among them, setting hot and cold marks for memory pages according to hot and cold scores includes: comparing the hot and cold scores to a first threshold; When the hot / cold score is less than a first threshold and the utilization of the storage medium of the high-bandwidth memory is greater than a preset utilization threshold, a hot / cold mark is set for the memory page as cold data, and the memory data of the memory page is forcibly migrated; When the hot / cold score is greater than or equal to the first threshold and less than or equal to the second threshold, the hot / cold mark is set for the memory page as warm data, and the memory data of the memory page is asynchronously migrated.
[0039] In this embodiment, an adaptive migration strategy is adopted: a hardware migration circuit is designed in the CXL controller to automatically migrate cold data to a low-power medium (such as SCM / NVM), and hot data is retained in DRAM.
[0040] Forced migration: When Score < 0.4 and DRAM utilization > 80%, cold data is migrated immediately. Recommended migration: Asynchronously migrate the data with Score ∈ [0.4, 0.6] to avoid blocking the critical path.
[0041] like Figure 5 As shown, in this embodiment, in response to transferring the memory data of the memory page, the address of the storage medium where the memory page is located and the address of the target storage medium are obtained, and whether the current operation mode of the target storage medium supports the data transfer is determined, including: S31, after confirming the memory data type and the target storage medium of the memory page, performing address conversion, and obtaining the address of the target storage medium by querying the address conversion table; S32, obtaining the current operation mode of the target storage medium according to the address of the target storage medium, and obtaining the transfer operation mode preset for data transfer of the target storage medium; S33, determining whether the current operation mode of the target storage medium is the transfer operation mode, if so, determining that the current operation mode of the target storage medium supports data transfer, otherwise determining that the current operation mode of the target storage medium does not support data transfer.
[0042] Among them, the address translation table is an SRAM that stores 16K entry mapping relationships, and the hash index is combined with the Bloom filter to achieve a 5ns query delay.
[0043] like Figure 6As shown, in this embodiment, in response to the current operation mode of the target storage medium supporting data transfer, migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium includes: S41, migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, and determining whether the memory data of the memory page has been transferred; S42: in response to the completion of the transfer of the memory data of the memory page, the address translation table is updated to release the space of the storage medium where the memory page is located.
[0044] This application can reduce energy consumption and avoid energy consumption of maintaining a larger storage space by timely releasing the space of the storage medium where the memory page is located.
[0045] In this embodiment, before migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, the following steps are also included: The address of the storage medium where the memory page is located is locked, and the memory data of the memory page is read from the address of the storage medium where the memory page is located.
[0046] Among them, concurrent access conflicts can be prevented by locking the address of the storage medium where the memory page is located.
[0047] In this embodiment, before migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, the following steps are also included: Determine the validity of data migration permissions and parameters. If valid, check whether they meet the switching restriction conditions. If invalid, issue an alarm message. In response to meeting the switching restriction condition, it is determined that the data migration is legal, and the memory data of the memory page is migrated to the target storage medium.
[0048] The CXL controller parses the request, verifies the validity of permissions and parameters, and checks whether the switching restrictions are met. If legal, the information is sent to the target medium, driving the GPIO signal to switch the medium state and update the internal state machine.
[0049] In this embodiment, converting the current operation mode of the target storage medium to support data transfer includes: Obtain whether there is an intermediate transition mode when the current operation mode of the target storage medium is converted to a transfer operation mode preset for data transfer; In response to the existence of the intermediate transition mode, converting the current operation mode of the target storage medium into the intermediate transition mode, and then converting the intermediate transition mode into the transfer operation mode; In response to the absence of the intermediate transition mode, the current operation mode of the target storage medium is converted to the transfer operation mode.
[0050] The data migration engine drives the storage medium to switch the operation mode through GPIO signals, making the DRAM switching delay less than 100ns.
[0051] Specifically, define multiple power consumption modes P1-P6, and dynamically switch according to the storage medium type: DRAM: full speed mode (P1: 5W / GB), self-refresh mode (P2: 1W / GB); SCM: full speed mode (P3: 2W / GB), low power mode (P4: 0.5W / GB); NVM: full speed mode (P5: 1W / GB), deep sleep mode (P6: 0.1W / GB).
[0052] The state migration mechanism of each storage medium is as follows: First, the full-speed mode of DRAM state migration is converted to self-refresh mode: Condition: DRAM is not accessed for 5 consecutive cycles (5ms).
[0053] Operation: Send the PRECHARGE ALL command to enter low power consumption state.
[0054] Second, the DRAM state migration self-refresh mode is converted to full-speed mode: Condition: An access request is detected.
[0055] Action: Send the REFRESH EXIT command to resume full-speed mode.
[0056] Third, the SCM state transitions from full-speed mode to low-power mode: Condition: The SCM has not been accessed for 20 consecutive cycles (20ms).
[0057] Action: Shut down the redundant power domain, preserving critical status registers.
[0058] Fourth, the low-power mode of SCM state migration is converted to full-speed mode: Condition: An access request was detected. Action: Restore power and initialize the I / O interface.
[0059] Fifth, the full-speed mode of NVM state migration is converted to deep sleep mode: Condition: NVM is not accessed for 100 consecutive cycles (100ms).
[0060] Operation: Disconnect the main power supply, leaving only the standby circuit.
[0061] Sixth, NVM state migration deep sleep mode to full speed mode: Condition: The controller sends an activate command or a direct access request.
[0062] Action: Re-power on and load the metadata.
[0063] In this embodiment, converting the current operation mode of the target storage medium to support data transfer includes: Obtaining target storage medium restriction conditions of the target storage medium, parsing the target storage medium restriction conditions to determine a precondition for switching from a current operation mode to a target operation mode supporting data transfer; The target storage medium is controlled to meet the precondition, and after the target storage medium meets the precondition, the current operation mode is converted to the target operation mode.
[0064] The switching restrictions are as follows: DRAM: It is not possible to switch directly from full-speed mode to deep sleep mode, and a transition through self-refresh mode is required; SCM: Writing is prohibited in low power mode, only reading is supported; NVM: Deep sleep mode requires at least 1ms wake-up time, during which access requests are queued.
[0065] Among them, by first obtaining the restriction conditions of the conversion when converting the current operating mode of the target storage medium to support data transfer, and then realizing the operating mode conversion after the preconditions are met, it can be ensured that the operating mode conversion is completed smoothly.
[0066] In this embodiment, converting the current operation mode of the target storage medium to support data transfer includes: Configuring the target storage medium to a demand state according to the energy consumption management information, and sending a pre-wake-up signal to the target storage medium; In response to the target storage medium receiving the pre-wake-up signal, the operation mode is switched.
[0067] When data enters the memory module through the CXL controller, the CXL controller obtains data information through the CXL.io protocol, and marks a memory page as hot data (Hot), warm data (Warm), and cold data (Cold) through the hot and cold score calculator. After confirming the data type and the target storage medium, the data migration engine performs address conversion and obtains the target DRAM / SCM / NVM physical address by querying the address conversion table. At this time, the DMA controller is notified to read data from the source DRAM through the CXL.memory protocol, and migrate the memory data to the target storage medium according to the DRAM / SCM / NVM target address. After completing the data migration, the address conversion table is updated to release the source DRAM space.
[0068] At the same time, the power consumption mode, medium information, mode switching and other information are sent to the target storage medium through the CXL.memory protocol. The target storage medium is configured to the required state according to the energy consumption management information. At this time, if the target DRAM / SCM / NVM is in low power consumption or self-refresh mode, a pre-wake-up signal will be sent; it supports dynamic operation mode switching of DRAM, SCM, and NVM, and can report the real-time energy consumption status to the host by extending the CXL.io protocol field.
[0069] In this embodiment, after transferring the memory data of the memory page, the following steps are further included: Acquire the real-time energy consumption status data of the target storage medium, set the preset duration for reporting the real-time energy consumption status data, and report the real-time energy consumption status data of the target storage medium to the host end according to the preset duration or after the operation mode of the target storage medium is converted.
[0070] A new 16-byte extension field is added to the CXL.memory TLP of the CXL protocol layer, including the media type (DRAM / SCM / NVM), current power consumption mode (full-speed mode / low-power mode / deep sleep mode) and cumulative energy consumption value (μJ). The newly added 16-byte field is located in the TLP header extension area, which does not affect the original data transmission and control logic and is compatible with existing CXL devices (such as memory modules and accelerators). In addition, the ASIC / FPGA controller can support the parsing of the new field through microcode upgrades without the need to reconstruct the physical layer and link layer design.
[0071] The CXL protocol layer also includes mode switching instructions, and defines a dedicated opcode (Opcode=0x2F) for issuing switching commands, supporting execution and permission verification, etc. An example of switching SCM to low power mode is: media type=0x2, target mode=0x1.
[0072] CXL.io adds control information bytes such as energy consumption status and data migration.
[0073] In this embodiment, the memory management method further includes: Send a request packet to the memory module, the request packet is used to send an operation mode switching command or an energy consumption query request; After sending the request packet, a completion packet is obtained, which is used to return energy consumption status data or operation mode switching operation results.
[0074] The CXL protocol is designed to be highly scalable, and its transaction layer reserves flexible header expansion space to support the addition of custom fields. New fields are registered through the CXL.memory and CXL.io management interfaces to ensure collaborative operations between the host and the device, achieve elastic expansion of memory pool resources, and avoid conflicts with the CXL.cache protocol. CXL.memory defines the transmission mechanism through TLP extension, (status management unit) mainly completes device status energy consumption query and energy consumption mode switching, where the request packet (Request TLP) is used to issue mode switching commands or query requests; the completion packet (Completion TLP) is used to return energy consumption status or confirm operation results.
[0075] The energy consumption status data feedback is reported periodically. By default, the current status is reported once every 1ms through Completion TLP, and it is reported immediately after the storage medium operation mode is switched. Users can also integrate command tools in the firmware for active query, and the Host forces the acquisition of real-time status through Request TLP.
[0076] The energy consumption mode switching can be sent by the CXL controller to the target medium, or the user can send the switching command on the host side. The implementation steps are as follows: 1. Software initiates a request: The host driver constructs a Request TLP (Opcode=0x2F) to specify the target medium and mode; Example: Switching SCM to low power mode is as follows: media type = 0x2, target mode = 0x1.
[0077] 2. Controller response: The CXL controller parses the request, verifies permissions and parameter validity, and checks whether the switching restrictions are met (described below); if legal, it sends the information to the target medium, drives the GPIO signal to switch the medium state, and updates the internal state machine.
[0078] 3. Completion confirmation: The CXL controller returns a Completion TLP containing the result of the operation (success / failure code). Appends error details on failure (such as invalid mode or media failure).
[0079] The switching restrictions are as follows: DRAM cannot be switched directly from full-speed mode to deep sleep mode, and must transition through self-refresh mode; In the low power mode of SCM, writing is prohibited and only reading is supported; The deep sleep mode of NVM requires at least 1ms wake-up time, during which access requests are queued.
[0080] The specific field extension definition in CXL.Mem TLP is shown in Table 1.
[0081] Table 1 Field extension definition
[0082] Through the above medium power consumption definition and state migration mechanism, dynamic load adaptation can be achieved, data location can be dynamically allocated in combination with hot and cold scores (Score), and the utilization rate of each medium can be monitored in real time. Collaborative operation at the protocol layer, through CXL.mem, CXL.io protocol extension field (ESF) to report and send the current power consumption mode, real-time statistics of the energy consumption proportion of each medium, optimize task scheduling, achieve the effect of on-demand allocation of hot and cold data, dynamic management of energy consumption, and allocate resource costs according to energy consumption in cloud computing scenarios.
[0083] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.
[0084] like Figure 7 , Figure 8 As shown, an embodiment of the present application further provides a memory management device 10, comprising: a cold and hot score calculator 1, an energy consumption management module 2 and a data migration engine 3; The hot and cold score calculator 1 is used to obtain the memory data of the memory page in the memory module, obtain the hot and cold score of the memory data of the memory page, and set the hot and cold mark for the memory page according to the hot and cold score; The data migration engine 3 is used to obtain the type of storage medium where the memory page is located, and determine whether to transfer the memory data of the memory page according to the type of storage medium and the hot and cold flags set for the memory page; The energy consumption management module 2 is used for obtaining the address of the storage medium where the memory page is located and the address of the target storage medium in response to transferring the memory data of the memory page, and determining whether the current operation mode of the target storage medium supports the data transfer; The data migration engine 3 is used to migrate the memory data of the memory page to the target storage medium according to the address of the target storage medium in response to the current operating mode of the target storage medium supporting data transfer. Otherwise, the energy consumption management module 2 is used to convert the current operating mode of the target storage medium to support data transfer.
[0085] In this embodiment, obtaining memory data of a memory page in a memory module, obtaining a hot / cold score of the memory data of the memory page, and setting a hot / cold mark for the memory page according to the hot / cold score include: Get the access frequency, temporal locality and task priority of memory data of memory pages; Obtain the hot and cold scores of the memory data of the memory page according to the access frequency, temporal locality and task priority of the memory data of the memory page; Get the types of hot and cold tags, which include hot data, warm data, and cold data. Mark the memory pages with hot and cold tags according to the hot and cold scores of the memory data of the memory pages.
[0086] In this embodiment, obtaining the hot / cold score of the memory data of the memory page according to the access frequency, temporal locality and task priority of the memory data of the memory page includes: Set temporal locality to a weight value that decreases over time based on an exponential decay model; Set weight coefficients for access frequency, temporal locality, and task priority; The access frequency, temporal locality, and task priority are multiplied by their corresponding weight coefficients and then summed to obtain the hot and cold scores of the memory data of the memory page.
[0087] In this embodiment, obtaining the type of storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of storage medium and the hot and cold flags set for the memory page includes: Obtaining a storage medium type in a memory module, the storage medium type including high bandwidth memory, low power consumption medium, and large capacity memory; Obtain the type of preset hot and cold marks of the memory data stored corresponding to the storage medium type, the memory data marked as hot data in the high-bandwidth memory, the memory data marked as warm data in the low-power medium, and the memory data marked as cold data in the large-capacity storage; Obtain the type of preset hot and cold marks corresponding to the type of storage medium where the memory page is located, and determine whether the hot and cold marks marked by the memory data of the memory page are the same as the type of preset hot and cold marks corresponding to the type of storage medium where the memory page is located; if they are different, determine to transfer the memory data of the memory page; otherwise, determine not to transfer the memory data of the memory page.
[0088] In this embodiment, in response to transferring the memory data of the memory page, obtaining the address of the storage medium where the memory page is located and the address of the target storage medium, and determining whether the current operation mode of the target storage medium supports the data transfer includes: After confirming the memory data type and the target storage medium of the memory page, address conversion is performed, and the address of the target storage medium is obtained by querying the address conversion table; Acquire the current operation mode of the target storage medium according to the address of the target storage medium, and acquire the transfer operation mode preset by the target storage medium for data transfer; It is determined whether the current operation mode of the target storage medium is the transfer operation mode. If so, it is determined that the current operation mode of the target storage medium supports data transfer. Otherwise, it is determined that the current operation mode of the target storage medium does not support data transfer.
[0089] In this embodiment, in response to the current operation mode of the target storage medium supporting data transfer, migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium includes: Migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, and determining whether the memory data of the memory page has been transferred; In response to the completion of the transfer of the memory data of the memory page, the address translation table is updated to release the space of the storage medium where the memory page is located.
[0090] In this embodiment, before migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, the following steps are also included: The address of the storage medium where the memory page is located is locked, and the memory data of the memory page is read from the address of the storage medium where the memory page is located.
[0091] In this embodiment, before migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, the following steps are also included: Determine the validity of data migration permissions and parameters. If valid, check whether they meet the switching restriction conditions. If invalid, issue an alarm message. In response to meeting the switching restriction condition, it is determined that the data migration is legal, and the memory data of the memory page is migrated to the target storage medium.
[0092] In this embodiment, converting the current operation mode of the target storage medium to support data transfer includes: Obtain whether there is an intermediate transition mode when the current operation mode of the target storage medium is converted to a transfer operation mode preset for data transfer; In response to the existence of the intermediate transition mode, converting the current operation mode of the target storage medium into the intermediate transition mode, and then converting the intermediate transition mode into the transfer operation mode; In response to the absence of the intermediate transition mode, the current operation mode of the target storage medium is converted to the transfer operation mode.
[0093] In this embodiment, converting the current operation mode of the target storage medium to support data transfer includes: Configuring the target storage medium to a demand state according to the energy consumption management information, and sending a pre-wake-up signal to the target storage medium; In response to the target storage medium receiving the pre-wake-up signal, the operation mode is switched.
[0094] In this embodiment, after transferring the memory data of the memory page, the following steps are further included: Acquire the real-time energy consumption status data of the target storage medium, set the preset duration for reporting the real-time energy consumption status data, and report the real-time energy consumption status data of the target storage medium to the host end according to the preset duration or after the operation mode of the target storage medium is converted.
[0095] like Figure 7 As shown, in this embodiment, the memory management device 10 further includes: an instruction query module 4.
[0096] The instruction query module 4 is used to send a request packet to the memory module, the request packet is used to issue an operation mode switching command or an energy consumption query request; after sending the request packet, a completion packet is obtained, and the completion packet is used to return energy consumption status data or an operation mode switching operation result.
[0097] For the description of the features in the embodiment corresponding to the memory management device, reference can be made to the relevant description of the embodiment corresponding to the memory management method, which will not be repeated here.
[0098] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above-mentioned memory management method embodiments.
[0099] The electronic device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store memory management data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a memory management method is implemented.
[0100] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned memory management method embodiments when running.
[0101] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0102] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above memory management method embodiments are implemented.
[0103] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned memory management method embodiments are implemented.
[0104] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0105] The above is a detailed introduction to a memory management method, electronic device, storage medium and computer program product provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A memory management method, characterized in that: include: Acquire memory data of a memory page in a memory module, acquire a hot / cold score of the memory data of the memory page, and set a hot / cold mark for the memory page according to the hot / cold score; Obtaining the type of the storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page; In response to transferring the memory data of the memory page, an address of a storage medium where the memory page is located and an address of a target storage medium are obtained, and it is determined whether a current operation mode of the target storage medium supports data transfer; In response to the current operating mode of the target storage medium supporting data transfer, the memory data of the memory page is migrated to the target storage medium according to the address of the target storage medium, otherwise the current operating mode of the target storage medium is converted to support data transfer.
2. The memory management method according to claim 1, characterized in that: The acquiring memory data of a memory page in a memory module, acquiring a hot / cold score of the memory data of the memory page, and setting a hot / cold mark for the memory page according to the hot / cold score comprises: Obtaining access frequency, temporal locality, and task priority of memory data of the memory page; Obtaining a hot / cold score of the memory data of the memory page according to the access frequency, temporal locality, and task priority of the memory data of the memory page; The types of hot and cold marks are obtained, where the hot and cold marks include hot data, warm data, and cold data, and the hot and cold marks are marked on the memory page according to the hot and cold scores of the memory data of the memory page.
3. The memory management method according to claim 2, characterized in that: The step of obtaining the hot / cold score of the memory data of the memory page according to the access frequency, time locality and task priority of the memory data of the memory page includes: Setting the temporal locality to a weight value that decreases over time based on an exponential decay model; Setting weight coefficients of the access frequency, the temporal locality, and the task priority; The access frequency, the temporal locality, and the task priority are respectively multiplied by their corresponding weight coefficients and then summed to obtain a hot / cold score of the memory data of the memory page.
4. The memory management method according to claim 2, characterized in that: The obtaining the type of the storage medium where the memory page is located, and determining whether to transfer the memory data of the memory page according to the type of the storage medium and the hot and cold flags set for the memory page includes: Acquire a storage medium type in the memory module, wherein the storage medium type includes a high-bandwidth memory, a low-power medium, and a large-capacity memory; Acquire the type of preset hot and cold marks of the memory data stored in the storage medium type, the high-bandwidth memory stores the memory data marked as hot data, the low-power medium stores the memory data marked as warm data, and the large-capacity memory stores the memory data marked as cold data; Obtain the type of preset hot and cold marks corresponding to the type of storage medium where the memory page is located, and determine whether the hot and cold marks marked by the memory data of the memory page are the same as the type of preset hot and cold marks corresponding to the type of storage medium where the memory page is located; if they are different, determine to transfer the memory data of the memory page; otherwise, determine not to transfer the memory data of the memory page.
5. The memory management method according to claim 1, characterized in that: In response to transferring the memory data of the memory page, acquiring the address of the storage medium where the memory page is located and the address of the target storage medium, and determining whether the current operation mode of the target storage medium supports data transfer includes: After confirming the memory data type of the memory page and the target storage medium, performing address conversion, and obtaining the address of the target storage medium by querying an address conversion table; Acquire the current operation mode of the target storage medium according to the address of the target storage medium, and acquire the transfer operation mode preset by the target storage medium for data transfer; Determine whether the current operation mode of the target storage medium is the transfer operation mode, if so, determine that the current operation mode of the target storage medium supports data transfer, otherwise, determine that the current operation mode of the target storage medium does not support data transfer.
6. The memory management method according to claim 5, characterized in that: In response to the current operation mode of the target storage medium supporting data transfer, migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium comprises: Migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, and determining whether the memory data of the memory page has been transferred; In response to the completion of the transfer of the memory data of the memory page, the address translation table is updated to release the space of the storage medium where the memory page is located.
7. The memory management method according to claim 6, characterized in that: Before migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, the method further includes: The address of the storage medium where the memory page is located is locked, and the memory data of the memory page is read from the address of the storage medium where the memory page is located.
8. The memory management method according to claim 6, characterized in that: Before migrating the memory data of the memory page to the target storage medium according to the address of the target storage medium, the method further includes: Determine the validity of data migration permissions and parameters. If valid, check whether they meet the switching restriction conditions. If invalid, issue an alarm message. In response to meeting the switching restriction condition, it is determined that the data migration is legal, and the memory data of the memory page is migrated to the target storage medium.
9. The memory management method according to claim 5, characterized in that: Converting the current operation mode of the target storage medium to support data transfer includes: Acquire whether there is an intermediate transition mode when the current operation mode of the target storage medium is converted into a transfer operation mode preset for data transfer; In response to the existence of the intermediate transition mode, converting the current operation mode of the target storage medium to the intermediate transition mode, and then converting the intermediate transition mode to the transfer operation mode; In response to the absence of the intermediate transition mode, the current operation mode of the target storage medium is converted to the transfer operation mode.
10. The memory management method according to claim 1, characterized in that: Converting the current operation mode of the target storage medium to support data transfer includes: Configuring the target storage medium to a demand state according to the energy consumption management information, and sending a pre-wake-up signal to the target storage medium; In response to the target storage medium receiving the pre-wake-up signal, an operation mode conversion is performed.
11. The memory management method according to claim 1, characterized in that: After transferring the memory data of the memory page, the method further includes: Acquire real-time energy consumption status data of the target storage medium, set a preset duration for interval reporting of the real-time energy consumption status data, and report the real-time energy consumption status data of the target storage medium to the host end according to the preset duration or after the operating mode of the target storage medium is converted.
12. The memory management method according to claim 1, characterized in that: Also includes: Sending a request packet to the memory module, wherein the request packet is used to send an operation mode switching command or an energy consumption query request; After sending the request packet, a completion packet is obtained, and the completion packet is used to return energy consumption status data or operation results of the operation mode switching.
13. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the memory management method according to any one of claims 1 to 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the memory management method according to any one of claims 1 to 12.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the memory management method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Coroutine execution method and device
CN114063894A
Data processing method and device, processor and hybrid memory system
CN115904212A
COMPUTING HIGH SPEED NONVOLATILE MEMORY (NVMe) ON HIGH SPEED LINK (CXL)
CN116486868A
Management method and management device of hybrid memory system, equipment and medium
CN117234432A
Layered memory page management method and system based on random dynamic access memory and heterogeneous memory
CN119201452A
Cited By
Heterogeneous acceleration method of database, electronic equipment, storage medium and program product
CN120561153A
Memory hierarchical management method, electronic equipment, storage medium and program product
CN120832310A
Storage control system and storage control method
CN120892218A
A storage control system and a storage control method
CN120892218B
Memory management method, electronic device, storage medium, and computer program product
WO2026194301A1