WO2024061344A1 - 数据迁移方法、装置、芯片以及计算机可读存储介质 - Google Patents

数据迁移方法、装置、芯片以及计算机可读存储介质 Download PDF

Info

Publication number
WO2024061344A1
WO2024061344A1 PCT/CN2023/120667 CN2023120667W WO2024061344A1 WO 2024061344 A1 WO2024061344 A1 WO 2024061344A1 CN 2023120667 W CN2023120667 W CN 2023120667W WO 2024061344 A1 WO2024061344 A1 WO 2024061344A1
Authority
WO
WIPO (PCT)
Prior art keywords
storage unit
data
migration
storage medium
storage
Prior art date
Application number
PCT/CN2023/120667
Other languages
English (en)
French (fr)
Inventor
杨春
卢霄
王官皓
杨瑞
祝晓平
罗兴宇
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2024061344A1 publication Critical patent/WO2024061344A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers

Definitions

  • the present application relates to the field of storage technology, and in particular to a data migration method, device, chip and computer-readable storage medium.
  • the processor of the computing device can be configured with a hybrid memory system including multiple storage media.
  • the storage performance of each storage medium in the hybrid memory system is different, and the processor can store a certain storage medium in the hybrid memory system. Migrate the data to another storage medium to take advantage of the storage performance of each storage medium.
  • each storage medium in the hybrid memory system includes multiple pages.
  • the processor For the pages to be migrated (that is, old pages) of a certain storage medium in the hybrid memory system, the processor first Allocate a page of another storage medium (i.e., a new page), then obtain the page lock of the old page, cancel the mapping relationship of the old page in the page table, and invalidate the old page in the translation lookaside buffer (TLB) TLB table entry, then, obtain the page lock of the new page, copy the data from the old page to the new page, and finally, complete the mapping of the new page through the page table, release the page lock of the new page, release the old page and the pages of the old page Lock.
  • TLB translation lookaside buffer
  • the above data migration process relies on the page lock mechanism.
  • the processor needs to obtain the page locks of the old page and the new page respectively. After completing the data migration, it also needs to release the page locks of the old page and the new page.
  • the data migration process is complicated and increases This shortens the data migration time and reduces data migration efficiency.
  • This application provides a data migration method, device, chip and computer-readable storage medium, which can improve data migration efficiency.
  • a data migration method is provided.
  • the method is applied to a hybrid memory system.
  • the hybrid memory system includes a first storage medium and a second storage medium.
  • the method includes the following steps: obtaining a data migration request, wherein the data migration request indication Migrating the data in the first storage unit of the first storage medium to the second storage medium; then, migrating the data in the first storage unit to the second storage unit in the second storage medium; integrating the first storage unit into The first address associated during addressing is assigned to the second storage unit, where the second storage unit does not participate in unified addressing in the hybrid memory system.
  • This method migrates the data in the storage unit to a storage unit in the second storage medium that does not participate in unified addressing when a data migration request for the storage unit of the first storage medium is obtained.
  • the storage unit of the address does not support application access.
  • the storage unit that does not participate in unified addressing does not need to be locked. , which simplifies the migration process and accordingly reduces the data migration time and improves the data migration efficiency.
  • mapping relationship between the first address and the second address of the first storage unit in the first storage medium to indicate that the first address is assigned to the first storage unit.
  • the decoupling of the placement of the first address and the second address in the hybrid memory system is achieved. Without changing the first address, the migration of data in different storage media is achieved without affecting the processor. execution process.
  • the method further includes the following steps: receiving a first data write request from the application program, the first data write request indicating writing of data to the first storage unit; and then, according to the first data write request , query the migration status of the first storage unit; if the migration status is migrating, convert the first data write request into a second data write request, where the migration status indicates the migration progress of the first storage unit, and the migration status indicates that the first data write request is being transferred. Data in one storage unit is migrated to a second storage unit, and the second data write request indicates writing data to the second storage unit.
  • the processor writes data to the first address during the data migration process, the data will be written to the first storage unit or the second storage unit according to the migration status of the first storage unit associated with the first address. , to overwrite the old data stored in the first address and ensure that the data written to the first address is the latest data, so that the processor can later read the latest data in the first address.
  • the method further includes the following steps: receiving a first data read request from the application program, wherein the first data read request indicates reading data from the first cache line of the first storage unit; and then , according to the first data read request, obtain the write status of the second cache line corresponding to the first cache line in the second storage unit; if the write status is write completion, convert the first data read request to the second data read request, wherein the write status indicates the progress of writing data to the second cache line, the write completion indicates that the second cache line has written data, and the second data read request indicates that the data is read from the second cache line.
  • the processor reads the data in the first cache line of the first storage unit, according to the writing of the second cache line corresponding to the first cache line in the second storage unit, Enter the state and read data in the first storage unit or the second cache line to ensure that the latest data is read.
  • the above-mentioned process of obtaining the data migration request includes: first performing data migration detection on the first storage medium; if it is detected that the first storage unit meets the migration conditions, generating a data migration request.
  • the first storage unit satisfying the migration condition includes the number of accesses of the first storage unit reaching the value range of the migration threshold.
  • the above-mentioned process of detecting data migration on the first storage medium includes : Detect a data access request sent to the hybrid memory system, the data access request indicates access to a storage unit in the hybrid memory system; obtain the number of times the first storage unit has been accessed based on the detected data access request.
  • the first storage unit satisfies the migration conditions including that the access delay of the first storage medium is less than the access delay of the second storage medium, the number of free storage units in the first storage medium is less than or equal to the number threshold, and the first storage unit is a non-free storage unit whose access times do not reach the access threshold; based on this, the above-mentioned process of performing data migration detection on the first storage medium includes: first obtaining the access times of each storage unit in the first storage medium; and then determining the free storage units and non-free storage units in the first storage medium according to the access times of each storage unit in the first storage medium.
  • the free storage units and non-free storage units in the first storage medium are determined by the number of accesses to each storage unit in the first storage medium, without having to query whether each storage unit in the first storage medium stores data.
  • the determination method is simple and quick.
  • the method further includes the following steps: if it is detected that the first storage unit meets the migration condition and a data access request for the first storage unit is received from the application program, generating a data migration request.
  • the method before the step of migrating data in the first storage unit to the second storage unit in the second storage medium, the method also includes the following steps: determining the second storage unit from candidate storage units of the second storage medium, the candidate storage unit being an idle storage unit that does not participate in unified addressing.
  • the second storage unit is determined from the free storage units that do not participate in unified addressing, so that the data in the first storage unit is migrated to the free storage unit that does not participate in unified addressing.
  • the free storage unit with unified addressing does not support application access and does not store data.
  • migrating data to the free storage unit that does not participate in unified addressing write consistency problems will not occur, so there is no need to modify the free storage unit that does not participate in unified addressing.
  • Unit locking simplifies the migration process and improves data migration efficiency.
  • the candidate storage unit is located in the candidate storage unit queue of the second storage medium. After migrating the data in the first storage unit to the second storage unit, the method further includes the following steps: removing the candidate The second storage unit in the storage unit queue; if the candidate storage units in the candidate storage unit queue are not full, add the idle storage units in the second storage medium that participate in unified addressing to the candidate storage unit queue.
  • the storage space in the second storage medium used to store the migrated data and does not support application programs to write data is dynamically maintained, so that subsequent data migration to the second storage medium is not affected.
  • a data migration method is provided.
  • the method is applied to a hybrid memory system.
  • the hybrid memory system includes a first storage medium and a second storage medium.
  • the method includes the following steps: obtaining a data migration request, where the data migration request Instruct to migrate the data in the first storage unit of the first storage medium to the second storage medium; then determine the second storage unit from the candidate storage units of the second storage medium; and then, transfer the data in the first storage unit Migrate to a second storage unit in the second storage medium, where the candidate storage unit is a free storage unit that does not participate in unified addressing.
  • This method migrates the data in the storage unit to an idle storage unit in the second storage medium that does not participate in unified addressing when a data migration request for the storage unit of the first storage medium is obtained.
  • the addressed free storage unit does not support application access and does not store data.
  • Addressed free storage units do not need to be locked, which simplifies the migration process.
  • the data migration time is reduced and the data migration efficiency is improved.
  • a data migration device in a third aspect, includes various modules for executing the data migration method in the first aspect or any possible implementation of the first aspect, or the device includes modules for executing the second aspect. Each module of the data migration method.
  • the fourth aspect provides a chip, which is used to implement the operation steps of the data migration method as in the first aspect or any possible implementation of the first aspect, or the chip is used to implement the data migration as in the second aspect. The steps of the method.
  • a computer-readable storage medium is provided. At least one program code is stored in the storage medium. The program code is read by the processor to cause the chip to perform the operation steps of the above-mentioned data migration method.
  • a computer program product or computer program includes program code.
  • the program code is stored in a computer-readable storage medium.
  • the processor of the chip reads the program code from the computer-readable storage medium.
  • the program code is executed by the processor, so that the chip executes the method provided in the above-mentioned first aspect or various optional implementations of the first aspect.
  • Figure 1 is a schematic diagram of an application system of a data migration access method provided by this application
  • Figure 2 is a structural diagram of an electronic device applying a data migration method provided by this application
  • Figure 3 is a structural diagram of another electronic device applying a data migration method provided by this application.
  • Figure 4 is a flow chart of a data migration method provided by this application.
  • Figure 5 is a flow chart provided by this application for obtaining data migration requests based on method A;
  • Figure 6 is a flow chart provided by this application for obtaining data migration requests based on method B;
  • Figure 7 is a flow chart of a data migration process provided by this application.
  • Figure 8 is an access flow chart of a storage unit in the case of parallel data migration and data writing provided by this application;
  • FIG. 9 is a schematic diagram of a data migration process provided by the present application when a first data write request reaches the manager before a migration read request;
  • Figure 10 is a schematic diagram of the data migration process provided by this application when the first data write request reaches the manager after the read request is migrated and before the write request is migrated;
  • Figure 11 is a schematic diagram of the data migration process when the first data write request reaches the manager after the migration write request provided by this application;
  • Figure 12 is a flow chart of accessing a storage unit in the case of parallel data migration and data reading provided by this application;
  • Figure 13 is a schematic diagram of the data migration process when the first data read request reaches the manager after migrating the write request provided by this application;
  • Figure 14 is a schematic diagram of the data migration process when a processor accesses the first storage unit twice;
  • Figure 15 is a flow chart of data migration based on processor access commands provided by this application.
  • Figure 16 is a schematic structural diagram of a data migration device provided by this application.
  • Figure 17 is a schematic structural diagram of another data migration device provided by this application.
  • Figure 18 is a schematic structural diagram of a chip provided by this application.
  • this application provides a data migration method applied to a hybrid memory system.
  • the storage units participating in unified addressing When there is a need for data migration between two storage media in the hybrid memory system, the storage units participating in unified addressing and When performing data migration for storage units that do not participate in unified addressing, the data in the storage units to be migrated is migrated to storage units that do not participate in unified addressing in other storage media in the hybrid memory system.
  • FIG. 1 is a schematic diagram of an application system of a data migration access method provided by this application.
  • the application system includes a processor 101, a cache (cache) 102, a hybrid memory system 103 and a manager of the hybrid memory system 103 104.
  • the processor 101 can adopt an application-specific integrated circuit (ASIC), a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable gate array. It can be implemented by at least one hardware form in a programmable logic array (PLA).
  • the processor 101 can also have other hardware implementation methods, which is not limited in this application.
  • the processor 101 is, for example, a central processing unit (CPU).
  • the processor 101 can also be implemented using an image processor (graphics processing unit, GPU) or a data processing unit (data processing unit, DPU).
  • the GPU is responsible for rendering and drawing the content that needs to be displayed on the display.
  • the processor 101 also includes an artificial intelligence (artificial intelligence, AI) processor, which is used to process computing operations related to machine learning.
  • AI artificial intelligence
  • the processor 101 accesses the storage medium 31 of the hybrid memory system 103 to read data from or write data to the storage medium 31 data.
  • the processor 101 may copy part of the data in the storage medium 31 to the cache 102 so that this part of the data can be quickly read from the cache 102 later.
  • the application system does not include the cache 102 , and in this case the processor 101 directly accesses the storage medium 31 .
  • the hybrid memory system 103 includes a variety of storage media 31, which are used to store data (such as code or business data).
  • Various storage media 31 such as static random access high bandwidth memory (HBM) 311, phase change memory (PCM) 312 and double rate synchronous dynamic random access memory (double data Rate) shown in Figure 1 SDRAM, DDR)313.
  • the hybrid memory system 103 includes any two of these three storage media, or other storage media in addition to these three storage media, such as magnetic random access memory (magnetic random access memory, MRAM), static random-access memory (static random-access memory, SRAM), etc.
  • MRAM magnetic random access memory
  • SRAM static random-access memory
  • the embodiment of the present application does not limit the number and type of storage media 31 in the hybrid memory system 103.
  • the hybrid memory system 103 also includes a controller 32 of the storage medium 31 .
  • the controller 32 is used to implement data exchange between the corresponding storage medium 31 and the processor 101 .
  • the controllers 32 of HBM311, PCM312 and DDR313 are respectively: HBM controller 321, PCM controller 322 and DDR controller 323.
  • the manager 104 is used to connect the cache 102 and each controller 32.
  • the application system does not include the cache 102.
  • the manager 104 is used to connect the processor 101 and each controller 32. Controller 32.
  • the manager 104 serves as the upper-level controller of the controller 32 and interacts with the processor 101 in data. For example, when the processor 101 accesses the HBM 311, the processor 101 sends an access request to the HBM 311 to the manager 104.
  • the manager 104 sends the data access request to the HBM controller 321, and the HBM controller 321 accesses the HBM 311 according to the data access request. , wherein the data access request indicates access to a storage unit in the hybrid memory system 103 .
  • different storage media 31 in the hybrid memory system 103 have different storage performance. For example, some storage media 31 have large storage capacity but high access latency, while some storage media 31 have small storage capacity but low access latency.
  • the manager 104 is also used to migrate data in any storage medium 31 in the hybrid memory system 103 to another storage medium 31 through this data migration method, so as to take advantage of the advantageous performance of each storage medium 31 in the hybrid memory system 103 .
  • the manager 104 is implemented by software, hardware, or a combination of software and hardware.
  • the manager 104 is an example of a software functional unit.
  • the manager 104 includes code running on a computing instance.
  • the computing instance includes at least one of a virtual machine and a container.
  • the above computing instance may be one or more.
  • the manager 104 includes code running on multiple virtual machines/containers.
  • multiple virtual machines/containers used to run the code may be distributed in the same region (region), or they may be distributed in different regions.
  • multiple virtual machines/containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs.
  • Each AZ includes a data center or multiple geographical locations. Data centers in close proximity. Among them, usually a region can include multiple AZs.
  • VPC virtual private cloud
  • multiple virtual machines/containers used to run the code can be distributed in the same virtual private cloud (VPC) or across multiple VPCs.
  • VPC virtual private cloud
  • Cross-region communication between two VPCs in the same region and between VPCs in different regions requires a communication gateway in each VPC, and the interconnection between VPCs is realized through the communication gateway. .
  • the manager 104 is an example of a hardware functional unit.
  • the manager 104 may be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD).
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • the above-mentioned PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a general array logic (generic array logic, GAL), or any combination thereof.
  • CPLD complex programmable logical device
  • FPGA field-programmable gate array
  • GAL general array logic
  • the application system shown in Figure 1 is provided by an electronic device, which may be a server or a terminal device.
  • the server may be a cloud server, a central server, an edge server, or a remote data center. Remote server or local server in local data center, etc.
  • Terminal devices such as desktop computers, laptops, or smartphones.
  • the storage medium 31 in the hybrid memory system 103 may be an on-chip memory, a memory external to the processor 101, or a storage medium in a storage device expanded by the electronic device through a serial bus.
  • serial buses such as high-speed serial computer expansion bus standard (peripheral component interconnect express, PCIE) bus, computer express link (compute express link, CXL) bus, accelerator cache coherent interconnect protocol (cache coherent interconnect for accelerators, CCIX) Bus, etc.
  • PCIE peripheral component interconnect express
  • CXL compute express link
  • CCIX accelerator cache coherent interconnect protocol
  • the embodiment of the present application does not limit the location of the storage medium 31 in the hybrid memory system 103.
  • Figure 2 is a structural diagram of an electronic device applying a data migration method provided by the present application.
  • the electronic device 200 includes a processor 101, a cache 102, and a manager 104a of a hybrid memory system 103a.
  • the processor 101 includes at least one processor core 11 and storage medium 31a.
  • the processor 11 also has an external storage medium 31b.
  • the electronic device 200 is connected to the storage device 105 through the PCIE/CXL/CCIX bus.
  • the storage device 105 includes a storage medium 31c and a storage medium 31d.
  • the hybrid memory system 103a includes storage media 31a to 31d, and the controllers of the storage media 31a to 31d are controllers 32a, 32b, 32c and 32d respectively.
  • Each storage medium in the hybrid memory system 103a is connected to the manager 104a through its own controller, so that the manager 104a serves as a communication bridge between the hybrid memory system 103a and the processor 101.
  • the storage media 31a to 31d are different types of storage media respectively, and there may be at least one of each storage medium in the hybrid memory system 103a.
  • the storage medium 31a is HBM, DDR or PCM integrated on the processor 101 chip.
  • the storage medium 31b is HBM, DDR or PCM external to the processor 101 in the electronic device.
  • the storage medium 31c or the storage medium 31d is HBM, DDR, PCM, etc. in the storage device 105.
  • the embodiment of the present application does not limit the types of storage media 31a to 31d.
  • the hybrid memory system 103a in Figure 2 is an example of the hybrid memory system 103 in Figure 1.
  • the hybrid memory system 103a does not include any storage medium 31a and 31d. media, or does not include storage media 31c and 31d.
  • the manager 104a in Figure 2 is an example of the manager 104 in Figure 1. If the manager 104a serves as a hardware functional unit, the manager 104a is used to connect the cache 102 and each controller 32 in the hybrid memory system 103a.
  • manager 104a is integrated in a host memory bridge between cache 102 and controller 32. Alternatively, the manager 104a serves as a separate chip that connects the host memory bridge chip and each controller 32.
  • the storage media in the hybrid memory system 103 consists only of storage media in storage devices that the electronic device extends through a serial bus.
  • Figure 3 is a structural diagram of another electronic device applying a data migration method provided by this application.
  • the electronic device 300 includes a processor 101, a cache 102, at least one storage medium 105, and each storage medium 105.
  • the controller 106 and the electronic device 300 are connected to the storage device 107 through the PCIE/CXL/CCIX bus.
  • the storage device 107 includes a hybrid memory system 103b and a manager 104b of the hybrid memory system 103b.
  • the hybrid memory system 103b includes a storage medium 31e and a storage medium 31e.
  • FIG. 3 shows an example of the hybrid memory system 103b including two storage media.
  • the hybrid memory system 103b includes more than two storage media 31.
  • the embodiment of the present application describes the hybrid memory system 103b.
  • the type of storage medium 31 is not limited.
  • the hybrid memory system 103b shown in Figure 3 is an example of the hybrid memory system 103 shown in Figure 1
  • the manager 104b is an example of the manager 104. If the manager 104b is used as a hardware functional unit, unlike Figure 2, in the embodiment shown in Figure 3, the manager 104b is located in a storage device connected to the electronic device, while the manager 104a shown in Figure 2 is located in the electronic device.
  • Figure 4 is a flow chart of a data migration method provided by this application. The method is applied to a hybrid memory system.
  • the hybrid memory system includes a first storage medium and a second storage medium. The method includes the following steps.
  • Step 401 The manager obtains a data migration request, which indicates migrating data in the first storage unit of the first storage medium to the second storage medium.
  • the hybrid memory system includes a variety of storage media.
  • the hybrid memory system is any of the hybrid systems introduced above.
  • Each storage medium in the hybrid memory system includes multiple storage units, and the storage units are used to store data.
  • the storage units are pages in the storage medium.
  • the storage unit is the basic unit of data migration.
  • the data capacity of the storage unit may be 4 kilobytes (KB), 64KB, or 2 megabytes (MByte, MB).
  • the embodiment of the present application describes the data capacity of the storage unit. No restrictions.
  • Storage units in various storage media are divided into candidate storage units and non-candidate storage units for migrating data, where the number of candidate storage units in the storage medium is smaller than the number of non-candidate storage units.
  • the processor in the electronic device uniformly addresses non-candidate storage units of multiple storage media in the hybrid memory system, obtains the physical address of each non-candidate storage unit, and organizes the non-candidate storage units of multiple storage media into the hybrid
  • the memory system provides storage space for applications.
  • the non-candidate storage units are storage units that participate in unified addressing, so that the processor accesses the non-candidate storage unit when running the application program (such as storing data in the non-candidate storage unit or reading data in the non-candidate storage unit). ), that is, the non-candidate storage unit is a storage unit that supports application access.
  • Candidate storage units are free storage units that do not participate in unified addressing.
  • the manager establishes a mapping relationship between the physical address and the media address of each storage unit that participates in unified addressing, and sets the mapping relationship between the storage units that do not participate in unified addressing.
  • the media address of the storage unit is added to the candidate storage unit queue corresponding to the storage medium to which it belongs, where the media address of the storage unit is used to indicate the location of the storage unit in the storage medium to which it belongs. Based on this, the subsequent manager can migrate the data stored in the non-candidate storage unit of a certain storage medium to the candidate storage unit in another storage medium according to the media address in the candidate storage unit queue, that is, the candidate storage unit supports migration.
  • a free storage location that contains data and does not support application access.
  • the physical address of a non-candidate storage unit is used to indicate the location of the storage unit in the storage space. Taking the non-candidate storage unit as a page in the storage medium as an example, the physical address is the page frame number of the page in the hybrid memory system.
  • the processor also allocates virtual addresses in the virtual storage space to each non-candidate storage unit.
  • the virtual address of the non-candidate storage unit is transparent to the application program, and the application program accesses the non-candidate storage unit through the virtual address.
  • the controllers of various storage media store the first mapping relationship between the physical address and the virtual address of the respective non-candidate storage unit.
  • the first mapping relationship is recorded by a first unit mapping table.
  • the first unit mapping table shown in Table 1 below includes a plurality of first unit mapping table entries, each of which includes the physical address and the virtual address of the non-candidate storage unit, and each of which is the first mapping relationship between the physical address and the virtual address of the non-candidate storage unit.
  • the first storage medium is any storage medium in the hybrid memory system
  • the second storage medium is any storage medium in the hybrid memory system that supports data exchange with the first storage medium.
  • the hybrid memory system includes storage medium 1 to storage medium 3. Data exchange is supported between storage medium 1 and storage medium 2, but data exchange is not supported between storage medium 1 and 3. If storage medium 1 is If the first storage medium is the first storage medium, storage medium 2 is the second storage medium. In the case where storage medium 1 to storage medium 3 support data exchange with each other, if storage medium 1 is the first storage medium, the second storage medium may be storage medium 2 or 3.
  • the first storage unit is any non-candidate storage unit of the data to be migrated in the first storage medium.
  • the data migration request includes the physical address of the first storage unit and the media attribute identifier of the second storage medium.
  • the media attribute identifier is used to indicate the second storage medium.
  • the data migration request does not include the media attribute identifier of the second storage medium.
  • the manager obtains the data migration request through at least one of the following methods A or B.
  • Method A The manager receives a data migration request from the processor to the first storage unit.
  • method A is introduced as follows:
  • Step A1 The processor performs data migration detection on the first storage medium.
  • the processor performs data migration detection on the first storage medium to determine whether each storage unit (ie, candidate storage unit) that supports application access in the first storage medium meets migration conditions.
  • the storage unit satisfying the migration condition includes that the number of times the storage unit is accessed reaches the value range of the migration threshold, where the number of accesses is the number of times the processor accesses the storage unit, and the value range of the migration threshold is: Determine the access latency of the first storage medium and the second storage medium. For example, if the access latency of the first storage medium is greater than the access latency of the second storage medium, the value range of the migration threshold is greater than or equal to the first migration threshold. If the access latency of the first storage medium is less than the second storage medium The access delay, the value range of the migration threshold is greater than 0 and less than or equal to the second migration threshold, and the first migration threshold is greater than the second migration threshold. Based on this migration condition, the process of data migration detection on the first storage medium is introduced as follows:
  • the electronic device where the hybrid memory system is located is also provided with a statistics unit.
  • the statistics unit calculates the access times of multiple storage units participating in unified addressing in the first storage medium based on the data access request issued by the processor to the first storage medium. Periodic statistics provide the processor with the number of accesses of the multiple storage units periodically.
  • the statistics unit processor periodically provides the access times of the multiple storage units. For example, the statistics unit sends to the processor the access times of the multiple storage units counted in the current cycle after each statistical cycle.
  • the statistics unit stores the number of accesses of the plurality of storage units counted in the latest statistical cycle, and the processor periodically or non-periodically reads the latest access times of the pair of storage units from the statistics unit, so as to calculate the access times of the pair of storage units according to each The number of times a storage unit is accessed determines whether each storage unit meets the migration conditions.
  • the statistics unit stores the number of accesses of the plurality of storage units counted in the current period to the first storage medium, and the processor periodically or aperiodically reads each access number from the first storage medium. The latest number of accesses of the storage unit, so as to determine whether each storage unit meets the migration conditions based on the number of accesses of each storage unit.
  • the statistical unit can be implemented by hardware or software.
  • the statistical unit is a chip.
  • the chip can be implemented by CPU, or it can be implemented by ASIC, or it can be implemented by PLD.
  • the above PLD can be CPLD, FPGA, GAL, data processing unit (DPU), system on chip (SoC) or any combination thereof.
  • the chip may be integrated in a manager, a processor, a first controller of the first storage medium, or an adapter card to which the first storage medium is plugged.
  • the processor determines whether each storage unit satisfies the migration condition based on the access times of each storage unit and the value range of the migration threshold. For example, for the first storage unit in the first storage medium, if the access latency of the first storage medium is greater than the access latency of the second storage medium, and the number of accesses of the first storage unit is greater than or equal to the first migration threshold , Then the first storage unit satisfies the migration condition.
  • the first storage unit is a storage unit frequently accessed by the processor (i.e., hot page), and the data in the first storage unit is data frequently accessed by the processor (i.e., hot data).
  • the hot data in the first storage unit is then migrated to a second storage medium with low access latency, so that the data can be quickly read from the second storage medium later.
  • the access latency of the first storage medium is less than the access latency of the second storage medium, and the number of times the first storage unit is accessed is less than or equal to the second migration threshold, then the first storage unit satisfies the migration condition. At this time, the first storage unit meets the migration condition.
  • One storage unit is a storage unit that is not frequently accessed by the processor (i.e., a cold page).
  • the data in the first storage unit is data that is not frequently accessed by the processor (i.e., cold data).
  • the cold data in the first storage unit is then migrated.
  • the second storage medium has the highest access latency, so that the first storage unit stores data frequently accessed by the processor in the second storage medium, and the processor can quickly obtain the frequently accessed data.
  • the processor after obtaining the number of times each storage unit in the first storage medium is accessed, the processor first sorts the number of times each storage unit is accessed to obtain a number sequence, and then determines whether each storage unit in the first storage medium meets the migration condition based on the number sequence and the value range of the access threshold.
  • the processor starts from the smallest number of accesses in the sequence of times and compares the number of accesses in the sequence with the first migration threshold. , if any number of visits is less than the first migration threshold, then compare the next number of visits in the sequence of times with the first migration threshold, if any number of visits is greater than or equal to the first migration threshold threshold, then the storage unit corresponding to any number of accesses in the sequence of times and the number of accesses after any number of accesses satisfies the migration condition, and the comparison ends.
  • the processor sequentially compares the number of accesses in the sequence with the first migration threshold. If any number of accesses is greater than or equal to the first migration threshold, then the processor The next number of visits in the number of visits is compared with the first migration threshold. If any number of visits is less than the first migration threshold, then the number of visits before any number of visits in the sequence corresponds to All storage units meet the migration conditions, and the comparison ends.
  • the processor starts from the maximum number of accesses in the sequence of times and compares the number of accesses in the sequence of times with the second migration threshold. If If any number of visits is greater than the second migration threshold, then the next number of visits in the sequence of times is compared with the second migration threshold. If any number of visits is less than or equal to the second migration threshold, Then the storage unit corresponding to any number of accesses in the sequence of times and the number of accesses after any one of the number of accesses satisfies the migration condition, and the comparison ends.
  • the processor starts from the smallest number of accesses in the sequence of times, and sequentially compares the number of accesses in the sequence with the first migration threshold. If any number of accesses is less than or equal to the second migration threshold, then The next number of visits in the number of visits is compared with the first migration threshold. If any number of visits is greater than the second migration threshold, then the number of visits before any number of visits in the sequence corresponds to All storage units meet the migration conditions, and the comparison ends.
  • the number of times the storage unit of the first storage medium is accessed is compared with the migration threshold to determine the storage unit that meets the migration condition, Therefore, there is no need to compare the number of accesses in the sequence of times with the migration threshold one by one, which improves the efficiency of determining storage units that meet migration conditions.
  • the access delay of the first storage medium is greater than the access delay of the second storage medium, and the number of accesses of the first storage unit is less than the first migration threshold, then the first storage unit does not meet the migration condition. If the access latency of the first storage medium is less than the access latency of the second storage medium, and the number of times the first storage unit is accessed is greater than the second migration threshold, the first storage unit does not meet the migration condition.
  • the statistical unit periodically sends the number of accesses of each storage unit of the first storage medium to the processor.
  • the statistical unit stores the number of accesses of each storage unit of the first storage medium, and after obtaining the number of accesses of each storage unit counted in the current cycle, updates the number of accesses of each storage unit previously stored to the number of accesses of each storage unit counted in the current cycle, and the processor periodically or non-periodically reads the latest number of accesses of each storage unit from the statistical unit, so as to determine whether each storage unit meets the migration condition according to the number of accesses of each storage unit.
  • the statistical unit stores the number of accesses of each storage unit counted in the current cycle to the first storage medium after each statistical cycle, and the processor periodically or non-periodically reads the latest number of accesses of each storage unit from the first storage medium, so as to determine whether each storage unit meets the migration condition according to the number of accesses of each storage unit.
  • Step A2 If it is detected that the first storage unit of the first storage medium meets the migration condition, the processor generates a data migration request and sends the data migration request to the manager.
  • the processor queries the virtual address corresponding to the first mapping relationship. Physical address, based on which the data migration request is generated. Or, if it is detected that the first storage unit meets the migration condition, and the number of accesses of the first storage unit provided by the statistics unit corresponds to the physical address of the first storage unit, the processor generates the data migration request based on the physical address, At this time, the data migration request includes the physical address.
  • the processor for each storage unit that meets the migration condition, Each generates a data migration request and sends the generated data migration request to the manager.
  • Step A3 The manager receives the data migration request.
  • Method B The manager generates a data migration request for the first storage unit.
  • method B is introduced as follows:
  • Step B1 The manager performs data migration detection on the first storage medium.
  • the manager performs data migration detection on the first storage medium through any one of the following methods B11-B13.
  • Mode B11 The manager obtains the access counts of multiple storage units participating in unified addressing in the first storage medium counted by the statistical unit, and determines the storage unit that meets the migration condition according to the access counts of each storage unit and the value range of the migration threshold.
  • method B11 is the same as the above-mentioned method A.
  • Method B12 The manager detects a data access request sent to the hybrid memory system, which indicates access to a storage unit of the hybrid memory system, and determines a storage unit that satisfies the migration condition based on the detected data access request.
  • the data access request includes the physical address of the storage unit to be accessed in the first storage medium.
  • the processor When the processor accesses any non-candidate storage unit in the memory hybrid system, the processor sends a data access request to the storage unit to the manager.
  • the manager parses the received data access request to obtain the physical location of the storage unit. address to detect data access requests.
  • the manager uses the first period of time as the statistical period. Every time the first period of time passes, the manager counts the number of each physical address parsed within the first period of time, and uses the counted number of each physical address as the accessed number of the corresponding storage unit. frequency.
  • the manager sets an access count for each non-candidate storage unit in the hybrid memory system. Initially, the access count of each storage unit is 0. In any first period of time, every time any storage unit is parsed out, The physical address of the unit is added to the number of accesses of any storage unit by 1. At the end of the first period of time, the manager obtains the number of accesses of each storage unit. In addition, at the end of the first period, the manager will also clear the number of accesses of each storage unit to 0 so that it can be counted in the next first period, so that the number of accesses of each storage unit can indicate the number of accesses in the most recent time period.
  • the access status of the storage unit allows the manager to determine whether to perform data migration on the storage unit based on the access status of each storage unit in the recent period, thereby improving the accuracy of data migration.
  • the manager determines the number of accesses of each storage unit and the migration threshold.
  • the value range of the processor determines whether each storage unit meets the migration conditions. This process can refer to the processor's value range based on the number of times each storage unit is accessed and the migration threshold to determine whether each storage unit meets the migration conditions.
  • the manager When the first storage unit satisfies the migration conditions, it includes that the access latency of the first storage medium is less than the access latency of the second storage medium, the number of free storage units in the first storage medium is less than or equal to the number threshold, and the first storage unit If it is a non-free storage unit whose number of accesses has not reached the access threshold, the manager performs data migration detection on the first storage medium through the following method B13.
  • the free storage unit refers to a storage unit that does not store data
  • the non-idle storage unit refers to a storage unit that stores data.
  • the migration threshold is the second migration threshold.
  • Method B13 The manager detects free storage units and non-free storage units in the first storage medium, and determines storage units that meet migration conditions based on the free storage units and non-free storage units.
  • the manager uses the first duration as a cycle to obtain the number of times each storage unit in the first storage medium has been accessed in the first duration ( For the acquisition method, refer to the above-mentioned method B11 or method B12). For any storage unit in the first storage medium, if the number of accesses of any storage unit is greater than 0, then any storage unit is a non-free storage unit; otherwise, the first storage unit is a free storage unit.
  • the manager determines the free storage units and non-free storage units in the first storage medium through the number of accesses of each storage unit in the first storage medium, without querying whether each storage unit stores data from the first storage medium, and determines The method is simple and quick.
  • the manager determines the free storage units and non-free storage units in the first storage medium by querying whether each storage unit stores data from the first storage medium, and the determined free storage units and non-free storage units are Free memory cells are accurate.
  • the manager After determining the non-free storage units and free storage units in the storage medium, if the number of free storage units in the first storage medium is less than or equal to the number threshold, the number of accesses of the first storage unit is less than or equal to the second migration threshold, and the first storage unit is a non-free storage unit, the manager determines that the first storage unit satisfies the migration condition, otherwise the first unit does not satisfy the migration condition.
  • the number threshold is greater than 0 and less than or equal to 0.1%, 0.01%, 0.001% of the number of storage units in the first storage medium, or the number threshold is 0.
  • the embodiment of the present application The value range of the threshold is not limited.
  • the number of free storage units in the first storage medium is less than or equal to the number threshold, it means that the currently available storage space in the first storage medium is relatively small. If the number of accesses of the first storage unit is less than or equal to the second migration threshold, And the first storage unit is a non-idle storage unit, indicating that the data in the first storage unit is cold data, then it is determined that the first storage unit meets the migration condition, and the data in the first storage unit is triggered. data migration, and then migrate the cold data in the first storage unit to a second storage medium with high access latency, so that the first storage unit becomes an idle storage unit, so that the first storage medium can have more idle storage units to store hot data. data.
  • Step B2 If it is detected that the first storage unit meets the migration condition, the manager generates the data migration request.
  • Step B2 is the same as step A2, and step B2 will not be described again in this embodiment of the present application.
  • Step B3 If the first storage unit meets the migration conditions and receives a data access request from the application program to the first storage unit, the manager generates the data migration request.
  • the application is any application run by the processor. If the processor generates a data access request from the application program to the storage unit in the hybrid memory system while running the application program, and sends the data access request to the manager, if the manager parses the first storage unit in the data access request physical address, it means that the data access request is a data access request for the first storage unit by the application program. If the first storage unit meets the migration condition at this time, the manager generates the migration request.
  • the manager records a trigger identification for a storage unit in the hybrid memory system to indicate whether to trigger the generation of a data migration request when receiving a data access request for the storage unit from an application program.
  • the trigger identification includes a first trigger identification and a second trigger identification.
  • the first trigger identification indicates that the generation of the data migration request is triggered when an application program's data access request for the storage unit is received.
  • the second trigger identification indicates that the data migration request is triggered when the application program receives a data access request for the storage unit. Data access requests to this storage unit do not trigger the generation of data migration requests.
  • the way to record the trigger identification for the storage unit is, for example, that the manager stores a second mapping relationship between each storage unit (ie, non-candidate storage unit) supported for program access in the hybrid memory system and the trigger identification.
  • the second mapping relationship is recorded by a second unit mapping table, such as the second unit mapping table shown in Table 2 below.
  • the second unit mapping table includes a plurality of second unit mapping table entries, each The second unit mapping table entry includes a first address, a second address, a media attribute identifier and a trigger identifier of a storage unit, where the first address is either the physical address or the virtual address of the storage unit.
  • the first address is the physical address of the storage unit as an example for introduction.
  • the second address is the address of the storage unit in the storage medium to which it belongs.
  • the second address is the media address of the storage unit.
  • the second address is the page frame number of the storage unit in the storage medium to which it belongs.
  • the second mapping relationship between the storage unit and the trigger identification is that there is a mapping relationship between the first address of the storage unit and the second address of the storage unit in the storage medium to indicate that the hybrid memory will be The first address when the system performs unified addressing is assigned to this storage unit.
  • the media attribute identifier is used to indicate the storage medium to which the storage unit belongs.
  • Table 2 shows an example of a hybrid memory system including DDR and PCM storage media. It should be understood that the hybrid memory system may also include other storage media besides DDR and PCM, or the hybrid memory system may not include DDR. and PCM, but includes other storage media besides DDR and PCM. Table 2 takes characters (such as "DDR", "PCM") as examples as media attribute identifiers.
  • the manager assigns a media number to each storage medium in the hybrid memory system.
  • the media attribute identifier The media number of the storage medium.
  • the trigger identification in the second mapping relationship of any storage unit is the second trigger identification. If any storage unit meets the migration condition, the manager will In the two mapping relationships, the second trigger identification corresponding to any storage unit is updated to the first trigger identification. Afterwards, if the manager receives any data access request sent by the processor, it obtains the trigger identification of the storage unit to be accessed indicated by the any data access request. If the trigger identification is the first trigger identification, the manager generates a For the data migration request of the storage unit to be accessed, the trigger identification is modified to the second trigger identification. Otherwise, the data migration request for the storage unit to be accessed is not generated and the trigger identification is not modified.
  • the manager will migrate data to the storage unit only when the storage unit meets the migration conditions and there is an access requirement to the storage unit. However, when the storage unit meets the migration conditions but there is no access requirement to the storage unit, the manager will migrate data to the storage unit. In this case, there is no need to migrate data to the storage unit, which reduces the number of times the manager migrates storage units and reduces the workload of the manager.
  • the manager will In the second mapping relationship, the trigger identification corresponding to the first storage unit is recorded as the first trigger identification; if the access delay of the first storage medium is less than the access delay of the second storage medium, the manager will record the trigger identification in the second mapping relationship.
  • the trigger identification corresponding to the first storage unit is recorded as the second trigger identification.
  • the access delay of the first storage medium is greater than the access delay of the second storage medium, it means that the processor preferentially accesses the data in the second storage medium. Even if a certain storage unit in the first storage medium meets the migration condition, The processor may no longer access the storage unit later. Therefore, the trigger identification corresponding to the storage unit in the second mapping relationship is recorded as the first trigger identification so that it can be regenerated later when the application program has access requirements for the storage unit. In response to the data migration request for the storage unit, perform data migration on the storage unit to avoid invalid data migration.
  • the processor preferentially accesses the data in the first storage medium and records the trigger identification corresponding to the storage unit in the second mapping relationship as the second trigger. After that, if the storage unit in the first storage medium meets the migration conditions, data migration is performed on the storage unit. There is no need to wait until the access data request is issued before performing data migration, as the first storage medium More storage units are freed up to store hot data in the second storage medium with low access latency.
  • step B2 and step B3 are parallel solutions.
  • the manager performs either step B2 or step B3, or if the access delay of the first storage medium is less than the access delay of the second storage medium, the manager performs steps B2: Generate a data access request. If the access delay of the first storage medium is greater than the access delay of the second storage medium, the manager generates a data access request according to step B3.
  • Step 402 The manager migrates the data in the first storage unit to a second storage unit in the second storage medium.
  • the second storage unit does not participate in unified addressing in the hybrid memory system.
  • the second storage unit is any storage unit in the second storage medium that does not participate in unified addressing in the hybrid memory system.
  • the second storage medium includes a plurality of candidate storage units, and the manager migrates the data in the first storage unit to any one of the plurality of candidate storage units. At this time, any one of the candidate storage units The candidate storage unit is also the second storage unit.
  • the manager before migrating the data in the first storage unit to the second storage unit, the manager first determines the second storage unit from the candidate storage units of the second storage medium.
  • a candidate storage unit queue of the second storage medium is stored in the manager.
  • the candidate storage unit queue includes the second addresses of multiple candidate storage units.
  • the manager stores the second candidate storage unit queue at the head of the queue.
  • the storage unit indicated by the address serves as the second storage unit, and data is migrated to the second storage unit.
  • step 402 In conjunction with the flow chart of a data migration process provided by this application shown in Figure 7, the data migration process in step 402 is introduced as follows:
  • the data migration process includes a migration read process and a migration write process.
  • the migration read process is to read data from the first storage unit, and the migration read process includes the following steps 4021 to 4024.
  • the migration write process is to write the read data to the second storage unit, and the migration write process includes the following steps 4025 to 4028.
  • Step 4021 The manager generates a migration read request according to the second address of the first storage unit, where the migration read request indicates reading data from the first storage unit.
  • the migration read request includes the second address of the first storage unit.
  • the manager stores a third mapping relationship between the first address and the second address of each storage unit of the hybrid memory system that does not participate in unified addressing, to indicate that the first address is allocated to the storage unit indicated by the second address.
  • the third mapping relationship is recorded by a third unit mapping table, such as the third unit mapping table shown in Table 3 below.
  • the third unit mapping table includes multiple third unit mapping table entries, each The third unit mapping table entry includes the first address, the second address and the media attribute identifier of a storage unit participating in unified addressing.
  • the manager obtains the physical address of the first storage unit from the migration request, takes the physical address as the first address of the first storage unit, and obtains the physical address from the third mapping relationship of the first storage unit.
  • a second address corresponding to the first address of the first memory unit, and a migration read request is generated based on the second address.
  • the manager only needs to store one of the second unit mapping table and the third unit mapping table. For example, if the manager stores the second unit mapping table, there is no need to store the third unit mapping table, but the third unit mapping table. The three columns of the first address, the second address and the media attribute identification in the two-unit mapping table serve as the third unit mapping table. If the second unit mapping table is not stored in the manager, the manager stores the third mapping unit mapping table. It should be understood that the second unit mapping table or the third unit mapping table is a mapping table newly added by the manager for the hybrid memory system, and is used to record each first address (such as a physical address) obtained by addressing the hybrid memory system.
  • the manager will reallocate the first address allocated to the storage unit based on the newly added mapping table.
  • Any unit mapping table from the first unit mapping table to the third unit mapping table mentioned above multiple column tables in the unit mapping table may be stored in the same location, thereby forming a table to indicate the mapping relationship.
  • the multi-column table may not be stored in the same location, and each column table is a separate table.
  • the manager uses entries in the same row in multiple tables to indicate the mapping relationship.
  • Step 4022 The manager sends the migration read request to the first controller of the first storage medium.
  • the first controller is a controller of the first storage medium.
  • Step 4023 The first controller reads data from the first storage unit of the first storage medium according to the received migration read request.
  • the first controller obtains the second address of the first storage unit from the received migration read request, and reads data from the first storage unit according to the second address.
  • Step 4024 The first controller sends the read first data to the manager.
  • the first data is data read from the first storage unit. After the manager receives the first data, the following step 4025 is executed.
  • Step 4025 The manager generates a migration write request according to the second address of the second storage unit and the received first data.
  • the migration write request instructs to write the first data to the second storage unit.
  • the migration write request includes the second address of the second storage unit and the first data.
  • the manager first obtains the second address of the second storage unit from the candidate storage unit queue of the second storage medium, and then generates a migration write request based on the second address of the second storage unit and the received first data.
  • Step 4026 The manager sends a migration write request to the second controller of the second storage medium.
  • the second controller is a controller of the second storage medium.
  • Step 4027 The second controller writes the first data to the second storage unit of the second storage medium according to the received migration write request.
  • the second controller obtains the second address and the first data of the second storage unit from the received migration write request, and writes the first data to the second storage unit according to the second address.
  • Step 4028 After writing is completed, the second controller sends a write completion response to the manager, where the write completion response indicates that the first data has been written into the second storage unit.
  • the migration is complete. If the manager determines the second storage unit from the candidate storage units, after the migration is completed, the manager removes the second storage unit from the candidate storage unit queue. For example, the manager pops the first second address in the candidate storage unit queue from the candidate storage unit queue, and moves the remaining second addresses in the candidate storage unit queue to the position of the previous second address, so that The original second second address in the candidate storage unit queue is used as the first second address, and so on.
  • the candidate storage units in the candidate storage unit queue are not full. If the candidate storage units in the candidate storage unit queue are not full, the manager adds the free storage units in the second storage medium to the candidate storage unit queue to dynamically maintain the second storage medium for storing migration data and does not support applications. The storage space where the program writes data does not affect the subsequent migration of data to the second storage medium.
  • the manager will The second address of the third memory unit is added after the last second address in the candidate memory unit queue.
  • the third storage unit is a non-candidate storage unit in the second storage medium, and the fact that the data in the third storage unit has been migrated means that the data in the third storage unit has been migrated to another storage unit.
  • the manager queries multiple storage units that participate in unified addressing from the second storage medium and queries the free storage unit.
  • the last second storage unit in the candidate storage unit queue After the address, the second address of the queried free storage unit is added in sequence until the storage unit in the candidate storage unit queue is full. It should be understood that when the second address of any storage unit that does not participate in unified addressing is added to the candidate storage unit queue, the role of the storage unit changes from participating non-candidate storage units to candidate storage units.
  • Step 403 The manager assigns the first address associated with the first storage unit during the unified addressing to the second storage unit.
  • mapping relationship between the first address and the second address of the first storage unit in the first storage medium to indicate that the first address is assigned to the first storage unit.
  • the mapping relationship is, for example, the first storage unit.
  • the manager modifies the second address of the first storage unit in the third mapping relationship of the first storage unit to the second address of the second storage unit, so as to place the first storage unit in the unified
  • the first address associated during addressing is assigned to the second memory unit.
  • the manager uses the physical address of the first storage unit as the first address associated with the first storage unit, queries the first address of the first storage unit in the third unit mapping table, and for the third unit mapping table entry where the queried first address is located, modifies the second address in the third unit mapping page table entry to the second address of the second storage unit, and modifies the medium attribute identifier of the first storage medium to the medium attribute identifier of the second storage medium.
  • the second mapping relationship between the first address and the second address of the first memory unit is recorded by the first unit mapping table entry in Table 3,
  • the second storage medium is PCM
  • the second address of the second storage unit is 000010.
  • the manager updates the second address "000001" in the first unit mapping entry to "000010” and sets the media attribute identifier "DDR" Update to "PCM” to obtain Table 4 below.
  • the first address 1 is the address of the second storage unit in the hybrid memory system.
  • the storage space provided by the hybrid memory system is certain.
  • the storage space includes the storage units indicated by each first address in the third storage unit mapping table, even if the manager associates the first storage unit with The first address is assigned to the second storage unit.
  • the first address does not change. Therefore, the embodiment of the present application realizes the placement of the first address and the second address in the hybrid memory system through the third mapping relationship.
  • the decoupling realizes the migration of data in different storage media without changing the first address, and does not affect the execution flow of the processor.
  • the application perceives that it is a virtual address assigned to the application in the hybrid memory system.
  • the processor runs The application program generates a data access request of the application program, and the data access request carries the virtual address of the storage unit to be accessed in the hybrid memory system.
  • the processor converts the virtual address in the data access request into a physical address according to the first mapping relationship in the hybrid memory system, and then sends the data access request carrying the physical address to the manager.
  • the manager uses the physical address in the data access request as the first address, queries the second address corresponding to the first address from the third mapping relationship, and accesses the storage unit indicated by the queried second address.
  • the first address in the third mapping relationship does not change. Therefore, during the data migration process, the running process of the application program on the processor will not be interrupted, making the application program unaware of the data migration. .
  • the data migration method shown in Figure 4 migrates the data in the storage unit to storage in the second storage medium that does not participate in unified addressing when a data migration request for the storage unit of the first storage medium is obtained.
  • the data migration method shown in Figure 4 includes steps 401 to 402. After step 402 is executed, the data migration is completed. At this time, data can still be migrated to storage units that do not participate in unified addressing. The migration process, accordingly, reduces the data migration time and improves data migration efficiency.
  • the application when the first storage unit in the hybrid memory system is in the process of data migration, or after the data migration is completed, the application may access the first storage unit, and the manager passes the migration status of the first storage unit, The auxiliary application program completes accessing the first storage unit.
  • the application program may access the first storage unit by writing data to the first storage unit or by reading the data in the first storage unit.
  • the following uses the embodiments shown in Figure 8 and Figure 12 respectively to assist the manager application. The process of the program writing data to the first storage unit and the process of assisting the application program to read the data of the first storage unit are described below.
  • Figure 8 is a flowchart of accessing a storage unit in a case where data migration and data writing are carried out in parallel, provided by the present application.
  • the method is applied to a hybrid memory system, which includes a first storage medium and a second storage medium.
  • the method is executed by a manager of the hybrid memory system, and the method includes the following steps.
  • Step 801 The manager obtains a data migration request, which indicates migrating data in the first storage unit of the first storage medium to the second storage medium.
  • this step 801 is the same as the above-mentioned step 401.
  • this step 801 will not be described again in this embodiment of the present application.
  • Step 802 The manager determines a second storage unit in a second storage medium according to the data migration request, where the second storage unit does not participate in the unified addressing in the hybrid memory system.
  • the second storage unit is determined from the candidate units of the second storage medium. This process is described in step 402.
  • Step 803 The manager establishes a fourth mapping relationship between the first storage unit, the second storage unit, and the migration status of the first storage unit, where the migration status indicates the migration progress of the first storage unit.
  • the migration status includes migration in progress and migration completed, wherein migration in progress indicates that the data in the first storage unit is being migrated to the third storage unit.
  • migration completion indicates that the data in the first storage unit has been migrated to the second storage unit.
  • the storage unit is called the source storage unit (
  • the storage unit used to store the migration data of the storage unit is called the destination storage unit (such as the second storage unit).
  • a migration table is stored in the manager, and the manager establishes a fourth mapping relationship between the first storage unit, the second storage unit, and the migration state of the first storage unit in the migration state.
  • the migration table includes multiple migration entries. Each migration table entry includes the migration status of the data to be migrated, the source address, the source media attribute identifier, the destination address, and the destination migration attribute identifier. .
  • a migration status of 1 indicates that the migration is in progress
  • a migration status of 0 indicates that the migration is completed.
  • a migration status of 0 indicates that the migration is in progress
  • a migration status of 1 indicates that the migration is completed.
  • the source address is the second address of the source storage unit of the data to be migrated
  • the source media attribute identifier is the media attribute identifier of the storage medium to which the source storage unit belongs
  • the destination address is the second address of the destination storage unit of the data to be migrated
  • the destination media attribute The identifier is the media attribute identifier of the storage medium to which the destination storage unit belongs.
  • the manager uses migrating as the migration state, uses the second address of the first storage unit as the source address, uses the media attribute identifier of the first storage medium as the source media attribute identifier, and uses the second address of the second storage unit as the destination address, Using the media attribute identifier of the second storage medium as the destination medium attribute identifier, a target migration entry is added to the migration table to establish a fourth link between the first storage unit, the second storage unit, and the migration status of the first storage unit. Mapping relations.
  • the manager migrates as shown in Table 5 Add the target migration table entry to the first row of the table.
  • each storage unit in the hybrid memory system includes multiple cache lines.
  • the migration entry in the migration table also includes cache line status, and the cache line status includes multiple status bits.
  • multiple status bits correspond to multiple cache lines of the destination storage unit one-to-one, and the status bits are used to store the write status of the cache line to indicate the progress of writing data in the cache line.
  • the write status includes write completion and write incomplete.
  • Write completion indicates that the cache line has written data
  • write incomplete indicates that the cache line has not completed writing data.
  • a writing status of 1 indicates that the writing is completed
  • a writing status of 0 indicates that the writing is not completed
  • a writing status of 0 indicates that the writing is completed
  • a writing status of 0 indicates that the writing is completed.
  • a value of 1 indicates that the write is not completed.
  • the manager when adding the migration table entry corresponding to the first storage unit in the migration table, the manager sets the cache line status in the migration table entry to write incomplete to indicate Each cache line in the second storage unit has not yet completed writing data.
  • the write status of each cache line of the destination storage unit is recorded through the cache line status, so that the manager can confirm the progress of data migration.
  • the cache line status is an optional item in the migration table.
  • the migration table does not include the cache line status. For example, when the manager has no requirement for the write status of the cache line in the destination storage unit, the migration table does not Includes cache line status.
  • Step 804 The manager migrates the data in the first storage unit to the second storage unit, and allocates the first address associated with the first storage unit during unified addressing to the second storage unit.
  • this step 804 is the same as the above-mentioned step 402 and step 403, and the details of this step 804 will not be repeated here.
  • the first controller reads the data in each cache line of the first storage unit in sequence according to the order of the cache lines in the first storage unit, and then sends the data in each cache line to the manager in sequence.
  • the manager When processing a request to access the storage unit (such as a data access request of an application, a migration read request or a migration write request of the manager), the manager prioritizes the first request obtained and then processes the later request according to the principle of first come first served. Therefore, in the case where the migration table includes the cache status, each time the manager receives data in a cache line of the first storage unit, it queries the write status of the target cache line corresponding to the cache line in the second storage unit from the migration table according to the position of the cache line in the first storage unit.
  • the manager updates the write status to write status, wherein the position of the target cache line in the second storage unit is the same as the position of the cache line in the first storage unit. If the write status is write complete, the currently received data is discarded, and the subsequent migration write operation of the cache line is abandoned.
  • the manager when sending the first data in the migration write request to the second controller of the second storage unit, sequentially sends the data to the second controller according to the order of cache lines in the first storage unit. Send data in each cache line of the first storage unit.
  • the manager updates the migration status of the first storage unit to migration completed to indicate that the data in the first storage unit has been migrated to the second storage unit. After that, the manager The first address point associated with the unit in unified addressing Allocate second storage unit.
  • the migration status of the first storage unit is updated to migration completed, it is also indicated that the migration table entry in which the migration status is located is invalid.
  • the migration table entry whose migration status is in migration is valid. After that, the migration status can be queried on the valid entries in the migration table to reduce the number of migration table entries to be queried when querying the migration table.
  • Step 805 The manager receives a first data write request from the application program, where the first data write request indicates writing data to the first storage unit.
  • the first data write request is a data access request of an application program, and the first data write request includes the physical address of the first storage unit and the second data to be written to the physical address.
  • the application program first sends the first data write request to the processor.
  • the first data write request includes the virtual address of the first storage unit and the second data.
  • the processor obtains the first data by querying the first unit mapping table.
  • the virtual address of the first storage unit in the write request is converted into a physical address.
  • the processor sends the first data write request after the address conversion to the manager.
  • the manager receives the first data write request included in the first data write request. is the virtual address of the first storage unit rather than the physical address.
  • Step 806 The manager queries the migration status of the first storage unit according to the first data write request.
  • the migration status indicates the migration progress of the first storage unit.
  • the manager queries the second address of the first storage unit in the third mapping relationship based on the physical address of the first storage unit in the first data write request. For example, the manager uses the physical address of the first storage unit as the first address of the first storage unit, queries the first address of the first storage unit among the first addresses recorded in the third unit mapping table, and searches for the first address of the first storage unit. The first address is located in the third mapping entry, and the second address of the first storage unit and the media attribute identifier of the first storage medium are obtained.
  • the manager queries the migration status of the first storage unit in the migration table according to the second address of the first storage unit. For example, the manager queries the second address of the first storage unit and the media attribute identifier of the first storage medium from the source address and source media attribute identifier recorded in the migration table. If the second address of the first storage unit and the media attribute identifier of the first storage medium are queried, If the media attribute identifier of a storage medium is located in the same migration entry in the migration table (that is, the target migration entry), the manager obtains the migration status of the first storage unit from the target migration entry.
  • the migration entry in the migration table whose migration status is migration completed is an invalid migration entry
  • the migration entry in the migration table whose migration status is migration is a valid migration entry. From each valid migration table in the migration table The source address and source media attribute identifier of the item are queried for the second address of the first storage unit and the media attribute identifier of the first storage medium. If the second address of the first storage unit and the media attribute identifier of the first storage medium are queried, The same valid migration entry in the migration table, then the migration status of the first storage unit at this time is migrating.
  • Step 807 If the migration status is migrating, the manager converts the first data write request into a second data write request, and sends the second data write request to the second storage medium.
  • the second data write request indicates to write the second data into the second storage unit. Accordingly, the second data write request includes the second address and the second data of the second storage unit.
  • the migration status is Migrating, it means that the manager is migrating the first data in the first storage unit to the second storage unit, and before the first data write request, the manager has already performed data processing on the first storage unit.
  • the second data in the first data write request is the latest data of the first storage unit, and the second storage unit is the destination storage unit of the first storage unit. Therefore, the manager transfers the first data in the first data write request to The physical address of the storage unit is modified to the second address of the second storage unit, a second data write request is obtained, and the second data write request is sent to the second storage medium.
  • the manager sends a second data write request to the second controller of the second storage medium, and the second controller writes the second data in the second data write request into the second storage unit according to the second data write request.
  • the second controller writes the second data in the second data write request into the second storage unit according to the second data write request.
  • the second data overwrites the migrated data, thereby ensuring that the data in the second storage unit is the latest data of the first storage unit.
  • the manager when the cache line status is stored in the migration table, if the migration status is migrating, the manager also determines the offset of the second data in the first storage unit according to the first data write request. address, determine the cache line in the first storage unit to which the second data is to be written (called the third cache line), and obtain the cache line corresponding to the third cache line in the second storage unit (called the fourth cache line).
  • Write status if the write status of the fourth cache line is write completed, send a second data write request to the second storage medium to overwrite the data previously migrated to the fourth cache line.
  • the manager updates the writing status of the fourth cache line to writing completed, sends a second data writing request to the second storage medium, and then, if The migration read request reads the data of the third cache line, and the write status of the fourth cache line is write completion, then the manager discards the data read from the third cache line.
  • the data read from the third cache line is no longer written to the fourth cache line to prevent the data of the third cache line from overwriting the second data in the fourth cache line.
  • the position of the third cache line in the first storage medium is the same as the position of the fourth cache line in the second storage medium.
  • the manager calculates the target in the migration table based on the position of the third cache line in the first storage medium. Migrate the cache status of the entry and obtain the write status of the fourth cache line.
  • the position of the third cache line in the first storage medium is the same as the position of the writing state of the fourth cache line in the cache state.
  • the manager If the migration status of the first storage unit is migration completed and the first address associated with the first storage unit has not been assigned to the second storage unit, the manager also first assigns the first address associated with the first storage unit to Allocate it to the second storage unit, and then send the second data write request to the second storage medium.
  • Step 808 If the migration status is not found, the manager sends a first data write request to the first storage medium.
  • the manager modifies the physical address of the first storage unit in the first data write request to the second address of the first storage unit, and sends the first data to the first storage medium. Data write request.
  • the manager sends a first data write request to a first controller of the first storage medium, and the first controller writes the second data in the first data write request into the first storage unit according to the first data write request. , to overwrite the original first data in the first storage unit, thereby ensuring that the second data in the first storage unit is the latest data.
  • the data migration method shown in Figure 8 can achieve the beneficial effects that the data migration method shown in Figure 4 can achieve.
  • the application's data access request (such as a data write request) is routed to the first storage medium or the second storage medium by querying the mapping relationship in the third unit mapping table and the migration status in the migration table.
  • the address of the second storage unit is assigned to the application program to ensure that the application program writes the latest data at the address to be accessed.
  • Figure 8 illustrates from an overall perspective the process of the manager processing the first data write request to the first storage unit by maintaining the migration status of the first storage unit and the cache line status of the second storage unit, but the above-mentioned steps 805 to 805 are Each step in 808 may occur before or after steps 801 to 804, or during execution.
  • the first data write request may reach the manager before or after the migration read request, or may reach the manager before or after the migration write request.
  • the data migration process will be introduced as follows:
  • Figure 9 is a schematic diagram of the data migration process when the first data write request reaches the manager before the migration read request provided by this application.
  • the processor issues data migration to the first storage unit to the manager. request or the manager generates the data migration request.
  • the manager adds the target migration table entry of the first storage unit to the migration table.
  • the migration status of the first storage unit in the target migration table entry is also set to Migrating.
  • the first data write request issued by the processor to the manager reaches the manager before the migration read request is generated. If the target migration entry does not exist in the migration table, the manager will, based on the first data write request, If the target migration table entry cannot be queried in the migration table, and the first data write request does not hit the migration table, it means that the data in the first storage unit has not been migrated at this time, and the manager sends the first data write request to The first storage medium to which the first storage unit belongs is used to write the latest data into the first storage unit. Then a migration read request is generated for the first storage unit, the latest data is read from the first storage unit through the migration read request, and then the latest data is written to the second storage unit through the migration write request.
  • Figure 10 is a schematic diagram of the data migration process when the first data write request provided by this application reaches the manager after the migration read request and before the migration write request.
  • the manager is in the migration table
  • the target migration table entry sets the migration status of the first storage unit to Migrating.
  • the manager After the manager generates the migration read request, it receives the first data write request issued by the processor to the manager.
  • the manager first sends the migration read request to the first storage medium to pass the migration read request. Read the data in the first storage unit, and then process the first data write request.
  • the target migration table entry is queried in the migration table according to the first data write request.
  • the first data write request hits the migration table. It means that the first storage unit is being migrated and the data in the first storage unit will eventually be stored in the second storage unit.
  • the manager modifies the physical address of the first storage unit in the first data write request to the second storage unit's physical address. Second address, obtain a second data write request, and write the latest data to the second storage unit through the second data write request.
  • the manager also modifies the cache line status of the second storage unit in the target migration option in the migration table to write completion according to the second data write request.
  • the manager After that, the manager generates a migration write request based on the data read from the first storage unit. According to the migration write request, it is found that the cache line status of the second storage unit in the target migration option in the migration table is write completed, then the manager cancels Send a migration write request to the second storage medium to prevent old data in the first storage unit from overwriting the latest data written in the second data request.
  • Figure 11 is a schematic diagram of the data migration process when the first data write request reaches the manager after the migration write request provided by this application.
  • the manager's target migration table in the migration table The item sets the migration status of the first storage unit to Migrating.
  • the manager reads the data in the first storage unit according to the migration request through the migration request, and then The data read by the storage unit generates a migration write request, and the read data is written to the second storage unit through the migration write request. Afterwards, the manager receives the first data write request of the processor to the first storage unit. At this time, the old data of the first storage unit is being written to the second storage unit or the writing to the second storage unit has been completed. Then, the manager modifies the physical address of the first storage unit in the first data write request to the second address of the second storage unit, obtains the second data write request, and writes the latest data to the second storage unit through the second data write request to overwrite the old data of the first storage unit.
  • Figure 12 is a flow chart of accessing a storage unit in the case of parallel data migration and data reading provided by this application.
  • This method is applied to a hybrid memory system.
  • the hybrid memory system includes a first storage medium and a second storage medium.
  • the method is executed by a manager of the hybrid memory system and includes the following steps.
  • Step 1201 The manager obtains a data migration request, which indicates migrating data in the first storage unit of the first storage medium to the second storage medium.
  • this step 1201 is the same as the above-mentioned step 401.
  • this step 1201 will not be described again in this embodiment of the present application.
  • Step 1202 The manager determines a second storage unit in the second storage medium based on the data migration request.
  • the second storage unit does not participate in unified addressing in the hybrid memory system.
  • the second storage unit is determined from the candidate units of the second storage medium. This process is described in step 402.
  • Step 1203 The manager establishes a fourth mapping relationship between the first storage unit, the second storage unit, and the migration status of the first storage unit, where the migration status indicates the migration progress of the first storage unit.
  • Step 1204 is the same as step 803. This step 1203 will not be described again in this embodiment of the present application.
  • Step 1204 The manager migrates the data in the first storage unit to the second storage unit, and allocates the first address associated with the first storage unit during unified addressing to the second storage unit.
  • Step 1204 is the same as step 804. This step 1204 will not be described again in this embodiment of the present application.
  • Step 1205 The manager receives a first data read request from the application program, where the first data read request indicates reading data from the first cache line of the first storage unit.
  • the first data read request is a data access request of an application program
  • the first data write request includes the physical address of the first storage unit and the offset address of the first cache line in the first storage unit.
  • the first cache line is any cache line in the first storage unit.
  • the application program first sends the first data read request to the processor.
  • the first data read request includes the virtual address of the first storage unit and the offset address.
  • the processor queries the first unit mapping table to obtain the first data read request.
  • the virtual address of the first storage unit in the data read request is converted into a physical address.
  • the processor sends the first data read request after the address conversion to the manager.
  • the manager receives the first data read request including is the virtual address of the first storage unit rather than the physical address.
  • Step 1206 The manager obtains the writing status of the second cache line corresponding to the first cache line in the second storage unit according to the first data read request.
  • the writing status indicates the progress of writing data in the second cache line. .
  • the position of the first cache line in the first storage medium is the same as the position of the second cache line in the second storage medium.
  • the manager queries the migration status of the first storage unit according to the first data read request.
  • the process may refer to the manager querying the migration status of the first storage unit according to the first data write request.
  • the manager queries the write status of the second cache line from the cache status of the second storage unit in the migration table based on the offset address of the first cache line. Enter state. For example, the manager queries the write status of the second cache line from the cache status of the second storage unit in the migration table based on the offset address of the first cache line. At the position indicated by the offset address, the write state at this position in the cache state of the second memory unit is obtained as the write state of the second cache line.
  • Step 1207 If the write status of the second cache line is write completed, the manager converts the first data read request into a second data read request, and sends the second data read request to the second storage medium.
  • the completion indicates that data has been written to the second cache line, and the second data read request indicates that data is read from the second cache line.
  • the second data write request includes the second address of the second storage unit and the offset address of the second cache line in the second storage unit.
  • the manager If the migration status of the first storage unit is migrating and the writing status of the second cache line is writing completed, it means that the manager is migrating the data in the first storage unit to the second storage unit at this time, and the The second cache line has been migrated into the data in the first cache line.
  • the manager updates the physical address of the first storage unit in the first data read request to the second cache line.
  • the second address of the storage unit is used to obtain a second data read request, and the offset address of the first cache line in the first storage unit in the second data read request is equivalent to the offset address of the second cache line in the second storage unit.
  • the offset address of the unit is used to obtain a second data read request, and the offset address of the first cache line in the first storage unit in the second data read request is equivalent to the offset address of the second cache line in the second storage unit.
  • the manager sends a second data read request to the second controller of the second storage medium, and the second controller reads the second data read request according to the second address of the second storage unit and the offset address in the second data write request.
  • the data in the second cache line in the second storage unit (called the third data) returns the third data to the manager.
  • the manager uses the third data as a read completion response to the first data read request and sends it to the application.
  • the program sends a read completion response.
  • Step 1208 If the writing status of the second cache line is writing incomplete, the manager sends a first data read request to the first storage medium.
  • the writing status of the second cache line is writing incomplete, it means that the data in the first cache line has not been migrated to the second cache line at this time, and the manager will read the first storage data in the first storage unit in the request.
  • the physical address is modified to the second address of the first storage unit, and a first data read request is sent to the first storage medium.
  • the target migration entry is not queried in the effective migration entry of the migration table, it means that the data in the first storage unit has not been migrated to other storage units. At this time, the data stored in the first storage unit is the latest data. , then the manager does not need to query the write status of the second cache line and does not need to perform the above step 1207.
  • the manager modifies the physical address of the first storage unit in the first data read request to the second address of the first storage unit, and sends the The first storage medium sends the modified first data read request.
  • the process of the manager sending the first data read request to the first storage medium is the same as the process of sending the second data read request to the second storage medium, which will not be described in detail here.
  • the data migration method shown in Figure 12 can achieve the beneficial effects that the data migration method shown in Figure 4 can achieve, and during the data migration process, the application's access request (such as a data read request) is made by querying the third unit
  • the mapping relationship in the mapping table and the migration status in the migration table are routed to the first storage medium or the second storage medium.
  • the address of the second storage unit is assigned to the application program to ensure that the application program reads at the address to be accessed. Get the latest data.
  • Figure 12 illustrates from an overall perspective the process of the manager processing the first data read request for the first storage unit by maintaining the migration status of the first storage unit and the cache line status of the second storage unit, but the above-mentioned steps 1205 to 12 Each step in 1208 may occur before, after, or during the execution of steps 1201 to 1204.
  • the first data read request may reach the manager before or after the migration read request during the data migration process, or it may arrive at the manager before the migration write request. before and after reaching the manager.
  • the data migration process is introduced as follows in conjunction with Figure 13:
  • Figure 13 is a schematic diagram of the data migration process when the first data read request reaches the manager after the migration write request provided by this application.
  • the manager generates a migration based on the data migration request for the first storage unit. read request, send a migration read request to the first storage medium to read data from the first storage unit, and then generate a migration write request based on the read data, and send a migration write request to the second storage medium to read data from the first storage unit.
  • the second storage unit writes the read data.
  • the manager invalidates the target migration entry in the migration table.
  • the manager when sending a migration write request to the second storage medium, adds the second address of the first storage unit to the third mapping unit table entry where the first address associated with the first storage unit is located in the third mapping unit table. Update to the second address of the second storage unit, and assign the first address to the second storage unit.
  • the manager receives a first data read request from the processor for the first storage unit after sending a migration write request to the second storage medium, the data in the first storage unit is written to the second storage unit in advance. At this time, the second address in the third mapping unit table entry where the first address is located has been updated to the second address of the second storage unit. The manager then modifies the physical address of the first storage unit in the first data read request to the second address of the second storage unit, obtains the second data read request, and sends the second data read request to the second storage medium to read the latest data in the first address from the second storage unit.
  • the manager modifies the physical address of the first storage unit in the first data read request to the first The second address of the storage unit sends a first data read request to the first storage medium to read the latest data in the first address from the first storage unit.
  • FIG. 14 is a schematic diagram of the data migration process when a processor provided by this application accesses the first storage unit twice.
  • the manager first reads data from the first storage unit by sending a migration read request to the first storage medium. Afterwards, the manager receives a first data write request from the processor to the first storage unit, and sends a second data write request to the second controller according to the first data write request to write the first data into the second storage unit. After writing the latest data of the address to the second storage unit, the second controller sends a write completion response to the manager, and the manager forwards the write completion response to the processor. In addition, the manager writes data to the second storage unit.
  • the manager when the manager sends the second data write request to the second memory controller, it also modifies the cache line state of the second storage unit to write Afterwards, if a first data read request for the first storage unit is received, the manager converts the first data read request into a second data read request and sends the second data read request to the second controller to read the latest data from the second storage unit.
  • the manager cancels the request to the second controller based on the current cache line status of the second storage unit. Send a migration write request.
  • Figure 14 is based on the situation where the processor accesses the storage unit to be migrated twice during the data migration process. In another embodiment, during the data migration process, the processor may also access the storage unit to be migrated 2 times. In the case of more than one time, for any process of the processor accessing the storage unit to be migrated, if the processor writes data to the migrated storage unit, refer to the process of the manager processing the first data write request in Figure 8. If the processor reads the migration For the data in the storage unit, refer to the process of the manager processing the first data read request in Figure 12.
  • the processor issues a data access request to a certain storage medium in the hybrid memory system to the manager.
  • the manager queries the medium corresponding to the physical address in the second unit mapping table based on the physical address of the storage unit to be accessed in the data access request. address and trigger identification to convert the physical address in the data access request into the source media address (ie, the second address of the storage unit to be accessed). If the queried trigger identification is the first trigger identification, data migration is triggered, and the manager generates a data migration request for the storage unit to be accessed.
  • the manager queries the migration status of the source storage unit and the cache status of the destination storage unit in the migration table according to the data access request. If the data access request is a data write request, and the data write request hits the migration table, and the migration status of the source storage unit is Migrating, then the data write request conflicts with the data migration request, and the source media address in the data write request is changed. Convert to the destination media address (that is, the second address of the destination storage unit), and then send it to the controller of the destination storage unit before issuing, and write the write status of the cache line to be accessed in the destination storage unit in the hit migration table entry. Set to write complete. If the data access request does not hit the migration table, there is no conflict between the data write request and the data migration request. The manager does not modify the source media address in the data write request and sends the data write request to the controller of the storage unit to be accessed.
  • the data read request conflicts with the data migration request. If the write status of the cache line to be read in the data read request is write completed, the manager modifies the source media address in the data read request to the destination media address, and sends the data read request to the controller of the destination storage unit. If the write status of the cache line to be read in the data read request is write incomplete, the manager does not modify the source media address in the data read request and sends the data read request to the controller of the storage unit to be accessed.
  • the various method embodiments shown in Figure 4 to Figure 15 all take the manager processing a data migration as an example for explanation.
  • the manager will periodically perform a data migration on all the nodes participating in unified addressing in the hybrid memory system.
  • Storage unit for data migration For example, in each migration cycle, the manager and/or processor detects whether each storage unit participating in unified addressing in the hybrid memory system meets the migration conditions, and generates a migration list (list) based on the storage units that meet the migration conditions.
  • the list includes at least one data migration request, and each data migration request indicates data migration for a storage unit that meets the migration conditions.
  • the manager processes each data migration request in the migration list in turn.
  • the processing process of each data migration request can refer to the above-mentioned embodiment shown in Figure 4 to Figure 15.
  • Figure 16 is a schematic structural diagram of a data migration device provided by this application.
  • the device 1600 shown in Figure 16 can be the manager or part of the manager of the hybrid memory system in the previous embodiments, and is used to execute the tasks executed by the manager.
  • Data migration method the device 1600 is applied to a hybrid memory system, the hybrid memory system includes a first storage medium and a second storage medium, the device 1600 includes:
  • Obtain module 1601 obtain a data migration request, the data migration request indicates migrating data in the first storage unit of the first storage medium to the second storage medium;
  • Migration module 1602 migrates the data in the first storage unit to a second storage unit in the second storage medium, and the second storage unit does not participate in unified addressing in the hybrid memory system;
  • the allocation module 1603 allocates the first address associated with the first storage unit during the unified addressing to the second storage unit.
  • the device 1600 in the embodiment of the present application can be implemented by a CPU, an application-specific integrated circuit (ASIC), or a programmable logic device (PLD).
  • PLD programmable logic device
  • the above-mentioned PLD can be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a general array logic (GAL), a data processing unit (data processing unit) , DPU), system on chip (SoC), or any combination thereof.
  • Device 1600 can also pass The methods shown in Figures 4 to 15 are implemented through software. When implemented through software, the device 1600 and its respective modules may also be software modules.
  • the allocation module 1603 is used to:
  • the device module 1600 further includes a first processing module:
  • the first data write request is converted into a second data write request, and the migrating state indicates that the data in the first storage unit is being migrated to the second storage unit,
  • the second data write request indicates writing data to the second storage unit.
  • the device module 1600 further includes a second processing module:
  • the write status of the second cache line corresponding to the first cache line in the second storage unit where the write status indicates the write status of the data written in the second cache line.
  • the write status is write completion
  • the first data read request is converted into a second data read request.
  • the write completion indicates that the second cache line has written data
  • the second data read request is The request indicates that data is to be read from the second cache line.
  • first processing module and second processing module may be the same module or different modules.
  • the acquisition module 1601 includes:
  • a detection submodule used to detect data migration on the first storage medium
  • a generating subunit is configured to generate the data migration request if it is detected that the first storage unit satisfies the migration condition.
  • the first storage unit satisfying the migration condition includes that the number of times the first storage unit is accessed reaches the value range of the migration threshold, and the detection sub-module is used to: detect the data sent to the first storage unit.
  • a data access request of the hybrid memory system the data access request indicates access to a storage unit in the hybrid memory system; and, based on detecting the data access request, obtaining the number of times the first storage unit has been accessed.
  • the first storage unit satisfies the migration conditions including that the access delay of the first storage medium is less than the access delay of the second storage medium, the number of free storage units in the first storage medium is less than or equal to the number threshold, and the first storage unit is a non-free storage unit whose access times do not reach the access threshold; the detection submodule is used to: obtain the access times of each storage unit in the first storage medium; and determine the free storage units and non-free storage units in the first storage medium according to the access times of each storage unit in the first storage medium.
  • the device 1600 further includes: a generating module, configured to: if it is detected that the first storage unit satisfies the migration condition and an application program’s data access to the first storage unit is received request to generate the data migration request.
  • a generating module configured to: if it is detected that the first storage unit satisfies the migration condition and an application program’s data access to the first storage unit is received request to generate the data migration request.
  • the device 1600 further includes: a determination module, configured to determine the second storage unit from candidate storage units of the second storage medium, wherein the candidate storage unit is an idle storage unit that does not participate in the unified addressing.
  • the determination module is further configured to: remove the second storage unit in the candidate storage unit queue; if the candidate storage units in the candidate storage unit queue are not full, remove the second storage unit from the candidate storage unit queue.
  • the idle storage units participating in the unified addressing in the second storage medium are added to the candidate storage unit queue.
  • Figure 17 is a schematic structural diagram of another data migration device provided by this application.
  • the device 1700 includes a mapping module 1701, a migration command triggering module 1702, a migration command scheduling module 1703, a migration module 1704, and a migration conflict management module. 1705 and arbitration module 1706.
  • the mapping module 1701 is used to maintain the second storage unit mapping table, convert the physical address in the data access request issued by the processor into a media address and then send it to the migration conflict management module 1705.
  • a data access request triggers migration, In this case, a data migration request is sent to the migration command scheduling module 1703.
  • the migration command triggering module 1702 is an optional module.
  • the migration command triggering module 1702 and the processor in the electronic device can be used to determine the number of accesses of each storage unit participating in unified addressing in the hybrid memory system based on statistics from the statistical unit.
  • the storage unit that meets the migration conditions issues a data migration request to the migration command scheduling module 1703 based on the storage unit that meets the migration conditions.
  • the migration command triggering module 1702 is an optional module.
  • the migration command scheduling module 1703 is used to maintain each storage medium in the hybrid memory system (such as the connection between the first controller and the second controller).
  • Storage medium) candidate storage unit queue add the media address of the destination storage unit in the received data migration request, and convert the physical address of the source storage unit in the data migration request into a media address by querying the second storage unit mapping table , sending a data migration request carrying the media address to the migration module 1704.
  • the migration module 1704 is configured to add migration entries to the migration conflict table management module 1705 according to the received data migration request, and process the data migration request (such as issuing a migration read request and a migration write request to the arbitration module 1706). After the data migration is completed, the corresponding migration table entry is invalidated, and the migration command scheduling module 1703 is notified to process the next migration request.
  • the migration conflict table management module 1705 is used to maintain the migration table, determine whether to update the media address in the data access migration request according to the hit status of the data access request in the migration table, and then send the updated or non-updated data access request to the arbitration module 1706.
  • the arbitration module 1706 is used to add the processing request to the tail of the sending queue every time it receives a processing request (such as from a data access request, a migration read request or a migration write request), and send each processing request in sequence from the head of the sending queue. , each time a processing response of a processing request is received, the processing response is added to the end of the receiving queue, and each processing response is returned from the head of the receiving queue in sequence.
  • a processing request such as from a data access request, a migration read request or a migration write request
  • the implementation of the device 1700 may refer to the device 1600. Here, the implementation of the device 1700 will not be described in detail in this embodiment of the application.
  • the device corresponds to the manager in the above method embodiment, and each module in the device and the above other operations and/or functions are respectively intended to implement the method embodiment.
  • the manager for any one of the device 1600 and the device 1700, the device corresponds to the manager in the above method embodiment, and each module in the device and the above other operations and/or functions are respectively intended to implement the method embodiment.
  • the manager for specific details of various steps and methods implemented by the manager, please refer to the above method embodiments. For the sake of brevity, they will not be described again here.
  • the above-mentioned division of each functional module is only used as an example. In actual applications, the above-mentioned functions can be allocated according to needs. Different functional modules are completed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the device provided by the above embodiments and the above method embodiments belong to the same concept, and the specific implementation process can be found in the above method embodiments, which will not be described again here.
  • any one of the device 1600 and the device 1700 may be equivalent to the managers 104, 104a, and 104b in FIGS. 1 to 3, or equivalent to the execution components in the managers 104, 104a, and 104b.
  • FIG 18 is a schematic structural diagram of a chip provided by this application.
  • chip 1800 includes a processor 1801 and an interface circuit 1802.
  • the interface circuit 1802 is used to receive instructions and transmit them to the processor 1801.
  • the processor 1801 for example, can be a specific implementation form of the device 1600 or the device 1700, and can be used to execute the above-mentioned data migration method.
  • the processor 1801 is coupled to the memory 1803.
  • the memory 1803 is used to store program code.
  • the program code is executed by the processor 1801, the chip system composed of the processor 1801, the interface circuit 1802 and the memory 1803 implements the above-mentioned Figures 4 to 15. The operating steps of the method in any of the method embodiments.
  • processor 1801 there is at least one processor 1801 in the chip system.
  • the processor 1801 can be a CPU or other general-purpose processor.
  • the processor 1801 can also be one or more processors for Integrated circuits that implement the solution of this application, such as digital signal processing (DSP), ASIC, PLD, FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
  • DSP digital signal processing
  • ASIC application specific integrated circuits
  • PLD programmable logic devices
  • a general-purpose processor can be a microprocessor or any conventional processor, etc.
  • the memory 1803 may be integrated with the processor 1801 or may be provided separately from the processor 1801, which is not limited by this application.
  • the memory 1803 can be integrated with the processor 1801 on the same chip.
  • the memory 1803 can also be provided on different chips from the processor 1801. This application describes the type of the memory 1803 and the type of the memory 1803.
  • the setting method of the processor 1801 is not specifically limited.
  • the memory 1803 may include read-only memory and random access memory, and provide instructions and data to the processor 1801.
  • Memory 1803 may also include non-volatile random access memory.
  • memory 1803 may also store device type information.
  • Memory 1803 may also be volatile memory, or may include both volatile and non-volatile memory.
  • non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically removable memory. Erase electrically programmable read-only memory (EPROM, EEPROM) or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache.
  • RAM static random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • Double data rate synchronous dynamic random access memory double data date SDRAM, DDR SDRAM
  • enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
  • synchronous link dynamic random access memory direct rambus RAM, DR RAM
  • the chip system can be an FPGA, an ASIC, an SoC, a CPU, a network processor (network processor, NP), or a digital signal processing circuit (digital signal processor, DSP), it can also be a microcontroller unit (MCU), it can also be a PLD) or other integrated chips.
  • a network processor network processor, NP
  • DSP digital signal processing circuit
  • MCU microcontroller unit
  • PLD PLD
  • the application also provides a computer-readable storage medium, such as a memory including program code.
  • the program code can be used by an electronic device.
  • the processor in (or chip) executes to complete the data migration method in the above embodiment.
  • the implementation of the computer-readable storage medium may be referred to the memory 1803 in FIG. 18 .
  • the application also provides a computer program product or computer program, which includes program code.
  • the program code is stored in a computer-readable storage medium.
  • the processor reads the program code from the computer-readable storage medium.
  • the processor executes the program code, causing the chip or electronic device where the processor is located to execute the above data migration method.
  • this application also provides a device.
  • This device can be a chip, a component or a module.
  • the device can include a connected processor and a memory.
  • the memory is used to store computer execution instructions.
  • the processor can Execute the computer execution instructions stored in the memory, so that the chip executes the data migration method in each of the above method embodiments.
  • the devices, equipment, computer-readable storage media, computer program products or chips provided by this application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the methods provided above. The beneficial effects of the corresponding methods will not be described again here.
  • the above embodiments may be implemented in whole or in part by software, hardware, firmware, or any other combination.
  • the above-described embodiments may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the processes or functions described in the embodiments of the present invention are generated in whole or in part.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another, e.g., the computer instructions may be transferred from a website, computer, server, or data center Transmission to another website, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means.
  • the computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or a data center that contains one or more sets of available media.
  • the available media may be magnetic media (eg, floppy disk, hard disk, tape), optical media (eg, DVD), or semiconductor media.
  • the semiconductor medium may be a solid state disk (SSD).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据迁移方法、装置、芯片以及计算机可读存储介质,涉及存储技术领域。该方法通过在获取到对第一存储介质的存储单元的数据迁移请求的情况下,将该存储单元中的数据迁移至第二存储介质中未参与统一编址的存储单元,迁移过程中应用程序的数据访问请求通过查询第二单元映射表中的映射关系和迁移表中的迁移状态路由到第一存储介质或者第二存储介质,迁移完成后再将第二存储单元的地址分配给应用程序,由于参与迁移的存储单元无须加锁,简化了迁移流程,相应地,降低了数据迁移的时长,提高了数据迁移效率。

