WO2016041501A1 - 一种内存分配的方法及装置 - Google Patents

一种内存分配的方法及装置 Download PDF

Info

Publication number
WO2016041501A1
WO2016041501A1 PCT/CN2015/089796 CN2015089796W WO2016041501A1 WO 2016041501 A1 WO2016041501 A1 WO 2016041501A1 CN 2015089796 W CN2015089796 W CN 2015089796W WO 2016041501 A1 WO2016041501 A1 WO 2016041501A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
data
mirrored
allocated
stored
Prior art date
Application number
PCT/CN2015/089796
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 华为技术有限公司
Priority to JP2017512349A priority Critical patent/JP6478430B2/ja
Priority to BR112017001965-5A priority patent/BR112017001965B1/pt
Priority to EP15841888.9A priority patent/EP3171276B1/en
Priority to KR1020177004358A priority patent/KR101996975B1/ko
Publication of WO2016041501A1 publication Critical patent/WO2016041501A1/zh
Priority to US15/460,132 priority patent/US10353609B2/en
Priority to US16/425,872 priority patent/US10990303B2/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/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/1666Error detection or correction of the data by redundancy in hardware where the redundant component is memory or memory area
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • 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
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0673Single storage device
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for memory allocation.
  • Mirroring Memory technology works by dividing two memory areas in hardware, one as main memory and one as mirror memory.
  • the operating system runs two copies of memory data in main memory and mirror memory. in. So there are two complete sets of backups of the memory data.
  • the complete mirrored memory requires all the data in the memory to have a copy.
  • the original system is used when the server system is running normally. When one of the hosts fails, the other one is immediately replaced, effectively preventing the memory channel.
  • the data loss caused by the failure greatly improves the reliability of the server. But to achieve this function requires double the physical memory, and the actual capacity utilization is only 50%. Because of the high cost, few products in reality use full mirrored memory.
  • Partially mirrored memory technology has appeared in the prior art, which can make part of the memory (such as a certain segment or segments of memory address area) in the computer system mirrored memory.
  • the mirrored memory in the prior art only stays at the hardware layer, and the operating system does not sense the hardware layer.
  • the operating system cannot accurately find the mirrored memory, resulting in the inability to prepare the data for storage.
  • the mirrored memory and because the mirrored memory size is limited, and the computer system allocates mirrored memory for the data, only the mirrored memory is allocated for the first generated data. After the mirrored memory is full, the mirrored memory cannot be allocated for other needs. The data is allocated to the mirrored memory.
  • the memory allocation method provided by the embodiment of the present invention is provided to solve the problem that the operating system cannot perceive the change of the mirrored memory in the prior art, and the mirrored memory is limited in size, and the mirrored memory cannot be allocated to the data that needs to be allocated the mirrored memory. , can accurately find the mirror memory, and need to store to The mirrored memory allocates mirrored memory, which ensures the use of limited mirrored memory and improves system reliability.
  • Embodiments of the present invention also provide corresponding devices.
  • a first aspect of the present invention provides a method for memory allocation, the method being applied to a computer system, where the computer system includes a memory resource, a basic input/output system BOIS, and an operating system OS, where the memory resource includes an initial mirror memory.
  • the method includes:
  • the initial mirrored memory is a mirrored memory indicated by a mirrored memory address range provided by the BOIS to the OS during initialization of the OS;
  • the mirrored memory is allocated from the unoccupied mirrored memory to the data to be stored in the mirrored memory.
  • the method before the detecting the data to be allocated, the method further includes:
  • the data to be allocated memory is detected, including:
  • the mirrored memory is allocated from the unoccupied mirrored memory to the data to be stored in the mirrored memory, including:
  • the data of the to-be-allocated memory When it is detected that the data of the to-be-allocated memory carries the image identifier, determining that the data of the to-be-allocated memory is the kernel data or the key user data, from the unoccupied mirror memory, The kernel data or the key user data is allocated mirror memory.
  • the method further includes:
  • the same process data is transferred to the initial mirror memory.
  • the storing the image memory from the unoccupied image memory The data is allocated to the mirrored memory, including:
  • the mirrored memory is allocated to the data to be stored in the mirrored memory from the unoccupied mirrored memory of the associated pre-divided memory resource area.
  • the storing the image memory from the unoccupied image memory After the data is allocated to the mirrored memory the method further includes:
  • the occupied flag is set for the address range of the mirrored memory allocated to the data to be stored in the mirrored memory.
  • a second aspect of the present invention provides an apparatus for memory allocation, the apparatus being applied to a computer system, the computer system including a memory resource, a basic input/output system BOIS, and an operating system OS, wherein the memory resource includes an initial mirror memory.
  • the device includes:
  • An obtaining unit configured to acquire unoccupied mirrored memory in the initial mirrored memory, where the initial mirrored memory is a mirrored memory indicated by a mirrored memory address interval provided by the BOIS to the OS during initialization of the OS;
  • An allocating unit configured to: when the detecting unit detects that the data is data to be stored in the mirrored memory, the unoccupied mirrored memory acquired from the acquiring unit is the to-be-stored to the mirrored memory. Data is allocated to mirror memory.
  • a first setting unit configured to set a mirror identifier for the kernel data and the key user data before the detecting unit detects the data to be allocated the memory, where the key user data is data specified by the user and needs to be mirrored and stored;
  • the detecting unit is configured to detect whether the data of the to-be-allocated memory carries the image identifier set by the first setting unit;
  • the allocating unit is configured to: when the detecting unit detects that the data of the to-be-allocated memory carries the image identifier, determining that the data of the to-be-allocated memory is the kernel data or the number of key users
  • the mirrored memory is allocated for the kernel data or the key user data from the unoccupied mirror memory.
  • the apparatus further includes:
  • a determining unit configured to determine, when the data of the to-be-allocated memory is the key user data, whether the same process data is stored in the initial image memory, where the same process data is generated before the key user data Data generated by the same process of the key user data;
  • the allocating unit includes:
  • an allocation subunit configured to allocate mirrored memory for the data to be stored into the mirrored memory from the unoccupied mirrored memory of the associated pre-divided memory resource area determined by the determining subunit.
  • the device further includes:
  • the method for memory allocation provided by the embodiment of the present invention is applied to a computer system, where the computer system includes a memory resource, a basic input and output system BOIS, and an operating system OS, where the memory resource includes an initial image memory.
  • the method includes: acquiring an unoccupied mirrored memory in the initial mirrored memory, where the initial mirrored memory is a mirrored memory address interval provided by the BOIS to the OS when the OS is initialized.
  • the mirrored memory indicated; the data to be allocated to the memory is detected; when the data is detected as the data to be stored in the mirrored memory, the data to be stored in the mirrored memory is from the unoccupied mirrored memory Allocate mirrored memory.
  • FIG. 2 is a schematic diagram of an embodiment of a method for memory allocation in an embodiment of the present invention
  • FIG. 3 is a schematic diagram of an embodiment of an apparatus for memory allocation in an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of another embodiment of an apparatus for memory allocation in an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of another embodiment of an apparatus for memory allocation in an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of another embodiment of an apparatus for memory allocation in an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of another embodiment of an apparatus for memory allocation in an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of an embodiment of a memory allocation device in an embodiment of the present invention.
  • a computer system architecture may include: a hardware resource layer, a basic input output system (BOIS), an operating system (OS), and a user application layer.
  • Layers can include processor, memory, input
  • the operating system may be a Linux system.
  • the user application layer may include various service applications.
  • the operating system in the embodiment of the present invention may be a Linux system.
  • the memory can include mirrored memory.
  • BOIS reports the memory information to the OS.
  • the memory information can be the address range of each type of memory, including the address range of the mirrored memory.
  • the following information can be included in the e820 map.
  • the form can be expressed as:
  • the address corresponding to the address range of the mirror is the mirrored memory.
  • the address range of the mirrored memory is (1M to 1G), (12G to 13G), (24G to 25G), and (36G to 37G).
  • the operating system can create a mirrored memory management area MIRROR ZONE according to the memory information reported by the BIOS.
  • MIRROR ZONE is used to track and manage the mirrored memory area and is organized in the same way as a normal memory management area.
  • MIRROR ZONEs There are multiple MIRROR ZONEs, and multiple MIRROR ZONEs make up a ZONE List.
  • the mirror memory in the embodiment of the present invention may have four MIRROR ZONEs, which are (1M to 1G), (12G to 13G), (24G to 25G), and (36G to 37G).
  • MIRROR_ZONE1, MIRROR_ZONE2, MIRROR_ZONE3 and MIRROR_ZONE4 can divide 48G memory into 4 nodes, which are (0M ⁇ 12G), (13G ⁇ 24G), (25G ⁇ 36G), (37G ⁇ 48G), 4 MIRROR ZONE belong to 4 nodes respectively.
  • NUMA Non Uniform Memory Access Architecture
  • the mirror memory is allocated, the mirror memory of the node is preferentially allocated to avoid accessing the memory across the nodes, causing a large delay.
  • __GFP_MIRROR flag As the identifier for prioritizing the mirrored memory in the kernel.
  • the OS starts and determines whether the mirror memory priority allocation feature is supported. (If there is MIRROR type memory in the memory map reported by the BIOS, this feature is supported).
  • the OS creates one or more MIRROR ZONEs based on the memory information reported by the BIOS and adds them to all NODE ZONE lists so that each node can choose to allocate memory in MIRROR ZONE.
  • alloc_pages() is the most basic pager allocator. All memory allocations will eventually come here. It is responsible for allocating one or more (2 integer powers) consecutive page frames in the specified page area (ZONE). . If the __GFP_MIRROR flag is set, memory is preferentially allocated from MIRROR ZONE.
  • the memory is allocated from the MIRROR ZONE area first. If the memory of the MIRROR type is insufficient, it is allocated from the normal area.
  • the identifier can be set by a system call or a user state command.
  • MIRROR_FIRST When allocating memory, if MIRROR_FIRST is set, the mirrored memory is used first, and the memory is allocated first from MIRROR ZONE. Otherwise, normal memory is used, and memory is allocated from NORMAL ZONE. If the mirror memory is insufficient, normal memory is also allocated.
  • MIRROR_FIRST When the child process is created, the settings identified by MIRROR_FIRST are inherited by default.
  • an embodiment of a method for memory allocation provided by an embodiment of the present invention includes:
  • the method is applied to a computer system, where the computer system includes a memory resource, a basic input and output system BOIS, and an operating system OS.
  • the memory resource includes an initial image memory.
  • the data to be allocated for memory is detected.
  • the operating system can not perceive the change of the memory, and in the case that the image memory size is limited, the image allocation method provided by the embodiment of the present invention is not able to allocate the mirror memory for the data that needs to be allocated the mirror memory.
  • the BOIS provides a mirrored memory address range to the OS, so that the mirrored memory can be accurately found, and the mirrored memory is allocated to the data that needs to be stored in the mirrored memory, thereby ensuring the use efficiency of the limited mirrored memory and improving the reliability of the system.
  • the method It can also include:
  • the detecting the data to be allocated to the memory may include:
  • the data of the to-be-allocated memory When it is detected that the data of the to-be-allocated memory carries the image identifier, determining that the data of the to-be-allocated memory is the kernel data or the key user data, from the unoccupied mirror memory, The kernel data or the key user data is allocated mirror memory.
  • the kernel data may be all allocated to the mirrored memory, and the user data may be set according to the user's requirements.
  • the mirrored identifier is set for the type of data.
  • Type data is allocated to mirror memory.
  • the method may further include:
  • the same process data is transferred to the initial mirror memory.
  • a mirror mark is set for an ongoing process, for example, a word document that the user is editing.
  • the user specifies the word document as key user data, and the word document is Part of the edited data has been allocated normal memory, and the edited portion of the data is allocated to the mirrored memory, so that the previous data in the normal memory can also be transferred to the mirrored memory.
  • Allocating mirrored memory for the data to be stored in the mirrored memory in the occupied mirror memory may include:
  • the mirrored memory is allocated to the data to be stored in the mirrored memory from the unoccupied mirrored memory of the associated pre-divided memory resource area.
  • the embodiment of the present invention is directed to the case where the mirrored memory is distributed in different NUMA nodes, and the mirrored memory is allocated in the node, so that the memory can be avoided to be accessed across the nodes, causing a large delay.
  • the method may further include:
  • the occupied flag is set for the address range of the mirrored memory allocated to the data to be stored in the mirrored memory.
  • a flag is set on the address range of the mirrored memory that is occupied, so that when the memory is allocated, the unoccupied mirrored memory can be quickly found.
  • the obtaining unit 201 is configured to acquire the unoccupied mirrored memory in the initial mirrored memory, where the initial mirrored memory is the mirrored memory indicated by the mirrored memory address interval provided by the BOIS to the OS during the OS initialization. ;
  • the detecting unit 202 is configured to detect data to be allocated memory
  • the unoccupied mirror memory obtained by the unit 201 allocates mirror memory for the data to be stored in the mirror memory.
  • the first setting unit 204 is configured to: before the detecting unit 202 detects the data to be allocated memory, set a mirror identifier for the kernel data and the key user data, where the key user data is data specified by the user and needs to be mirrored and stored;
  • the detecting unit 202 is configured to detect whether the data of the to-be-allocated memory carries the image identifier set by the first setting unit 204;
  • the allocating unit 203 is configured to: when the detecting unit 202 detects that the data of the to-be-allocated memory carries the image identifier, determining that the data of the to-be-allocated memory is the kernel data or the key user data, Mirror memory is allocated for the kernel data or the key user data from the unoccupied mirror memory.
  • a determining unit 205 configured to: when the data of the to-be-allocated memory is the key user data set by the setting unit 204, determine whether the same process data is stored in the initial mirror memory, where the same process data is in the The key user data is previously generated by the same process that generated the key user data;
  • the transferring unit 206 is configured to: when the determining unit 205 determines that the same process data is not stored in the mirror memory, transfer the same process data into the initial mirror memory.
  • the allocation sub-unit 2032 is configured to allocate mirrored memory for the data to be stored into the mirrored memory from the unoccupied mirror memory of the associated pre-divided memory resource area determined by the determining sub-unit 2021.
  • the apparatus 20 further includes:
  • FIG. 8 is a schematic structural diagram of a memory allocation device 40 according to an embodiment of the present invention.
  • the memory allocation device 40 can include an input/output device 410, a processor 430, and a memory 440.
  • Memory 440 can include read only memory and random access memory and provides instructions and data to processor 430. A portion of memory 440 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • Memory 440 stores the following elements, executable modules or data structures, or subsets thereof, or their extended sets:
  • Operation instructions include various operation instructions for implementing various operations.
  • Operating system Includes a variety of system programs for implementing various basic services and handling hardware-based tasks.
  • the memory allocation device is applied to a computer system, where the computer system includes a memory resource, a basic input/output system BOIS, and an operating system OS, where the memory resource includes an initial image memory, and when the operating system is running, the present invention
  • the processor 430 performs the following operations by calling an operation instruction stored in the memory 440, which can be stored in the operating system:
  • the mirrored memory is allocated from the unoccupied mirrored memory to the data to be stored in the mirrored memory.
  • the BOIS of the memory allocation device 40 provides a mirrored memory address interval to the OS, so that the mirrored memory can be accurately found, and the mirrored memory is allocated for the data that needs to be stored in the mirrored memory, thereby ensuring the limited mirrored memory. Use efficiency and improve system reliability.
  • the processor 430 controls the operation of the memory allocation device 40, which may also be referred to as a CPU (Central Processing Unit).
  • Memory 440 can include read only memory and random access memory and provides instructions and data to processor 430. A portion of memory 440 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • the various components of the memory allocation device 40 are coupled together by a bus system 450.
  • the bus system 450 may include a power bus, a control bus, a status signal bus, and the like in addition to the data bus. However, for clarity of description, various buses are labeled as bus system 450 in the figure.
  • Processor 430 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the foregoing method may be completed by an integrated logic circuit of hardware in the processor 430 or an instruction in a form of software.
  • the processor 430 described above may be a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or discrete hardware. Component.
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA off-the-shelf programmable gate array
  • the methods, steps, and logical block diagrams disclosed in the embodiments of the present invention may be implemented or carried out.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention may be directly implemented as a hardware decoding processor, or by using a hard processor in the decoding processor.
  • the combination of the piece and the software module is completed.
  • the software module can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like.
  • the storage medium is located in memory 440, and processor 430 reads the information in memory 440 and, in conjunction with its hardware, performs the steps of the above method.
  • the processor 430 is further configured to set a mirror identifier for the kernel data and the key user data, where the key user data is data specified by the user that needs to be mirrored, and whether the data of the to-be-allocated memory is carried.
  • Mirroring identifier when it is detected that the data of the to-be-allocated memory carries the image identifier, determining that the data of the to-be-allocated memory is the kernel data or the key user data, from the unoccupied mirror memory Mirroring memory is allocated for the kernel data or the key user data.
  • the processor 430 is specifically configured to determine a pre-divided memory resource region to which the data to be stored into the mirrored memory belongs; from the unoccupied mirror memory of the associated pre-divided memory resource region, The data to be stored in the mirrored memory allocates mirror memory.
  • the storage medium may include: a ROM, a RAM, a magnetic disk, or an optical disk.

