WO2017107163A1 - Memory management method and system based on heterogeneous hybrid memory - Google Patents

Memory management method and system based on heterogeneous hybrid memory Download PDF

Info

Publication number
WO2017107163A1
WO2017107163A1 PCT/CN2015/098817 CN2015098817W WO2017107163A1 WO 2017107163 A1 WO2017107163 A1 WO 2017107163A1 CN 2015098817 W CN2015098817 W CN 2015098817W WO 2017107163 A1 WO2017107163 A1 WO 2017107163A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
nvm
request
application
application request
Prior art date
Application number
PCT/CN2015/098817
Other languages
French (fr)
Chinese (zh)
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 研祥智能科技股份有限公司
Priority to PCT/CN2015/098817 priority Critical patent/WO2017107163A1/en
Publication of WO2017107163A1 publication Critical patent/WO2017107163A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a memory management method and system based on heterogeneous mixed memory.
  • Non-Volatile Memory Non-Volatile Memory
  • DRAM Dynamic Random Access Memory
  • Heterogeneous hybrid memory has the characteristics of NVM and DRAM at the same time. It not only has the function of conventional memory, but the data stored in DRAM will disappear immediately after power off, which is volatile. At the same time, it can also play the NVM after power failure.
  • the ability to save data and take full advantage of the non-volatile nature of NVM is a new type of memory that is used in combination.
  • Heterogeneous hybrid memory adopts DDR3 (Double Data Rate, double-rate synchronous dynamic random access memory, third generation) interface memory module design to meet the conventional memory interface of existing industrial control equipment, without introducing new industrial control equipment or adding New auxiliary equipment has become a research hotspot.
  • DDR3 Double Data Rate, double-rate synchronous dynamic random access memory, third generation
  • the application field of heterogeneous mixed memory is mainly the industrial control field that requires big data and large memory computing.
  • the Linux operating system is widely used in the industrial control field because of its open source code, powerful function and easy migration and optimization. Therefore, the memory management of heterogeneous mixed memory is implemented on the Linux operating system. The promotion of memory is of great significance.
  • heterogeneous mixed memory integrates NVM and DRAM.
  • the conventional memory management method is only the management of DRAM memory, which cannot satisfy the management and operation of NVM memory. Therefore, it will not be used for heterogeneous mixed memory. It is applicable, so it is necessary to provide a memory management method that can be applied to heterogeneous mixed memory, and can simultaneously manage NVM memory and DRAM memory.
  • a memory management method based on heterogeneous mixed memory comprising:
  • NVM flag exists in the memory application request, determining whether the memory application request meets a permission requirement, and if yes, allocating NVM memory according to the memory application request, and if not, ending;
  • the DRAM memory is allocated according to the memory request.
  • the memory request request includes a memory length of the application; before the step of determining whether the memory application request meets the permission requirement, the method further includes:
  • the memory request request includes a memory length of the application; the root
  • the steps for allocating NVM memory according to the request for the application include:
  • the virtual address space is located in an indirect mapped address space in the kernel space of Linux.
  • the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area in the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
  • a memory management system based on heterogeneous mixed memory comprising:
  • a receiving module configured to receive a memory application request
  • a detecting module configured to detect whether an NVM flag exists in the memory application request
  • a first determining module configured to determine, if the NVM flag exists in the memory application request, whether the memory application request meets a permission requirement, and if yes, allocate NVM memory according to the memory application request, and if not, not process ;
  • An application module configured to allocate NVM memory according to the memory application request if the memory application request meets a permission requirement
  • the application module is further configured to allocate DRAM memory according to the memory application request if the NVM flag does not exist in the memory application request or does not meet the permission requirement.
  • the memory request request includes a memory length of the application
  • the system further includes:
  • the second judging module is configured to determine whether the memory length of the application exceeds the total length of the NVM memory, and if not, notify the first judging module whether the memory application request meets the permission requirement, and if not, not deal with.
  • the memory request request includes a memory length of the application
  • the application module includes:
  • a virtual address space application unit configured to apply and initialize a virtual address space of the same size according to a memory length of the application, where the virtual address space includes a first address and a tail address of the virtual address space;
  • An address conversion unit configured to convert a first address of the virtual address space into a physical address
  • the memory application unit is configured to apply for the same size of the NVM memory in the NVM according to the physical address and the requested memory length.
  • the virtual address space is located in an indirect mapped address space in the kernel space of Linux.
  • the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area in the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
  • the above heterogeneous mixed memory based memory management method and system by detecting whether there is an NVM flag in the memory application request, and further determining whether the memory application request meets the permission requirement when the NVM flag exists in the memory application request, and according to the detection and The result of the judgment is to allocate DRAM memory or NVM memory.
  • This memory management method and system can be compatible with the application and allocation of conventional DRAM memory, and can introduce new NVM memory application and allocation, so that NVM memory and DRAM memory can be managed simultaneously to meet the use of heterogeneous mixed memory.
  • 1 is an interface diagram of a heterogeneous mixed memory in one embodiment
  • FIG. 2 is a flow chart of a memory management method based on heterogeneous mixed memory in one embodiment
  • FIG. 3 is a flow chart of a memory management method based on heterogeneous mixed memory in another embodiment
  • FIG. 5 is a distribution diagram of a virtual address space in a 64-bit Linux system in an embodiment
  • FIG. 6 is a physical address space distribution diagram of a heterogeneous mixed memory in an embodiment
  • FIG. 7 is a structural block diagram of a memory management system based on heterogeneous mixed memory in one embodiment
  • FIG. 8 is a structural block diagram of a memory management system based on heterogeneous mixed memory in another embodiment
  • Figure 9 is a block diagram showing the structure of an application module in one embodiment.
  • the heterogeneous hybrid memory adopts a physical connection method consistent with the DDR3 (Double Data Rate, double-rate synchronous dynamic random access memory, third generation) interface circuit.
  • DDR3 Double Data Rate, double-rate synchronous dynamic random access memory, third generation
  • Figure 1 it is an interface diagram of heterogeneous mixed memory.
  • the memory module is inserted into the commonly used DDR3 interface circuit through the JEDEC (Joint Electron Device Engineering Council) standard interface connector, and the address (Address, Addr) and command transmitted by the operating system to the heterogeneous mixed memory ( Information such as Command, Cmd, and Data can be input to the controller through the interface circuit.
  • the Controller controls the DRAM memory and the NVM memory through the received data and internal logic.
  • the controller can be an MCU (Micro Control Unit), an FPGA (Field-Programmable Gate Array), a CPLD (Complex Programmable Logic Device), or an ARM (Advanced RISC Machine, Advanced).
  • the reduced instruction set machine is implemented by a processor, and provides corresponding read and write control and timing operations according to the respective characteristics of the DRAM and the NVM.
  • the present invention is a memory management method and system based on heterogeneous mixed memory implemented in an interface environment as described above.
  • a memory management method based on heterogeneous mixed memory includes:
  • Step S110 receiving a memory application request.
  • the operating system driver, the library function, and the application program may need to apply for memory.
  • the memory application request is sent to the operating system kernel, and the operating system kernel allocates the memory according to the received memory application request.
  • Step S120 detecting whether there is an NVM flag in the memory application request, if yes, proceeding to step S130, otherwise proceeding to step S150.
  • NVM flag in the memory request such as the last bit stored in the memory request. If it is detected that there is an NVM flag in the memory request request, it indicates that NVM memory needs to be applied. If not, it indicates that you need to apply for DRAM memory.
  • Step S130 determining whether the memory application request meets the permission requirement, if yes, proceeding to step S140, otherwise ending.
  • User permissions are an aspect of Linux security, and different users have different permissions.
  • the root user can have any files and commands in the operating system and has the highest authority. You can specify which users have permission to allocate NVM memory as needed.
  • the NVM memory in the heterogeneous mixed memory The application only allows the root user to operate, and other users do not have permission to apply for NVM memory. If the memory application request is sent by the root user, it is determined to meet the permission requirement, otherwise the permission requirement is not met.
  • Step S140 allocating NVM memory according to the memory application request.
  • the NVM memory and the DRAM memory can be uniformly addressed in advance, and paging is performed in units of physical pages. For example, the size of each physical page defaults to 4 KB.
  • the NVM memory and DRAM memory are divided into different Linux kernel memory management areas.
  • the Linux kernel memory management is divided into ZONE_DMA, ZONE_NORMAL and ZONE_HIGHMEM, and the NVM memory can be divided into any memory management area.
  • the request may include information such as the length of the application's memory, the type of memory management area requested, and the memory continuity requirements of the application.
  • the memory length of the application is used to determine the size of the memory to be allocated.
  • the type of the memory management area to be used is used to determine which of the above memory management areas is allocated NVM memory, and the requested memory continuity requirement is used to determine whether to allocate contiguous memory.
  • the Linux kernel can implement memory allocation based on this information.
  • Step S150 allocating DRAM memory according to the memory application request.
  • the NVM memory and the DRAM memory are collectively addressed in advance, and paging is performed in units of physical pages. For example, the size of each physical page defaults to 4 KB.
  • the NVM memory and DRAM memory are divided into different Linux kernel memory management areas.
  • the Linux kernel memory management is divided into ZONE_DMA, ZONE_NORMAL and ZONE_HIGHMEM, and the DRAM memory can be divided into any memory management area.
  • the request may include information such as the length of the application's memory, the type of memory management area requested, and the memory continuity requirements of the application.
  • the memory length of the application is used to determine the size of the memory to be allocated.
  • the type of memory management area used is used to determine which of the above memory management areas is allocated DRAM memory.
  • the requested memory continuity requirement is used to determine whether to allocate contiguous memory.
  • the Linux kernel can implement memory allocation based on this information.
  • This memory management method and system can be compatible with the application and allocation of conventional DRAM memory, and can introduce new NVM memory application and allocation, so that NVM memory and DRAM memory can be managed simultaneously to meet the use of heterogeneous mixed memory.
  • the memory application request meets the permission requirement, and only if the memory application request meets the permission requirement, for example, only the root user can request to allocate the NVM memory, so that only the user with the highest authority can be stored in the In the non-volatile storage space, unnecessary waste of storage space is avoided, and security is also ensured.
  • a memory management method based on heterogeneous mixed memory includes:
  • Step S210 receiving a memory application request.
  • Step S220 detecting whether there is an NVM flag in the memory application request, if yes, proceeding to step S230, otherwise proceeding to step S260.
  • step S230 it is determined whether the requested memory length exceeds the total length of the NVM memory. If not, the process proceeds to step S240; if not, the process ends.
  • the memory application request includes the requested memory length. If the requested memory length exceeds the total length of the NVM memory, the NVM memory cannot satisfy the memory application request, and the application can be directly ended, and a flag indicating that the allocation fails is returned. .
  • Step S240 determining whether the memory application request meets the permission requirement, if yes, proceeding to step S250, otherwise ending.
  • Step S250 allocating NVM memory according to the memory application request.
  • Step S260 allocating DRAM memory according to the memory application request.
  • the requested memory length exceeds the maximum allowed by the total capacity of the NVM memory, it indicates that the NVM memory cannot meet its storage requirement and can be directly terminated. In this way, the efficiency of NVM memory allocation can be improved.
  • the memory request request includes the memory length of the application.
  • the steps of allocating NVM memory according to the request for application include:
  • Step S251 applying and initializing a virtual address space of the same size according to the requested memory length, where the virtual address space includes a first address and a tail address of the virtual address space.
  • Step S252 converting the first address of the virtual address space into a physical address.
  • Step S253 applying NVM memory of the same size in the NVM according to the physical address and the requested memory length.
  • heterogeneous mixed memory The application field of heterogeneous mixed memory is mainly for the application of big data and large memory computing in industrial control field. Its addressing space is large. In order to improve the reliability of big data access, heterogeneous mixed memory is often used in 64-bit processors. On the system. Therefore, memory management of heterogeneous mixed memory on a 64-bit Linux system is of great significance for the promotion of heterogeneous mixed memory.
  • the principle of the memory management method for the heterogeneous mixed memory provided by the embodiment of the present invention is described in detail below by taking a 64-bit Linux system as an example.
  • the virtual address space includes 128T user space and 128T kernel space, which is a huge gap between user space and kernel space.
  • 128T kernel space which is a huge gap between user space and kernel space.
  • a total of 128T virtual address range is user space, 0xFFFF, 8000, 0000, 0000 or more virtual address space a total of 128T for kernel space, and slave address 0x0000, 7FFF, FFFF, F000 to 0xFFFF, 8000, 0000, 0000 is a huge void, reserved for future expansion.
  • the 64T virtual address space from address 0xFFFF, 8800, 0000, 0000 to 0xFFFF, C7FF, FFFF, FFFF can be directly mapped to physical memory, that is, directly mapped to DRAM memory in heterogeneous mixed memory. This is consistent with the distribution of the traditional Linux kernel virtual address space.
  • the 32T address space between the addresses 0xFFFF, C900, 0000, 0000 to 0xFFFF, C8FF, FFFF, FFFF is an indirect mapped address space in the kernel space of Linux.
  • the so-called indirect mapping address space means that the physical memory is not directly mapped.
  • the address space of this part is used by the preset function, and the virtual address space is requested by a preset function. Since the virtual address space is not directly mapped to the physical memory, the applied virtual address space cannot obtain the physical address through a simple linear relationship, but needs to be converted into a physical address according to the mapping relationship, thereby allocating the memory according to the converted physical address. .
  • the default functions include vmalloc function, ioremap function and nvmmalloc function.
  • the vmalloc function and ioremap are functions related to DRAM memory. You can call vmalloc to allocate DRAM memory, and call ioremap to input I/O (input/output, input/output port) interface.
  • the DRAM memory is mapped to the virtual address space of the kernel.
  • the nvmmalloc function is newly added to allocate NVM memory.
  • the virtual address space allocated by these three functions is dynamic and random in the above 32T space, and there is no strict division. The three of them use the address together until the address is exhausted.
  • the memory application request includes the memory length of the application, for example, the size parameter is used to identify the memory length of the application, and is used as an input parameter of the nvmmalloc function to allocate NVM memory through the nvmmalloc function.
  • the nvmmalloc function When the nvmmalloc function is called, it is virtualized according to the input parameter size. The space of the same size is applied in the address space and initialized, and the value in the requested space is cleared by the initialization.
  • the nvmmalloc function returns the first address of the requested virtual address space.
  • the virtual address space applied by the nvmmalloc function is located in the indirect mapping address space in the kernel space of the above Linux system.
  • nvmmalloc function In addition, you can define other parameters of the nvmmalloc function. For example, the definition of flags indicates whether a virtual address space has been allocated. When a virtual address space has been allocated, it is marked to prevent duplicate allocation. It is also possible to define nvmflags to indicate that the allocated virtual address space is mapped to the NVM memory.
  • the controller in the heterogeneous mixed memory is triggered, and the controller converts the first address of the virtual address space into a physical address.
  • the Linux kernel sends the first address of the virtual address space to the controller through the interface circuit, where the mapping relationship between the virtual address and the physical address is stored, and the virtual address can be converted into a physical address, and according to the physical address and
  • the requested memory length is the same size NVM memory in the NVM.
  • the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area of the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
  • the NVM memory and the DRAM memory are uniformly addressed in advance, and all physical memory is paged by a fixed size, and all physical pages are divided into three types of memory management areas.
  • the range of the ZONE_DMA area is 0 to 16 M.
  • the physical page of this area is dedicated to DMA (Direct Memory Access) of the I/O device.
  • DMA Direct Memory Access
  • the reason why the physical page of the DMA needs to be managed separately is because the DMA directly accesses the memory using the physical address and needs a continuous buffer. Therefore, in order to provide a physically contiguous buffer, a region must be specifically allocated from the physical address space for DMA. .
  • the range of the ZONE_NORMAL area is 16M to 60T, the area of the area
  • the page is directly mapped to the virtual address space and is DRAM memory.
  • the space above 60T is the ZONE_HIGHMEM area, and the physical page and virtual address space of this area are indirectly mapped.
  • the NVM storage medium that can be used has a low access speed and is inefficient.
  • the NVM memory and the virtual address space are not directly mapped, but the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area. And connected to the ZONE_NORMAL area.
  • the size of the NVM memory affects the size of the ZONE_NORMAL area.
  • the total length of the ZONE_DMA area, the ZONE_NORMAL area, and the NVM memory is 64T.
  • the NVM memory is 4T
  • the tail address of the ZONE_NORMAL area is 60T.
  • the space from 60T to 64T is NVM memory indirectly mapped to the virtual address space.
  • the space from 64T to 256T is consistent with the traditional high-end memory, which can be allocated and used in the traditional way.
  • the NVM memory and the DRAM memory are uniformly and reasonably distributed in the 64-bit Linux system, and the corresponding physical address is efficiently found by the controller through the virtual address, and the NVM memory and the DRAM memory can be quickly allocated.
  • a memory management system based on heterogeneous mixed memory including:
  • the receiving module 310 is configured to receive a memory application request.
  • the detecting module 320 is configured to detect whether an NVM flag exists in the memory application request.
  • the first determining module 330 is configured to determine, if the NVM flag exists in the memory application request, whether the memory application request meets the permission requirement, and if yes, allocate the NVM memory according to the memory application request, and if not, not process.
  • the application module 340 is configured to request according to the memory request if the memory application request meets the permission requirement Allocating NVM memory; also used to allocate DRAM memory according to the memory request request if the NVM flag does not exist in the memory request request or does not meet the permission requirement.
  • the memory request request may include information such as the requested memory length, the type of memory management area requested, and the memory continuity requirement of the application.
  • a memory management system based on a heterogeneous mixed memory is provided.
  • the system shown in FIG. 7 further includes:
  • the second determining module 350 is configured to determine whether the requested memory length exceeds the total length of the NVM memory. If not, the first determining module 330 is notified whether the memory request request meets the permission requirement, and if not, the processing is not performed.
  • the memory application request includes the memory length of the application.
  • the application module 340 includes:
  • the virtual address space application unit 341 is configured to apply for and initialize the virtual address space of the same size according to the requested memory length, where the virtual address space includes a first address and a tail address of the virtual address space;
  • An address conversion unit 342 configured to convert a first address of the virtual address space into a physical address
  • the memory application unit 343 is configured to apply for the same size of NVM memory in the NVM according to the physical address and the requested memory length.
  • the virtual address space of the above system is located in an indirect mapped address space in the kernel space of Linux.
  • the physical address of the NVM memory of the above system is pre-allocated in the ZONE_HIGHMEN area of the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Dram (AREA)

Abstract

A memory management method based on a heterogeneous hybrid memory. The method comprises: receiving a memory application request (S110); detecting whether an NVM mark exists in the memory application request (S120); if the NVM mark exists in the memory application request, judging whether the memory application request meets the permission requirements (S130), if so, distributing an NVM according to the memory application request (S140), and if not, ending; and, if the NVM mark does not exist in the memory application request, distributing a DRAM according to the memory application request (S150). According to the method, by detecting whether an NVM mark exists in a memory application request, and judging whether the memory application request meets the permission requirements, whether the DRAM or the NVM is distributed is determined according to detection and judgment results, so that the NVM and the DRAM can be managed simultaneously. In addition, also provided is a memory management system based on a heterogeneous hybrid memory.

Description

基于异构混合内存的内存管理方法和系统Memory management method and system based on heterogeneous mixed memory 技术领域Technical field
本发明涉及计算机技术领域,特别是涉及一种基于异构混合内存的内存管理方法和系统。The present invention relates to the field of computer technologies, and in particular, to a memory management method and system based on heterogeneous mixed memory.
背景技术Background technique
随着电阻存储器、铁电存储器、相变存储器等为代表的新兴非易失性随机存储介质(Non-Volatile Memory,NVM)技术的发展,推进了存储技术的发展,为新型的内存与存储体系结构的产生打下了良好的基础。通过把新型的NVM和动态随机访问存储器(Dynamic Random Access Memory,DRAM)相结合,搭建混合内存架构,形成异构混合内存。异构混合内存同时具有NVM和DRAM的特点,不仅仅具备常规内存的功能,存储在DRAM中的数据在断电后会立即消失,是易失性的;同时还能发挥NVM在断电后还能保存数据的优势,充分发挥NVM非易失性的特点,是一种混合使用的新型内存。With the development of emerging non-volatile memory (Non-Volatile Memory, NVM) technology represented by resistor memory, ferroelectric memory, phase change memory, etc., the development of memory technology is advanced, and it is a new type of memory and storage system. The structure has laid a good foundation. By combining the new NVM with Dynamic Random Access Memory (DRAM), a hybrid memory architecture is built to form heterogeneous mixed memory. Heterogeneous hybrid memory has the characteristics of NVM and DRAM at the same time. It not only has the function of conventional memory, but the data stored in DRAM will disappear immediately after power off, which is volatile. At the same time, it can also play the NVM after power failure. The ability to save data and take full advantage of the non-volatile nature of NVM is a new type of memory that is used in combination.
异构混合内存采用兼容DDR3(Double Data Rate,双倍速率同步动态随机存储器,第三代)接口的内存模块设计,满足现有工业控制设备的常规内存接口,无需引进新的工业控制设备或添加新的辅助设备,成为了一个研究热点。Heterogeneous hybrid memory adopts DDR3 (Double Data Rate, double-rate synchronous dynamic random access memory, third generation) interface memory module design to meet the conventional memory interface of existing industrial control equipment, without introducing new industrial control equipment or adding New auxiliary equipment has become a research hotspot.
异构混合内存的应用领域主要是需要大数据和大内存计算的工业控制领域,Linux操作系统由于其源代码开放,功能强大又易于移植优化从而在工业控制领域被广泛采用。因此在Linux操作系统上实现异构混合内存的内存管理对异构混 合内存的推广有重大意义。The application field of heterogeneous mixed memory is mainly the industrial control field that requires big data and large memory computing. The Linux operating system is widely used in the industrial control field because of its open source code, powerful function and easy migration and optimization. Therefore, the memory management of heterogeneous mixed memory is implemented on the Linux operating system. The promotion of memory is of great significance.
异构混合内存作为一种新型内存,将NVM和DRAM集成于一体,常规的内存管理方法只是对DRAM内存的管理,无法满足对NVM内存的管理和操作,所以对异构混合内存而言将不再适用,因此有必要提供一种能适用于异构混合内存的内存管理方法,能同时管理NVM内存和DRAM内存。As a new type of memory, heterogeneous mixed memory integrates NVM and DRAM. The conventional memory management method is only the management of DRAM memory, which cannot satisfy the management and operation of NVM memory. Therefore, it will not be used for heterogeneous mixed memory. It is applicable, so it is necessary to provide a memory management method that can be applied to heterogeneous mixed memory, and can simultaneously manage NVM memory and DRAM memory.
发明内容Summary of the invention
基于此,有必要针对上述技术问题,提供一种基于异构混合内存的内存管理方法和系统,能同时管理NVM内存和DRAM内存。Based on this, it is necessary to provide a memory management method and system based on heterogeneous mixed memory for the above technical problems, and can simultaneously manage NVM memory and DRAM memory.
一种基于异构混合内存的内存管理方法,所述方法包括:A memory management method based on heterogeneous mixed memory, the method comprising:
接收内存申请请求;Receiving a memory application request;
检测内存申请请求中是否存在NVM标志;Detect whether there is an NVM flag in the memory request request;
如果所述内存申请请求中存在NVM标志,则判断所述内存申请请求是否符合权限要求,如果符合,则根据所述内存申请请求分配NVM内存,如果不符合则结束;If the NVM flag exists in the memory application request, determining whether the memory application request meets a permission requirement, and if yes, allocating NVM memory according to the memory application request, and if not, ending;
如果所述内存申请请求中不存在NVM标志,则根据所述内存申请请求分配DRAM内存。If the NVM flag does not exist in the memory request request, the DRAM memory is allocated according to the memory request.
在其中一个实施例中,所述内存申请请求中包含申请的内存长度;在所述判断所述内存申请请求是否符合权限要求的步骤之前,还包括:In one embodiment, the memory request request includes a memory length of the application; before the step of determining whether the memory application request meets the permission requirement, the method further includes:
判断所述申请的内存长度是否超过NVM内存的总长度,如果没有超过,则进入所述判断所述内存申请请求是否符合权限要求的步骤;如果超过,则结束。Determining whether the memory length of the application exceeds the total length of the NVM memory, and if not, entering the step of determining whether the memory application request meets the permission requirement; if yes, ending.
在其中一个实施例中,所述内存申请请求中包含申请的内存长度;所述根 据所述申请请求分配NVM内存的步骤包括:In one embodiment, the memory request request includes a memory length of the application; the root The steps for allocating NVM memory according to the request for the application include:
根据所述申请的内存长度申请相同大小的虚拟地址空间并进行初始化,所述虚拟地址空间包含虚拟地址空间的首地址和尾地址;Applying and initializing a virtual address space of the same size according to the memory length of the application, where the virtual address space includes a first address and a tail address of the virtual address space;
将所述虚拟地址空间的首地址转换为物理地址,根据所述物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。Converting the first address of the virtual address space into a physical address, and applying NVM memory of the same size in the NVM according to the physical address and the requested memory length.
在其中一个实施例中,所述虚拟地址空间位于Linux的内核空间中的间接映射地址空间中。In one of these embodiments, the virtual address space is located in an indirect mapped address space in the kernel space of Linux.
在其中一个实施例中,所述NVM内存的物理地址预先分配在Linux内核内存管理区中的ZONE_HIGHMEN区中,与Linux内核内存管理区中的ZONE_NORMAL区相连。In one of the embodiments, the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area in the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
一种基于异构混合内存的内存管理系统,所述系统包括:A memory management system based on heterogeneous mixed memory, the system comprising:
接收模块,用于接收内存申请请求;a receiving module, configured to receive a memory application request;
检测模块,用于检测所述内存申请请求中是否存在NVM标志;a detecting module, configured to detect whether an NVM flag exists in the memory application request;
第一判断模块,用于如果所述内存申请请求中存在NVM标志,则判断所述内存申请请求是否符合权限要求,如果符合,则根据所述内存申请请求分配NVM内存,如果不符合则不作处理;a first determining module, configured to determine, if the NVM flag exists in the memory application request, whether the memory application request meets a permission requirement, and if yes, allocate NVM memory according to the memory application request, and if not, not process ;
申请模块,用于如果所述内存申请请求符合权限要求,则根据所述内存申请请求分配NVM内存;An application module, configured to allocate NVM memory according to the memory application request if the memory application request meets a permission requirement;
所述申请模块还用于如果所述内存申请请求中不存在NVM标志或不符合权限要求,则根据所述内存申请请求分配DRAM内存。The application module is further configured to allocate DRAM memory according to the memory application request if the NVM flag does not exist in the memory application request or does not meet the permission requirement.
在其中一个实施例中,所述内存申请请求中包含申请的内存长度,所述系统还包括: In one embodiment, the memory request request includes a memory length of the application, and the system further includes:
第二判断模块,用于判断所述申请的内存长度是否超过NVM内存的总长度,如果没有超过,则通知所述第一判断模块判断所述内存申请请求是否符合权限要求,如果超过,则不作处理。The second judging module is configured to determine whether the memory length of the application exceeds the total length of the NVM memory, and if not, notify the first judging module whether the memory application request meets the permission requirement, and if not, not deal with.
在其中一个实施例中,所述内存申请请求中包含申请的内存长度,所述申请模块包括:In one embodiment, the memory request request includes a memory length of the application, and the application module includes:
虚拟地址空间申请单元,用于根据所述申请的内存长度申请相同大小的虚拟地址空间并进行初始化,所述虚拟地址空间包含虚拟地址空间的首地址和尾地址;a virtual address space application unit, configured to apply and initialize a virtual address space of the same size according to a memory length of the application, where the virtual address space includes a first address and a tail address of the virtual address space;
地址转换单元,用于将所述虚拟地址空间的首地址转换为物理地址;An address conversion unit, configured to convert a first address of the virtual address space into a physical address;
内存申请单元,用于根据所述物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。The memory application unit is configured to apply for the same size of the NVM memory in the NVM according to the physical address and the requested memory length.
在其中一个实施例中,所述虚拟地址空间位于Linux的内核空间中的间接映射地址空间中。In one of these embodiments, the virtual address space is located in an indirect mapped address space in the kernel space of Linux.
在其中一个实施例中,所述NVM内存的物理地址预先分配在Linux内核内存管理区中的ZONE_HIGHMEN区中,与Linux内核内存管理区中的ZONE_NORMAL区相连。In one of the embodiments, the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area in the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
上述基于异构混合内存的内存管理方法和系统,通过检测内存申请请求中是否存在NVM标志,并在内存申请请求中存在NVM标志时进一步对内存申请请求是否符合权限要求进行判断,并根据检测和判断的结果选择分配DRAM内存或NVM内存。这种内存管理方法和系统能兼容常规DRAM内存的申请和分配,同时能够引入新型的NVM内存的申请和分配,从而能同时管理NVM内存和DRAM内存,满足异构混合内存的使用。 The above heterogeneous mixed memory based memory management method and system, by detecting whether there is an NVM flag in the memory application request, and further determining whether the memory application request meets the permission requirement when the NVM flag exists in the memory application request, and according to the detection and The result of the judgment is to allocate DRAM memory or NVM memory. This memory management method and system can be compatible with the application and allocation of conventional DRAM memory, and can introduce new NVM memory application and allocation, so that NVM memory and DRAM memory can be managed simultaneously to meet the use of heterogeneous mixed memory.
附图说明DRAWINGS
图1为一个实施例中异构混合内存的接口图;1 is an interface diagram of a heterogeneous mixed memory in one embodiment;
图2为一个实施例中基于异构混合内存的内存管理方法的流程图;2 is a flow chart of a memory management method based on heterogeneous mixed memory in one embodiment;
图3为另一个实施例中基于异构混合内存的内存管理方法的流程图;3 is a flow chart of a memory management method based on heterogeneous mixed memory in another embodiment;
图4为一个实施例中根据申请请求分配NVM内存的流程图;4 is a flow chart of allocating NVM memory according to an application request in an embodiment;
图5为一个实施例中64位Linux系统中虚拟地址空间的分布图;5 is a distribution diagram of a virtual address space in a 64-bit Linux system in an embodiment;
图6为一个实施例中异构混合内存的物理地址空间分布图;6 is a physical address space distribution diagram of a heterogeneous mixed memory in an embodiment;
图7为一个实施例中基于异构混合内存的内存管理系统的结构框图;7 is a structural block diagram of a memory management system based on heterogeneous mixed memory in one embodiment;
图8为另一个实施例中基于异构混合内存的内存管理系统的结构框图;8 is a structural block diagram of a memory management system based on heterogeneous mixed memory in another embodiment;
图9为一个实施例中申请模块的结构框图。Figure 9 is a block diagram showing the structure of an application module in one embodiment.
具体实施方式detailed description
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
异构混合内存采用与DDR3(Double Data Rate,双倍速率同步动态随机存储器,第三代)接口电路一致的物理连接方式。如图1所示,为异构混合内存的接口图。该内存模块通过JEDEC(Joint Electron Device Engineering Council,联合电子设备工程委员会)标准接口连接器插入到常用的DDR3接口电路上使用,操作系统向异构混合内存传递的地址(Address,Addr)、命令(Command,Cmd)和数据(Data)等信息可以通过接口电路输入到控制器(Controller),Controller通过所接收到的数据及内部逻辑来控制DRAM内存和NVM内存。其中 Controller可以采用MCU(Micro Control Unit,微控制单元)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、CPLD(Complex Programmable Logic Device,复杂可编程逻辑器件)或ARM(Advanced RISC Machine,高级精简指令集机器)等处理器来实现,依据DRAM和NVM的各自特性提供相应的读写控制和时序操作。本发明就是在如上所述的接口环境下实现的基于异构混合内存的内存管理方法和系统。The heterogeneous hybrid memory adopts a physical connection method consistent with the DDR3 (Double Data Rate, double-rate synchronous dynamic random access memory, third generation) interface circuit. As shown in Figure 1, it is an interface diagram of heterogeneous mixed memory. The memory module is inserted into the commonly used DDR3 interface circuit through the JEDEC (Joint Electron Device Engineering Council) standard interface connector, and the address (Address, Addr) and command transmitted by the operating system to the heterogeneous mixed memory ( Information such as Command, Cmd, and Data can be input to the controller through the interface circuit. The Controller controls the DRAM memory and the NVM memory through the received data and internal logic. among them The controller can be an MCU (Micro Control Unit), an FPGA (Field-Programmable Gate Array), a CPLD (Complex Programmable Logic Device), or an ARM (Advanced RISC Machine, Advanced). The reduced instruction set machine) is implemented by a processor, and provides corresponding read and write control and timing operations according to the respective characteristics of the DRAM and the NVM. The present invention is a memory management method and system based on heterogeneous mixed memory implemented in an interface environment as described above.
在一个实施例中,如图2所示,提供了一种基于异构混合内存的内存管理方法,该方法包括:In an embodiment, as shown in FIG. 2, a memory management method based on heterogeneous mixed memory is provided, and the method includes:
步骤S110,接收内存申请请求。Step S110, receiving a memory application request.
本实施例中,操作系统驱动、库函数及应用程序都可能会需要申请内存,在申请内存时会向操作系统内核发送内存申请请求,操作系统内核会根据接收到的内存申请请求来分配内存。In this embodiment, the operating system driver, the library function, and the application program may need to apply for memory. When the memory is applied, the memory application request is sent to the operating system kernel, and the operating system kernel allocates the memory according to the received memory application request.
步骤S120,检测内存申请请求中是否存在NVM标志,若存在则进入步骤S130,否则进入步骤S150。Step S120, detecting whether there is an NVM flag in the memory application request, if yes, proceeding to step S130, otherwise proceeding to step S150.
本实施例中,在内存申请请求中可能有NVM标志位,比如保存在内存申请请求的最后一位。如果检测出内存申请请求中存在NVM标志位,则表明需要申请NVM内存。如果没有,则表明需要申请DRAM内存。In this embodiment, there may be an NVM flag in the memory request, such as the last bit stored in the memory request. If it is detected that there is an NVM flag in the memory request request, it indicates that NVM memory needs to be applied. If not, it indicates that you need to apply for DRAM memory.
步骤S130,判断内存申请请求是否符合权限要求,若符合则进入步骤S140,否则结束。Step S130, determining whether the memory application request meets the permission requirement, if yes, proceeding to step S140, otherwise ending.
用户权限是Linux安全性的一个方面,不同用户所具有的权限也不同。其中根用户可以操作系统中的任何文件和命令,拥有最高权限。可以根据需要规定哪些用户有权限分配NVM内存。本实施例中,异构混合内存中的NVM内存的 申请只允许根用户才能操作,其他用户没有申请NVM内存的权限。如果内存申请请求是根用户发送的,则判断为符合权限要求,否则不符合权限要求。User permissions are an aspect of Linux security, and different users have different permissions. The root user can have any files and commands in the operating system and has the highest authority. You can specify which users have permission to allocate NVM memory as needed. In this embodiment, the NVM memory in the heterogeneous mixed memory The application only allows the root user to operate, and other users do not have permission to apply for NVM memory. If the memory application request is sent by the root user, it is determined to meet the permission requirement, otherwise the permission requirement is not met.
步骤S140,根据内存申请请求分配NVM内存。Step S140, allocating NVM memory according to the memory application request.
本实施例中,可预先将NVM内存和DRAM内存进行统一编址,并以物理页面为单位进行分页,比如每个物理页面的大小默认为4KB。并将NVM内存和DRAM内存划分到不同的Linux内核内存管理区中,Linux内核内存管理区分为ZONE_DMA、ZONE_NORMAL和ZONE_HIGHMEM,NVM内存可以划分到任一个内存管理区中。申请请求中可包含一些信息,比如申请的内存长度、申请的内存管理区类型、申请的内存连续性要求等。其中,申请的内存长度用来确定需要分配的内存大小,申请的内存管理区类型用来确定在以上哪个内存管理区中分配NVM内存,申请的内存连续性要求用来确定是否分配连续的内存。Linux内核可根据这些信息实现内存分配。In this embodiment, the NVM memory and the DRAM memory can be uniformly addressed in advance, and paging is performed in units of physical pages. For example, the size of each physical page defaults to 4 KB. The NVM memory and DRAM memory are divided into different Linux kernel memory management areas. The Linux kernel memory management is divided into ZONE_DMA, ZONE_NORMAL and ZONE_HIGHMEM, and the NVM memory can be divided into any memory management area. The request may include information such as the length of the application's memory, the type of memory management area requested, and the memory continuity requirements of the application. The memory length of the application is used to determine the size of the memory to be allocated. The type of the memory management area to be used is used to determine which of the above memory management areas is allocated NVM memory, and the requested memory continuity requirement is used to determine whether to allocate contiguous memory. The Linux kernel can implement memory allocation based on this information.
步骤S150,根据内存申请请求分配DRAM内存。Step S150, allocating DRAM memory according to the memory application request.
如上所述,预先将NVM内存和DRAM内存进行统一编址,并以物理页面为单位进行分页,比如每个物理页面的大小默认为4KB。并将NVM内存和DRAM内存划分到不同的Linux内核内存管理区中,Linux内核内存管理区分为ZONE_DMA、ZONE_NORMAL和ZONE_HIGHMEM,DRAM内存可以划分到任一个内存管理区中。申请请求中可包含一些信息,比如申请的内存长度、申请的内存管理区类型、申请的内存连续性要求等。其中,申请的内存长度用来确定需要分配的内存大小,申请的内存管理区类型用来确定在以上哪个内存管理区中分配DRAM内存,申请的内存连续性要求用来确定是否分配连续的内存。Linux内核可根据这些信息实现内存分配。 As described above, the NVM memory and the DRAM memory are collectively addressed in advance, and paging is performed in units of physical pages. For example, the size of each physical page defaults to 4 KB. The NVM memory and DRAM memory are divided into different Linux kernel memory management areas. The Linux kernel memory management is divided into ZONE_DMA, ZONE_NORMAL and ZONE_HIGHMEM, and the DRAM memory can be divided into any memory management area. The request may include information such as the length of the application's memory, the type of memory management area requested, and the memory continuity requirements of the application. The memory length of the application is used to determine the size of the memory to be allocated. The type of memory management area used is used to determine which of the above memory management areas is allocated DRAM memory. The requested memory continuity requirement is used to determine whether to allocate contiguous memory. The Linux kernel can implement memory allocation based on this information.
本实施例中,通过检测内存申请请求中是否存在NVM标志,并在内存申请请求中存在NVM标志时进一步对内存申请请求是否符合权限要求进行判断,并根据检测和判断的结果选择分配DRAM内存或NVM内存。这种内存管理方法和系统能兼容常规DRAM内存的申请和分配,同时能够引入新型的NVM内存的申请和分配,从而能同时管理NVM内存和DRAM内存,满足异构混合内存的使用。In this embodiment, by detecting whether the NVM flag exists in the memory application request, and when the NVM flag exists in the memory application request, further determining whether the memory application request meets the permission requirement, and selecting to allocate the DRAM memory according to the result of the detection and the judgment NVM memory. This memory management method and system can be compatible with the application and allocation of conventional DRAM memory, and can introduce new NVM memory application and allocation, so that NVM memory and DRAM memory can be managed simultaneously to meet the use of heterogeneous mixed memory.
另外,在分配NVM内存之前,判断内存申请请求是否符合权限要求,只有在内存申请请求符合权限要求的情况下,例如保证只有根用户才能请求分配NVM内存,确保了只有最高权限的用户才能存储在非易失性存储空间中,避免了不必要的存储空间的浪费,也能保证安全性。In addition, before the NVM memory is allocated, it is determined whether the memory application request meets the permission requirement, and only if the memory application request meets the permission requirement, for example, only the root user can request to allocate the NVM memory, so that only the user with the highest authority can be stored in the In the non-volatile storage space, unnecessary waste of storage space is avoided, and security is also ensured.
在另一个实施例中,如图3所示,提供了一种基于异构混合内存的内存管理方法,该方法包括:In another embodiment, as shown in FIG. 3, a memory management method based on heterogeneous mixed memory is provided, and the method includes:
步骤S210,接收内存申请请求。Step S210, receiving a memory application request.
步骤S220,检测内存申请请求中是否存在NVM标志,若存在则进入步骤S230,否则进入步骤S260。Step S220, detecting whether there is an NVM flag in the memory application request, if yes, proceeding to step S230, otherwise proceeding to step S260.
步骤S230,判断申请的内存长度是否超过NVM内存的总长度,如果没有超过,则进入步骤S240;如果超过,则结束。In step S230, it is determined whether the requested memory length exceeds the total length of the NVM memory. If not, the process proceeds to step S240; if not, the process ends.
本实施例中,内存申请请求中包含申请的内存长度,如果申请的内存长度超过NVM内存的总长度,则NVM内存无法满足内存申请请求,则可以直接结束此次申请,返回一个分配失败的标志。In this embodiment, the memory application request includes the requested memory length. If the requested memory length exceeds the total length of the NVM memory, the NVM memory cannot satisfy the memory application request, and the application can be directly ended, and a flag indicating that the allocation fails is returned. .
步骤S240,判断内存申请请求是否符合权限要求,若符合则进入步骤S250,否则结束。 Step S240, determining whether the memory application request meets the permission requirement, if yes, proceeding to step S250, otherwise ending.
步骤S250,根据内存申请请求分配NVM内存。Step S250, allocating NVM memory according to the memory application request.
步骤S260,根据内存申请请求分配DRAM内存。Step S260, allocating DRAM memory according to the memory application request.
本实施例中,在申请的内存长度超过NVM内存的总容量所允许的最大值时,表明NVM内存无法满足其存储要求,可直接结束。这样,可以提高NVM内存分配的效率。In this embodiment, when the requested memory length exceeds the maximum allowed by the total capacity of the NVM memory, it indicates that the NVM memory cannot meet its storage requirement and can be directly terminated. In this way, the efficiency of NVM memory allocation can be improved.
在一个实施例中,内存申请请求中包含申请的内存长度。如图4所示,根据申请请求分配NVM内存的步骤包括:In one embodiment, the memory request request includes the memory length of the application. As shown in FIG. 4, the steps of allocating NVM memory according to the request for application include:
步骤S251,根据申请的内存长度申请相同大小的虚拟地址空间并进行初始化,所述虚拟地址空间包含虚拟地址空间的首地址和尾地址。Step S251, applying and initializing a virtual address space of the same size according to the requested memory length, where the virtual address space includes a first address and a tail address of the virtual address space.
步骤S252,将虚拟地址空间的首地址转换为物理地址。Step S252, converting the first address of the virtual address space into a physical address.
步骤S253,根据物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。Step S253, applying NVM memory of the same size in the NVM according to the physical address and the requested memory length.
异构混合内存的应用领域主要针对工业控制领域大数据和大内存计算方面的应用,其寻址空间较大,为了提高大数据访问的可靠性,异构混合内存往往使用在64位处理器的系统上。因此在64位的Linux系统上实现异构混合内存的内存管理对异构混合内存的推广有重大意义。以下以64位的Linux系统为例来详细说明本发明实施例所提供的异构混合内存的内存管理方法的原理。The application field of heterogeneous mixed memory is mainly for the application of big data and large memory computing in industrial control field. Its addressing space is large. In order to improve the reliability of big data access, heterogeneous mixed memory is often used in 64-bit processors. On the system. Therefore, memory management of heterogeneous mixed memory on a 64-bit Linux system is of great significance for the promotion of heterogeneous mixed memory. The principle of the memory management method for the heterogeneous mixed memory provided by the embodiment of the present invention is described in detail below by taking a 64-bit Linux system as an example.
如图5所示,为64位的Linux虚拟地址空间的分布图。64位Linux系统中,虚拟地址空间包括128T用户空间和128T内核空间,在用户空间和内核空间之间是一个巨大的空洞。其中,从0x0000,0000,0000,0000到0x0000,7FFFF,FFFF,F000共128T的虚拟地址区间为用户空间,0xFFFF,8000,0000,0000以上的虚拟地址空间共128T为内核空间,而从地址 0x0000,7FFF,FFFF,F000到0xFFFF,8000,0000,0000之间是一个巨大的空洞,是为以后的扩展预留的。As shown in Figure 5, it is a distribution map of 64-bit Linux virtual address space. In 64-bit Linux systems, the virtual address space includes 128T user space and 128T kernel space, which is a huge gap between user space and kernel space. Among them, from 0x0000, 0000, 0000, 0000 to 0x0000, 7FFFF, FFFF, F000, a total of 128T virtual address range is user space, 0xFFFF, 8000, 0000, 0000 or more virtual address space a total of 128T for kernel space, and slave address 0x0000, 7FFF, FFFF, F000 to 0xFFFF, 8000, 0000, 0000 is a huge void, reserved for future expansion.
在内核空间中,从地址0xFFFF,8800,0000,0000到0xFFFF,C7FF,FFFF,FFFF共64T的虚拟地址空间可以直接和物理内存进行映射,也就是和异构混合内存中的DRAM内存进行直接映射,这与传统的Linux内核虚拟地址空间的分布一致。In the kernel space, the 64T virtual address space from address 0xFFFF, 8800, 0000, 0000 to 0xFFFF, C7FF, FFFF, FFFF can be directly mapped to physical memory, that is, directly mapped to DRAM memory in heterogeneous mixed memory. This is consistent with the distribution of the traditional Linux kernel virtual address space.
进一步的,在内核空间中,从地址0xFFFF,C900,0000,0000到0xFFFF,C8FF,FFFF,FFFF之间的32T地址空间是Linux的内核空间中的间接映射地址空间。所谓间接映射地址空间,是指不直接与物理内存进行映射,这个部分的地址空间给预设函数使用,通过预设函数来申请虚拟地址空间。由于这部分虚拟地址空间不与物理内存直接映射,因此申请到的虚拟地址空间不能通过简单的线性关系得到物理地址,而需按照映射关系转换为物理地址,从而根据转换得到的物理地址来分配内存。Further, in the kernel space, the 32T address space between the addresses 0xFFFF, C900, 0000, 0000 to 0xFFFF, C8FF, FFFF, FFFF is an indirect mapped address space in the kernel space of Linux. The so-called indirect mapping address space means that the physical memory is not directly mapped. The address space of this part is used by the preset function, and the virtual address space is requested by a preset function. Since the virtual address space is not directly mapped to the physical memory, the applied virtual address space cannot obtain the physical address through a simple linear relationship, but needs to be converted into a physical address according to the mapping relationship, thereby allocating the memory according to the converted physical address. .
预设函数包括vmalloc函数、ioremap函数和nvmmalloc函数,其中vmalloc函数和ioremap是与DRAM内存相关的函数,可以调用vmalloc来分配DRAM内存,调用ioremap把I/O(input/output,输入输出端口)接口的DRAM内存映射到内核的虚拟地址空间。而nvmmalloc函数是新增加的用来分配NVM内存的。这三个函数分配的虚拟地址空间在上述32T的空间中动态随意,没有严格的划分,它们三个共同使用这块地址,直到这块地址用尽为止。The default functions include vmalloc function, ioremap function and nvmmalloc function. The vmalloc function and ioremap are functions related to DRAM memory. You can call vmalloc to allocate DRAM memory, and call ioremap to input I/O (input/output, input/output port) interface. The DRAM memory is mapped to the virtual address space of the kernel. The nvmmalloc function is newly added to allocate NVM memory. The virtual address space allocated by these three functions is dynamic and random in the above 32T space, and there is no strict division. The three of them use the address together until the address is exhausted.
本实施例中,内存申请请求中包含申请的内存长度,例如size参数用来标识申请的内存长度,其作为nvmmalloc函数的输入参数,通过nvmmalloc函数来分配NVM内存。当nvmmalloc函数被调用时,则根据输入参数size在虚拟地 址空间中申请相同大小的空间并进行初始化,初始化即对申请的空间中的值进行清0。nvmmalloc函数返回的是申请的虚拟地址空间的首地址。具体的,nvmmalloc函数申请的虚拟地址空间位于上述Linux系统的内核空间中的间接映射地址空间中。In this embodiment, the memory application request includes the memory length of the application, for example, the size parameter is used to identify the memory length of the application, and is used as an input parameter of the nvmmalloc function to allocate NVM memory through the nvmmalloc function. When the nvmmalloc function is called, it is virtualized according to the input parameter size. The space of the same size is applied in the address space and initialized, and the value in the requested space is cleared by the initialization. The nvmmalloc function returns the first address of the requested virtual address space. Specifically, the virtual address space applied by the nvmmalloc function is located in the indirect mapping address space in the kernel space of the above Linux system.
另外,还可以定义nvmmalloc函数的其他参数,如定义flags表示某块虚拟地址空间是否已被分配,当某块虚拟地址空间已被分配时对它进行标记,防止重复分配。还可定义nvmflags表示分配的虚拟地址空间是与NVM内存映射的。In addition, you can define other parameters of the nvmmalloc function. For example, the definition of flags indicates whether a virtual address space has been allocated. When a virtual address space has been allocated, it is marked to prevent duplicate allocation. It is also possible to define nvmflags to indicate that the allocated virtual address space is mapped to the NVM memory.
同时,nvmmalloc函数被调用时会触发异构混合内存中的控制器,控制器将虚拟地址空间的首地址转换为物理地址。具体的,Linux内核通过接口电路将虚拟地址空间的首地址发送给控制器,控制器中存有虚拟地址和物理地址的映射关系,可以将虚拟地址转换为物理地址,并根据所述物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。At the same time, when the nvmmalloc function is called, the controller in the heterogeneous mixed memory is triggered, and the controller converts the first address of the virtual address space into a physical address. Specifically, the Linux kernel sends the first address of the virtual address space to the controller through the interface circuit, where the mapping relationship between the virtual address and the physical address is stored, and the virtual address can be converted into a physical address, and according to the physical address and The requested memory length is the same size NVM memory in the NVM.
在一个实施例中,NVM内存的物理地址预先分配在Linux内核内存管理区中的ZONE_HIGHMEN区中,与Linux内核内存管理区中的ZONE_NORMAL区相连。In one embodiment, the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area of the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
具体的,如图6所示,预先将NVM内存和DRAM内存进行统一编址,并将所有物理内存按固定大小进行分页,并将所有的物理页面划分到3类内存管理区中。ZONE_DMA区的范围是0~16M,该区域的物理页面专门供I/O设备的DMA(Direct Memory Access,存储器直接访问)使用。之所以需要单独管理DMA的物理页面,是因为DMA直接使用物理地址访问内存,并且需要连续的缓冲区,所以为了能够提供物理上连续的缓冲区,必须从物理地址空间专门划分一段区域用于DMA。ZONE_NORMAL区的范围是16M到60T,该区域的物 理页面是与虚拟地址空间直接映射的,是DRAM内存。60T以上的空间是ZONE_HIGHMEM区,该区域的物理页面与虚拟地址空间是间接映射的。由于现有水平下,能使用的NVM存储介质访问速度低,效率不高,本实施例中没有将NVM内存和虚拟地址空间直接映射,而是将NVM内存的物理地址预先分配在ZONE_HIGHMEN区中,并与ZONE_NORMAL区相连。另外,NVM内存的大小会影响ZONE_NORMAL区的大小,其中ZONE_DMA区、ZONE_NORMAL区和NVM内存的总长度的总和为64T,比如本实施例中NVM内存为4T,那么ZONE_NORMAL区的尾地址就是60T。从60T到64T的空间是与虚拟地址空间间接映射的NVM内存,从64T到256T的空间与传统的高端内存一致,可使用传统的方法分配与使用这段内存。Specifically, as shown in FIG. 6, the NVM memory and the DRAM memory are uniformly addressed in advance, and all physical memory is paged by a fixed size, and all physical pages are divided into three types of memory management areas. The range of the ZONE_DMA area is 0 to 16 M. The physical page of this area is dedicated to DMA (Direct Memory Access) of the I/O device. The reason why the physical page of the DMA needs to be managed separately is because the DMA directly accesses the memory using the physical address and needs a continuous buffer. Therefore, in order to provide a physically contiguous buffer, a region must be specifically allocated from the physical address space for DMA. . The range of the ZONE_NORMAL area is 16M to 60T, the area of the area The page is directly mapped to the virtual address space and is DRAM memory. The space above 60T is the ZONE_HIGHMEM area, and the physical page and virtual address space of this area are indirectly mapped. The NVM storage medium that can be used has a low access speed and is inefficient. In this embodiment, the NVM memory and the virtual address space are not directly mapped, but the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area. And connected to the ZONE_NORMAL area. In addition, the size of the NVM memory affects the size of the ZONE_NORMAL area. The total length of the ZONE_DMA area, the ZONE_NORMAL area, and the NVM memory is 64T. For example, in this embodiment, the NVM memory is 4T, and the tail address of the ZONE_NORMAL area is 60T. The space from 60T to 64T is NVM memory indirectly mapped to the virtual address space. The space from 64T to 256T is consistent with the traditional high-end memory, which can be allocated and used in the traditional way.
本实施例中,在64位的Linux系统中将NVM内存与DRAM内存进行统一合理的分布,并通过控制器高效的由虚拟地址找到对应的物理地址,可快速的分配NVM内存和DRAM内存。In this embodiment, the NVM memory and the DRAM memory are uniformly and reasonably distributed in the 64-bit Linux system, and the corresponding physical address is efficiently found by the controller through the virtual address, and the NVM memory and the DRAM memory can be quickly allocated.
如图7所示,在一个实施例中,提供了一种基于异构混合内存的内存管理系统,包括:As shown in FIG. 7, in one embodiment, a memory management system based on heterogeneous mixed memory is provided, including:
接收模块310,用于接收内存申请请求。The receiving module 310 is configured to receive a memory application request.
检测模块320,用于检测内存申请请求中是否存在NVM标志。The detecting module 320 is configured to detect whether an NVM flag exists in the memory application request.
第一判断模块330,用于如果内存申请请求中存在NVM标志,则判断内存申请请求是否符合权限要求,如果符合,则根据内存申请请求分配NVM内存,如果不符合则不作处理。The first determining module 330 is configured to determine, if the NVM flag exists in the memory application request, whether the memory application request meets the permission requirement, and if yes, allocate the NVM memory according to the memory application request, and if not, not process.
申请模块340,用于如果内存申请请求符合权限要求,则根据内存申请请求 分配NVM内存;还用于如果内存申请请求中不存在NVM标志或不符合权限要求,则根据内存申请请求分配DRAM内存。The application module 340 is configured to request according to the memory request if the memory application request meets the permission requirement Allocating NVM memory; also used to allocate DRAM memory according to the memory request request if the NVM flag does not exist in the memory request request or does not meet the permission requirement.
内存申请请求可包含申请的内存长度、申请的内存管理区类型、申请的内存连续性要求等信息。The memory request request may include information such as the requested memory length, the type of memory management area requested, and the memory continuity requirement of the application.
如图8所示,在另一个实施例中,提供了一种基于异构混合内存的内存管理系统,在图7所示实施例的基础上还包括:As shown in FIG. 8, in another embodiment, a memory management system based on a heterogeneous mixed memory is provided. The system shown in FIG. 7 further includes:
第二判断模块350,用于判断申请的内存长度是否超过NVM内存的总长度,如果没有超过,则通知第一判断模块330判断内存申请请求是否符合权限要求,如果超过,则不作处理。The second determining module 350 is configured to determine whether the requested memory length exceeds the total length of the NVM memory. If not, the first determining module 330 is notified whether the memory request request meets the permission requirement, and if not, the processing is not performed.
在一个实施例中,内存申请请求中包含申请的内存长度,如图9所示,上述申请模块340包括:In one embodiment, the memory application request includes the memory length of the application. As shown in FIG. 9, the application module 340 includes:
虚拟地址空间申请单元341,用于根据申请的内存长度申请相同大小的虚拟地址空间并进行初始化,所述虚拟地址空间包含虚拟地址空间的首地址和尾地址;The virtual address space application unit 341 is configured to apply for and initialize the virtual address space of the same size according to the requested memory length, where the virtual address space includes a first address and a tail address of the virtual address space;
地址转换单元342,用于将虚拟地址空间的首地址转换为物理地址;An address conversion unit 342, configured to convert a first address of the virtual address space into a physical address;
内存申请单元343,用于根据物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。The memory application unit 343 is configured to apply for the same size of NVM memory in the NVM according to the physical address and the requested memory length.
在一个实施例中,上述系统的虚拟地址空间位于Linux的内核空间中的间接映射地址空间中。In one embodiment, the virtual address space of the above system is located in an indirect mapped address space in the kernel space of Linux.
在一个实施例中,上述系统的NVM内存的物理地址预先分配在Linux内核内存管理区中的ZONE_HIGHMEN区中,与Linux内核内存管理区中的ZONE_NORMAL区相连。 In one embodiment, the physical address of the NVM memory of the above system is pre-allocated in the ZONE_HIGHMEN area of the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。 The above-mentioned embodiments are merely illustrative of several embodiments of the present invention, and the description thereof is more specific and detailed, but is not to be construed as limiting the scope of the invention. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the invention. Therefore, the scope of the invention should be determined by the appended claims.

Claims (10)

  1. 一种基于异构混合内存的内存管理方法,所述方法包括:A memory management method based on heterogeneous mixed memory, the method comprising:
    接收内存申请请求;Receiving a memory application request;
    检测内存申请请求中是否存在NVM标志;Detect whether there is an NVM flag in the memory request request;
    如果所述内存申请请求中存在NVM标志,则判断所述内存申请请求是否符合权限要求,如果符合,则根据所述内存申请请求分配NVM内存,如果不符合则结束;If the NVM flag exists in the memory application request, determining whether the memory application request meets a permission requirement, and if yes, allocating NVM memory according to the memory application request, and if not, ending;
    如果所述内存申请请求中不存在NVM标志,则根据所述内存申请请求分配DRAM内存。If the NVM flag does not exist in the memory request request, the DRAM memory is allocated according to the memory request.
  2. 根据权利要求1所述的方法,其特征在于,所述内存申请请求中包含申请的内存长度;在所述判断所述内存申请请求是否符合权限要求的步骤之前,还包括:The method according to claim 1, wherein the memory request request includes a memory length of the application; and before the step of determining whether the memory application request meets the permission requirement, the method further includes:
    判断所述申请的内存长度是否超过NVM内存的总长度,如果没有超过,则进入所述判断所述内存申请请求是否符合权限要求的步骤;如果超过,则结束。Determining whether the memory length of the application exceeds the total length of the NVM memory, and if not, entering the step of determining whether the memory application request meets the permission requirement; if yes, ending.
  3. 根据权利要求1所述的方法,其特征在于,所述内存申请请求中包含申请的内存长度;所述根据所述申请请求分配NVM内存的步骤包括:The method according to claim 1, wherein the memory request request includes a memory length of the application; and the step of allocating NVM memory according to the application request comprises:
    根据所述申请的内存长度申请相同大小的虚拟地址空间并进行初始化,所述虚拟地址空间包含虚拟地址空间的首地址和尾地址;Applying and initializing a virtual address space of the same size according to the memory length of the application, where the virtual address space includes a first address and a tail address of the virtual address space;
    将所述虚拟地址空间的首地址转换为物理地址,根据所述物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。Converting the first address of the virtual address space into a physical address, and applying NVM memory of the same size in the NVM according to the physical address and the requested memory length.
  4. 根据权利要求3所述的方法,其特征在于,所述虚拟地址空间位于Linux的内核空间中的间接映射地址空间中。 The method of claim 3 wherein the virtual address space is located in an indirect mapped address space in a kernel space of Linux.
  5. 根据权利要求1所述的方法,其特征在于,所述NVM内存的物理地址预先分配在Linux内核内存管理区中的ZONE_HIGHMEN区中,与Linux内核内存管理区中的ZONE_NORMAL区相连。The method according to claim 1, wherein the physical address of the NVM memory is pre-allocated in a ZONE_HIGHMEN area in a Linux kernel memory management area, and is connected to a ZONE_NORMAL area in a Linux kernel memory management area.
  6. 一种基于异构混合内存的内存管理系统,其特征在于,所述系统包括:A memory management system based on heterogeneous mixed memory, characterized in that the system comprises:
    接收模块,用于接收内存申请请求;a receiving module, configured to receive a memory application request;
    检测模块,用于检测所述内存申请请求中是否存在NVM标志;a detecting module, configured to detect whether an NVM flag exists in the memory application request;
    第一判断模块,用于如果所述内存申请请求中存在NVM标志,则判断所述内存申请请求是否符合权限要求,如果符合,则根据所述内存申请请求分配NVM内存,如果不符合则不作处理;a first determining module, configured to determine, if the NVM flag exists in the memory application request, whether the memory application request meets a permission requirement, and if yes, allocate NVM memory according to the memory application request, and if not, not process ;
    申请模块,用于如果所述内存申请请求符合权限要求,则根据所述内存申请请求分配NVM内存;An application module, configured to allocate NVM memory according to the memory application request if the memory application request meets a permission requirement;
    所述申请模块还用于如果所述内存申请请求中不存在NVM标志,则根据所述内存申请请求分配DRAM内存。The application module is further configured to allocate DRAM memory according to the memory request request if the NVM flag does not exist in the memory application request.
  7. 根据权利要求6所述的系统,其特征在于,所述内存申请请求中包含申请的内存长度,所述系统还包括:The system according to claim 6, wherein the memory request request includes a memory length of the application, and the system further comprises:
    第二判断模块,用于判断所述申请的内存长度是否超过NVM内存的总长度,如果没有超过,则通知所述第一判断模块判断所述内存申请请求是否符合权限要求,如果超过,则不作处理。The second judging module is configured to determine whether the memory length of the application exceeds the total length of the NVM memory, and if not, notify the first judging module whether the memory application request meets the permission requirement, and if not, not deal with.
  8. 根据权利要求6所述的系统,其特征在于,所述内存申请请求中包含申请的内存长度,所述申请模块包括:The system according to claim 6, wherein the memory application request includes a memory length of the application, and the application module includes:
    虚拟地址空间申请单元,用于根据所述申请的内存长度申请相同大小的虚 拟地址空间并进行初始化,所述虚拟地址空间包含虚拟地址空间的首地址和尾地址;a virtual address space application unit, configured to apply for the same size virtual number according to the memory length of the application The address space is initialized, and the virtual address space includes a first address and a tail address of the virtual address space;
    地址转换单元,用于将所述虚拟地址空间的首地址转换为物理地址;An address conversion unit, configured to convert a first address of the virtual address space into a physical address;
    内存申请单元,用于根据所述物理地址和申请的内存长度在NVM中申请相同大小的NVM内存。The memory application unit is configured to apply for the same size of the NVM memory in the NVM according to the physical address and the requested memory length.
  9. 根据权利要求8所述的系统,其特征在于,所述虚拟地址空间位于Linux的内核空间中的间接映射地址空间中。The system of claim 8 wherein said virtual address space is located in an indirect mapped address space in a kernel space of Linux.
  10. 根据权利要求6所述的系统,其特征在于,所述NVM内存的物理地址预先分配在Linux内核内存管理区中的ZONE_HIGHMEN区中,与Linux内核内存管理区中的ZONE_NORMAL区相连。 The system according to claim 6, wherein the physical address of the NVM memory is pre-allocated in the ZONE_HIGHMEN area in the Linux kernel memory management area, and is connected to the ZONE_NORMAL area in the Linux kernel memory management area.
PCT/CN2015/098817 2015-12-25 2015-12-25 Memory management method and system based on heterogeneous hybrid memory WO2017107163A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/098817 WO2017107163A1 (en) 2015-12-25 2015-12-25 Memory management method and system based on heterogeneous hybrid memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/098817 WO2017107163A1 (en) 2015-12-25 2015-12-25 Memory management method and system based on heterogeneous hybrid memory

Publications (1)

Publication Number Publication Date
WO2017107163A1 true WO2017107163A1 (en) 2017-06-29

Family

ID=59088890

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/098817 WO2017107163A1 (en) 2015-12-25 2015-12-25 Memory management method and system based on heterogeneous hybrid memory

Country Status (1)

Country Link
WO (1) WO2017107163A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108268220A (en) * 2018-02-08 2018-07-10 重庆邮电大学 Optimization method for software based on non-volatile hybrid memory in real time embedded system
CN110096366A (en) * 2019-05-10 2019-08-06 苏州浪潮智能科技有限公司 A kind of configuration method, device and the server of isomery memory system
CN112015669A (en) * 2019-05-31 2020-12-01 华为技术有限公司 Hybrid memory management method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7685376B2 (en) * 2006-05-03 2010-03-23 Intel Corporation Method to support heterogeneous memories
CN104102590A (en) * 2014-07-22 2014-10-15 浪潮(北京)电子信息产业有限公司 Heterogeneous memory management method and device
CN104216837A (en) * 2013-05-31 2014-12-17 华为技术有限公司 Memory system, memory access request processing method and computer system
CN104239225A (en) * 2014-09-04 2014-12-24 浪潮(北京)电子信息产业有限公司 Method and device for managing heterogeneous hybrid memory
CN105786725A (en) * 2014-12-25 2016-07-20 研祥智能科技股份有限公司 Memory management method and system based on heterogeneous hybrid memory

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7685376B2 (en) * 2006-05-03 2010-03-23 Intel Corporation Method to support heterogeneous memories
CN104216837A (en) * 2013-05-31 2014-12-17 华为技术有限公司 Memory system, memory access request processing method and computer system
CN104102590A (en) * 2014-07-22 2014-10-15 浪潮(北京)电子信息产业有限公司 Heterogeneous memory management method and device
CN104239225A (en) * 2014-09-04 2014-12-24 浪潮(北京)电子信息产业有限公司 Method and device for managing heterogeneous hybrid memory
CN105786725A (en) * 2014-12-25 2016-07-20 研祥智能科技股份有限公司 Memory management method and system based on heterogeneous hybrid memory

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108268220A (en) * 2018-02-08 2018-07-10 重庆邮电大学 Optimization method for software based on non-volatile hybrid memory in real time embedded system
CN108268220B (en) * 2018-02-08 2020-12-18 重庆邮电大学 Software optimization method of non-volatile mixed memory in real-time embedded system
CN110096366A (en) * 2019-05-10 2019-08-06 苏州浪潮智能科技有限公司 A kind of configuration method, device and the server of isomery memory system
CN110096366B (en) * 2019-05-10 2022-03-04 苏州浪潮智能科技有限公司 Configuration method and device of heterogeneous memory system and server
CN112015669A (en) * 2019-05-31 2020-12-01 华为技术有限公司 Hybrid memory management method and device

Similar Documents

Publication Publication Date Title
CN105786725B (en) Memory management method and system based on heterogeneous hybrid memory
TWI661301B (en) Memory system and control method for controlling non-volatile memory
US10592408B2 (en) Apparatus, computer program product, system, and method for managing multiple regions of a memory device
EP3217294B1 (en) File access method and apparatus and storage device
US10078453B1 (en) Storage system, computer program product, and method for managing a hybrid memory device system
WO2018196839A1 (en) Internal memory access method and computer system
US10795599B2 (en) Data migration method, host and solid state disk
US10565103B2 (en) Method for creating multi-namespace and method for accessing data therein
US9317312B2 (en) Computer and memory management method
US11886333B2 (en) Memory block reclamation method and apparatus
KR20070070121A (en) Unified memory and controller
BR112016019305B1 (en) ARRANGEMENT CONTROLLER, SOLID STATE DISK, AND METHOD FOR CONTROLLING SOLID STATE DISK TO WRITE DATA
KR101579941B1 (en) Method and apparatus for isolating input/output of virtual machines
US20230244394A1 (en) Gradually Reclaim Storage Space Occupied by a Proof of Space Plot in a Solid State Drive
US11775188B2 (en) Communications to reclaim storage space occupied by proof of space plots in solid state drives
KR20200139433A (en) Operating method of controller and memory system
KR20200072639A (en) Storage device and operating method thereof
US20240192883A1 (en) Management of Storage Space in Solid State Drives to Support Proof of Space Activities
WO2017107163A1 (en) Memory management method and system based on heterogeneous hybrid memory
CN116342365A (en) Techniques for expanding system memory via use of available device memory
US20170357579A1 (en) Hypervisor translation bypass
CN115168317A (en) LSM tree storage engine construction method and system
JPH1063525A (en) Information processor, and information processing system and control method therefor
WO2023077519A1 (en) Storage device supporting multiple operation systems, and configuration method and computer system
US11714753B2 (en) Methods and nodes for handling memory

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: 15911162

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15911162

Country of ref document: EP

Kind code of ref document: A1