Description

数据迁移方法、装置、芯片以及计算机可读存储介质
本申请要求于2022年09月23日提交中国专利局、申请号为202211168045.0、发明名称为“数据迁移方法、装置、芯片以及计算机可读存储介质”的中国专利申请的优先权,所述专利申请的全部内容通过引用结合在本申请中。
技术领域
本申请涉及存储技术领域,特别涉及一种数据迁移方法、装置、芯片以及计算机可读存储介质。
背景技术
计算设备的处理器可配置包括多个存储介质的混合内存***,对于处理器而言,混合内存***中的各个存储介质的存储性能不同,处理器可以将对混合内存***中某一存储介质中的数据迁移至另一存储介质,以便发挥各个存储介质的存储性能。
目前,数据迁移的过程为:混合内存***中的各个存储介质均包括多个页面,对于混合内存***中某一存储介质的待迁移页面(即旧页面),处理器先为旧页面中的数据分配另一存储介质的某个页面(即新页面),然后,获取旧页面的页面锁,取消页面表中旧页面的映射关系,无效掉转译后备缓冲器(translation lookaside buffer,TLB)中旧页面的TLB表项,之后,获取新页面的页面锁,将数据从旧页面复制到新页面,最后,通过页面表完成新页面的映射,释放新页面的页面锁,释放旧页面以及旧页面的页面锁。
但是,上述数据迁移过程依赖于页面锁机制,处理器需要分别获取旧页面和新页面的页面锁,在完成数据迁移后,还需要释放旧页面和新页面的页面锁,数据迁移流程复杂,增加了数据迁移的时长,降低了数据迁移效率。
发明内容
本申请提供了一种数据迁移方法、装置、芯片以及计算机可读存储介质,能够提高数据迁移效率。
第一方面,提供了一种数据迁移方法,方法应用于混合内存***,混合内存***包括第一存储介质和第二存储介质,该方法包括如下步骤:获取数据迁移请求,其中,数据迁移请求指示将第一存储介质的第一存储单元中的数据迁移至第二存储介质;之后,将第一存储单元中的数据迁移至第二存储介质中的第二存储单元;将第一存储单元在统一编址时所关联的第一地址分配给第二存储单元,其中,第二存储单元未参与混合内存***中的统一编址。
该方法通过在获取到对第一存储介质的存储单元的数据迁移请求的情况下,将该存储单元中的数据迁移至第二存储介质中未参与统一编址的存储单元,由于未参与统一编址的存储单元不支持应用程序访问,在向未参与统一编址的存储单元迁移数据的过程中,也就不存在写数据一致性维护问题,因此,未参与统一编址的存储单元无须加锁,简化了迁移流程,相应地,降低了数据迁移的时长,提高了数据迁移效率。
在一种可能的实现方式中,第一地址与第一存储单元在第一存储介质中的第二地址之间具有映射关系,以指示将第一地址分配给第一存储单元,基于此,上述将第一存储单元在统一编址时所关联的第一地址分配给第二存储单元的实现过程包括:将映射关系中的第二地址修改为第二存储单元在第二存储介质中的第二地址。
基于上述可能的实现方式,实现了混合内存***中第一地址和第二地址放置的解耦,在不改变第一地址的情况下,实现了数据在不同存储介质中的迁移,不影响处理器的执行流程。
在另一种可能的实现方式中,该方法还包括如下步骤:接收应用程序的第一数据写请求,第一数据写请求指示向第一存储单元写入数据;之后,根据第一数据写请求,查询第一存储单元的迁移状态;若迁移状态为迁移中,将第一数据写请求转换为第二数据写请求,其中,迁移状态指示第一存储单元的迁移进度,迁移中指示正在将第一存储单元中的数据迁移至第二存储单元,第二数据写请求指示向第二存储单元写入数据。
基于上述可能的实现方式,在数据迁移过程中若处理器向第一地址写入数据,根据关联第一地址的第一存储单元的迁移状态,向第一存储单元或第二存储单元写入数据,以覆盖掉第一地址中存储的旧数据,确保写入到第一地址的数据为最新数据,以便之后处理器能够在第一地址中读取到最新数据。
在另一种可能的实现方式中,该方法还包括如下步骤:接收应用程序的第一数据读请求,其中,第一数据读请求指示从第一存储单元的第一缓存行读取数据;之后,根据第一数据读请求,获取第二存储单元中第一缓存行对应的第二缓存行的写入状态;若写入状态为写入完成,将第一数据读请求转换为第二数据读请求,其中,写入状态指示第二缓存行写入数据的进度写入完成指示第二缓存行已经写入数据,第二数据读请求指示从第二缓存行读取数据。
基于上述可能的实现方式,在数据迁移过程中若处理器读取第一存储单元的第一缓存行中的数据,根据第二存储单元中与该第一缓存行对应的第二缓存行的写入状态,在第一存储单元或第二缓存行读取数据,以确保读取到最新数据。
在另一种可能的实现方式中,上述获取数据迁移请求的过程包括:先对第一存储介质进行数据迁移检测;若检测到第一存储单元满足迁移条件,在生成数据迁移请求。
在另一种可能的实现方式中,第一存储单元满足迁移条件包括第一存储单元的被访问次数达到迁移阈值的取值范围,基于此,上述对第一存储介质进行数据迁移检测的过程包括:检测发往混合内存***的数据访问请求,数据访问请求指示访问混合内存***中的存储单元;根据检测到数据访问请求,获取第一存储单元的被访问次数。
在另一种可能的实现方式中,第一存储单元满足迁移条件包括第一存储介质的访问时延小于第二存储介质的访问时延,第一存储介质中空闲存储单元的个数小于或等于个数阈值,且第一存储单元为被访问次数未达到访问阈值的非空闲存储单元;基于此,上述对第一存储介质进行数据迁移检测的过程包括:先获取第一存储介质中各个存储单元的被访问次数;再根据第一存储介质中各个存储单元的被访问次数,确定第一存储介质中的空闲存储单元以及非空闲存储单元。
基于上述可能的实现方式,通过第一存储介质中的各个存储单元的访问次数,确定第一存储介质中的空闲存储单元和非空闲存储单元,而无需从第一存储介质查询的各个存储单元是否存储有数据,确定方式简单且快捷。
在另一种可能的实现方式中,该方法还包括如下步骤:若检测到第一存储单元满足迁移条件,且接收到应用程序对第一存储单元的数据访问请求,生成数据迁移请求。
基于上述可能的实现方式,在应用程序对该存储单元有访问需求的情况下,再生成对该存储单元的数据迁移请求,对该存储单元进行数据迁移,从而避免无效的数据迁移。
在另一种可能的实现方式中,在将第一存储单元中的数据迁移至第二存储介质中的第二存储单元的步骤之前,该方法还包括如下步骤:从第二存储介质的候选存储单元中,确定第二存储单元,候选存储单元为用于未参与统一编址的空闲存储单元。
基于上述可能的实现方式,通过从未参与统一编址的空闲存储单元中确定出第二存储单元,以便将第一存储单元中的数据迁移至未参与统一编址的空闲存储单元,由未参与统一编址的空闲存储单元不支持应用程序访问且未存储数据,再向未参与统一编址的空闲存储单元迁移数据时不会出现写一致性问题,从而无须对未参与统一编址的空闲存储单元加锁,简化了迁移流程,提高了数据迁移效率。
在另一种可能的实现方式中,候选存储单元位于第二存储介质的候选存储单元队列,将第一存储单元中的数据迁移至第二存储单元之后,该方法还包括如下步骤:移除候选存储单元队列中的第二存储单元;若候选存储单元队列中的候选存储单元未满,将第二存储介质中参与统一编址的空闲存储单元加入候选存储单元队列。
基于上述可能的实现方式,动态维护第二存储介质中用于存储迁移数据且不支持应用程序写入数据的存储空间,从而不影响之后向第二存储介质继续迁移数据。
第二方面,提供了一种数据迁移方法,该方法应用于混合内存***,混合内存***包括第一存储介质和第二存储介质,该方法包括如下步骤:获取数据迁移请求,其中,数据迁移请求指示将第一存储介质的第一存储单元中的数据迁移至第二存储介质;之后从第二存储介质的候选存储单元中,确定第二存储单元;再之后,将第一存储单元中的数据迁移至第二存储介质中的第二存储单元,其中,候选存储单元为用于未参与统一编址的空闲存储单元。
该方法通过在获取到对第一存储介质的存储单元的数据迁移请求的情况下,将该存储单元中的数据迁移至第二存储介质中未参与统一编址的空闲存储单元,由于未参与统一编址的空闲存储单元不支持应用程序访问,且没有存储数据,在向未参与统一编址的空闲存储单元迁移数据的过程中,也就不存在写数据一致性维护问题,因此,未参与统一编址的空闲存储单元无须加锁,简化了迁移流程,相应地,降低了数据迁移的时长,提高了数据迁移效率。
第三方面,提供了一种数据迁移装置,该装置包括用于执行第一方面或第一方面任一种可能实现方式中的数据迁移方法的各个模块,或者该装置包括用于执行第二方面的数据迁移方法的各个模块。
第四方面,提供一种芯片,该芯片用于实现如第一方面或第一方面任一种可能实现方式中的数据迁移方法的操作步骤,或该芯片用于实现如第二方面的数据迁移方法的操作步骤。
第五方面,提供一种计算机可读存储介质,该存储介质中存储有至少一条程序代码,该程序代码由处理器读取以使芯片执行如上述数据迁移方法的操作步骤。
第六方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括程序代码,该程序代码存储在计算机可读存储介质中,芯片的处理器从计算机可读存储介质读取该程序代码,处理器执行该程序代码,使得该芯片执行上述第一方面或者第一方面的各种可选实现方式中提供的方法。
本申请在上述各方面提供的实现方式的基础上,还可以进行进一步组合以提供更多实现方式。
附图说明
图1是本申请提供的一种数据迁移访问方法的应用***示意图;
图2是本申请提供的一种应用数据迁移方法的电子设备的结构图;
图3是本申请提供的另一种应用数据迁移方法的电子设备的结构图;
图4是本申请提供的一种数据迁移方法的流程图;
图5是本申请提供的一种基于方式A获取数据迁移请求的流程图;
图6是本申请提供的一种基于方式B获取数据迁移请求的流程图;
图7是本申请提供的一种数据迁移过程的流程图;
图8是本申请提供的一种数据迁移与数据写入并行的情况下存储单元的访问流程图;
图9是本申请提供的一种第一数据写请求在迁移读请求之前达到管理器时的数据迁移过程示意图;
图10是本申请提供的一种第一数据写请求在迁移读请求之后迁移写请求之前达到管理器时的数据迁移过程示意图;
图11是本申请提供的一种第一数据写请求在迁移写请求之后达到管理器时的数据迁移过程示意图;
图12是本申请提供的一种数据迁移与数据读取并行的情况下存储单元的访问流程图;
图13是本申请提供的一种第一数据读请求在迁移写请求之后达到管理器时的数据迁移过程示意图;
图14是本申请提供的一种处理器两次访问第一存储单元时的数据迁移过程示意图;
图15是本申请提供的一种基于处理器的访问命令进行数据迁移的流程图;
图16是本申请提供的一种数据迁移装置的结构示意图;
图17是本申请提供的另一种数据迁移装置的结构示意图;
图18是本申请提供的一种芯片的结构示意图。
具体实施方式
为了提升数据迁移的效率,本申请提供一种应用于混合内存***的数据迁移方法,在混合内存***中的两个存储介质之间有数据迁移的需求时,区分参与统一编址的存储单元和未参与统一编址的存储单元,在执行数据迁移时,将待迁移的存储单元中的数据迁移至混合内存***中其他存储介质内未参与统一编址的存储单元。
下面将结合附图对本申请所提供的混合内存***的数据迁移方法作进一步地详细描述。
图1是本申请提供的一种数据迁移访问方法的应用***示意图,如图1所示,该应用***包括处理器101、缓存(cache)102、混合内存***103以及混合内存***103的管理器104,其中,处理器101可以采用专用集成电路(application-specific integrated circuit,ASIC)、数字信号处理(digital signal processing,DSP)、现场可编程门阵列(field-programmable gate array,FPGA)、可编程逻辑阵列(programmable logic array,PLA)中的至少一种硬件形式来实现,当然,处理器101也可以有其他的硬件实现方式,对此本申请不做限定。处理器101例如中央处理器(central processing unit,CPU),在一些实施例中,处理器101还可以利用图像处理器(graphics processing unit,GPU)或数据处理单元(data processing unit,DPU)实现,GPU用于负责显示屏所需要显示的内容的渲染和绘制。在一些实施例中,处理器101还包括人工智能(artificial intelligence,AI)处理器,AI处理器用于处理有关机器学习的计算操作。
处理器101访问混合内存***103的存储介质31,以从存储介质31读取数据或者向存储介质31写入 数据。在访问存储介质31时,处理器101可以将存储介质31中的部分数据复制到缓存102中,以便后续能够从缓存102快速读取这部分数据。在另一些实施例中,该应用***不包括缓存102,此时处理器101直接访问存储介质31。
混合内存***103包括多种存储介质31,该多种存储介质31用于存储数据(如代码或者业务数据)。多种存储介质31例如图1所示的静态随机存取高速带宽内存(high bandwidth memory,HBM)311、相变存储器(phase change memory,PCM)312以及双倍速率同步动态随机存储器(double data Rate SDRAM,DDR)313。在另一些实施例中,混合内存***103包括这3种存储介质中的任意2种,或者包括除这3种存储介质以外的其他存储介质,其他存储介质例如磁性随机存储器(magnetic random access memory,MRAM)、静态随机存取存储器(static random-access memory,SRAM)等,在此,本申请实施例对混合内存***103中存储介质31的数目以及种类不做限定。
混合内存***103还包括存储介质31的控制器32,控制器32用于实现对应存储介质31与处理器101之间的数据交换。如图1所示,HBM311、PCM312以及DDR313的控制器32分别为:HBM控制器321、PCM控制器322、DDR控制器323。
如图1所示,管理器104用于连接缓存102和各个控制器32,在另一些实施例中,该应用***中不包括缓存102,此时,管理器104用于连接处理器101和各个控制器32。管理器104作为控制器32的上一级控制器,与处理器101进行数据交互。例如,在处理器101访问HBM311时,处理器101向管理器104下发对HBM311的访问请求,管理器104将数据访问请求发送给HBM控制器321,由HBM控制器321根据数据访问请求访问HBM311,其中,数据访问请求指示访问混合内存***103中的存储单元。
另外,混合内存***103中的不同存储介质31具有不同的存储性能,例如,有些存储介质31存储容量大,但访问时延高,而有些存储介质31存储容量小,但访问时延低。管理器104还用于通过该数据迁移方法,将混合内存***103中任一种存储介质31中的数据迁移至另一种存储介质31,以便发挥混合内存***103中各个存储介质31的优势性能。
管理器104通过软件实现、硬件实现或者软硬件结合的方式实现。管理器104作为软件功能单元的一种举例,管理器104包括运行在计算实例上的代码。其中,计算实例包括虚拟机、容器中的至少一种。进一步地,上述计算实例可以是一台或者多台。例如,管理器104包括运行在多个虚拟机/容器上的代码。另外,用于运行该代码的多个虚拟机/容器可能分布在相同的区域(region)中,也可能分布在不同的region中。进一步地,用于运行该代码的多个虚拟机/容器可能分布在相同的可用区(availability zone,AZ)中,也可能分布在不同的AZ中,每个AZ包括一个数据中心或多个地理位置相近的数据中心。其中,通常一个region可以包括多个AZ。
同样,用于运行该代码的多个虚拟机/容器可以分布在同一个虚拟私有云(virtual private cloud,VPC)中,也可以分布在多个VPC中。其中,通常一个VPC设置在一个region内,同一region内两个VPC之间,以及不同region的VPC之间跨区通信需在每个VPC内设置通信网关,经通信网关实现VPC之间的互连。
管理器104作为硬件功能单元的一种举例,管理器104可能是利用专用集成电路(application-specific integrated circuit,ASIC)实现或可编程逻辑器件(programmable logic device,PLD)实现的设备等。其中,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD)、现场可编程门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合实现。
在一些实施例中,图1所示的应用***由电子设备提供,该电子设备可能是服务器,也可能是终端设备,其中,服务器例如云服务器、中心服务器、边缘服务器、远端数据中心中的远端服务器或本地数据中心中的本地服务器等。终端设备例如台式机、笔记本电脑或者智能手机等。此时,混合内存***103中的存储介质31可能是片上存储器(on chip memory)、处理器101外挂的存储器或者电子设备通过串行总线扩展的存储设备中的存储介质。其中,串行总线例如高速串行计算机扩展总线标准(peripheral component interconnect express,PCIE)总线、计算机高速链接(compute express link,CXL)总线、加速器的缓存一致互联协议(cache coherent interconnect for accelerators,CCIX)总线等,在此,本申请实施例对混合内存***103中存储介质31的位置不做限定。
例如,图2所示的本申请提供的一种应用数据迁移方法的电子设备的结构图,参见图2,电子设备200包括处理器101、缓存102以及混合内存***103a的管理器104a,处理器101包括至少一个处理器核心11以及存储介质31a。在电子设备200中,处理器11还外挂存储介质31b。电子设备200通过PCIE/CXL/CCIX总线连接存储设备105,存储设备105包括存储介质31c和存储介质31d。
如图2所示混合内存***103a包括存储介质31a至存储介质31d,存储介质31a至31d的控制器分别为控制器32a、32b、32c以及32d。混合内存***103a内各个存储介质分别通过各自的控制器连接管理器104a,从而使得管理器104a作为混合内存***103a与处理器101沟通的桥梁。应当理解,存储介质31a至31d分别为不同种类的存储介质,混合内存***103a中的每种存储介质均可以有至少一个。
存储介质31a为处理器101片上集成的HBM、DDR或PCM等。存储介质31b为电子设备内处理器101外挂HBM、DDR或PCM等。存储介质31c或存储介质31d为存储设备105中的HBM、DDR或PCM等。在此,本申请实施例对存储介质31a至31d的种类不做限定。
可以理解的是,图2中的混合内存***103a为图1中混合内存***103的一种示例,在另一些实施例中,混合内存***103a不包括存储介质31a和31d中的任一种存储介质,或者不包括存储介质31c和31d。图2中的管理器104a为图1中管理器104的一种示例,若管理器104a作为硬件功能单元,管理器104a用于连接缓存102和混合内存***103a中的各个控制器32。例如,管理器104a集成在缓存102和控制器32之间的主机内存桥片(host memory bridge)中。或者,管理器104a作为一个单独的芯片,连接主机内存桥片和各个控制器32。
在另一些实施例中,混合内存***103中的存储介质仅有电子设备通过串行总线扩展的存储设备中的存储介质组成。例如图3所示的本申请提供的另一种应用数据迁移方法的电子设备的结构图,参见图3,电子设备300包括处理器101、缓存102、至少一个存储介质105以及每个存储介质105的控制器106,电子设备300通过PCIE/CXL/CCIX总线连接存储设备107,存储设备107包括混合内存***103b以及混合内存***103b的管理器104b,混合内存***103b包括存储介质31e、存储介质31e的控制器32e、存储介质31f以及存储介质31的控制器32f,控制器32e和32f均与管理器104b连接。其中,图3是混合内存***103b包括两种存储介质为例示出的,在一些实施例中,混合内存***103b包括2种以上的存储介质31,在此,本申请实施例对混合内存***103b中存储介质31的种类不做限定。
可以理解的是,图3所示的混合内存***103b为图1所示的混合内存***103的一种示例,管理器104b为管理器104的一种示例,若管理器104b作为硬件功能单元,和图2不同的是,在图3所示的实施例中,管理器104b位于电子设备所连接的存储设备中,而图2所示的管理器104a位于在电子设备中。
接下来,基于上述介绍应用***,对本申请提供的数据迁移方法作如下介绍:
图4是本申请提供的一种数据迁移方法的流程图,该方法应用于混合内存***,该混合内存***包括第一存储介质和第二存储介质,该方法包括如下步骤。
步骤401、管理器获取数据迁移请求,该数据迁移请求指示将第一存储介质的第一存储单元中的数据迁移至第二存储介质。
其中,混合内存***包括多种存储介质,例如,混合内存***为上文介绍的任一种混合***。混合内存***中的各个存储介质均包括多个存储单元,存储单元用于存储数据,例如,存储单元为存储介质中的页面。存储单元为数据迁移的基本单位,存储单元的数据容量可能为4千字节(kilobyte,KB)、64KB或2兆字节(MByte,MB),在此本申请实施例对存储单元的数据容量不做限定。
各种存储介质中的存储单元分为迁移数据的候选存储单元和非候选存储单元,其中,存储介质中的候选存储单元的数量小于非候选存储单元的数量。电子设备中的处理器对混合内存***中多种存储介质的非候选存储单元进行统一编址,得到各个非候选存储单元的物理地址,以将多种存储介质的非候选存储单元组织成该混合内存***为应用程序提供的存储空间。
可以理解的是,非候选存储单元为参与统一编址的存储单元,以便处理器在运行应用程序时访问非候选存储单元(如在非候选存储单元存储数据或读取非候选存储单元中的数据),即非候选存储单元为支持应用程序访问的存储单元。候选存储单元为未参与统一编址的空闲存储单元。为区分参与统一编址的存储单元和未参与统一编址的存储单元,管理器为参与统一编的各个存储单元分别建立各自的物理地址和介质地址之间的映射关系,将未参与统一编址的存储单元的介质地址添加到所属存储介质对应的候选存储单元队列,其中,存储单元的介质地址用于指示存储单元在所属存储介质中的位置。基于此,后续管理器可以根据候选存储单元队列中的介质地址,将某一存储介质的非候选存储单元中存储的数据迁移至另一存储介质中的候选存储单元,即候选存储单元为支持迁移数据且不支持应用程序访问的空闲存储单元。
非候选存储单元的物理地址用于指示该存储单元在该存储空间中的位置。以非候选存储单元为存储介质中的页面为例,该物理地址为该页面在该混合内存***中的页面框号。另外,处理器还为各个非候选存储单元分别分配虚拟存储空间中的虚拟地址,非候选存储单元的虚拟地址对应用程序透明,应用程序通过虚拟地址对非候选存储单元进行访问。
在一些实施例,各种存储介质的控制器中存储有各自的非候选存储单元的物理地址与虚拟地址之间的第一映射关系。示例性地,该第一映射关系由第一单元映射表来记录。例如下述表1所示的第一单元映射表,第一单元映射表包括多个第一单元映射表项,每个第一单元映射表项包括非候选存储单元的物理地址以及虚拟地址,每个第一单元映射表项也即是非候选存储单元的物理地址以及虚拟地址之间的第一映射关系。
表1
第一存储介质为混合内存***中的任一种存储介质,第二存储介质为混合内存***中支持与第一存储介质进行数据交换的任一存储介质。例如,混合内存***包括存储介质1至存储介质3,在存储介质1和存储介质2之间支持数据交换,而存储介质1和3之间不支持数据交换的情况下,若在存储介质1为第一存储介质,则存储介质2为第二存储介质。在存储介质1至存储介质3互相支持数据交换的情况下,若在存储介质1为第一存储介质,第二存储介质可能是存储介质2或3。
第一存储单元为第一存储介质中待迁移数据的任一非候选存储单元,该数据迁移请求包括第一存储单元的物理地址以及第二存储介质的介质属性标识,该介质属性标识用于指示该第二存储介质。另外,在管理器已知第一存储介质与第二存储介质之间支持数据迁移的情况下,该数据迁移请求不包括第二存储介质的介质属性标识。
其中,管理器通过下述方式A或者方式B中的至少一种方式,来获取数据迁移请求。
方式A、管理器接收处理器对第一存储单元的数据迁移请求。
结合图5所示的本申请提供的一种基于方式A获取数据迁移请求的流程图,对方式A做如下介绍:
步骤A1、处理器对第一存储介质进行数据迁移检测。
处理器通过对第一存储介质进行数据迁移检测,以确定第一存储介质中支持应用程序访问的各个存储单元(即候选存储单元)是否满足迁移条件。
在一种可能的实现方式中,存储单元满足迁移条件包括存储单元的被访问次数达到迁移阈值的取值范围,其中,被访问次数为处理器访问存储单元的次数,迁移阈值的取值范围由第一存储介质和第二存储介质的访问时延来确定。例如,若第一存储介质的访问时延大于第二存储介质的访问时延,迁移阈值的取值范围为大于或等于第一迁移阈值,若第一存储介质的访问时延小于第二存储介质的访问时延,迁移阈值的取值范围为大于0且小于或等于第二迁移阈值,第一迁移阈值大于第二迁移阈值。基于这种迁移条件,对第一存储介质进行数据迁移检测的过程做如下介绍:
混合内存***所在的电子设备还提供有统计单元,统计单元根据处理器向第一存储介质下发的数据访问请求,对第一存储介质中参与统一编址的多个存储单元的被访问次数进行周期性统计,向处理器周期性提供该多个存储单元的被访问次数。其中,统计单元处理器周期性提供该多个存储单元的被访问次数的方式,例如,统计单元每经过一个统计周期,向处理器发送当前周期统计到的该多个存储单元的被访问次数。再例如,统计单元存储最近统计周期统计到的该多个存储单元的被访问次数,处理器周期性或者非周期性的从统计单元读取该对个存储单元最新的被访问次数,以便根据各个存储单元的被访问次数确定各个存储单元是否满足迁移条件。再例如,统计单元每经过一个统计周期,将当前周期统计到的该多个存储单元的被访问次数存储至第一存储介质,处理器周期性或者非周期性的从第一存储介质读取各个存储单元最新的被访问次数,以便根据各个存储单元的被访问次数确定各个存储单元是否满足迁移条件。
其中,该统计单元可以通过硬件实现或者通过软件形式,在通过硬件实现时,该统计单元为芯片,该芯片通过CPU实现,也可以通过ASIC实现,也可以通过PLD实现,上述PLD可以是CPLD、FPGA、GAL、数据处理单元(data processing unit,DPU)、片上***(system on chip,SoC)或其任意组合。芯片可能集成在管理器、处理器、第一存储介质的第一控制器或插接有第一存储介质的转接卡。
处理器获取到该多个存储单元的被访问次数后,根据各个存储单元的被访问次数以及迁移阈值的取值范围,确定各个存储单元是否满足迁移条件。例如,对于第一存储介质中的第一存储单元,若第一存储介质的访问时延大于第二存储介质的访问时延,且该第一存储单元的被访问次数大于或等于第一迁移阈值, 则该第一存储单元满足迁移条件,此时第一存储单元为处理器频繁访问的存储单元(即热页面),第一存储单元中的数据为处理器频繁访问的数据(即热数据),之后将第一存储单元中的热数据迁移至低访问时延的第二存储介质,以便后续能够从第二存储介质快速读取到该数据。
若第一存储介质的访问时延小于第二存储介质的访问时延,且该第一存储单元的被访问次数小于或等于第二迁移阈值,则该第一存储单元满足迁移条件,此时第一存储单元为处理器不频繁访问的存储单元(即冷页面),第一存储单元中的数据为处理器不频繁访问的数据(即冷数据),之后将第一存储单元中的冷数据迁移至高访问时延的第二存储介质,以便第一存储单元存储第二存储介质中处理器频繁访问的数据,处理器能够快速获取频繁访问的数据。
在另一些实施例中,处理器在获取到第一存储介质中各个存储单元的被访问次数后,先对各个存储单元的被访问次数进行排序,得到次数序列,之后,再根据次数序列以及访问阈值的取值范围,确定第一存储介质中的各个存储单元是否满足迁移条件。
例如,若第一存储介质的访问时延大于第二存储介质的访问时延,处理器从次数序列中最小的被访问次数开始,依次将次数序列中的被访问次数与第一迁移阈值进行比较,若任一被访问次数小于第一迁移阈值,则对次数序列中该任一被访问次数的下一个被访问次数与第一迁移阈值进行比较,若任一被访问次数大于或等于第一迁移阈值,则次数序列中该任一被访问次数以及该任一被访问次数之后的被访问次数所对应存储单元均满足迁移条件,比较结束。或者,处理器从次数序列中最大的被访问次数开始,依次将次数序列中的被访问次数与第一迁移阈值进行比较,若任一被访问次数大于或等于第一迁移阈值,则对次数序列中该任一被访问次数的下一个被访问次数与第一迁移阈值进行比较,若任一被访问次数小于第一迁移阈值,则次数序列中该任一被访问次数之前的被访问次数所对应存储单元均满足迁移条件,比较结束。
若第一存储介质的访问时延小于第二存储介质的访问时延,处理器从次数序列中最大的被访问次数开始,依次将次数序列中的被访问次数与第二迁移阈值进行比较,若任一被访问次数大于第二迁移阈值,则对次数序列中该任一被访问次数的下一个被访问次数与第二迁移阈值进行比较,若任一被访问次数小于或等于第二迁移阈值,则次数序列中该任一被访问次数以及该任一被访问次数之后的被访问次数所对应存储单元均满足迁移条件,比较结束。或者,处理器从次数序列中最小的被访问次数开始,依次将次数序列中的被访问次数与第一迁移阈值进行比较,若任一被访问次数小于或等于第二迁移阈值,则对次数序列中该任一被访问次数的下一个被访问次数与第一迁移阈值进行比较,若任一被访问次数大于第二迁移阈值,则次数序列中该任一被访问次数之前的被访问次数所对应存储单元均满足迁移条件,比较结束。
对于第一迁移阈值和第二迁移阈值中的任一迁移阈值,按照次数序列,将第一存储介质的存储单元的被访问次数与该迁移阈值进行比较,以确定出满足迁移条件的存储单元,从而无须对次数序列中的被访问次数与该迁移阈值进行一一对比,提高了确定满足迁移条件的存储单元的效率。相应地,若第一存储介质的访问时延大于第二存储介质的访问时延,且该第一存储单元的被访问次数小于第一迁移阈值,则该第一存储单元不满足迁移条件。若第一存储介质的访问时延小于第二存储介质的访问时延,且该第一存储单元的被访问次数大于第二迁移阈值,则该第一存储单元不满足迁移条件。
另外,上述是以统计单元周期性向处理器发送第一存储介质的各个存储单元的被访问次数为例进行说明的,另一些实施例中,统计单元存储第一存储介质的各个存储单元的被访问次数,在获取到当前周期统计到的各个存储单元的被访问次数后,将之前存储的各个存储单元的被访问次数更新为当前周期统计到的各个存储单元的被访问次数,处理器周期性或者非周期性的从统计单元读取各个存储单元最新的被访问次数,以便根据各个存储单元的被访问次数确定各个存储单元是否满足迁移条件。或者,统计单元每经过一个统计周期,将当前周期统计到的各个存储单元的被访问次数存储至第一存储介质,处理器周期性或者非周期性的从第一存储介质读取各个存储单元最新的被访问次数,以便根据各个存储单元的被访问次数确定各个存储单元是否满足迁移条件。
步骤A2、若检测到该第一存储介质的第一存储单元满足迁移条件,处理器生成数据迁移请求,向管理器发送数据迁移请求。
例如,若检测到第一存储单元满足迁移条件,且统计单元提供的第一存储单元的被访问次数与第一存储单元的虚拟地址对应,处理器从第一映射关系中查询该虚拟地址对应的物理地址,根据该物理地址,生成该数据迁移请求。或者,若检测到第一存储单元满足迁移条件,且统计单元提供的第一存储单元的被访问次数与第一存储单元的物理地址对应,则处理器根据该物理地址,生成该数据迁移请求,此时该数据迁移请求包括该物理地址。
相应地,若第一存储单元中有多个存储单元满足迁移条件,处理器针对满足迁移条件的每个存储单元, 都生成一个数据迁移请求,向管理器发送生成的数据迁移请求。
步骤A3、管理器接收该数据迁移请求。
方式B、管理器生成对第一存储单元的数据迁移请求。
下面结合图6所示的本申请提供的一种基于方式B获取数据迁移请求的流程图,对方式B做如下介绍:
步骤B1、管理器对第一存储介质进行数据迁移检测。
其中,管理器通过下述方式B11-B13中的任一方式,对第一存储介质进行数据迁移检测。
方式B11、管理器获取统计单元统计的第一存储介质中参与统一编址的多个存储单元的被访问次数,根据各个存储单元的被访问次数以及迁移阈值的取值范围,确定满足迁移条件的存储单元。
其中,方式B11与上述的方式A同理。
方式B12、管理器检测发往该混合内存***的数据访问请求,该数据访问请求指示访问混合内存***的存储单元,根据检测到的数据访问请求,确定满足迁移条件的存储单元。
其中,该数据访问请求包括第一存储介质中待访问的存储单元的物理地址。
在处理器访问内存混合***中的任一非候选存储单元时,处理器向管理器发送对该存储单元的数据访问请求,管理器对接收到的数据访问请求进行解析,得到该存储单元的物理地址,以实现对数据访问请求的检测。管理器以第一时长为统计周期,每经过第一时长,统计在该第一时长内解析出的各个物理地址的个数,将统计出的各个物理地址的个数作为对应存储单元的被访问次数。
例如,管理器为该混合内存***中每个非候选存储单元分别设置一个被访问次数,初始时,每个存储单元的被访问次数均为0,在任一第一时长中,每解析出任一存储单元的物理地址,将该任一存储单元的被访问次数加1,在该第一时长结束时,管理器获取到每个存储单元的被访问次数。另外,在该第一时长结束时,管理器还将每个存储单元的被访问次数清0,以便在下一个第一时长进行计数,使得每个存储单元的被访问次数能够指示最近时间段内各个存储单元的被访问情况,以便管理器根据最近时间段内各个存储单元的被访问情况,确定是否对存储单元进行数据迁移,提高数据迁移的准确性。
在获取到混合内存***中的各个存储单元的被访问次数的情况下,也就获取到了第一存储介质中各个存储单元的被访问次数,之后管理器根据各个存储单元的被访问次数以及迁移阈值的取值范围,确定各个存储单元是否满足迁移条件,该过程可参考处理器根据各个存储单元的被访问次数以及迁移阈值的取值范围,以确定各个存储单元是否满足迁移条件。
在第一存储单元满足迁移条件包括第一存储介质的访问时延小于第二存储介质的访问时延,第一存储介质中空闲存储单元的个数小于或等于个数阈值,且第一存储单元为被访问次数未达到访问阈值的非空闲存储单元的情况下,管理器通过下述方式B13,对第一存储介质进行数据迁移检测。其中,空闲存储单元为没有存储数据的存储单元,非空闲存储单元是指存储有数据的存储单元,此时,该迁移阈值为第二迁移阈值。
方式B13、管理器检测第一存储介质中的空闲存储单元和非空闲存储单元,根据空闲存储单元和非空闲存储单元,确定满足迁移条件的存储单元。
在第一存储介质的访问时延小于第二存储介质的访问时延的情况下,管理器以第一时长为周期,获取该第一存储介质中各个存储单元在第一时长的被访问次数(获取方式参考上述的方式B11或方式B12)。对于第一存储介质中的任一存储单元,若任一存储单元的被访问次数大于0,则该任一存储单元为非空闲存储单元,否则,该第一存储单元为空闲存储单元。
管理器通过第一存储介质中的各个存储单元的访问次数,确定第一存储介质中的空闲存储单元和非空闲存储单元,而无需从第一存储介质查询的各个存储单元是否存储有数据,确定方式简单且快捷。而在一些实施例中,管理器通过从第一存储介质查询的各个存储单元是否存储有数据,以确定第一存储介质中的空闲存储单元和非空闲存储单元,确定出的空闲存储单元和非空闲存储单元准确。
在确定出存储介质中的非空闲存储单元和空闲存储单元后,若第一存储介质中空闲存储单元的个数小于或等于个数阈值,第一存储单元的被访问次数小于或等于第二迁移阈值,且第一存储单元为非空闲存储单元,则管理器确定第一存储单元满足迁移条件,否则该第一单元不满足迁移条件。
其中,个数阈值大于0且小于或等于第一存储介质中0.1%、0.01%、0.001%的存储单元的个数,或者是,个数阈值为0,在此,本申请实施例对个数阈值的取值范围不做限定。
若第一存储介质中空闲存储单元的个数小于或等于个数阈值,说明第一存储介质中当前可用的存储空间比较小,若第一存储单元的被访问次数小于或等于第二迁移阈值,且第一存储单元为非空闲存储单元,说明该第一存储单元中的数据为冷数据,则判定该第一存储单元满足迁移条件,触发对第一存储单元的数 据迁移,之后将第一存储单元中的冷数据迁移至高访问时延的第二存储介质,使得第一存储单元变为空闲存储单元,以便第一存储介质能够有更多的空闲存储单元存储热数据。
步骤B2、若检测到该第一存储单元满足迁移条件,管理器生成该数据迁移请求。
其中,步骤B2与步骤A2同理,在此,本申请实施例对步骤B2不再赘述。
步骤B3、若第一存储单元满足迁移条件,且接收到应用程序对该第一存储单元的数据访问请求,管理器生成该数据迁移请求。
其中,该应用程序为处理器运行的任一应用程序。若处理器在运行应用程序过程中,生成应用程序对混合内存***中的存储单元的数据访问请求,向管理器发送该数据访问请求,若管理器在该数据访问请求中解析出第一存储单元的物理地址,则说明该数据访问请求为应用程序对该第一存储单元的数据访问请求,若此时第一存储单元满足迁移条件,则管理器生成该迁移请求。
在一种可能的实现方式中,管理器通过为混合内存***中的存储单元记录触发标识,来指示在接收到应用程序对该存储单元的数据访问请求时是否触发生成数据迁移请求。其中,触发标识包括第一触发标识和第二触发标识,第一触发标识指示在接收到应用程序对该存储单元的数据访问请求时触发生成数据迁移请求,第二触发标识指示在接收到应用程序对该存储单元的数据访问请求时不触发生成数据迁移请求。
其中,为存储单元记录触发标识的方式,例如,管理器中存储有混合内存***中支持用于程序访问的各个存储单元(即非候选存储单元)与触发标识之间的第二映射关系。在一些实施例中,该第二映射关系由第二单元映射表来记录,例如下述表2所示的第二单元映射表,第二单元映射表包括多个第二单元映射表项,每个第二单元映射表项包括一个存储单元的第一地址、第二地址、介质属性标识以及触发标识,其中,第一地址为该存储单元的物理地址和虚拟地址中的任一个,在本申请实施例中,以第一地址为存储单元的物理地址为例进行介绍。该第二地址为该存储单元在所属存储介质中的地址,换言之,第二地址为存储单元的介质地址。以该存储单元为页面为例,第二地址为该存储单元在所属存储介质中的页面框号。此时,该存储单元与触发标识之间的第二映射关系也即是该存储单元的第一地址与该存储单元在所属存储介质中的第二地址之间具有映射关系,以指示将混合内存***统一编址时的第一地址分配给该存储单元。
介质属性标识用于指示存储单元所属的存储介质。其中,表2,是以混合内存***包括DDR和PCM两种存储介质为例示出的,应当理解,混合内存***还可能包括除DDR和PCM以外的其他存储介质,或者,混合内存***不包括DDR和PCM,而是包括除DDR和PCM以外的其他存储介质。表2以字符(如“DDR”、“PCM”)为例作为介质属性标识示出,在一些实施例中,管理器为混合内存***中的每种存储介质分别分配一个介质编号,介质属性标识为存储介质的介质编号。
表2
基于上述的第二映射关系,对管理器基于映射关系,生成数据迁移的过程做如下介绍:
在一些实施例中,初始时,对于任一存储单元,在该任一存储单元的第二映射关系中的触发标识为第二触发标识,若任一存储单元的满足迁移条件,管理器将第二映射关系中,该任一存储单元对应的第二触发标识更新为第一触发标识。之后,若管理器接收到处理器发送的任一数据访问请求,获取该任一数据访问请求所指示的待访问存储单元的触发标识,若该触发标识为第一触发标识,则管理器生成对该待访问存储单元的数据迁移请求,将该触发标识修改为第二触发标识,否则,不生成对该待访问存储单元的数据迁移请求,也不修改触发标识。
从而在存储单元满足迁移条件,且对该存储单元有访问需求的情况下,管理器才会对该存储单元进行数据迁移,而在存储单元满足迁移条件,但对该存储单元没有访问需求的情况下,无须对该存储单元进行数据迁移,减少了管理器迁移存储单元的次数,降低了管理器的工作负担。
在另一些实施例中,对于第一存储介质中第一存储单元,若第一存储介质的访问时延大于第二存储介质的访问时延,且该第一存储单元满足迁移条件,管理器将第二映射关系中,该第一存储单元对应触发标识记录为第一触发标识;若第一存储介质的访问时延小于第二存储介质的访问时延,管理器将第二映射关系中,该第一存储单元对应触发标识记录为第二触发标识。
其中,若第一存储介质的访问时延大于第二存储介质的访问时延,说明处理器优先访问第二存储介质中的数据,即使第一存储介质中的某一存储单元满足迁移条件,但处理器之后可能不再访问该存储单元,因此,将第二映射关系中,该存储单元对应触发标识记录为第一触发标识,以便之后在应用程序对该存储单元有访问需求的情况下,再生成对该存储单元的数据迁移请求,对该存储单元进行数据迁移,从而避免无效的数据迁移。若第一存储介质的访问时延小于第二存储介质的访问时延,说明处理器优先访问第一存储介质中的数据,将第二映射关系中,该存储单元对应触发标识记录为第二触发标识,之后,在该第一存储介质中的存储单元满足迁移条件的情况下,再对该存储单元进行数据迁移,无须再等到访问数据请求下发时再进行数据迁移,以为该第一存储介质空出更多的存储单元来存储低访问时延的第二存储介质中的热数据。
其中,步骤B2和步骤B3为并列方案,管理器执行步骤B2和步骤B3中任一步骤,或者,若第一存储介质的访问时延小于第二存储介质的访问时延,则管理器按照步骤B2,生成数据访问请求,若第一存储介质的访问时延大于第二存储介质的访问时延,则管理器按照步骤B3,生成数据访问请求。
步骤402、管理器将该第一存储单元中的数据迁移至该第二存储介质中的第二存储单元,该第二存储单元未参与混合内存***中的统一编址。
其中,第二存储单元为第二存储介质中未参与混合内存***中的统一编址的任一存储单元。
在一些实施例中,第二存储介质包括多个候选存储单元,管理器将该第一存储单元中的数据迁移至该多个候选存储单元中的任一候选存储单元,此时,该任一候选存储单元也即是第二存储单元。
在另一些实施例中,在将该第一存储单元中的数据迁移至第二存储单元之前,管理器先从第二存储介质的候选存储单元中,确定第二存储单元。示例性地,管理器中存储有第二存储介质的候选存储单元队列,该候选存储单元队列包括多个候选存储单元的第二地址,管理器将该候选存储单元队列中处于队头的第二地址所指示的存储单元作为第二存储单元,向第二存储单元迁移数据。
下面结合图7所示的本申请提供的一种数据迁移过程的流程图,对步骤402的数据迁移过程作如下介绍:
其中,数据迁移过程包括迁移读过程和迁移写过程,迁移读过程是从第一存储单元中读取数据,迁移读过程包括下述步骤4021至4024,迁移写过程是向第二存储单元写入读取到数据,迁移写过程包括下述步骤4025至4028。
步骤4021、管理器根据第一存储单元的第二地址,生成迁移读请求,该迁移读请求指示从第一存储单元中读取数据。
其中,该迁移读请求包括该第一存储单元的第二地址。
管理器中存储有混合内存***的未参与统一编址的各个存储单元的第一地址与第二地址之间的第三映射关系,以指示为第二地址所指示的存储单元分配第一地址。
在一些实施例中,该第三映射关系由第三单元映射表来记录,例如下述表3所示的第三单元映射表,第三单元映射表包括多个第三单元映射表项,每个第三单元映射表项包括参与统一编址的一个存储单元的第一地址、第二地址以及介质属性标识。
表3
以第一存储单元为例,管理器从迁移请求中获取第一存储单元的物理地址,以物理地址为第一存储单元的第一地址,从第一存储单元的第三映射关系中,获取该第一存储单元的第一地址对应的第二地址,根据该第二地址,生成迁移读请求。
另外,管理器存储第二单元映射表和第三单元映射表中的一个即可,例如,若管理器中存储有第二单元映射表,则无须存储第三映射单元映射表,而是将第二单元映射表中的第一地址、第二地址以及介质属性标识这三列内容作为第三单元映射表。若管理器中没有存储第二单元映射表,则管理器存储第三映射单元映射表。应当理解,第二单元映射表或第三单元映射表是管理器为该混合内存***新增的映射表,用于记录对混合内存***一编址得到的各个第一地址(如物理地址)被分配给哪些存储单元,以便后续在某一存储单元迁移完成后,管理器基于新增的映射表,对该存储单元所分配到的第一地址进行重分配。对于上 述的第一单元映射表至第三单元映射表中的任一单元映射表,该单元映射表中的多列表格可能存储在同一位置,进而形成一张表格,以指示映射关系。该多列表格也可能不存储在同一位置,每列表格为单独表格,管理器在查询单元映射表时,以多个表格中的处于同一行的表项来指示映射关系进行查询。
步骤4022、管理器向第一存储介质的第一控制器发送该迁移读请求。
其中,第一控制器为第一存储介质的控制器。
步骤4023、第一控制器根据接收到的迁移读请求,从第一存储介质的第一存储单元读取数据。
例如,第一控制器从接收到的迁移读请求中,获取第一存储单元的第二地址,根据该第二地址,从该第一存储单元读取数据。
步骤4024、第一控制器向管理器发送读取到的第一数据。
其中,第一数据为从第一存储单元读取到的数据。当管理器接收到第一数据后,执行下述步骤4025。
步骤4025、管理器根据第二存储单元的第二地址以及接收到的第一数据,生成迁移写请求,该迁移写请求指示向第二存储单元写入第一数据。
其中,该迁移写请求包括第二存储单元的第二地址以及该第一数据。
例如,管理器先从第二存储介质的候选存储单元队列中获取第二存储单元的第二地址,然后再根据第二存储单元的第二地址以及接收到的第一数据,生成迁移写请求。
步骤4026、管理器向第二存储介质的第二控制器发送迁移写请求。
其中,第二控制器为第二存储介质的控制器。
步骤4027、第二控制器根据接收到的迁移写请求,向第二存储介质的第二存储单元写入第一数据。
例如,第二控制器从接收到的迁移写请求中,获取第二存储单元的第二地址以及第一数据,根据该第二地址,向该第二存储单元写入第一数据。
步骤4028、写入完成后,第二控制器向管理器发送写入完成响应,该写入完成响应指示已经将第一数据写入第二存储单元。
在管理器接收到该写入完成响应的情况下,迁移完成。若管理器是从候选存储单元中确定的第二存储单元,则迁移完成后,该管理器移除候选存储单元队列中的该第二存储单元。例如,管理器将该候选存储单元队列中的第一个第二地址从该候选存储单元队列弹出,将该候选存储单元队列中剩余的各个第二地址移动到前一个第二地址的位置,使得该候选存储单元队列中原来的第二个第二地址作为第一个第二地址,依此类推。
在候选存储单元队列中的至少一个候选存储单元移除后,候选存储单元队列中的候选存储单元出现未满的情况。若候选存储单元队列中的候选存储单元未满,管理器将该第二存储介质中的空闲存储单元加入该候选存储单元队列,以动态维护第二存储介质中用于存储迁移数据且不支持应用程序写入数据的存储空间,从而不影响之后向第二存储介质继续迁移数据。
例如,若第二存储介质的第三存储单元中的数据已经迁移完成,查询候选存储单元队列中的候选存储单元是否未满,若候选存储单元队列中的候选存储单元未满,管理器将该第三存储单元的第二地址添加在该候选存储单元队列中的最后一个第二地址之后。其中,第三存储单元为第二存储介质中非候选存储单元,且第三存储单元中的数据已经迁移完成是指第三存储单元中的数据已经迁移到另一存储单元。
或者,若候选存储单元队列中的候选存储单元未满,管理器从第二存储介质中参与统一编址的多个存储单元,查询空闲存储单元,在该候选存储单元队列中的最后一个第二地址之后,依次添加查询到的空闲存储单元的第二地址,直至候选存储单元队列中的存储单元已满为止。应当理解,当将该非参与统一编址的任一存储单元的第二地址添加在该候选存储单元队列时,该存储单元的角色从参与非候选存储单元变成候选存储单元。
步骤403、管理器将该第一存储单元在该统一编址时所关联的第一地址分配给该第二存储单元。
其中,该第一地址与该第一存储单元在第一存储介质中的第二地址之间具有映射关系,以指示将该第一地址分配给该第一存储单元,该映射关系例如第一存储单元的第三映射关系
在一些实施例中,管理器将第一存储单元的第三映射关系中,第一存储单元的第二地址修改为该第二存储单元的第二地址,以将该第一存储单元在该统一编址时所关联的第一地址分配给该第二存储单元。
例如,管理器以第一存储单元的物理地址为该第一存储单元所关联的第一地址,在第三单元映射表中查询第一存储单元的第一地址,对于查询到的第一地址所在的第三单元映射表项,将该第三单元映射页面表项中的第二地址修改为该第二存储单元的第二地址,第一存储介质的介质属性标识修改为第二存储介质的介质属性标识。
仍以表3所示的第三单元映射表为例,若第一存储单元的第一地址与第二地址之间的第二映关系由表3中的第一个单元映射表项来记录,第二存储介质为PCM,第二存储单元的第二地址为000010,管理器将该第一个单元映射表项中的第二地址“000001”更新为“000010”,将介质属性标识“DDR”更新为“PCM”,得到下述的表4。此时,对于管理器而言,第一地址1为第二存储单元在混合内存***中的地址。
表4
对于处理器而言,混合内存***提供的存储空间是一定的,该存储空间包括第三存储单元映射表中的各个第一地址所指示的存储单元,即使管理器将该第一存储单元所关联的第一地址分配给第二存储单元,对于处理器而言,该第一地址没有发生变化,因此,本申请实施例通过第三映射关系实现了混合内存***中第一地址和第二地址放置的解耦,在不改变第一地址的情况下,实现了数据在不同存储介质中的迁移,不影响处理器的执行流程。
另外,在第一地址为存储单元的物理地址的情况下,应用程序感知到是混合内存***中分配给该应用程序的虚拟地址,在应用程序访问混合内存***中的存储单元时,处理器运行应用程序,生成应用程序的数据访问请求,该数据访问请求携带混合内存***中的待访问存储单元的虚拟地址。之后,处理器根据混合内存***中的第一映射关系,将数据访问请求中的虚拟地址转换为物理地址,然后,向管理器发送携带物理地址的数据访问请求。管理器以数据访问请求中的物理地址为第一地址,从第三映射关系中查询该第一地址对应的第二地址,访问查询到的第二地址所指示的存储单元。而数据迁移的过程中,第三映射关系中的第一地址没有发生变化,因此,在数据迁移的过程中,不会打断处理器上应用程序的运行流程,使得应用程序对数据迁移无感知。
图4所示的数据迁移方法,通过在获取到对第一存储介质的存储单元的数据迁移请求的情况下,将该存储单元中的数据迁移至第二存储介质中未参与统一编址的存储单元,由于未参与统一编址的存储单元不支持应用程序访问,在向未参与统一编址的存储单元迁移数据的过程中,也就不存在写数据一致性维护问题,因此,未参与统一编址的存储单元无须加锁,简化了迁移流程,相应地,降低了数据迁移的时长,提高了数据迁移效率。在另一些实施例中图4所示的数据迁移方法包括步骤401至步骤402,当步骤402执行完毕后,数据迁移完成,此时,还是向未参与统一编址的存储单元迁移数据,仍然能够迁移流程,相应地,降低了数据迁移的时长,提高了数据迁移效率。
在一些实施例中,当混合内存***中的第一存储单元正在数据迁移的过程中,或者数据迁移完成后,应用程序可能会访问第一存储单元,管理器通过第一存储单元的迁移状态,辅助应用程序完成访问第一存储单元。应用程序访问第一存储单元可能是向第一存储单元写入数据,也可能是读取第一存储单元中的数据,下面分别以图8和图12所示的实施例,对管理器辅助应用程序向第一存储单元写入数据的过程以及辅助应用程序读取第一存储单元数据的过程作如下介绍。
图8是本申请提供的一种数据迁移与数据写入并行的情况下存储单元的访问流程图,该方法应用于混合内存***中,该混合内存***包括第一存储介质和第二存储介质,该方法由混合内存***的管理器来执行,该方法包括如下步骤。
步骤801、管理器获取数据迁移请求,该数据迁移请求指示将第一存储介质的第一存储单元中的数据迁移至第二存储介质。
其中,本步骤801与上述步骤401同理,在此,本申请实施例对本步骤801不再赘述。
步骤802、管理器根据该数据迁移请求,确定第二存储介质中的第二存储单元,该第二存储单元未参与所述混合内存***中的统一编址。
例如,当接收到该数据迁移请求后,从第二存储介质的候选单元中确定第二存储单元,该过程在步骤402中有相关介绍。
步骤803、管理器建立第一存储单元、第二存储单元以及第一存储单元的迁移状态之间的第四映射关系,该迁移状态指示该第一存储单元的迁移进度。
其中,迁移状态包括迁移中以及迁移完成,其中,迁移中指示正在将第一存储单元中的数据迁移至第 二存储单元,迁移完成指示已经将第一存储单元中的数据迁移至第二存储单元,另外,为了便于描述,在对某个存储单元进行数据迁移时,将该存储单元称为源存储单元(如第一存储单元),将用于存储将该存储单元的迁移数据的存储单元称为目的存储单元(如第二存储单元)。
在一种可能的实现方式中,管理器中存储有迁移表,管理器在迁移状态中建立第一存储单元、第二存储单元以及第一存储单元的迁移状态之间的第四映射关系。
以下述表5所示的迁移表为例,该迁移表包括多个迁移表项,每个迁移表项包括待迁移数据的迁移状态、源地址、源介质属性标识、目的地址以及目的迁移属性标识。在表5中,以迁移状态为1表示迁移中,以迁移状态为0表示迁移完成,在另一些实施例中,迁移状态为0表示迁移中,以迁移状态为1表示迁移完成。源地址为待迁移数据的源存储单元的第二地址,源介质属性标识为该源存储单元所属存储介质的介质属性标识,目的地址为待迁移数据的目的存储单元的第二地址,目的介质属性标识为该目的存储单元所属存储介质的介质属性标识。
表5
管理器以迁移中为迁移状态,以第一存储单元的第二地址为源地址,以第一存储介质的介质属性标识为源介质属性标识,以第二存储单元的第二地址为目的地址,以第二存储介质的介质属性标识为目的介质属性标识,在迁移表中添加目标迁移表项,以实现建立第一存储单元、第二存储单元以及第一存储单元的迁移状态之间的第四映射关系。
以第一存储单元为DDR中第二地址“000001”所指示的存储单元,第二存储单元为PCM中第二地址“000010”所指示的存储单元为例,管理器在表5所示的迁移表的第一行添加目标迁移表项。
另外,混合内存***中的各个存储单元都包括多个缓存行,在一些实施例中,如表5所示,迁移表中的迁移表项还包括缓存行状态,缓存行状态包括多个状态位,多个状态位与目的存储单元的多个缓存行一一对应,状态位用于存储缓存行的写入状态,以指示缓存行写入数据的进度。
其中,写入状态包括写入完成和写入未完成,写入完成指示缓存行已经写入数据,写入未完成指示该缓存行还未完成写入数据。在表5中,以写入状态为1表示写入完成,以写入状态为0表示写入未完成,在另一些实施例中,以写入状态为0表示写入完成,以写入状态为1表示写入未完成。
在迁移表项包括缓存状态的情况下,在该迁移表中添加第一存储单元对应的迁移表项时,管理器将该迁移表项中缓存行状态都置位为写入未完成,以指示第二存储单元中的各个缓存行还未完成写入数据。通过缓存行状态记录目的存储单元的各个缓存行的写入状态,以便管理器确认数据迁移的进度。
缓存行状态为迁移表中的可选项,在一些实施例中,迁移表不包括缓存行状态,例如,在管理器对目的存储单元的缓存行的写入状态没有需求的情况下,迁移表不包括缓存行状态。
步骤804、管理器将该第一存储单元中的数据迁移至第二存储单元,将第一存储单元在统一编址时所关联的第一地址分配给第二存储单元。
其中,本步骤804与上述步骤402和步骤403同理,在此本步骤804不再赘述。
另外,在数据迁移的迁移读过程中,第一控制器按照第一存储单元中缓存行的排序,依次读取第一存储单元的各个缓存行中的数据,再向管理器依次发送各个缓存行中的数据。且在处理访问存储单元的请求(如应用程序的数据访问请求、管理器的迁移读请求或迁移写请求)时,管理器按照先到先处理的原则,优先处理最先获取到的请求,再处理后获取的请求,因此,在迁移表包括缓存状态的情况下,管理器每接收到第一存储单元的一个缓存行中的数据,根据该缓存行在第一存储单元中的位置,从迁移表中查询第二存储单元中该缓存行对应的目标缓存行的写入状态,若该写入状态为写入未完成,管理器将该写入状态更新为写入状态,其中,目标缓存行在第二存储单元中的位置和该缓存行在该第一存储单元中的位置相同,若该写入状态为写入完成,则丢弃当前收到的数据,放弃后续改缓存行的迁移写入操作。
在数据迁移的迁移写过程中,在向第二存储单元的第二控制器发送迁移写请求中的第一数据时,管理器按照第一存储单元中缓存行的排序,依次向第二控制器发送第一存储单元的各个缓存行中的数据。
在第一存储单元迁移完成后,管理器将第一存储单元的迁移状态更新为迁移完成,以指示已经该第一存储单元中的数据迁移至第二存储单元,之后,管理器将第一存储单元在统一编址时所关联的第一地址分 配给第二存储单元。另外,在一些实施例中,当将第一存储单元的迁移状态更新为迁移完成时,还指示该迁移状态所在的迁移表项无效,相应地,迁移状态为迁移中的迁移表项为有效表项,之后,可在迁移表中的有效表项查询迁移状态,以减少查询迁移表时待查询迁移表项的个数。
步骤805、管理器接收应用程序的第一数据写请求,该第一数据写请求指示向该第一存储单元写入数据。
其中,该第一数据写请求为应用程序的一种数据访问请求,该第一数据写请求包括第一存储单元的物理地址以及向该物理地址待写入的第二数据。
应当理解,应用程序先将第一数据写请求发送给处理器,此时第一数据写请求包括第一存储单元的虚拟地址以及第二数据,处理器通过查询第一单元映射表,第一数据写请求中的第一存储单元的虚拟地址转换为物理地址,之后,处理器在向管理器发送地址转换后的第一数据写请求,相应地,管理器接收到第一数据写请求中包括的是第一存储单元的虚拟地址而不是物理地址。
步骤806、管理器根据该第一数据写请求,查询第一存储单元的迁移状态,该迁移状态指示该第一存储单元的迁移进度。
在一种可能的实现方式中,管理器根据该第一数据写请求中第一存储单元的物理地址,在第三映射关系中,查询该第一存储单元的第二地址。例如,管理器以第一存储单元的物理地址为第一存储单元的第一地址,在第三单元映射表中记录的第一地址中,查询第一存储单元的第一地址,在查询到的第一地址所在第三映射表项中,获取第一存储单元的第二地址以及第一存储介质的介质属性标识。
之后,管理器根据该第一存储单元的第二地址,在迁移表中查询该第一存储单元的迁移状态。例如,管理器从迁移表中记录的源地址以及源介质属性标识,查询第一存储单元的第二地址以及第一存储介质的介质属性标识,若查询到第一存储单元的第二地址以及第一存储介质的介质属性标识位于迁移表中的同一迁移表项(即目标迁移表项),则管理器从目标迁移表项,获取第一存储单元的迁移状态。再例如,以迁移表中迁移状态为迁移完成的迁移表项为无效迁移表项,以迁移表中迁移状态为迁移中的迁移表项为有效迁移表项,从迁移表中的各个有效迁移表项的源地址以及源介质属性标识,查询第一存储单元的第二地址以及第一存储介质的介质属性标识,若查询到第一存储单元的第二地址以及第一存储介质的介质属性标识位于迁移表中的同一有效迁移表项,则此时第一存储单元的迁移状态为迁移中。
步骤807、若该迁移状态为迁移中,管理器将该第一数据写请求转换为第二数据写请求,向第二存储介质发送第二数据写请求。
其中,该第二数据写请求指示向该第二存储单元写入第二数据,相应地,第二数据写请求包括第二存储单元的第二地址以及第二数据。
若该迁移状态为迁移中,说明在管理器正在将第一存储单元中的第一数据迁移至第二存储单元,在第一数据写请求之前,管理器已经进行对该第一存储单元进行数据迁移,第一数据写请求中的第二数据为第一存储单元的最新数据,而第二存储单元为第一存储单元的目的存储单元,因此,管理器将第一数据写请求中的第一存储单元的物理地址修改为第二存储单元的第二地址,得到第二数据写请求,向第二存储介质发送第二数据写请求。
例如,管理器向第二存储介质的第二控制器发送第二数据写请求,由第二控制器根据第二数据写请求,将第二数据写请求中的第二数据写入第二存储单元,另外,若此时第二存储单元中的已经迁移了部分数据,在向第二存储单元写入第二数据时,若迁移的这部分数据的存储位置和第二数据的存储位置相同,则第二数据覆盖掉已经迁移的数据,从而确保第二存储单元中的数据为第一存储单元的最新数据。
在一些实施例中,在迁移表中存储有缓存行状态的情况下,若该迁移状态为迁移中,该管理器还根据第一数据写请求中第二数据在第一存储单元中的偏移地址,确定第一存储单元中待写入该第二数据的缓存行(称为第三缓存行),获取第二存储单元中第三缓存行对应的缓存行(称为第四缓存行)的写入状态,若该第四缓存行的写入状态为写入完成,向第二存储介质发送第二数据写请求,以覆盖之前迁移到第四缓存行中的数据。若该第四缓存行的写入状态为写入未完成,则管理器将该第四缓存行的写入状态更新为写入完成,向第二存储介质发送第二数据写请求,之后,若迁移读请求读取到该第三缓存行的数据,且第四缓存行的写入状态为写入完成,则管理器丢弃从该第三缓存行读取到的数据,在迁移写的过程中,不再向第四缓存行写入从该第三缓存行读取到的数据,以避免该第三缓存行的数据覆盖掉第四缓存行中的第二数据。
其中,第三缓存行在第一存储介质中的位置和第四缓存行在第二存储介质中的位置相同,管理器根据第三缓存行在第一存储介质中的位置,在迁移表中目标迁移表项的缓存状态,获取第四缓存行的写入状态。 其中,该第三缓存行在第一存储介质中的位置与第四缓存行的写入状态在缓存状态中的位置相同。
若第一存储单元的该迁移状态为迁移完成,且还未将第一存储单元所关联的第一地址分配给第二存储单元,则管理器还先将第一存储单元所关联的第一地址分配给第二存储单元,再向第二存储介质发送第二数据写请求。
步骤808、若没有查询到该迁移状态,管理器向第一存储介质发送第一数据写请求。
例如,若管理器没有在迁移表的有效迁移表项中没有查询到目标迁移表项,说明没有将第一存储单元中的数据迁移至第二存储单元,而第一数据写请求中的第二数据为第一存储单元待写入的最新数据,因此,管理器将第一数据写请求中第一存储单元的物理地址修改为第一存储单元的第二地址,向第一存储介质发送第一数据写请求。
例如,管理器向第一存储介质的第一控制器发送第一数据写请求,由第一控制器根据第一数据写请求,将第一数据写请求中的第二数据写入第一存储单元,以盖掉第一存储单元中的原来的第一数据,从而确保第一存储单元中的第二数据为最新数据。
图8所示的数据迁移方法,能够达到图4所示的数据迁移方法所能达到的有益效果。并且,在数据迁移过程中,应用程序的数据访问请求(如数据写请求)通过查询第三单元映射表中的映射关系和迁移表中的迁移状态路由到第一存储介质或者第二存储介质,迁移完成后再将第二存储单元的地址分配给应用程序,以确保应用程序在待访问地址写入最新数据。
图8是从整体角度说明,管理器通过维护第一存储单元的迁移状态和第二存储单元的缓存行状态,处理对第一存储单元的第一数据写请求的过程,但是上述步骤805至步骤808中的各个步骤都可能在步骤801至804的前后,或者执行过程中发生,则第一数据写请求可能在迁移读请求的前后达到管理器,也可能在迁移写请求的前后达到管理器。为了便于理解,接下来从第一数据写请求到达管理器的不同时机出发,结合图9至图11,分别对数据迁移过程做如下介绍:
图9是本申请提供的一种第一数据写请求在迁移读请求之前达到管理器时的数据迁移过程示意图,如图9所示,处理器向管理器下发对第一存储单元的数据迁移请求或者管理器生成该数据迁移请求,之后,在根据数据迁移请求生成迁移读请求之前或者生成迁移读请求时,管理器在迁移表中增加第一存储单元的目标迁移表项,在管理器生成迁移读请求时,还将目标迁移表项中的第一存储单元迁移状态设置为迁移中。
如图9所示,处理器向管理器下发的第一数据写请求在迁移读请求生成之前达到管理器,若迁移表中不存在目标迁移表项,则管理器根据第一数据写请求,在迁移表中查询不到目标迁移表项,此时第一数据写请求未命中迁移表,说明此时第一存储单元中的数据还未迁移,则管理器将第一数据写请求下发给第一存储单元所属的第一存储介质,以将最新数据写入第一存储单元。之后再生成对第一存储单元的迁移读请求,通过迁移读请求从第一存储单元读取最新数据,然后,通过迁移写请求将最新数据写入到第二存储单元。
图10是本申请提供的一种第一数据写请求在迁移读请求之后迁移写请求之前达到管理器时的数据迁移过程示意图,在根据数据迁移请求生成迁移读请求时,管理器在迁移表中的目标迁移表项将第一存储单元的迁移状态设置为迁移中。
如图10所示,管理器在生成迁移读请求之后,接收到处理器向管理器下发的第一数据写请求,管理器先向第一存储介质发送该迁移读请求,以通过迁移读请求读取第一存储单元中的数据,再处理第一数据写请求。
在处理第一数据写请求时,由于此时迁移表中存在目标迁移表项,根据第一数据写请求,在迁移表中查询到目标迁移表项,此时第一数据写请求命中迁移表,说明第一存储单元正在迁移中,第一存储单元中的数据最终要存储在第二存储单元,则管理器将第一数据写请求中第一存储单元的物理地址修改为第二存储单元的第二地址,得到第二数据请求写请求,通过第二数据写请求向第二存储单元写入最新数据。另外,管理器还根据第二数据写请求,将迁移表中目标迁移选项内第二存储单元的缓存行状态修改为写入完成。
之后,管理器基于从第一存储单元读取的数据,生成迁移写请求,根据迁移写请求查询到迁移表中目标迁移选项内第二存储单元的缓存行状态为写入完成,则管理器取消向第二存储介质发送迁移写请求,以避免第一存储单元中的旧数据覆盖掉第二数据请求写入的最新数据。
图11是本申请提供的一种第一数据写请求在迁移写请求之后达到管理器时的数据迁移过程示意图,在根据数据迁移请求生成迁移读请求时,管理器在迁移表中的目标迁移表项将第一存储单元的迁移状态设置为迁移中。
如图11所示,管理器根据迁移请求,通过迁移请求读取第一存储单元中的数据,然后,基于从第一 存储单元读取的数据,生成迁移写请求,通过迁移写请求将读取到的数据写入第二存储单元。之后,管理器接收到处理器对第一存储单元的第一数据写请求,此时正在向第二存储单元写入第一存储单元的旧数据或者已经向第二存储单元写入完成,则管理器将第一数据写请求中第一存储单元的物理地址修改为第二存储单元的第二地址,得到第二数据请求写请求,通过第二数据写请求向第二存储单元写入最新数据,以覆盖掉第一存储单元的旧数据。
图12是本申请提供的一种数据迁移与数据读取并行的情况下存储单元的访问流程图,该方法应用于混合内存***中,该混合内存***包括第一存储介质和第二存储介质,该方法由混合内存***的管理器来执行,该方法包括如下步骤。
步骤1201、管理器获取数据迁移请求,该数据迁移请求指示将第一存储介质的第一存储单元中的数据迁移至第二存储介质。
其中,本步骤1201与上述步骤401同理,在此,本申请实施例对本步骤1201不再赘述。
步骤1202、管理器根据该数据迁移请求,确定第二存储介质中的第二存储单元,该第二存储单元未参与所述混合内存***中的统一编址。
例如,当接收到该数据迁移请求后,从第二存储介质的候选单元中确定第二存储单元,该过程在步骤402中有相关介绍。
步骤1203、管理器建立第一存储单元、第二存储单元以及第一存储单元的迁移状态之间的第四映射关系,该迁移状态指示该第一存储单元的迁移进度。
其中,本步骤1204与步骤803同理,在此,本申请实施例对本步骤1203不再赘述。
步骤1204、管理器将该第一存储单元中的数据迁移至第二存储单元,将第一存储单元在统一编址时所关联的第一地址分配给第二存储单元。
其中,本步骤1204与步骤804同理,在此,本申请实施例对本步骤1204不再赘述。
步骤1205、管理器接收应用程序的第一数据读请求,该第一数据读请求指示从该第一存储单元的第一缓存行读取数据。
其中,该第一数据读请求为应用程序的一种数据访问请求,该第一数据写请求包括第一存储单元的物理地址以及第一缓存行在该第一存储单元中的偏移地址。该第一缓存行为第一存储单元中的任一缓存行。应当理解,应用程序先将第一数据读请求发送给处理器,此时第一数据读请求包括第一存储单元的虚拟地址以及该偏移地址,处理器通过查询第一单元映射表,第一数据读请求中的第一存储单元的虚拟地址转换为物理地址,之后,处理器在向管理器发送地址转换后的第一数据读请求,相应地,管理器接收到第一数据读请求中包括的是第一存储单元的虚拟地址而不是物理地址。
步骤1206、管理器根据该第一数据读请求,获取该第二存储单元中第一缓存行对应的第二缓存行的写入状态,该写入状态指示该第二缓存行写入数据的进度。
其中,第一缓存行在第一存储介质中的位置与第二缓存行在第二存储介质中的位置相同。
在一种可能的实现方式中,管理器根据该第一数据读请求,查询第一存储单元的迁移状态,该过程可参考管理器根据该第一数据写请求,查询第一存储单元的迁移状态,
之后,若查询到该第一存储单元的迁移状态为迁移中,管理器根据第一缓存行的偏移地址,从迁移表中第二存储单元的缓存状态中,查询该第二缓存行的写入状态。例如,管理器根据第一缓存行的偏移地址,从迁移表中第二存储单元的缓存状态中,查询该第二缓存行的写入状态的过程,例如,管理器根据第一缓存行的偏移地址所指示的位置,将该第二存储单元的缓存状态中处于该位置的写入状态获取为该第二缓存行的写入状态。
步骤1207、若该第二缓存行的写入状态为写入完成,管理器将该第一数据读请求转换为第二数据读请求,向第二存储介质发送第二数据读请求,该写入完成指示该第二缓存行已经写入数据,该第二数据读请求指示从该第二缓存行读取数据。
其中,第二数据写请求包括第二存储单元的第二地址以及该第二缓存行在该第二存储单元的偏移地址。
若第一存储单元的迁移状态为迁移中,且该第二缓存行的写入状态为写入完成,说明此时管理器正在将第一存储单元中的数据迁移至第二存储单元,且第二缓存行已经迁移入第一缓存行中的数据,为了使得应用程序读取到第一缓存行中的数据,则管理器将第一数据读请求中第一存储单元的物理地址更新为第二存储单元的第二地址,得到第二数据读取请求,而第二数据读取请求中该第一缓存行在该第一存储单元的偏移地址相当于该第二缓存行在该第二存储单元的偏移地址。
例如,管理器向第二存储介质的第二控制器发送第二数据读请求,由第二控制器根据第二数据写请求中第二存储单元的第二地址以及该偏移地址,读取该第二存储单元中第二缓存行中的数据(称为第三数据),向管理器返回第三数据,之后,管理器再将第三数据作为第一数据读请求的读完成响应,向应用程序发送读完成响应。
步骤1208、若第二缓存行的写入状态为写入未完成,管理器向第一存储介质发送第一数据读请求。
若第二缓存行的写入状态为写入未完成,说明此时第一缓存行中的数据还未迁移至第二缓存行,则管理器将第一存储数据读取请求中第一存储单元的物理地址修改为第一存储单元的第二地址,向第一存储介质发送第一数据读请求。
或者,若在迁移表的有效迁移表项中没有查询到目标迁移表项,说明没有将第一存储单元中的数据迁移至其他存储单元,此时,第一存储单元中存储的数据为最新数据,则管理器无须查询第二缓存行的写入状态且无须执行上述步骤1207,管理器将第一数据读取请求中第一存储单元的物理地址修改为第一存储单元的第二地址,向第一存储介质发送修改后的第一数据读请求。
其中,管理器向第一存储介质发送第一数据读请求的过程与向第二存储介质发送第二数据读请求的过程同理,在此,不再赘述。
图12所述的数据迁移方法,能够达到图4所示的数据迁移方法所能达到的有益效果,并且,在数据迁移过程中,应用程序的访问请求(如数据读请求)通过查询第三单元映射表中的映射关系和迁移表中的迁移状态路由到第一存储介质或者第二存储介质,迁移完成后再将第二存储单元的地址分配给应用程序,以确保应用程序在待访问地址读取到最新数据。
图12是从整体角度说明,管理器通过维护第一存储单元的迁移状态和第二存储单元的缓存行状态,处理对第一存储单元的第一数据读请求的过程,但是上述步骤1205至步骤1208中的各个步骤都可能在步骤1201至步骤1204的前后或者执行过程中发生,则第一数据读请求可能在数据迁移过程中的在迁移读请求的前后达到管理器,也可能在迁移写请求的前后达到管理器,为了便于理解,接下来从第一数据读请求到达管理器的时机出发,结合图13对数据迁移过程做如下介绍:
图13是本申请提供的一种第一数据读请求在迁移写请求之后达到管理器时的数据迁移过程示意图,如图13所示,管理器根据对第一存储单元的数据迁移请求,生成迁移读请求,向第一存储介质发送迁移读请求,以从第一存储单元读取数据,之后,根据读取到的数据,生成迁移写请求,向第二存储介质发送迁移写请求,以向第二存储单元写入读取到的数据。另外,在向第二存储介质发送迁移写请求时,管理器将迁移表中的目标迁移表项无效。另外,在向第二存储介质发送迁移写请求时,管理器将第三映射单元表中第一存储单元关联的第一地址所在的第三映射单元表项内,第一存储单元的第二地址更新为第二存储单元的第二地址,以该第一地址分配给第二存储单元。
如图13所示,如果管理器在向第二存储介质发送迁移写请求后,接收到处理器对第一存储单元的第一数据读请求,第一存储单元中的数据提前写入到第二存储单元,此时第一地址所在的第三映射单元表项内的第二地址已经更新为第二存储单元的第二地址,则管理器将第一数据读请求中的第一存储单元的物理地址修改为第二存储单元的第二地址,得到第二数据读请求,向第二存储介质发送第二数据读请求,以从第二存储单元读取第一地址中的最新数据。
在另一些实施例中,如果管理器在向第二存储介质发送迁移写请求之前,接收到处理器对第一存储单元的第一数据读请求,此时第一存储单元中的数据还未迁移,第一地址所在的第三映射单元表项内的第二地址仍然为第一存储单元的第二地址,则管理器将第一数据读请求中的第一存储单元的物理地址修改为第一存储单元的第二地址,向第一存储介质发送第一数据读请求,以从第一存储单元读取第一地址中的最新数据。
图9至图13都是以数据迁移过程与处理器访问一次存储单元过程并行的情况下介绍,而在图14所示的实施例中,数据迁移过程还可能与处理器多次访问存储单元的过程并行。其中,图14是本申请提供的一种处理器两次访问第一存储单元时的数据迁移过程示意图。
如图14所示,在对第一存储单元进行数据迁移的过程中,管理器先通过向第一存储介质发送迁移读请求,以从第一存储单元读取数据。之后,管理器接收到处理器对第一存储单元的第一数据写请求,根据该第一数据写请求,向第二控制器发送第二数据写请求,以向第二存储单元写入第一地址的最新数据,第二存储单元写完成后,第二控制器向管理器发送写入完成响应,由管理器将写入完成响应转发给处理器。另外,管理器在向第二存储单元写入数据时。
另外,管理器在向第二内存控制发送第二数据写请求时,还将第二存储单元的缓存行状态修改为写入 完成。之后,若接收到对第一存储单元的第一数据读请求,管理器将第一数据读请求转换为第二数据读请求,向第二控制器发送第二数据读请求,以从第二存储单元读取最新数据。
另外,将第二存储单元的缓存行状态修改为写入完成之后,对于基于读取到的数据所生成迁移写请求,管理器根据第二存储单元当前的缓存行状态,取消向第二控制器发送迁移写请求。
应当理解,图14是以数据迁移过程中遇到处理器2次访问待迁移存储单元的情况,在另一下实施例中,在数据迁移过程中,还可能遇到处理器访问待迁移存储单元2次以上的情况,对于处理器任一访问待迁移存储单元的过程,若是处理器向迁移存储单元写入数据可参考图8中管理器处理第一数据写请求的过程,若是处理器读取迁移存储单元中的数据可参考图12中管理器处理第一数据读请求的过程。
下面再结合图15所示的本申请提供的一种基于处理器的访问命令进行数据迁移的流程图,对本申请的提出的数据迁移过程做如下介绍:
处理器向管理器下发对混合内存***中某一存储介质的数据访问请求,管理器根据数据访问请求中待访问存储单元的物理地址,在第二单元映射表中查询该物理地址对应的介质地址以及触发标识,将数据访问请求中的物理地址转换为源介质地址(即待访问存储单元的第二地址)。若查询到的触发标识为第一触发标识,则触发数据迁移,管理器生成对待访问存储单元的数据迁移请求。
另外,管理器在处理该数据访问请求的过程中,根据数据访问请求查询迁移表中源存储单元的迁移状态以及目的存储单元的缓存状态。若数据访问请求为数据写请求,且数据写请求命中迁移表,此时源存储单元的迁移状态为迁移中,则数据写请求和该数据迁移请求发生冲突,将数据写请求中的源介质地址转换为目的介质地址(即目的存储单元的第二地址),之后向目的存储单元的控制器发送后下发,并在命中的迁移表项中将目的存储单元的待访问缓存行的写入状态设置为写入完成。若数据访问请求未命中迁移表,则数据写请求和该数据迁移请求发送未发生冲突,管理器不修改数据写请求中的源介质地址,向待访问存储单元的控制器发送数据写请求。
若数据访问请求不为数据写请求为数据读请求,且数据读请求命中迁移表,此时源存储单元的迁移状态为迁移中,则数据读请求和该数据迁移请求发生冲突。若数据读请求待读取的缓存行的写入状态为写入完成,则管理器将数据读请求中的源介质地址修改为目的介质地址,向目的存储单元的控制器发送该数据读请求。若数据读请求待读取的缓存行的写入状态为写入未完成,则管理器不修改数据读请求中的源介质地址,向待访问存储单元的控制器发送该数据读请求。
图4至图15所示的各个方法实施例均是以管理器处理一个数据迁移为例进行说明,在另一些实施例中,管理器会周期性地对混合内存***中参与统一编址的各个存储单元进行数据迁移。例如,在每个迁移周期,管理器和/或处理器检测混合内存***中参与统一编址的各个存储单元是否满足迁移条件,基于满足迁移条件的存储单元,生成迁移列表(list),该迁移列表包括至少一个数据迁移请求,每个数据迁移请求指示对满足迁移条件的一个存储单元进行数据迁移。由管理器依次对迁移列表中的各个数据迁移求进行处理,每个数据迁移请求的处理过程可参考上述的图4至图15所示的实施例,当迁移列表中的各个数据迁移请求都处理完成后,进入下一个迁移周期。
以上介绍了本申请提供的数据迁移方法,接下来,结合附图进一步介绍下本申请提供的装置、芯片和电子设备。应理解,以下介绍的装置、芯片和电子设备可以实现上述任一方法中混合内存***的管理器或管理器一部分的任意功能。
图16是本申请提供的一种数据迁移装置的结构示意图,如图16所示的装置1600可以为前面各个实施例混合内存***的管理器或管理器的部分,用于执行管理器所执行的数据迁移方法,装置1600应用于混合内存***,所述混合内存***包括第一存储介质和第二存储介质,所述装置1600包括:
获取模块1601,获取数据迁移请求,所述数据迁移请求指示将所述第一存储介质的第一存储单元中的数据迁移至所述第二存储介质;
迁移模块1602,将所述第一存储单元中的数据迁移至所述第二存储介质中的第二存储单元,所述第二存储单元未参与所述混合内存***中的统一编址;
分配模块1603,将所述第一存储单元在所述统一编址时所关联的第一地址分配给所述第二存储单元。
应理解的是,本申请实施例的装置1600可以通过CPU实现,也可以通过专用集成电路(application-specific integrated circuit,ASIC)实现,也可以通过可编程逻辑器件(programmable logic device,PLD)实现,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD),现场可编程门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)、数据处理单元(data processing unit,DPU)、片上***(system on chip,SoC)或其任意组合。装置1600也可以通 过软件实现图4至图15所示的方法,在通过软件实现时,装置1600及其各个模块也可以为软件模块。
在一种可能的实现方式中,所述第一地址与所述第一存储单元在所述第一存储介质中的第二地址之间具有映射关系,以指示将所述第一地址分配给所述第一存储单元,所述分配模块1603用于:
将所述映射关系中的所述第二地址修改为所述第二存储单元在所述第二存储介质中的第二地址。
在另一种可能的实现方式中,所述装置模块1600还包括第一处理模块:
接收应用程序的第一数据写请求,所述第一数据写请求指示向所述第一存储单元写入数据;
根据所述第一数据写请求,查询所述第一存储单元的迁移状态,所述迁移状态指示所述第一存储单元的迁移进度;
若所述迁移状态为迁移中,将所述第一数据写请求转换为第二数据写请求,所述迁移中指示正在将所述第一存储单元中的数据迁移至所述第二存储单元,所述第二数据写请求指示向所述第二存储单元写入数据。
在另一种可能的实现方式中,所述装置模块1600还包括第二处理模块:
接收应用程序的第一数据读请求,所述第一数据读请求指示从所述第一存储单元的第一缓存行读取数据;
根据所述第一数据读请求,获取所述第二存储单元中所述第一缓存行对应的第二缓存行的写入状态,所述写入状态指示所述第二缓存行写入数据的进度;
若所述写入状态为写入完成,将所述第一数据读请求转换为第二数据读请求,所述写入完成指示所述第二缓存行已经写入数据,所述第二数据读请求指示从所述第二缓存行读取数据。
其中,上述的第一处理模块和第二处理模块可以为同一模块也可以为不同的模块。
在另一种可能的实现方式中,所述获取模块1601包括:
检测子模块,用于对所述第一存储介质进行数据迁移检测;
生成子单元,用于若检测到所述第一存储单元满足迁移条件,生成所述数据迁移请求。
在另一种可能的实现方式中,所述第一存储单元满足迁移条件包括所述第一存储单元的被访问次数达到迁移阈值的取值范围,所述检测子模块用于:检测发往所述混合内存***的数据访问请求,所述数据访问请求指示访问所述混合内存***中的存储单元;以及,根据检测到所述数据访问请求,获取所述第一存储单元的被访问次数。
在另一种可能的实现方式中,所述第一存储单元满足迁移条件包括所述第一存储介质的访问时延小于所述第二存储介质的访问时延,所述第一存储介质中空闲存储单元的个数小于或等于个数阈值,且所述第一存储单元为被访问次数未达到访问阈值的非空闲存储单元;所述检测子模块用于:获取所述第一存储介质中各个存储单元的被访问次数;根据所述第一存储介质中各个存储单元的被访问次数,确定所述第一存储介质中的空闲存储单元以及非空闲存储单元。
在另一种可能的实现方式中,所述装置1600还包括:生成模块,用于若检测到所述第一存储单元满足迁移条件,且接收到应用程序对所述第一存储单元的数据访问请求,生成所述数据迁移请求。
在另一种可能的实现方式中,所述装置1600还包括:确定模块,用于从所述第二存储介质的候选存储单元中,确定所述第二存储单元,所述候选存储单元为用于未参与所述统一编址的空闲存储单元。
在另一种可能的实现方式中,所述确定模块还用于:移除候选存储单元队列中的所述第二存储单元;若所述候选存储单元队列中的候选存储单元未满,将所述第二存储介质中参与所述统一编址的空闲存储单元加入所述候选存储单元队列。
上述所有可能的实现方案,可以采用任意结合形成本公开的可选实施例,在此不再一一赘述。
图17是本申请提供的另一种数据迁移装置的结构示意图,如图17所示,装置1700包括映射模块1701、迁移命令触发模块1702、迁移命令调度模块1703、迁移模块1704、迁移冲突管理模块1705以及仲裁模块1706。其中,映射模块1701,用于维护第二存储单元映射表,将处理器下发的数据访问请求中的物理地址转换为介质地址后发送给迁移冲突管理模块1705,在有数据访问请求触发迁移的情况下,向迁移命令调度模块1703发送数据迁移请求。
迁移命令触发模块1702为可选模块,迁移命令触发模块1702和电子设备中的处理器,都能用于根据统计单元统计的混合内存***中参与统一编址的各个存储单元的被访问次数,确定满足迁移条件的存储单元,基于满足迁移条件的存储单元,向迁移命令调度模块1703下发数据迁移请求。迁移命令触发模块1702为可选模块。
迁移命令调度模块1703,用于维护混合内存***中各个存储介质(如第一控制器和第二控制器连接的 存储介质)的候选存储单元队列,在接收到的数据迁移请求中添加目的存储单元的介质地址,通过查询第二存储单元映射表,将数据迁移请求中的源存储单元的物理地址转换为介质地址,向迁移模块1704发送携带介质地址的数据迁移请求。
迁移模块1704,用于根据接收到的数据迁移请求,在迁移冲突表管理模块1705中添加迁移表项,并处理数据迁移请求(如向仲裁模块1706下发迁移读请求和迁移写请求),在数据迁移完成后,无效对应的迁移表项,并通知迁移命令调度模块1703处理下一个迁移请求。
迁移冲突表管理模块1705,用于维护迁移表,根据数据访问请求在迁移表的命中情况,确定是否更新数据访问迁移请求中的介质地址,之后,将更新后的或未更新的数据访问请求发送给仲裁模块1706。
仲裁模块1706,用于每接收到一个处理请求(如来自数据访问请求、迁移读请求或迁移写请求),将处理请求加入到发送队列的队尾,从发送队列的队头依次发送各个处理请求,每接收到一个处理请求的处理响应,将处理响应加入到接收队列的队尾,从接收队列的队头依次原路返回各个处理响应。
装置1700的实现方式可参考装置1600,在此,本申请实施例对装置1700的实现方式不做赘述。
应理解,对于装置1600和装置1700中的任一装置,该装置对应于上述方法实施例中的管理器,该装置中的各模块和上述其他操作和/或功能分别为了实现方法实施例中的管理器所实施的各种步骤和方法,具体细节可参见上述方法实施例,为了简洁,在此不再赘述。
应理解,对于装置1600和装置1700中的任一装置,该任一装置在进行数据迁移时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将该装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的装置与上述方法实施例属于同一构思,其具体实现过程详见上述方法实施例,这里不再赘述。
应理解,对于装置1600和装置1700中的任一装置可以相当于图1至图3中的管理器104、104a以及104b,或者相当于管理器104、104a以及104b中的执行部件。
图18是本申请提供的一种芯片的结构示意图,如图18所示,芯片1800包括处理器1801和接口电路1802,其中,接口电路1802,用于接收指令并传输至处理器1801。处理器1801,例如可以是装置1600或装置1700的一种具体实现形式,可以用于执行上述应用于数据迁移方法。处理器1801与存储器1803耦合,存储器1803用于存储程序代码,当该程序代码被处理器1801执行时,使得处理器1801、接口电路1802以及存储器1803所组成的芯片***实现上述图4至图15中任一方法实施例中的方法的操作步骤。
可选地,该芯片***中的处理器1801有至少一个,应理解,在本申请实施例中,处理器1801可以是CPU或其他通用处理器,处理器1801还可以是一个或多个用于实现本申请方案的集成电路,例如,数字信号处理器(digital signal processing,DSP)、ASIC、PLD、FPGA或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者是任何常规的处理器等。
可选地,该芯片***中的存储器1803也可以为一个或多个。存储器1803可以与处理器1801集成在一起,也可以和处理器1801分离设置,本申请并不限定。示例性的,存储器1803可以与处理器1801集成在同一块芯片上,如图18所示,存储器1803也可以和处理器1801分别设置在不同的芯片上,本申请对存储器1803的类型以及存储器1803与处理器1801的设置方式不作具体限定。
其中,存储器1803可以包括只读存储器和随机存取存储器,并向处理器1801提供指令和数据。存储器1803还可以包括非易失性随机存取存储器。例如,存储器1803还可以存储设备类型的信息。存储器1803还可以是易失性存储器,或可包括易失性和非易失性存储器两者。
其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data date SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。
示例性的,该芯片***可以是FPGA,可以是ASIC,还可以是SoC,还可以是CPU,还可以是网络处理器(network processor,NP),还可以是数字信号处理电路(digital signal processor,DSP),还可以是微控制器(micro controller unit,MCU),还可以是PLD)或其他集成芯片。
本申请还提供了一种计算机可读存储介质,例如包括程序代码的存储器,上述程序代码可由电子设备 (或芯片)中的处理器执行以完成上述实施例中的数据迁移方法。该计算机可读存储介质的实现方式可参考与图18中的存储器1803。
本申请还提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括程序代码,该程序代码存储在计算机可读存储介质中,处理器从计算机可读存储介质读取该程序代码,处理器执行该程序代码,使得处理器所在芯片或电子设备执行上述数据迁移方法。
另外,本申请还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中数据迁移方法。
其中,本申请提供的装置、设备、计算机可读存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载或执行所述计算机程序指令时,全部或部分地产生按照本发明本申请实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)或者半导体介质。半导体介质可以是固态硬盘(solid state disk,SSD)。
以上所述,仅为本申请的具体实施方式。熟悉本技术领域的技术人员根据本申请提供的具体实施方式,可想到变化或替换,都应涵盖在本申请的保护范围之内。