Abstract

一种内存分配的方法,所述方法应用于计算机系统中,所述计算机系统包括内存资源、BOIS和OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存(101),对待分配内存的数据进行检测(102),当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存(103)。上述内存分配的方法,可以准确的找到镜像内存,并为需要存储到镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率。

Description

一种内存分配的方法及装置 技术领域
本发明涉及计算机技术领域,具体涉及一种内存分配的方法及装置。
背景技术
因内存的可靠性对计算机系统的可靠性影响很大。所以需要提高内存的可靠性,目前现有技术中通常采用镜像内存来提升内存可靠性。
镜像内存(Mirroring Memory)技术的工作原理:在硬件中划分两个内存区域,一个作为主内存,一个作为镜像内存,操作系统运行时将内存数据做两个拷贝,分别放在主内存和镜像内存中。因此使得内存数据有两套完整的备份。完整的镜像内存需要内存中的所有数据均存有副本,服务器系统正常运行时所使用的是原本,而当其中一份宿主失效时,另外那份就随即补替工作,有效防止了由于内存通道故障导致的数据丢失,极大提升了服务器可靠性。但是要实现这一功能需要双倍的物理内存,而实际容量的利用率只有50%。由于成本非常高,因此现实中很少有产品使用完整的镜像内存。
现有技术中已经出现了部分镜像内存技术,该技术可以将计算机系统中的一部分内存(比如某一段或几段内存地址区域)做镜像内存。但现有技术中的镜像内存只是停留在硬件层,操作系统并不感知硬件层,当硬件层的镜像内存发生变化时,操作系统中就不能准确的找到镜像内存,导致无法将数据准备的存储到镜像内存中,而且,由于镜像内存大小有限,而计算机系统在为数据分配镜像内存时,只会为先产生的数据分配镜像内存,镜像内存占满后,就无法再为其他需要分配镜像内存的数据分配镜像内存。
发明内容
为了解决现有技术中操作系统无法感知到镜像内存的变化,且在镜像内存大小有限的情况下,无法为需要分配镜像内存的数据分配镜像内存相比,本发明实施例提供的内存分配的方法,可以准确的找到镜像内存,并为需要存储到 镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率,而且提高了系统的可靠性。本发明实施例还提供了相应的装置。
本发明第一方面提供一种内存分配的方法,所述方法应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:
获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;
对待分配内存的数据进行检测;
当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。
结合第一方面,在第一种可能的实现方式中,所述对待分配内存的数据进行检测之前,所述方法还包括:
为内核数据和关键用户数据设置镜像标识,所述关键用户数据为用户指定的需要镜像存储的数据;
所述对待分配内存的数据进行检测,包括:
检测所述待分配内存的数据是否携带有所述镜像标识;
所述当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存,包括:
当检测到所述待分配内存的数据携带有所述镜像标识,确定所述待分配内存的数据为所述内核数据或所述关键用户数据,从所述未被占用的镜像内存中为所述内核数据或所述关键用户数据分配镜像内存。
结合第一方面第一种可能的实现方式,在第二种可能的实现方式中,所述方法还包括:
当所述待分配内存的数据为所述关键用户数据时,确定同一进程数据是否存储在所述初始镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;
若所述同一进程数据未存储到所述镜像内存中,则将所述同一进程数据转移到所述初始镜像内存中。
结合第一方面、第一方面第一种或第二种可能的实现方式,在第三种可能的实现方式中,所述从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存,包括:
确定所述待存储到镜像内存的数据所属的预划分内存资源区域;
从所述所属的预划分内存资源区域的未被占用的镜像内存中,为所述待存储到镜像内存的数据分配镜像内存。
结合第一方面、第一方面第一种或第二种可能的实现方式,在第四种可能的实现方式中,所述从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存之后,所述方法还包括:
为所述待存储到镜像内存的数据所分配的镜像内存的地址区间设置已占用标记。
本发明第二方面提供一种内存分配的装置,所述装置应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述装置包括:
获取单元,用于获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;
检测单元,用于对待分配内存的数据进行检测;
分配单元,用于当所述检测单元检测到所述数据为待存储到镜像内存的数据时,从所述获取单元获取的所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。
结合第二方面,在第一种可能的实现方式中,所述装置还包括:
第一设置单元,用于在所述检测单元对待分配内存的数据进行检测之前,为内核数据和关键用户数据设置镜像标识,所述关键用户数据为用户指定的需要镜像存储的数据;
所述检测单元,用于检测所述待分配内存的数据是否携带有所述第一设置单元设置的所述镜像标识;
所述分配单元,用于当所述检测单元检测到所述待分配内存的数据携带有所述镜像标识,确定所述待分配内存的数据为所述内核数据或所述关键用户数 据,从所述未被占用的镜像内存中为所述内核数据或所述关键用户数据分配镜像内存。
结合第二方面第一种可能的实现方式,在第二种可能的实现方式中,所述装置还包括:
确定单元,用于当所述待分配内存的数据为所述关键用户数据时,确定同一进程数据是否存储在所述初始镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;
转移单元,用于当所述确定单元确定所述同一进程数据未存储到所述镜像内存中时,则将所述同一进程数据转移到所述初始镜像内存中。
结合第二方面、第二方面第一种或第二种可能的实现方式,在第三种可能的实现方式中,所述分配单元包括:
确定子单元,用于确定所述待存储到镜像内存的数据所属的预划分内存资源区域;
分配子单元,用于从所述确定子单元确定的所属的预划分内存资源区域的未被占用的镜像内存中,为所述待存储到镜像内存的数据分配镜像内存。
结合第二方面、第二方面第一种或第二种可能的实现方式,在第四种可能的实现方式中,所述装置还包括:
第二设置单元,用于在所述分配单元分配镜像内存后,为所述待存储到镜像内存的数据所分配的镜像内存的地址区间设置已占用标记。
本发明实施例提供的内存分配的方法,所述方法应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;对待分配内存的数据进行检测;当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。与现有技术中操作系统无法感知到进行内存的变化,且在镜像内存大小有限的情况下,无法为需要分配镜像内存的数据分配镜像内存相比,本发明实施例提供的内存分配的方法,BOIS向所述OS提供镜像内存地址区间,从而可以准确的 找到镜像内存,并为需要存储到镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率,而且提高了系统的可靠性。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本发明实施例中计算机系统的架构示意图;
图2是本发明实施例中内存分配的方法的一实施例示意图;
图3是本发明实施例中内存分配的装置的一实施例示意图;
图4是本发明实施例中内存分配的装置的另一实施例示意图;
图5是本发明实施例中内存分配的装置的另一实施例示意图;
图6是本发明实施例中内存分配的装置的另一实施例示意图;
图7是本发明实施例中内存分配的装置的另一实施例示意图;
图8是本发明实施例中内存分配设备的一实施例示意图。
具体实施方式
本发明实施例提供一种内存分配的方法,可以准确的找到镜像内存,并为需要存储到镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率,而且提高了系统的可靠性。本发明实施例还提供了相应的装置及系统。以下分别进行详细说明。
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
参阅图1,本发明实施例提供的计算机系统架构可以包括:硬件资源层、基本输入输出系统(Basic Input Output System,BOIS)、操作系统(Operation System,OS)和用户应用层,所述硬件资源层可以包括处理器、内存、输入 输出系统等硬件资源,用户应用层可以包括各种业务应用,本发明实施例中的操作系统可以为Linux系统。
内存可以包括镜像内存,在操作系统初始化时,BOIS会向OS上报内存信息,内存信息可以为各类型内存的地址范围,其中包括镜像内存的地址范围,例如可以包含以下信息,通过e820映射图的形式可以表示为:
e820:BIOS-provided physical RAM map:
[mem 0x0000000000000000-0x000000000009a7ff]usable
[mem 0x000000000009a800-0x000000000009ffff]reserved
[mem 0x00000000000e4b60-0x00000000000fffff]reserved
[mem 0x0000000000100000-0x000000003fffffff]mirror (1M~1G)
[mem 0x0000000040000000-0x00000000bf78ffff]usable (1G~3063M)
[mem 0x00000000bf790000-0x00000000bf79dfff]ACPI data
[mem 0x00000000bf79e000-0x00000000bf7cffff]ACPI NVS
[mem 0x00000000bf7d0000-0x00000000bf7dffff]reserved
[mem 0x00000000bf7ec000-0x00000000bfffffff]reserved
[mem 0x00000000e0000000-0x00000000efffffff]reserved
[mem 0x00000000fee00000-0x00000000fee00fff]reserved
[mem 0x00000000fff00000-0x00000000ffffffff]reserved
[mem 0x0000000100000000-0x00000002ffffffff]usable  (4G~12G)
[mem 0x0000000300000000-0x000000033fffffff]mirror  (12G~13G)
[mem 0x0000000340000000-0x00000005ffffffff]usable  (13G~24G)
[mem 0x0000000600000000-0x000000063fffffff]mirror  (24G~25G)
[mem 0x0000000640000000-0x0000000bffffffff]usable  (25G~36G)
[mem 0x0000000900000000-0x000000093fffffff]mirror  (36G~37G)
[mem 0x0000000940000000-0x0000000c3fffffff]usable  (37G~48G)…
其中,标记为mirror的地址范围对应的内存为镜像内存,本发明实施例中镜像内存的地址范围为(1M~1G)、(12G~13G)、(24G~25G)、(36G~37G)。
操作系统根据BIOS上报的内存信息,可以建立一个镜像内存管理区MIRROR ZONE。MIRROR ZONE用来跟踪和管理镜像内存区域,其组织方式和普通的内存管理区相同。MIRROR ZONE可以有多个,多个MIRROR ZONE组成ZONE List。例如:本发明实施例中的镜像内存可以有4个MIRROR ZONE,分别为(1M~1G)、(12G~13G)、(24G~25G)、(36G~37G)。可以依次编号为:MIRROR_ZONE1、MIRROR_ZONE2、MIRROR_ZONE3和 MIRROR_ZONE4,按照非一致性内存访问(Non Uniform Memory Access Architecture,NUMA)架构,可以将48G的内存划分为4个节点,分别为(0M~12G)、(13G~24G)、(25G~36G)、(37G~48G),4个MIRROR ZONE分别属于4个节点,在分配镜像内存时,优先分配本节点的镜像内存,避免跨节点访问内存,造成较大的延迟。
在为内核数据分配内存时,可以通过新增__GFP_MIRROR标识,作为内核中优先分配镜像内存的标识。在为用户数据分配内存时,可以指定__GFP_MIRROR标识,优先分配镜像内存,也可以设置内核默认内核优先分配镜像内存。如以通过修改GFP_KERNEL的默认值,设置默认优先分配镜像内存:
#define GFP_KERNEL(__GFP_WAIT|__GFP_IO|__GFP_FS|__GFP_MIRROR)
针对内核数据优先分配镜像内存的过程如下:
1)OS启动,判断是否支持镜像内存优先分配的特性(BIOS上报的内存分布图中如果有MIRROR类型的内存,则说明支持该特性)。
2)若支持,OS根据BIOS上报的内存信息,建立一个或多个MIRROR ZONE,并加入到所有NODE的ZONE链表中,以便每个节点都可以选择在MIRROR ZONE中进行内存分配。
3)alloc_pages()是最基础的页框分配器,所有内存分配最终会走到这里,其负责在指定页区(ZONE)中分配1个或多个(2的整数次幂个)连续页框。如设置__GFP_MIRROR标识,则优先从MIRROR ZONE中分配内存。
4)分配内存时,优先从MIRROR ZONE区分配内存,若MIRROR类型的内存不足,则再从普通区域分配。
5)如果系统的镜像内存数量很少,不足以满足所有内核数据存储的情况下,也可以关闭默认分配镜像内存的设置,改为手动分配镜像内存。比如,某些重要驱动程序,有较高的可靠性需求,可在分配内存时,手动指定__GFP_MIRROR标识。
6)镜像内存使用完释放时,释放到对应的MIRROR ZONE里;
本发明实施例不改变alloc_pages()等内存分配函数的接口及使用方式,使 大量既有驱动程序不需做任何修改即可使用该特性。
针对用户进程数据优先分配镜像内存
针对新创建的进程:
1)创建进程
2)修改进程描述符,在进程描述符中设置镜像内存分配标识MIRROR_FIRST,本发明中,通过系统调用或用户态命令可以设置该标识。
3)分配内存时,如果MIRROR_FIRST设置,则优先使用镜像内存,优先从MIRROR ZONE分配内存,否则使用普通内存,从NORMAL ZONE分配内存,如果镜像内存不足,也分配普通内存。
4)子进程创建时,默认继承MIRROR_FIRST标识的设置。
针对正在运行的进程:
1)通过/proc接口或者系统调用设置进程的MIRROR_FIRST标识,使进程分配内存时,优先分配镜像内存。
2)同时,将之前分配的普通内存中的数据,迁移到镜像内存中.
参阅图2,本发明实施例提供的内存分配的方法的一实施例包括:
所述方法应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:
101、获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存。
102、对待分配内存的数据进行检测。
103、当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。
本发明实施例提供的内存分配的方法,所述方法应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;对待分 配内存的数据进行检测;当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。与现有技术中操作系统无法感知到进行内存的变化,且在镜像内存大小有限的情况下,无法为需要分配镜像内存的数据分配镜像内存相比,本发明实施例提供的内存分配的方法,BOIS向所述OS提供镜像内存地址区间,从而可以准确的找到镜像内存,并为需要存储到镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率,而且提高了系统的可靠性。
可选地,在上述图2对应的实施例的基础上,本发明实施例提供的内存分配的方法的第一个可选实施例中,所述对待分配内存的数据进行检测之前,所述方法还可以包括:
为内核数据和关键用户数据设置镜像标识,所述关键用户数据为用户指定的需要镜像存储的数据;
所述对待分配内存的数据进行检测,可以包括:
检测所述待分配内存的数据是否携带有所述镜像标识;
所述当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存,可以包括:
当检测到所述待分配内存的数据携带有所述镜像标识,确定所述待分配内存的数据为所述内核数据或所述关键用户数据,从所述未被占用的镜像内存中为所述内核数据或所述关键用户数据分配镜像内存。
本发明实施例中,可以将内核数据全部分配镜像内存,针对用户数据可以根据用户的需求进行设置,当用户指定某类型数据为关键用户数据时,则对该类型的数据设置镜像标识,为该类型的数据分配镜像内存。
可选地,在上述第一个可选实施例的基础上,本发明实施例提供的内存分配的方法的第二个可选实施例中,所述方法还可以包括:
当所述待分配内存的数据为所述关键用户数据时,确定同一进程数据是否存储在所述初始镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;
若所述同一进程数据未存储到所述镜像内存中,则将所述同一进程数据转移到所述初始镜像内存中。
本发明实施例中,是针对正在进行中的进程设置镜像标记的情况,例如:用户正在编辑的一个word文档,文档编辑一部分后,用户才指定该word文档为关键用户数据,则针对该word文档的数据已编辑的一部分已经分配了普通内存,在用户指定后再编辑的部分则会分配镜像内存,这样就可以将普通内存中的在先数据也转移到镜像内存中。
可选地,在上述图2对应的实施例或任一可选实施例的基础上,本发明实施例提供的内存分配的方法的第三个可选实施例中,所述从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存,可以包括:
确定所述待存储到镜像内存的数据所属的预划分内存资源区域;
从所述所属的预划分内存资源区域的未被占用的镜像内存中,为所述待存储到镜像内存的数据分配镜像内存。
本发明实施例是针对镜像内存分布在不同NUMA节点的情况,在本节点内分配镜像内存,可以避免跨节点访问内存,造成较大的延迟。
可选地,在上述图2对应的实施例或任一可选实施例的基础上,本发明实施例提供的内存分配的方法的第四个可选实施例中,所述从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存之后,所述方法还可以包括:
为所述待存储到镜像内存的数据所分配的镜像内存的地址区间设置已占用标记。
本发明实施例中,在镜像内存被占用后,要在备占用的镜像内存的地址区间上设置标记,这样,在分配进行内存时,就可以快速的查找到未被占用的镜像内存。
参阅图3,本发明实施例提供的内存分配的装置的一实施例包括:所述装置应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述装置20包括:
获取单元201,用于获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;
检测单元202,用于对待分配内存的数据进行检测;
分配单元203,用于当所述检测单元202检测到所述数据为待存储到镜像内存的数据时,从所述获取单元201获取的所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。
本发明实施例中提供的内存分配的装置,所述装置应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述装置20包括:获取单元201获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;检测单元202对待分配内存的数据进行检测;分配单元203当所述检测单元202检测到所述数据为待存储到镜像内存的数据时,从所述获取单元201获取的所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。与现有技术中操作系统无法感知到进行内存的变化,且在镜像内存大小有限的情况下,无法为需要分配镜像内存的数据分配镜像内存相比,本发明实施例提供的内存分配的装置,BOIS向所述OS提供镜像内存地址区间,从而可以准确的找到镜像内存,并为需要存储到镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率,而且提高了系统的可靠性。
可选地,在上述图3对应的实施例的基础上,参阅图4,本发明实施例提供的内存分配的装置的另一实施例中,所述装置20还包括:
第一设置单元204,用于在所述检测单元202对待分配内存的数据进行检测之前,为内核数据和关键用户数据设置镜像标识,所述关键用户数据为用户指定的需要镜像存储的数据;
所述检测单元202,用于检测所述待分配内存的数据是否携带有所述第一设置单元204设置的所述镜像标识;
所述分配单元203,用于当所述检测单元202检测到所述待分配内存的数据携带有所述镜像标识,确定所述待分配内存的数据为所述内核数据或所述关键用户数据,从所述未被占用的镜像内存中为所述内核数据或所述关键用户数据分配镜像内存。
可选地,在上述图4对应的实施例的基础上,参阅图5,本发明实施例提供 的内存分配的装置的另一实施例中,所述装置20还包括:
确定单元205,用于当所述待分配内存的数据为所述设置单元204设置的关键用户数据时,确定同一进程数据是否存储在所述初始镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;
转移单元206,用于当所述确定单元205确定所述同一进程数据未存储到所述镜像内存中时,则将所述同一进程数据转移到所述初始镜像内存中。
可选地,在上述图3对应的实施例的基础上,参阅图6,本发明实施例提供的内存分配的装置的另一实施例中,所述分配单元203包括:
确定子单元2031,用于确定所述待存储到镜像内存的数据所属的预划分内存资源区域;
分配子单元2032,用于从所述确定子单元2021确定的所属的预划分内存资源区域的未被占用的镜像内存中,为所述待存储到镜像内存的数据分配镜像内存。
可选地,在上述图3对应的实施例的基础上,参阅图7,本发明实施例提供的内存分配的装置的另一实施例中,所述装置20还包括:
第二设置单元207,用于在所述分配单元203分配镜像内存后,为所述待存储到镜像内存的数据所分配的镜像内存的地址区间设置已占用标记。
图8是本发明实施例内存分配设备40的结构示意图。内存分配设备40可包括输入/输出设备410、处理器430和存储器440。
存储器440可以包括只读存储器和随机存取存储器,并向处理器430提供指令和数据。存储器440的一部分还可以包括非易失性随机存取存储器(NVRAM)。
存储器440存储了如下的元素,可执行模块或者数据结构,或者它们的子集,或者它们的扩展集:
操作指令:包括各种操作指令,用于实现各种操作。
操作系统:包括各种系统程序,用于实现各种基础业务以及处理基于硬件的任务。
所述内存分配设备应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,在本发明实施例中,处理器430通过调用存储器440存储的操作指令(该操作指令可存储在操作系统中),执行如下操作:
获取所述初始镜像内存中未被占用的镜像内存,所述初始镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存;
对待分配内存的数据进行检测;
当检测到所述数据为待存储到镜像内存的数据时,从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存。
本发明实施例中,内存分配设备40的BOIS向所述OS提供镜像内存地址区间,从而可以准确的找到镜像内存,并为需要存储到镜像内存的数据分配镜像内存,从而保证的有限镜像内存的使用效率,而且提高了系统的可靠性。
处理器430控制内存分配设备40的操作,处理器430还可以称为CPU(Central Processing Unit,中央处理单元)。存储器440可以包括只读存储器和随机存取存储器,并向处理器430提供指令和数据。存储器440的一部分还可以包括非易失性随机存取存储器(NVRAM)。具体的应用中,内存分配设备40的各个组件通过总线系统450耦合在一起,其中总线系统450除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都标为总线系统450。
上述本发明实施例揭示的方法可以应用于处理器430中,或者由处理器430实现。处理器430可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器430中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器430可以是通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬 件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器440,处理器430读取存储器440中的信息,结合其硬件完成上述方法的步骤。
可选地,所述处理器430还用于为内核数据和关键用户数据设置镜像标识,所述关键用户数据为用户指定的需要镜像存储的数据;检测所述待分配内存的数据是否携带有所述镜像标识;当检测到所述待分配内存的数据携带有所述镜像标识,确定所述待分配内存的数据为所述内核数据或所述关键用户数据,从所述未被占用的镜像内存中为所述内核数据或所述关键用户数据分配镜像内存。
可选地,所述处理器430还用于当所述待分配内存的数据为所述关键用户数据时,确定同一进程数据是否存储在所述初始镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;若所述同一进程数据未存储到所述镜像内存中,则将所述同一进程数据转移到所述初始镜像内存中。
可选地,所述处理器430具体用于确定所述待存储到镜像内存的数据所属的预划分内存资源区域;从所述所属的预划分内存资源区域的未被占用的镜像内存中,为所述待存储到镜像内存的数据分配镜像内存。
可选地,所述处理器430还用于从所述未被占用的镜像内存中为所述待存储到镜像内存的数据分配镜像内存之后,为所述待存储到镜像内存的数据所分配的镜像内存的地址区间设置已占用标记。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件(例如处理器)来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:ROM、RAM、磁盘或光盘等。
以上对本发明实施例所提供的媒体流信息更新的方法、装置以及系统进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于 本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。