Claims (13)

  1. 一种数据迁移方法,其特征在于,所述方法应用于混合内存***,所述混合内存***包括第一存储介质和第二存储介质,所述方法包括:
    获取数据迁移请求,所述数据迁移请求指示将所述第一存储介质的第一存储单元中的数据迁移至所述第二存储介质;
    将所述第一存储单元中的数据迁移至所述第二存储介质中的第二存储单元,所述第二存储单元未参与所述混合内存***中的统一编址;
    将所述第一存储单元在所述统一编址时所关联的第一地址分配给所述第二存储单元。
  2. 根据权利要求1所述的方法,其特征在于,所述第一地址与所述第一存储单元在所述第一存储介质中的第二地址之间具有映射关系,以指示将所述第一地址分配给所述第一存储单元,所述将所述第一存储单元在所述统一编址时所关联的第一地址分配给所述第二存储单元包括:
    将所述映射关系中的所述第二地址修改为所述第二存储单元在所述第二存储介质中的第二地址。
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    接收应用程序的第一数据写请求,所述第一数据写请求指示向所述第一存储单元写入数据;
    根据所述第一数据写请求,查询所述第一存储单元的迁移状态,所述迁移状态指示所述第一存储单元的迁移进度;
    若所述迁移状态为迁移中,将所述第一数据写请求转换为第二数据写请求,所述迁移中指示正在将所述第一存储单元中的数据迁移至所述第二存储单元,所述第二数据写请求指示向所述第二存储单元写入数据。
  4. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    接收应用程序的第一数据读请求,所述第一数据读请求指示从所述第一存储单元的第一缓存行读取数据;
    根据所述第一数据读请求,获取所述第二存储单元中所述第一缓存行对应的第二缓存行的写入状态,所述写入状态指示所述第二缓存行写入数据的进度;
    若所述写入状态为写入完成,将所述第一数据读请求转换为第二数据读请求,所述写入完成指示所述第二缓存行已经写入数据,所述第二数据读请求指示从所述第二缓存行读取数据。
  5. 根据权利要求1或2所述的方法,其特征在于,所述获取数据迁移请求包括:
    对所述第一存储介质进行数据迁移检测;
    若检测到所述第一存储单元满足迁移条件,生成所述数据迁移请求。
  6. 根据权利要求5所述的方法,其特征在于,所述第一存储单元满足迁移条件包括所述第一存储单元的被访问次数达到迁移阈值的取值范围,所述对所述第一存储介质进行数据迁移检测包括:
    检测发往所述混合内存***的数据访问请求,所述数据访问请求指示访问所述混合内存***中的存储单元;
    根据检测到所述数据访问请求,获取所述第一存储单元的被访问次数。
  7. 根据权利要求5所述的方法,其特征在于,所述第一存储单元满足迁移条件包括所述第一存储介质 的访问时延小于所述第二存储介质的访问时延,所述第一存储介质中空闲存储单元的个数小于或等于个数阈值,且所述第一存储单元为被访问次数未达到访问阈值的非空闲存储单元;
    所述对所述第一存储介质进行数据迁移检测包括:
    获取所述第一存储介质中各个存储单元的被访问次数;
    根据所述第一存储介质中各个存储单元的被访问次数,确定所述第一存储介质中的空闲存储单元以及非空闲存储单元。
  8. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    若检测到所述第一存储单元满足迁移条件,且接收到应用程序对所述第一存储单元的数据访问请求,生成所述数据迁移请求。
  9. 根据权利要求1-2以及6-8中任一项所述的方法,其特征在于,所述将所述第一存储单元中的数据迁移至所述第二存储介质中的第二存储单元之前,所述方法还包括:
    从所述第二存储介质的候选存储单元中,确定所述第二存储单元,所述候选存储单元为用于未参与所述统一编址的空闲存储单元。
  10. 根据权利要求9所述的方法,其特征在于,所述候选存储单元位于所述第二存储介质的候选存储单元队列,所述将所述第一存储单元中的数据迁移至第二存储单元之后,所述方法还包括:
    移除候选存储单元队列中的所述第二存储单元;
    若所述候选存储单元队列中的候选存储单元未满,将所述第二存储介质中参与所述统一编址的空闲存储单元加入所述候选存储单元队列。
  11. 一种数据迁移装置,其特征在于,所述装置应用于混合内存***,所述混合内存***包括第一存储介质和第二存储介质,所述装置包括:
    获取模块,用于获取数据迁移请求,所述数据迁移请求指示将所述第一存储介质的第一存储单元中的数据迁移至所述第二存储介质;
    迁移模块,用于将所述第一存储单元中的数据迁移至所述第二存储介质中的第二存储单元,所述第二存储单元未参与所述混合内存***中的统一编址;
    分配模块,用于将所述第一存储单元在所述统一编址时所关联的第一地址分配给所述第二存储单元。
  12. 一种芯片,其特征在于,所述芯片包括处理器,所述处理器用于执行至少一条程序代码,使得所述芯片执行如权利要求1至权利要求10中任一项所述的方法。
  13. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有至少一条程序代码,所述至少一条程序代码由处理器读取以使芯片执行如权利要求1至权利要求10中任一项所述的方法。