Claims (15)

  1. 一种内存分配的方法,其特征在于,所述方法应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:
    检测待分配内存的数据是否携带有镜像标识,所述镜像标识设置在内核数据和关键用户数据上,所述关键用户数据为用户数据中用户指定的需要镜像存储的数据;
    当检测到所述待分配内存的数据携带有所述镜像标识时,从镜像内存中未被占用的部分为所述待分配内存的数据分配内存,其中,镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    当所述待分配内存的数据为所述关键用户数据时,确定同一进程数据是否存储在所述镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;
    若所述同一进程数据未存储到所述镜像内存中,则将所述同一进程数据转移到所述镜像内存中。
  3. 根据权利要求1或2所述的方法,其特征在于,所述从镜像内存中未被占用的部分为所述待分配内存的数据分配内存,包括:
    确定所述待分配内存的数据所属的预划分内存资源区域,每个区域对应一段或多段镜像内存;
    从所述待分配内存的数据所属的预划分内存资源区域对应的镜像内存中未被占用的部分,为所述待存储到镜像内存的数据分配镜像内存。
  4. 根据权利要求1-3任一所述的方法,其特征在于,所述方法还包括:
    为已分配的镜像内存的地址区间设置已占用标记。
  5. 一种内存分配的装置,其特征在于,所述装置应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,所述装置包括:
    检测单元,用于检测待分配内存的数据是否携带有镜像标识,所述镜像标识设置在内核数据和关键用户数据上,所述关键用户数据为用户数据中用户指 定的需要镜像存储的数据;
    分配单元,用于当检测到所述待分配内存的数据携带有所述镜像标识时,从镜像内存中未被占用的部分为所述待分配内存的数据分配内存,其中,所述镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存。
  6. 根据权利要求5所述的装置,其特征在于,所述装置还包括:
    确定单元,用于当所述待分配内存的数据为所述关键用户数据时,确定同一进程数据是否存储在所述初始镜像内存中,所述同一进程数据为在所述关键用户数据之前由产生所述关键用户数据的同一进程所产生的数据;
    转移单元,用于当所述确定单元确定所述同一进程数据未存储到所述镜像内存中时,则将所述同一进程数据转移到所述初始镜像内存中。
  7. 根据权利要求5或6所述的装置,其特征在于,所述分配单元包括:
    确定子单元,用于当检测到所述待分配内存的数据携带有所述镜像标识时,确定所述待分配内存的数据所对应的预划分内存资源区域,每个区域对应一段或多段镜像内存;
    分配子单元,用于从所述待分配内存的数据所属的预划分内存资源区域对应的镜像内存中未被占用的部分,为所述待存储到镜像内存的数据分配镜像内存。
  8. 根据权利要求5-7任一所述的装置,其特征在于,所述装置还包括:
    第二设置单元,用于为已分配的镜像内存的地址区间设置已占用标记。
  9. 一种内存分配的方法,其特征在于,所述方法应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,在所述操作系统运行时,所述方法包括:
    对待分配内存的数据进行检测;当检测到待分配内存的数据为待存储到镜像内存的数据时,确定所述待分配内存的数据所对应的预划分内存区域,从所述待分配内存的数据所属的预划分内存区域对应的一段或多段镜像内存中未被占用的部分为所述待存储到镜像内存的数据分配镜像内存,其中镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存。
  10. 根据权利要求9所述的方法,其特征在于,所述确定所述待分配内存的数据所对应的预划分内存区域,从所述待分配内存的数据所属的预划分内存区域对应的一段或多段镜像内存中未被占用的部分为所述待存储到镜像内存的数据分配镜像内存,包括:
    确定所述待分配内存的数据所对应的节点,从属于所述待分配内存的数据所对应的节点的镜像内存中未被占用的部分为所述待分配内存的数据分配镜像内存。
  11. 根据权利要求10所述的方法,其特征在于,所有节点按照非一致性内存访问NUMA架构划分,每个节点包括一段或多段镜像内存。
  12. 一种内存分配的装置,其特征在于,所述装置应用于计算机系统中,所述计算机系统包括内存资源、基本输入输出系统BOIS和操作系统OS,所述内存资源中包含初始镜像内存,所述装置包括:
    用于对待分配内存的数据进行检测的单元;
    用于当检测到待分配内存的数据为待存储到镜像内存的数据时,确定所述待分配内存的数据所对应的预划分内存区域,从所述待分配内存的数据所属的预划分内存区域对应的一段或多段镜像内存中未被占用的部分为所述待存储到镜像内存的数据分配镜像内存的单元,其中镜像内存为在所述OS初始化时所述BOIS向所述OS提供的镜像内存地址区间所指示的镜像内存。
  13. 根据权利要求12所述的方法,其特征在于,所述用于当检测到待分配内存的数据为待存储到镜像内存的数据时,确定所述待分配内存的数据所对应的预划分内存区域,从所述待分配内存的数据所属的预划分内存区域对应的一段或多段镜像内存中未被占用的部分为所述待存储到镜像内存的数据分配镜像内存的单元用于:确定所述待分配内存的数据所对应的节点,从属于所述待分配内存的数据所对应的节点的镜像内存中未被占用的部分为所述待分配内存的数据分配镜像内存。
  14. 根据权利要求13所述的方法,其特征在于,所有节点按照非一致性内存访问NUMA架构划分,每个节点包括一段或多段镜像内存。
  15. 根据权利要求14所述的方法,其特征在于,每段镜像内存均由镜像内存管理区MIRROR ZONE跟踪和管理,每个节点对应一个或多个MIRROR  ZONE。
PCT/CN2015/089796 2014-09-16 2015-09-16 一种内存分配的方法及装置 WO2016041501A1 (zh)

Priority Applications (6)

Application Number Priority Date Filing Date Title
JP2017512349A JP6478430B2 (ja) 2014-09-16 2015-09-16 メモリ割当て方法および装置
BR112017001965-5A BR112017001965B1 (pt) 2014-09-16 2015-09-16 Método de alocação de memória, aparelho e sistema de computador
EP15841888.9A EP3171276B1 (en) 2014-09-16 2015-09-16 Memory allocation method and device
KR1020177004358A KR101996975B1 (ko) 2014-09-16 2015-09-16 메모리 할당 방법 및 장치
US15/460,132 US10353609B2 (en) 2014-09-16 2017-03-15 Memory allocation method and apparatus
US16/425,872 US10990303B2 (en) 2014-09-16 2019-05-29 Memory allocation method and apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410471145.XA CN104252419B (zh) 2014-09-16 2014-09-16 一种内存分配的方法及装置
CN201410471145.X 2014-09-16

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/460,132 Continuation US10353609B2 (en) 2014-09-16 2017-03-15 Memory allocation method and apparatus

Publications (1)

Publication Number Publication Date
WO2016041501A1 true WO2016041501A1 (zh) 2016-03-24