PCT/CN2023/120667 2022-09-23 2023-09-22 数据迁移方法、装置、芯片以及计算机可读存储介质 WO2024061344A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211168045.0A CN117806526A (zh) 2022-09-23 2022-09-23 数据迁移方法、装置、芯片以及计算机可读存储介质
CN202211168045.0 2022-09-23

Publications (1)

Publication Number Publication Date
WO2024061344A1 true WO2024061344A1 (zh) 2024-03-28

Family

ID=90427510

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/120667 WO2024061344A1 (zh) 2022-09-23 2023-09-22 数据迁移方法、装置、芯片以及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN117806526A (zh)
WO (1) WO2024061344A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105353980A (zh) * 2013-11-22 2016-02-24 华为技术有限公司 一种内存数据的迁移方法、计算机和装置
CN107678981A (zh) * 2017-08-24 2018-02-09 北京盛和大地数据科技有限公司 数据处理方法及装置
CN108021336A (zh) * 2016-10-31 2018-05-11 甲骨文国际公司 用于无缝数据迁移的数据布局方案
CN109324758A (zh) * 2018-08-24 2019-02-12 华为技术有限公司 数据迁移方法、装置及存储设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105353980A (zh) * 2013-11-22 2016-02-24 华为技术有限公司 一种内存数据的迁移方法、计算机和装置
CN108021336A (zh) * 2016-10-31 2018-05-11 甲骨文国际公司 用于无缝数据迁移的数据布局方案
CN107678981A (zh) * 2017-08-24 2018-02-09 北京盛和大地数据科技有限公司 数据处理方法及装置
CN109324758A (zh) * 2018-08-24 2019-02-12 华为技术有限公司 数据迁移方法、装置及存储设备