Family

ID=52187342

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/089796 WO2016041501A1 (zh) 2014-09-16 2015-09-16 一种内存分配的方法及装置

Country Status (6)

Country Link
US (2) US10353609B2 (zh)
EP (1) EP3171276B1 (zh)
JP (1) JP6478430B2 (zh)
KR (1) KR101996975B1 (zh)
CN (1) CN104252419B (zh)
WO (1) WO2016041501A1 (zh)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104252419B (zh) 2014-09-16 2017-09-19 华为技术有限公司 一种内存分配的方法及装置
CN106648938B (zh) * 2016-12-30 2021-01-12 苏州浪潮智能科技有限公司 一种Linux系统应用程序内存管理方法及系统
CN107704399B (zh) * 2017-08-16 2021-01-29 华为技术有限公司 一种存储数据的方法和装置
CN110262893B (zh) 2019-05-16 2021-08-20 华为技术有限公司 配置镜像内存的方法、装置及计算机存储介质
US11294692B2 (en) * 2020-07-27 2022-04-05 Dell Products L.P. Basic input output system (BIOS)—identified memory size and node address range mirroring system
CN114090223A (zh) * 2020-08-24 2022-02-25 北京百度网讯科技有限公司 访存请求调度方法、装置、设备以及存储介质
JP2022080687A (ja) * 2020-11-18 2022-05-30 キヤノン株式会社 情報処理装置、情報処理装置の制御方法及びプログラム
US11734176B2 (en) * 2021-10-27 2023-08-22 Dell Products L.P. Sub-NUMA clustering fault resilient memory system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080140961A1 (en) * 2006-12-07 2008-06-12 Atherton William E Single channel memory mirror
CN103136110A (zh) * 2013-02-18 2013-06-05 华为技术有限公司 内存管理方法、内存管理装置及numa系统
CN103389884A (zh) * 2013-07-29 2013-11-13 华为技术有限公司 处理输入/输出请求的方法、宿主机、服务器和虚拟机
CN103530241A (zh) * 2013-09-24 2014-01-22 创新科存储技术(深圳)有限公司 一种用户态的双控内存镜像实现方法
CN104252419A (zh) * 2014-09-16 2014-12-31 杭州华为数字技术有限公司 一种内存分配的方法及装置