Also Published As

Publication number Publication date
CN117806526A (zh) 2024-04-02

Similar Documents

Publication Publication Date Title
US10289555B1 (en) Memory read-ahead using learned memory access patterns
US10031857B2 (en) Address translation services for direct accessing of local memory over a network fabric
US8250254B2 (en) Offloading input/output (I/O) virtualization operations to a processor
US7577816B2 (en) Remote translation mechanism for a multinode system
JP2019067417A (ja) 最終レベルキャッシュシステム及び対応する方法
KR101786871B1 (ko) 원격 페이지 폴트 처리 장치 및 그 방법
WO2019227883A1 (zh) 地址转换方法、装置及***
WO2015180598A1 (zh) 对存储设备的访问信息处理方法和装置、***
WO2023125524A1 (zh) 数据存储方法、***、存储访问配置方法及相关设备
WO2024093517A1 (zh) 内存管理方法及计算设备
WO2024036985A1 (zh) 存储***及其计算存储处理器、固体硬盘和数据读写方法
TWI744111B (zh) 查找表建立暨記憶體位址查詢方法、主機記憶體位址查找表建立方法與主機記憶體位址查詢方法
US20230333989A1 (en) Heterogenous-latency memory optimization
WO2024001310A1 (zh) 一种数据处理设备及方法
WO2024061344A1 (zh) 数据迁移方法、装置、芯片以及计算机可读存储介质
WO2019140885A1 (zh) 一种目录处理方法、装置及存储***
CN116383101A (zh) 内存访问方法、内存管理单元、芯片、设备和存储介质
WO2021238594A1 (zh) 存储介质管理方法、装置、设备以及计算机可读存储介质
US11875152B2 (en) Methods and systems for optimizing file system usage
WO2015161804A1 (zh) 一种Cache分区的方法及装置
WO2024082702A1 (zh) 数据处理方法、装置、芯片以及计算机可读存储介质
WO2023241655A1 (zh) 数据处理方法、装置、电子设备以及计算机可读存储介质
CN116644006B (zh) 一种内存页面管理方法、***、装置、设备及计算机介质
CN117851290B (zh) 页表管理方法、***、电子组件及电子设备
WO2023217255A1 (zh) 数据处理方法、装置、处理器及计算机***

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23867629

Country of ref document: EP

Kind code of ref document: A1