Family Cites Families (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5651133A (en) * 1995-02-01 1997-07-22 Hewlett-Packard Company Methods for avoiding over-commitment of virtual capacity in a redundant hierarchic data storage system
US6546472B2 (en) * 2000-12-29 2003-04-08 Hewlett-Packard Development Company, L.P. Fast suspend to disk
US7028215B2 (en) * 2002-05-03 2006-04-11 Hewlett-Packard Development Company, L.P. Hot mirroring in a computer system with redundant memory subsystems
US20050216552A1 (en) * 2004-03-24 2005-09-29 Samuel Fineberg Communication-link-attached persistent memory system
US20070214333A1 (en) * 2006-03-10 2007-09-13 Dell Products L.P. Modifying node descriptors to reflect memory migration in an information handling system with non-uniform memory access
US20090006793A1 (en) * 2007-06-30 2009-01-01 Koichi Yamada Method And Apparatus To Enable Runtime Memory Migration With Operating System Assistance
CN101470667A (zh) 2007-12-28 2009-07-01 英业达股份有限公司 Linux系统平台上指定地址范围分配物理内存的方法
JP2009199478A (ja) * 2008-02-25 2009-09-03 Hitachi Ltd メモリミラーリング自動構成制御方式
US8151138B2 (en) * 2008-10-31 2012-04-03 Dell Products L.P. Redundant memory architecture management methods and systems
CN101937400B (zh) * 2009-06-29 2012-07-25 联想(北京)有限公司 管理热备份内存的方法和电子设备
CN101604263A (zh) 2009-07-13 2009-12-16 浪潮电子信息产业股份有限公司 一种实现操作系统核心代码段多副本运行的方法
TWI460588B (zh) 2009-07-17 2014-11-11 Toshiba Kk Memory management device and memory information processing device
JP2011186563A (ja) * 2010-03-04 2011-09-22 Toshiba Corp メモリ管理装置およびメモリ管理方法
US8090977B2 (en) * 2009-12-21 2012-01-03 Intel Corporation Performing redundant memory hopping
US8335908B2 (en) * 2010-07-01 2012-12-18 Arm Limited Data processing apparatus for storing address translations
CN101901174B (zh) 2010-07-28 2012-07-18 西安交通大学 基于代码段多副本对比机制提高程序可靠性方法
JP2012043246A (ja) * 2010-08-20 2012-03-01 Canon Inc 情報処理装置、情報処理装置の制御方法、及び、プログラム
US8601310B2 (en) * 2010-08-26 2013-12-03 Cisco Technology, Inc. Partial memory mirroring and error containment
WO2011127862A2 (zh) 2011-05-20 2011-10-20 华为技术有限公司 多线程访问多副本的方法和装置
US8898408B2 (en) * 2011-12-12 2014-11-25 Dell Products L.P. Memory controller-independent memory mirroring
US9037903B2 (en) 2012-12-28 2015-05-19 Intel Corporation Apparatus and method for partial memory mirroring
CN103198028B (zh) 2013-03-18 2015-12-23 华为技术有限公司 一种内存数据迁移方法、装置及系统
CN103324582A (zh) * 2013-06-17 2013-09-25 华为技术有限公司 一种内存迁移方法、装置及设备
US9411695B2 (en) * 2013-12-04 2016-08-09 Lenovo Enterprise Solutions (Singapore) Pte. Ltd. Provisioning memory in a memory system for mirroring
US9753662B1 (en) * 2016-09-26 2017-09-05 International Business Machines Corporation Using mirror indicators to determine whether to mirror tracks in a data set in a primary volume mirrored to a secondary volume

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080140961A1 (en) * 2006-12-07 2008-06-12 Atherton William E Single channel memory mirror
CN103136110A (zh) * 2013-02-18 2013-06-05 华为技术有限公司 内存管理方法、内存管理装置及numa系统
CN103389884A (zh) * 2013-07-29 2013-11-13 华为技术有限公司 处理输入/输出请求的方法、宿主机、服务器和虚拟机
CN103530241A (zh) * 2013-09-24 2014-01-22 创新科存储技术(深圳)有限公司 一种用户态的双控内存镜像实现方法
CN104252419A (zh) * 2014-09-16 2014-12-31 杭州华为数字技术有限公司 一种内存分配的方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3171276A4 *

Also Published As

Publication number Publication date
EP3171276B1 (en) 2020-12-16
KR20170031230A (ko) 2017-03-20
JP6478430B2 (ja) 2019-03-06
BR112017001965A2 (pt) 2017-11-21
US20190278499A1 (en) 2019-09-12
US10353609B2 (en) 2019-07-16
CN104252419B (zh) 2017-09-19
KR101996975B1 (ko) 2019-07-05
EP3171276A4 (en) 2017-08-23
JP2017531252A (ja) 2017-10-19
EP3171276A1 (en) 2017-05-24
CN104252419A (zh) 2014-12-31
US20170185340A1 (en) 2017-06-29
US10990303B2 (en) 2021-04-27

Similar Documents

Publication Publication Date Title
WO2016041501A1 (zh) 一种内存分配的方法及装置
WO2018010654A1 (zh) 一种虚拟机热迁移的方法、装置及系统
US9672075B2 (en) Method, apparatus, and system for implementing hot migration of virtual machine
JP5262404B2 (ja) 複合型計算機及び複合型計算機の制御方法
US9354907B1 (en) Optimized restore of virtual machine and virtual disk data
CN103198028A (zh) 一种内存数据迁移方法、装置及系统
US20070214333A1 (en) Modifying node descriptors to reflect memory migration in an information handling system with non-uniform memory access
US20160266923A1 (en) Information processing system and method for controlling information processing system
CN104111897A (zh) 一种数据处理方法、装置及计算机系统
JP2017227969A (ja) 制御プログラム、システム、及び方法
US20170090964A1 (en) Post-copy virtual machine migration with assigned devices
US20170123998A1 (en) Efficient reclamation of pre-allocated direct memory access (dma) memory
US20180150232A1 (en) Memory overcommit by speculative fault
EP3304294A1 (en) Method and system for allocating resources for virtual hosts
US10061528B2 (en) Disk assignment for multiple distributed computing clusters in a virtualized computing environment
US20170277632A1 (en) Virtual computer system control method and virtual computer system
US9015418B2 (en) Self-sizing dynamic cache for virtualized environments
CN113760457A (zh) 一种虚拟机资源分配方法、装置、电子设备及存储介质
JP6476959B2 (ja) ストレージ制御装置、ストレージシステム、および制御プログラム
US20160019150A1 (en) Information processing device, control method of information processing device and control program of information processing device
US10976934B2 (en) Prioritizing pages to transfer for memory sharing
WO2017054636A1 (zh) 虚拟快照处理方法及装置
US9753670B2 (en) Prioritizing memory pages to copy for memory migration
WO2016013098A1 (ja) 物理計算機及び仮想計算機移行方法
US20230004417A1 (en) Method and apparatus to select assignable device interfaces for virtual device composition

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

Country of ref document: EP

Kind code of ref document: A1

REEP Request for entry into the european phase

Ref document number: 2015841888

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2015841888

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 20177004358

Country of ref document: KR

Kind code of ref document: A

REG Reference to national code

Ref country code: BR

Ref legal event code: B01A

Ref document number: 112017001965

Country of ref document: BR

ENP Entry into the national phase

Ref document number: 2017512349

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 112017001965

Country of ref document: BR

Kind code of ref document: A2

Effective date: 20170130