WO2023160397A1 - Memory management methods and apparatuses - Google Patents

Memory management methods and apparatuses Download PDF

Info

Publication number
WO2023160397A1
WO2023160397A1 PCT/CN2023/075100 CN2023075100W WO2023160397A1 WO 2023160397 A1 WO2023160397 A1 WO 2023160397A1 CN 2023075100 W CN2023075100 W CN 2023075100W WO 2023160397 A1 WO2023160397 A1 WO 2023160397A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
memory block
released
type
virtual machine
Prior art date
Application number
PCT/CN2023/075100
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 阿里巴巴(中国)有限公司
Publication of WO2023160397A1 publication Critical patent/WO2023160397A1/en

Links

Classifications

    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • 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/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

Provided in the embodiments of the present description are memory management methods and apparatuses. One memory management method comprises: receiving a memory release request in respect of a target virtual machine; in response to the memory release request, determining at least one memory block to be released corresponding to the target virtual machine, and determining memory block attribute information corresponding to each memory block to be released; determining a memory block to be released, the attribute information of which is of a first type, as a first-type memory block to be released; and releasing the memory of the first-type memory block to be released by adjusting refresh configuration parameters of the first-type memory block to be released. By means of the method, release and clearing of the memory can be rapidly completed by controlling the refreshing frequency of the first-type memory block to be released. In addition, the mode of adjusting the refreshing frequency of the memory block to be released occupies few resources and has little influence on other running virtual machines.

Description

内存管理方法以及装置Memory management method and device
本申请要求于2022年02月25日提交中国专利局、申请号为202210180906.0、申请名称为“内存管理方法以及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202210180906.0 and the application name "memory management method and device" submitted to the China Patent Office on February 25, 2022, the entire contents of which are incorporated in this application by reference.
技术领域technical field
本说明书实施例涉及计算机技术领域,特别涉及内存管理方法。The embodiments of this specification relate to the technical field of computers, and in particular to memory management methods.
背景技术Background technique
在基于虚拟化技术的云计算场景中,虚拟机在关机时为了保证数据安全,其使用的内存需要进行释放清零处理,在内存释放清零的过程中,需要占用宿主机的处理器算力和内存带宽资源,随着云计算技术的高速发展,目前虚拟机的内存规格越来越大,当关闭某个虚拟机时,相应的内存释放清零的时延和较高的资源占用均会对其他正在使用的虚拟机造成较大的影响。In a cloud computing scenario based on virtualization technology, in order to ensure data security when the virtual machine is shut down, the memory used by it needs to be released and cleared. and memory bandwidth resources. With the rapid development of cloud computing technology, the memory specifications of virtual machines are getting larger and larger. When a virtual machine is shut down, the corresponding memory release and clearing delay and high resource usage will be It has a greater impact on other virtual machines in use.
发明内容Contents of the invention
有鉴于此,本说明书施例提供了内存管理方法。本说明书一个或者多个实施例同时涉及内存管理装置,一种计算设备,一种计算机可读存储介质以及一种计算机程序,以解决现有技术中存在的技术缺陷。In view of this, the embodiment of this specification provides a memory management method. One or more embodiments of this specification also relate to a memory management device, a computing device, a computer-readable storage medium and a computer program, so as to solve technical defects existing in the prior art.
根据本说明书实施例的第一方面,提供了一种内存管理方法,包括:According to the first aspect of the embodiments of this specification, a memory management method is provided, including:
接收针对目标虚拟机的内存释放请求;Receive a memory release request for the target virtual machine;
响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;Determining at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determining memory block attribute information corresponding to each memory block to be released;
确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块,其中,第一类型的待释放内存块为完整内存块;Determining that the memory block attribute information is the first type of memory block to be released is the first type of memory block to be released, wherein the first type of memory block to be released is a complete memory block;
通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。The memory of the first type of memory block to be released is released by adjusting the refresh configuration parameters of the first type of memory block to be released.
根据本说明书实施例的第二方面,提供了一种内存管理方法,包括:According to the second aspect of the embodiments of this specification, a memory management method is provided, including:
接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息;receiving a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
获取空闲内存块数量和空闲内存块属性信息;Obtain the number of free memory blocks and attribute information of free memory blocks;
根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,其中,第一类型的空闲内存块为完整内存块。Allocating a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block, wherein the first type of free memory block is a complete memory block .
根据本说明书实施例的第三方面,提供了一种内存管理装置,包括:According to a third aspect of the embodiments of this specification, a memory management device is provided, including:
接收模块,被配置为接收针对目标虚拟机的内存释放请求;a receiving module configured to receive a memory release request for the target virtual machine;
响应模块,被配置为响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待 释放内存块,并确定每个待释放内存块对应的内存块属性信息;A response module, configured to determine at least one waiting memory corresponding to the target virtual machine in response to the memory release request Release the memory block, and determine the memory block attribute information corresponding to each memory block to be released;
确定模块,被配置为确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块,其中,第一类型的待释放内存块为完整内存块;The determining module is configured to determine that the attribute information of the memory block is that the first type of memory block to be released is the first type of memory block to be released, wherein the first type of memory block to be released is a complete memory block;
释放模块,被配置为通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。The release module is configured to release the memory of the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released.
根据本说明书实施例的第四方面,提供了一种内存管理装置,包括:According to a fourth aspect of the embodiments of this specification, a memory management device is provided, including:
分配请求接收模块,被配置为接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息;An allocation request receiving module configured to receive a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
信息获取模块,被配置以为获取空闲内存块数量和空闲内存块属性信息;An information acquisition module configured to acquire the number of free memory blocks and attribute information of the free memory blocks;
分配模块,被配置为根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,其中,第一类型的空闲内存块为完整内存块。An allocation module configured to allocate a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block, wherein the first type of free memory block A memory block is a complete memory block.
根据本说明书实施例的第五方面,提供了一种计算设备,包括:According to a fifth aspect of the embodiments of this specification, a computing device is provided, including:
存储器和处理器;memory and processor;
所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令,该计算机可执行指令被处理器执行时实现上述内存管理方法的步骤。The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above memory management method are implemented.
根据本说明书实施例的第六方面,提供了一种计算机可读存储介质,其存储有计算机可执行指令,该指令被处理器执行时实现上述内存管理方法的步骤。According to a sixth aspect of the embodiments of the present specification, there is provided a computer-readable storage medium, which stores computer-executable instructions, and implements the steps of the memory management method above when the instructions are executed by a processor.
根据本说明书实施例的第七方面,提供了一种计算机程序,其中,当所述计算机程序在计算机中执行时,令计算机执行上述内存管理方法的步骤。According to a seventh aspect of the embodiments of the present specification, a computer program is provided, wherein, when the computer program is executed in a computer, it causes the computer to execute the steps of the memory management method above.
本说明书一个实施例实现了接收针对目标虚拟机的内存释放请求;响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块;通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。通过本方法,可以通过控制第一类待释放内存块的刷新频率的方式,快速完成内存的释放清零,同时通过调整待释放内存块的刷新频率的方式占用资源少,对其他正在运行的虚拟机影响较小。An embodiment of this specification realizes receiving a memory release request for a target virtual machine; determining at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determining the memory corresponding to each memory block to be released Block attribute information; determine that the memory block attribute information is the first type of memory block to be released as the first type of memory block to be released; release the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released The memory of the memory block. Through this method, by controlling the refresh frequency of the first type of memory blocks to be released, the release and clearing of the memory can be quickly completed, and at the same time, by adjusting the refresh frequency of the memory blocks to be released, less resources are occupied, and other running virtual machine is less affected.
附图说明Description of drawings
图1是本说明书一个实施例提供的一种内存管理方法的流程图;FIG. 1 is a flowchart of a memory management method provided by an embodiment of this specification;
图2是本说明书另一个实施例提供的一种内存管理方法的流程图;Fig. 2 is a flow chart of a memory management method provided by another embodiment of this specification;
图3是本说明书一个实施例提供的一种应用于虚拟机M分配内存的内存管理方法的处理过程流程图;FIG. 3 is a flow chart of the processing process of a memory management method applied to a virtual machine M to allocate memory provided by an embodiment of the present specification;
图4是本说明书一个实施例提供的一种应用于虚拟机M释放内存的内存管理方法的处理过程流程图;FIG. 4 is a flow chart of a processing process of a memory management method applied to a virtual machine M to release memory provided by an embodiment of this specification;
图5是本说明书一个实施例提供的一种内存管理装置的结构示意图;Fig. 5 is a schematic structural diagram of a memory management device provided by an embodiment of this specification;
图6是本说明书另一个实施例提供的一种内存管理装置的结构示意图; Fig. 6 is a schematic structural diagram of a memory management device provided by another embodiment of this specification;
图7是本说明书一个实施例提供的一种计算设备的结构框图。Fig. 7 is a structural block diagram of a computing device provided by an embodiment of this specification.
具体实施方式Detailed ways
在下面的描述中阐述了很多具体细节以便于充分理解本说明书。但是本说明书能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本说明书内涵的情况下做类似推广,因此本说明书不受下面公开的具体实施的限制。In the following description, numerous specific details are set forth in order to provide a thorough understanding of the specification. However, this specification can be implemented in many other ways different from those described here, and those skilled in the art can make similar extensions without violating the connotation of this specification, so this specification is not limited by the specific implementations disclosed below.
在本说明书一个或多个实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本说明书一个或多个实施例。在本说明书一个或多个实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本说明书一个或多个实施例中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。Terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only, and are not intended to limit one or more embodiments of this specification. As used in one or more embodiments of this specification and the appended claims, the singular forms "a", "the", and "the" are also intended to include the plural forms unless the context clearly dictates otherwise. It should also be understood that the term "and/or" used in one or more embodiments of the present specification refers to and includes any or all possible combinations of one or more associated listed items.
应当理解,尽管在本说明书一个或多个实施例中可能采用术语第一、第二等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本说明书一个或多个实施例范围的情况下,第一也可以被称为第二,类似地,第二也可以被称为第一。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present specification, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, the first may also be referred to as the second, and similarly, the second may also be referred to as the first without departing from the scope of one or more embodiments of the present specification. Depending on the context, the word "if" as used herein may be interpreted as "at" or "when" or "in response to a determination."
首先,对本说明书一个或多个实施例涉及的名词术语进行解释。First, terms and terms involved in one or more embodiments of this specification are explained.
RAM:(Random access memory)动态随机存取存储器,又称为内存。RAM: (Random access memory) dynamic random access memory, also known as memory.
Bank:(内存芯片内的存储子块,每个子块具有多个字线,每一字线连接多个数据存储单元。如一个8G的内存,如果有8个Bank,则每个Bank的大小为1G,一个内存上的Bank共享一个内存的IO。每个Bank内的读写可以并行处理。Bank: (the storage sub-block in the memory chip, each sub-block has multiple word lines, and each word line is connected to multiple data storage units. For example, if there are 8 Banks in an 8G memory, the size of each Bank is 1G, the Bank on one memory shares the IO of one memory. The reading and writing in each Bank can be processed in parallel.
刷新:内存需要周期性(数毫秒内)刷新一次,否则保存在内存中的数据会丢失。Refresh: The memory needs to be refreshed periodically (within a few milliseconds), otherwise the data stored in the memory will be lost.
部分阵列自刷新:(Partial Array Self Refresh,PASR),一种内存控制器技术,可配置每个存储子块的自刷新参数,能够完全独立刷新存储器子块。Partial Array Self Refresh: (Partial Array Self Refresh, PASR), a memory controller technology that can configure the self-refresh parameters of each memory sub-block, and can refresh the memory sub-blocks completely independently.
PASR内存控制器驱动:运行在操作系统内核中,提供访问内存控制器中控制寄存器来动态调整内存块的刷新设置。PASR memory controller driver: It runs in the kernel of the operating system and provides access to the control registers in the memory controller to dynamically adjust the refresh settings of the memory block.
在基于虚拟化技术的云计算场景中,虚拟机在关机时为了保证数据安全,其使用的内存需要由Hypervisor进行清零处理,内存清零需要占用宿主机大量的CPU算力、内存带宽资源,随着云计算技术的发展,目前虚拟机的内存规格越来越大,单次清零需要更长的时延和更高的资源占用,因此,大规格的虚拟机在关机时的内存清零操作会对其他正在使用的虚拟机造成的影响也越来越大,如影响因内存不释放导致新虚拟机调度失败,宿主机清零任务与其他虚拟机争抢资源等问题,因此,如何高效低消耗的对内存清零就越来越重要。 In a cloud computing scenario based on virtualization technology, in order to ensure data security when a virtual machine is shut down, the memory used by it needs to be cleared by the Hypervisor. Memory clearing requires a large amount of CPU computing power and memory bandwidth resources of the host machine. With the development of cloud computing technology, the memory specifications of virtual machines are getting larger and larger, and a single reset requires longer delay and higher resource usage. Therefore, the memory of large-scale virtual machines is cleared when it is shut down. The impact of the operation on other virtual machines in use is also increasing, such as the failure of new virtual machine scheduling due to memory not being released, and the clearing task of the host machine competing for resources with other virtual machines. Therefore, how to efficiently It is more and more important to clear memory with low consumption.
在本说明书中,提供了内存管理方法,本说明书同时涉及内存管理装置,一种计算设备,以及一种计算机可读存储介质,在下面的实施例中逐一进行详细说明。In this specification, a memory management method is provided. This specification also relates to a memory management device, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
参见图1,图1示出了根据本说明书一个实施例提供的一种内存管理方法的流程图,具体包括以下步骤。Referring to FIG. 1 , FIG. 1 shows a flow chart of a memory management method provided according to an embodiment of the present specification, which specifically includes the following steps.
步骤102:接收针对目标虚拟机的内存释放请求。Step 102: Receive a memory release request for the target virtual machine.
其中,目标虚拟机具体是指需要执行内存释放清零的虚拟机,虚拟机运行于宿主机中,占用宿主机的CPU、内存等资源。内存释放请求具体是指对目标虚拟机占用内存进行释放清零的请求,对虚拟机占用的内存进行释放,具体是指将虚拟机占用的内存清零。Wherein, the target virtual machine specifically refers to a virtual machine that needs to perform memory release and clearing, and the virtual machine runs in the host machine and occupies resources such as CPU and memory of the host machine. The memory release request specifically refers to a request for releasing and clearing the memory occupied by the target virtual machine, releasing the memory occupied by the virtual machine, and specifically refers to clearing the memory occupied by the virtual machine.
在实际应用中,当关闭一个虚拟机时,需要对该虚拟机占用的宿主机内存进行清零,则该虚拟机为目标虚拟机,接收到关机请求时,同时触发内存释放请求。In practical applications, when shutting down a virtual machine, the memory of the host machine occupied by the virtual machine needs to be cleared, then the virtual machine is the target virtual machine, and when a shutdown request is received, a memory release request is triggered at the same time.
在本说明书提供的一具体实施方式中,以宿主机的内存有16G为例,运行有4个虚拟机分别为虚拟机1、虚拟机2、虚拟机3和虚拟机4,此时,关闭虚拟机3,则虚拟机3为目标虚拟机,触发对虚拟机3占用宿主机内存的内存释放请求。In a specific implementation provided in this specification, take the host machine with 16G of memory as an example, and there are 4 virtual machines running: virtual machine 1, virtual machine 2, virtual machine 3, and virtual machine 4. At this time, close the virtual machine machine 3, the virtual machine 3 is the target virtual machine, and triggers a memory release request for the memory of the host machine occupied by the virtual machine 3.
步骤104:响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息。Step 104: Determine at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determine memory block attribute information corresponding to each memory block to be released.
其中,内存块即为Bank,Bank是内存上的存储子块,如果一个内存为8G,有8个Bank,则一个Bank为1G。Among them, the memory block is the Bank, and the Bank is the storage sub-block on the memory. If a memory is 8G and there are 8 Banks, then a Bank is 1G.
在实际应用中,一个虚拟机在宿主机中运行时,会占用宿主机的内存、CPU资源,例如,一个虚拟机正常运行需要4G内存,则需要从宿主机中分配4G的内存资源供虚拟机使用,更进一步的,这4G的内存资源是分布于宿主机内存上的Bank中的,当对该虚拟机执行关闭处理时,需要对该虚拟机占用的4G的内存资源进行释放,即需要对4G内存对应的Bank进行释放,这4G内存对应的Bank即为待释放内存块,由于现在虚拟机的内存规格越来越大,其占用宿主机内存的Bank也越来越多,具体一个虚拟机对应几个内存块跟实际应用为准。In practical applications, when a virtual machine runs in the host machine, it will occupy the memory and CPU resources of the host machine. For example, if a virtual machine needs 4G memory to run normally, it needs to allocate 4G memory resources from the host machine for the virtual machine. Use, further, the 4G memory resources are distributed in the Bank on the host memory, when the virtual machine is shut down, the 4G memory resources occupied by the virtual machine need to be released, that is, the The Bank corresponding to the 4G memory is released. The Bank corresponding to the 4G memory is the memory block to be released. Since the memory specification of the virtual machine is getting larger and larger, it occupies more and more banks of the host memory. Specifically, a virtual machine The number of memory blocks corresponding to the actual application shall prevail.
在本说明书提供的一具体实施方式中,沿用上例,宿主机的内存有16G,共有16个内存块(Bank),则每个Bank的内存容量是1G,虚拟机3占用了4G内存,根据内存释放请求确定虚拟机3对应的5个Bank,分别为Bank3,Bank4,Bank5,Bank6,Bank7。In a specific implementation provided in this manual, following the above example, the memory of the host machine is 16G, and there are 16 memory blocks (Banks) in total, and the memory capacity of each Bank is 1G, and the virtual machine 3 occupies 4G of memory. According to The memory release request determines the five banks corresponding to the virtual machine 3, namely Bank3, Bank4, Bank5, Bank6, and Bank7.
在实际应用中,每个内存块对应有地址解码器、列地址解码器,每个内存块对应有相应的物理地址,简单来说,对于一个8G内存,共有8个内存块,内存块1对应的物理地址为1-1G,内存块2对应的物理地址为1G-2G,……以此类推,因此,根据相应的物理地址即可确定对应的内存块。基于此,响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,包括:In practical applications, each memory block corresponds to an address decoder and a column address decoder, and each memory block corresponds to a corresponding physical address. In simple terms, for an 8G memory, there are 8 memory blocks in total, and memory block 1 corresponds to The physical address of memory block 2 is 1-1G, the physical address corresponding to memory block 2 is 1G-2G, ... and so on. Therefore, the corresponding memory block can be determined according to the corresponding physical address. Based on this, determining at least one memory block to be released corresponding to the target virtual machine in response to the memory release request includes:
响应于所述内存释放请求确定所述目标虚拟机对应的虚拟机物理地址区间;determining a virtual machine physical address range corresponding to the target virtual machine in response to the memory release request;
确定所述虚拟机物理地址区间对应的内存块为待释放内存块。Determine the memory block corresponding to the physical address range of the virtual machine as the memory block to be released.
在接收到内存释放请求后,可以确定目标虚拟机对应的虚拟机物理地址区间,虚拟机物理地址区间具体是指目标虚拟机在运行时所占用的物理地址范围,当虚拟机启动时,会 根据宿主机内存的使用情况,为虚拟机分配虚拟机物理地址区间,相应的,当接收到内存释放请求后,可以确定目标虚拟机对应的虚拟机物理地址区间,根据虚拟机物理地址区间,即可确定对应的内存块为待释放内存块。After receiving the memory release request, the virtual machine physical address range corresponding to the target virtual machine can be determined. The virtual machine physical address range specifically refers to the physical address range occupied by the target virtual machine when it is running. When the virtual machine starts, it will According to the memory usage of the host machine, the virtual machine physical address range is allocated to the virtual machine. Correspondingly, when the memory release request is received, the virtual machine physical address range corresponding to the target virtual machine can be determined. According to the virtual machine physical address range, that is It can be determined that the corresponding memory block is a memory block to be released.
需要注意的是,在实际应用中,由于应用环境的不同,目标虚拟机对应的虚拟机物理地址区间可能是多个,即一个目标虚拟机对应的虚拟机物理地址区间有多个,例如某个虚拟机对应的虚拟机物理地址区间为0-140M、895M-1348M、1972M-3451M……等等,因此,每个虚拟机物理地址区间可能会对应一个或多个内存块。从而可以根据虚拟机物理地址区间来确定至少一个待释放内存块。It should be noted that in actual applications, due to different application environments, there may be multiple virtual machine physical address intervals corresponding to the target virtual machine, that is, there are multiple virtual machine physical address intervals corresponding to a target virtual machine, for example, a certain The virtual machine physical address interval corresponding to the virtual machine is 0-140M, 895M-1348M, 1972M-3451M...etc., therefore, each virtual machine physical address interval may correspond to one or more memory blocks. Therefore, at least one memory block to be released can be determined according to the physical address range of the virtual machine.
在确定了至少一个待释放内存块之后,即可确定每个待释放内存块的内存块属性信息,在本说明书提供的实施例中,内存块的属性信息用于表述该待释放内存块是否属于目标虚拟机独占的,例如,如果某个内存块上只运行了目标虚拟机,则该内存块的属性信息为第一类型,如果某个内存块上除了运行目标虚拟机之外,还运行有其他虚拟机,则该内存块的内存块属性信息为第二类型。After at least one memory block to be released is determined, the memory block attribute information of each memory block to be released can be determined. In the embodiment provided in this specification, the attribute information of the memory block is used to express whether the memory block to be released belongs to Exclusive to the target virtual machine. For example, if only the target virtual machine is running on a certain memory block, the attribute information of the memory block is the first type. For other virtual machines, the memory block attribute information of the memory block is the second type.
具体的,确定每个待释放内存块对应的内存块属性信息,包括:Specifically, determine the memory block attribute information corresponding to each memory block to be released, including:
在所述至少一个待释放内存块中确定目标待释放内存块;determining a target memory block to be released in the at least one memory block to be released;
确定所述目标待释放内存块的内存块物理地址区间;Determine the physical address range of the memory block of the target memory block to be released;
判断所述内存块物理地址区间中是否存在不属于所述虚拟机物理地址区间的内存块物理地址;Judging whether there is a memory block physical address in the physical address range of the memory block that does not belong to the physical address range of the virtual machine;
若否,则确定所述目标待释放内存块的内存块属性信息为第一类型;If not, then determine that the memory block attribute information of the target memory block to be released is the first type;
若是,则确定所述目标待释放内存块的内存块属性信息为第二类型。If yes, determine that the memory block attribute information of the target memory block to be released is the second type.
在实际应用中,待释放内存块有至少一个,需要对每个待释放内存块进行判断,判断该待释放内存块的内存块属性信息,此时,正在被确定内存块属性信息的待释放内存块为目标待释放内存块。In practical applications, there is at least one memory block to be released, and each memory block to be released needs to be judged to determine the memory block attribute information of the memory block to be released. At this time, the memory block to be released whose attribute information is being determined is block is the target memory block to be freed.
在确定了目标待释放内存块后,即可确定该目标待释放内存块的内存块物理地址区间,该内存块物理地址区间具体是指该目标待释放内存块的起始物理地址和结束物理地址间的区间,该内存块物理地址区间是连续的。After the target memory block to be released is determined, the memory block physical address range of the target memory block to be released can be determined, and the memory block physical address range specifically refers to the start physical address and the end physical address of the target memory block to be released The physical address range of the memory block is continuous.
在获得目标待释放内存块的内存块物理区间后,即判断在内存块物理地址区间中是否存在有不属于虚拟机物理地址区间的内存块物理地址,若否,则说明在该目标待释放内存块中仅运行有目标虚拟机,则该目标待释放内存块的内存块属性信息为第一类型;若是,则说明在该目标待释放内存块中不仅运行有目标虚拟机,还运行有其他虚拟机,则可以确定该目标待释放内存块的内存块属性信息为第二类型。After obtaining the memory block physical interval of the target memory block to be released, it is judged whether there is a memory block physical address that does not belong to the physical address interval of the virtual machine in the memory block physical address interval. If only the target virtual machine runs in the block, the memory block attribute information of the target memory block to be released is the first type; if so, it means that not only the target virtual machine but also other virtual machines are running in the target memory block to be released. machine, it may be determined that the memory block attribute information of the target memory block to be released is the second type.
在本说明书提供的一具体实施方式中,沿用上例,虚拟机3对应5个Bank,分别为Bank3,Bank4,Bank5,Bank6,Bank7,虚拟机3的虚拟机物理地址区间为“add3700-add4000、add4000-add5000、add5000-add6000、add6000-add7000,add7200-add7800”,Bank3的内存块物理地址区间为add3000-add4000,Bank4的内存块物理地址区间为add4000-add5000,Bank5的内存块物理地址区间为add5000-add6000,Bank6的内存块物理地址区间为add6000-add7000,Bank7的内存块物理地址区间为add7000-add8000。 In a specific implementation method provided in this manual, following the above example, virtual machine 3 corresponds to five Banks, namely Bank3, Bank4, Bank5, Bank6, Bank7, and the virtual machine physical address range of virtual machine 3 is "add3700-add4000, add4000-add5000, add5000-add6000, add6000-add7000, add7200-add7800", the physical address range of the memory block of Bank3 is add3000-add4000, the physical address range of the memory block of Bank4 is add4000-add5000, and the physical address range of the memory block of Bank5 is add5000 -add6000, the physical address range of the memory block of Bank6 is add6000-add7000, and the physical address range of the memory block of Bank7 is add7000-add8000.
以Bank3为目标待释放内存块,在Bank3中,存在add3000-add3700的内存块物理地址是不属于虚拟机物理地址区间,因此,Bank3的内存块属性信息为第二类型;以Bank4为目标待释放内存块,在Bank4中add4000-add5000都是虚拟机3对应的虚拟机物理地址区间,因此,Bank4的内存块属性信息为第一类型……,依次类推,Bank3的内存块属性信息为第二类型,Bank4的内存块属性信息为第一类型,Bank5的内存块属性信息为第一类型,Bank6的内存块属性信息为第一类型,Bank7的内存块属性信息为第二类型。Bank3 is the target memory block to be released. In Bank3, the memory block physical address of add3000-add3700 does not belong to the physical address range of the virtual machine. Therefore, the memory block attribute information of Bank3 is the second type; Bank4 is the target to be released For the memory block, add4000-add5000 in Bank4 is the virtual machine physical address range corresponding to virtual machine 3, therefore, the memory block attribute information of Bank4 is the first type..., and so on, the memory block attribute information of Bank3 is the second type , the memory block attribute information of Bank4 is the first type, the memory block attribute information of Bank5 is the first type, the memory block attribute information of Bank6 is the first type, and the memory block attribute information of Bank7 is the second type.
步骤106:确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块。Step 106: Determine that the memory block whose attribute information is the first type to be released is the first type of memory block to be released.
在确定了内存块属性信息之后,即可根据内存块属性信息为每个待释放内存块进行分类,相应的,内存块属性信息为第一类型的待释放内存块为第一类待释放内存块;内存块属性信息为第二类型的待释放内存块为第二类待释放内存块。对于不同类型的待释放内存块可以处以不同的内存释放策略。具体的,第一类待释放内存块为完整内存块,第二类待释放内存块为共享内存块。After the attribute information of the memory block is determined, each memory block to be released can be classified according to the attribute information of the memory block. Correspondingly, the memory block to be released whose attribute information of the memory block is the first type is the first type of memory block to be released ; The attribute information of the memory block is that the memory block to be released of the second type is the memory block to be released of the second type. Different memory release policies may be implemented for different types of memory blocks to be released. Specifically, the first type of memory block to be released is a complete memory block, and the second type of memory block to be released is a shared memory block.
在本说明书提供的一具体实施方式中,沿用上例,Bank4,Bank5,Bank6为第一类待释放内存块,Bank3和Bank7为第二类待释放内存块。In a specific implementation manner provided in this specification, following the above example, Bank4, Bank5, and Bank6 are the first type of memory blocks to be released, and Bank3 and Bank7 are the second type of memory blocks to be released.
步骤108:通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。Step 108: Release the memory of the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released.
对于第一类待释放内存块可以通过第一内存释放策略,即通过调整第一类待释放内存块的刷新配置参数来对第一类待释放内存块的内存进行释放清零处理。For the first type of memory block to be released, the memory of the first type of memory block to be released can be released and cleared through the first memory release policy, that is, by adjusting the refresh configuration parameters of the first type of memory block to be released.
PASR(Partial Array Self Refresh)部分阵列自刷新,是一种内存控制技术,该技术可以配置每个内存块的自刷新时间,可以完全独立控制每个内存块。内存块需要周期性(数毫秒内)的进行刷新,如果超过周期没有刷新,则该内存块的数据就会清零丢失。PASR (Partial Array Self Refresh) is a memory control technology that can configure the self-refresh time of each memory block and can completely independently control each memory block. The memory block needs to be refreshed periodically (within a few milliseconds). If the cycle is not refreshed, the data of the memory block will be cleared and lost.
基于此原理,在确定了第一类待释放内存块之后,即可通过调整第一类待释放内存块的刷新配置参数来对第一类待释放内存块的内存执行释放清零的处理。Based on this principle, after the first type of memory block to be released is determined, the memory of the first type of memory block to be released can be released and cleared by adjusting the refresh configuration parameters of the first type of memory block to be released.
具体的,通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存,包括:Specifically, release the memory of the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released, including:
将所述第一类待释放内存块的刷新配置参数设置为禁用,并统计禁用时长;Setting the refresh configuration parameter of the first type of memory block to be released to disabled, and counting the duration of the disabled;
在所述禁用时长大于预设阈值的情况下,将所述第一类待释放内存块的刷新配置参数设置为启用,其中,所述预设阈值为内存块保存数据的数据保存时长。When the disabled duration is greater than a preset threshold, the refresh configuration parameter of the first type of memory block to be released is set to enable, wherein the preset threshold is the data storage duration of the memory block to save data.
在实际应用中,通过PASR技术,将第一类待释放内存块的刷新配置参数设置为禁止,即不刷新,并统计禁用时间,当禁用时长超过了内存中数据的有效保持时间(即上述的周期性)之后,再将该内存块的刷新配置参数设置为启用,至此,第一类待释放内存块的内存完成了释放清零的处理。In practical applications, through the PASR technology, the refresh configuration parameters of the first type of memory block to be released are set to prohibit, that is, no refresh, and the disabled time is counted. When the disabled time exceeds the effective retention time of the data in the memory (that is, the above-mentioned Periodically), then the refresh configuration parameter of the memory block is set to enable. So far, the memory of the first type of memory block to be released has completed the process of releasing and clearing.
在本说明书提供的一具体实施方式中,沿用上例,Bank4,Bank5,Bank6为第一类待释放内存块,每个Bank的数据保存时长为50毫秒,调用内存控制器驱动,通过PASR将Bank4,Bank5,Bank6的刷新配置参数设置为禁用,将其调整为不刷新,并统计禁用时长,当禁用时长超过50毫秒的情况下,再将Bank4,Bank5,Bank6的刷新配置参数设置为启用,调整期可以刷新,至此Bank4,Bank5,Bank6的内存完成了释放清零的处理。 In a specific implementation method provided in this specification, following the above example, Bank4, Bank5, and Bank6 are the first type of memory blocks to be released, and the data storage time of each Bank is 50 milliseconds, and the memory controller is called to drive Bank4 through PASR , Bank5, Bank6 refresh configuration parameters are set to disabled, adjust it to no refresh, and count the disabled time length, when the disabled time exceeds 50 milliseconds, then set the Bank4, Bank5, Bank6 refresh configuration parameters to enable, adjust It can be refreshed during this period, and the memory of Bank4, Bank5, and Bank6 has completed the process of releasing and clearing.
在实际应用中,还有一部分内存块的内存块属性信息为第二类型,对于第二类型的内存块属性信息的处理包括:In practical applications, the memory block attribute information of some memory blocks is of the second type, and the processing of the second type of memory block attribute information includes:
确定内存块属性信息为第二类型的待释放内存块为第二类待释放内存块;Determining that the memory block attribute information is the second type of memory block to be released is the second type of memory block to be released;
获取每个第二类待释放内存块对应的待释放物理地址区间;Obtain the to-be-released physical address range corresponding to each second type of memory block to be released;
将每个待释放物理地址区间的内存清零。Clear the memory of each physical address range to be released.
与内存块属性信息为第一类型的内存块对应的,将内存块属性信息为第二类型的待释放内存块为第二类待释放内存块,进而获取每个第二类待释放内存块对应的待释放物理地址区间,待释放物理地址区间具体是指目标虚拟机在第二类待释放内存块中所占用的物理地址区间。Corresponding to the memory block whose attribute information of the memory block is the first type, the to-be-released memory block whose attribute information of the memory block is the second type is the second-type to-be-released memory block, and then obtains the corresponding The to-be-released physical address range, the to-be-released physical address range specifically refers to the physical address range occupied by the target virtual machine in the second type of memory block to be released.
在获取的待释放物理地址区间之后,即可对该区间内的内存清零,具体的,通过Hypervisor运行代码,使用CPU对每个待释放物理地址写0的方式来对待释放物理地址释放清零。After obtaining the physical address range to be released, the memory in the range can be cleared. Specifically, run the code through the Hypervisor, and use the CPU to write 0 to each physical address to be released to clear the physical address to be released. .
以上为对目标虚拟机在关机时的内存释放请求,在实际应用中,为了适用本说明书提供的上述实施例,优选的,为目标虚拟机分配同一个内存块,具体的,在接收针对目标虚拟机的内存释放请求之前,所述方法还包括S1002-S1006:The above is the memory release request for the target virtual machine when it is shut down. In practical applications, in order to apply the above-mentioned embodiments provided by this specification, it is preferable to allocate the same memory block for the target virtual machine. Specifically, after receiving the target virtual machine Before the memory release request of the machine, the method further includes S1002-S1006:
S1002、接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息。S1002. Receive a memory allocation request for the target virtual machine, where the memory allocation request carries memory information to be allocated.
内存分配请求具体是指为目标虚拟机分配内存的请求,在实际应用中,在宿主机中启动一个虚拟机,需要为该虚拟机分配内存,供该虚拟机启动使用,基于此,启动的虚拟机即为目标虚拟机,内存分配请求时为目标虚拟机分配内存的请求。在实际应用中,在内存分配请求中会携带有待分配内存信息,该待分配内存信息具体可以是目标虚拟机所需的内存大小。The memory allocation request specifically refers to the request to allocate memory for the target virtual machine. In practical applications, when starting a virtual machine in the host machine, it is necessary to allocate memory for the virtual machine for the virtual machine to start. Based on this, the started virtual machine The machine is the target virtual machine, and the memory allocation request is a request to allocate memory for the target virtual machine. In practical applications, the memory allocation request will carry information about the memory to be allocated, and the information about the memory to be allocated may specifically be the memory size required by the target virtual machine.
在本说明书提供的一具体实施方式中,以启动虚拟机m为例,接收针对虚拟机m的内存分配请求,在内存分配请求中携带有虚拟机m的待分配内存信息为2G。In a specific implementation manner provided in this specification, taking virtual machine m as an example, a memory allocation request for virtual machine m is received, and the memory allocation request carries 2G of memory information to be allocated for virtual machine m.
S1004、获取空闲内存块数量和空闲内存块属性信息。S1004. Obtain the number of free memory blocks and attribute information of the free memory blocks.
其中,空闲内存块数量具体是指宿主机在当前使用情况下,有几个内存块是完全空闲的,即宿主机的未被使用的内存块的数量。空闲内存块属性信息具体是指每个未被使用的空闲内存块的内存块容量、物理地址范围等等。The number of free memory blocks specifically refers to how many memory blocks are completely free in the current use of the host machine, that is, the number of unused memory blocks of the host machine. The free memory block attribute information specifically refers to the memory block capacity, physical address range, and the like of each unused free memory block.
在本说明书提供的一具体实施方式中,沿用上例,获取宿主机的空闲内存块的数量为3块,每个内存块的大小为512M。内存块1的物理地址范围为add1024-add1536,内存块2的物理地址范围为add1536-add2048,内存块3的物理地址范围为add2048-add2560。In a specific implementation manner provided in this specification, following the above example, the number of free memory blocks obtained from the host machine is 3, and the size of each memory block is 512M. The physical address range of memory block 1 is add1024-add1536, the physical address range of memory block 2 is add1536-add2048, and the physical address range of memory block 3 is add2048-add2560.
S1006、根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块。S1006. Allocate a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block.
第一类型的空闲内存块具体是指为目标虚拟机分配的一整块连续的内存块。第一类型的空闲内存块需要根据待分配内存信息、空闲内存块数量和空闲内存属性信息确定。The first type of free memory block specifically refers to a whole continuous memory block allocated for the target virtual machine. The first type of free memory block needs to be determined according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory.
具体的,根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,包括: Specifically, allocating a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block includes:
根据所述待分配内存信息和空闲内存块属性信息确定预分配空闲内存块数量;Determine the number of pre-allocated free memory blocks according to the memory information to be allocated and the attribute information of the free memory blocks;
根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。Allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks.
在实际应用中,根据待分配内存信息和空闲内存块属性信息来确定预分配空闲内存块数量,在一个宿主机中,内存的规格相同,内存块的内存块属性信息也相同,例如,对于一个8G的内存,有8个内存块,则每个内存块的大小均为1G;对于一个4G的内存,有8个内存块,则每个内存块的大小均为512M。In practical applications, the number of pre-allocated free memory blocks is determined according to the information of the memory to be allocated and the attribute information of the free memory blocks. In a host, the specifications of the memory are the same, and the attribute information of the memory blocks is also the same. For example, for a For 8G memory, there are 8 memory blocks, and the size of each memory block is 1G; for a 4G memory, there are 8 memory blocks, and the size of each memory block is 512M.
在确定空闲内存块属性信息后,再结合待分配内存信息可以确定预分配空闲内存块数量,如待分配内存信息为4G,空闲内存块属性信息为1G,则预分配空闲内存块数量为4;若待分配内存信息为3G,空闲内存块属性信息为512M,则预分配空闲内存块数量为6。After determining the attribute information of the free memory block, combined with the memory information to be allocated, the number of pre-allocated free memory blocks can be determined. If the memory information to be allocated is 4G, and the attribute information of the free memory block is 1G, then the number of pre-allocated free memory blocks is 4; If the memory information to be allocated is 3G, and the attribute information of the free memory block is 512M, then the number of pre-allocated free memory blocks is 6.
在确定预分配空闲内存块数量后,即可根据预分配空闲内存块数量和空闲内存块数量来为目标虚拟机分配第一类型的空闲内存块。具体的,根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块,包括:After the number of pre-allocated free memory blocks is determined, the first type of free memory blocks can be allocated to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks. Specifically, allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks includes:
在所述预分配空闲内存块数量小于等于所述空闲内存块数量的情况下,根据所述预分配空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块;When the number of pre-allocated free memory blocks is less than or equal to the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of pre-allocated free memory blocks;
在所述预分配空闲内存块数量大于所述空闲内存块数量的情况下,根据所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。If the number of pre-allocated free memory blocks is greater than the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of free memory blocks.
在实际应用中,具体是根据预分配空闲内存块数量和空闲内存块数量之间的关系来为目标虚拟机分配第一类型的空闲内存块,当预分配空闲内存块数量小于等于空闲内存块数量的情况下,根据预分配空闲内存块数量为目标虚拟机分配第一类型的空闲内存块;否则,根据空闲内存块数量为目标虚拟机分配第一类型的空闲内存块。In practical applications, the target virtual machine is allocated the first type of free memory blocks according to the relationship between the number of pre-allocated free memory blocks and the number of free memory blocks. When the number of pre-allocated free memory blocks is less than or equal to the number of free memory blocks In the case of , allocate the first type of free memory blocks to the target virtual machine according to the number of pre-allocated free memory blocks; otherwise, allocate the first type of free memory blocks to the target virtual machine according to the number of free memory blocks.
例如预分配空闲内存块数量为4,空闲内存块数量为5,则第一类型的空闲内存块为4块,为目标虚拟机分配4个第一类型的空闲内存块。若预分配空闲内存块数量为6,空闲内存块数量为5,则第一类型的空闲内存块为5块,为目标虚拟机分配5个第一类型的空闲内存块。For example, the number of pre-allocated free memory blocks is 4, and the number of free memory blocks is 5, then the number of free memory blocks of the first type is 4, and 4 free memory blocks of the first type are allocated for the target virtual machine. If the number of pre-allocated free memory blocks is 6 and the number of free memory blocks is 5, then the number of free memory blocks of the first type is 5, and five free memory blocks of the first type are allocated to the target virtual machine.
在实际应用中,通常会出现目标虚拟机所需要的内存无法全部被空闲内存块分配,或空闲内存块的数量不足的情况,此时,还需要为目标虚拟机分配非空闲的内存块。具体的,在根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块之后,所述方法还包括:In practical applications, it usually occurs that all the memory required by the target virtual machine cannot be allocated by free memory blocks, or the number of free memory blocks is insufficient. At this time, it is also necessary to allocate non-free memory blocks for the target virtual machine. Specifically, after allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks, the method further includes:
根据所述待分配内存信息和所述第一类型的空闲内存块确定未分配内存信息;determining unallocated memory information according to the to-be-allocated memory information and the first type of free memory block;
在所述未分配内存信息非空的情况下,根据所述未分配内存信息为所述目标虚拟机分配第二类型的内存块。If the unallocated memory information is not empty, allocate a second type of memory block to the target virtual machine according to the unallocated memory information.
其中,未分配内存信息具体是指待分配内存信息中已经分配到第一类型的空闲内存块之后还剩余的内存信息,例如待分配内存信息为3.2G内存,内存块属性信息为1G,则第一类型的空闲内存块有3个,此时已经可以分配的内存信息为3G,未分配内存信息为0.2G;若待分配内存信息为4G,内存块属性信息为1G,第一类型的空闲内存块为4块,则该虚拟机可以占用4个第一类型的空闲内存块,此时未分配内存信息为空;若待分配内存信息为4G,内存块属性信息为1G,第一类型的空闲内存块为3块,则该虚拟机的未分配内存 信息为1G。Among them, the unallocated memory information specifically refers to the remaining memory information after the memory information to be allocated has been allocated to the first type of free memory block. For example, the memory information to be allocated is 3.2G memory, and the attribute information of the memory block is 1G. There are 3 free memory blocks of the first type. At this time, the memory information that can be allocated is 3G, and the unallocated memory information is 0.2G; if the memory information to be allocated is 4G, the attribute information of the memory block is 1G, and the first type of free memory If there are 4 blocks, the virtual machine can occupy 4 free memory blocks of the first type. At this time, the unallocated memory information is empty; if the memory information to be allocated is 4G, the attribute information of the memory block is 1G, and the free memory blocks of the first type If there are 3 memory blocks, the unallocated memory of the virtual machine The information is 1G.
当未分配内存信息为空的情况下,说明虚拟机所需的内存资源已经分配完成。无需再分配额外的内存块。When the unallocated memory information is empty, it means that the memory resources required by the virtual machine have been allocated. There is no need to allocate additional memory blocks.
当未分配内存信息非空的情况下,说明在宿主机中没有空闲内存块或空闲内存块无法全部分配给该虚拟机,此时,需要根据未分配内存信息为目标虚拟机分配第二类型的内存块,在本说明书提供的实施例中,第二类型的内存块具体是指已经分配有其他虚拟机内存的内存块,例如,某个内存块的内存容量是1G,其中,有512M的空间分配给了虚拟机1,有512M的内存空间空闲,则该内存块为第二类型的内存块。When the unallocated memory information is non-empty, it means that there is no free memory block in the host machine or all free memory blocks cannot be allocated to the virtual machine. Memory block. In the embodiments provided in this manual, the second type of memory block specifically refers to a memory block that has been allocated with other virtual machine memory. For example, the memory capacity of a certain memory block is 1G, and there is 512M of space Allocated to virtual machine 1, there is 512M free memory space, then this memory block is the second type of memory block.
在本说明书提供的一具体实施方式中,在确定未分配内存信息后,根据未分配内存信息为目标虚拟机分配第二类型的内存块。如未分配内存信息为0.2G,内存块属性信息为1G,为其分配一个完整的空闲内存块,会造成资源的浪费,为了减少资源浪费,可以在已经使用的第二类型的内存块中分配0.2G的空间给该虚拟机。In a specific implementation manner provided in this specification, after the unallocated memory information is determined, a memory block of the second type is allocated to the target virtual machine according to the unallocated memory information. If the unallocated memory information is 0.2G, and the memory block attribute information is 1G, allocating a complete free memory block for it will cause waste of resources. In order to reduce resource waste, you can allocate it in the second type of memory block that has already been used 0.2G of space for the virtual machine.
本说明书提供的内存管理方法,接收针对目标虚拟机的内存释放请求;响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块;通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。本说明书提供的内存管理方法,通过调整内存块的刷新配置参数,可以在毫秒级时间内快速完成大规格的内存释放清零,极大减少了对资源的争抢,避免对新调度的虚拟机抢占资源、影响新调度虚拟机的启动。通过修改内存释放机制,对于连续完整的内存块,通过调整刷新配置参数的方式快速完成清零。The memory management method provided in this specification receives a memory release request for a target virtual machine; determines at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determines the memory block corresponding to each memory block to be released Memory block attribute information; determine that the memory block attribute information is the first type of memory block to be released as the first type of memory block to be released; release the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released Frees memory for a memory block. The memory management method provided in this manual can quickly complete large-scale memory release and reset within milliseconds by adjusting the refresh configuration parameters of memory blocks, greatly reducing resource contention and avoiding the need for newly scheduled virtual machines. Preempting resources and affecting the startup of newly scheduled virtual machines. By modifying the memory release mechanism, for continuous and complete memory blocks, clearing can be quickly completed by adjusting the refresh configuration parameters.
另外,在虚拟机分配时,以优先分配完整连续的内存块供虚拟机使用,便于在后续的内存释放中,使用修改内存的刷新配置参数来快速完整内存清零。In addition, when the virtual machine is allocated, a complete and continuous memory block is allocated first for the virtual machine to use, so that in the subsequent memory release, the refresh configuration parameters of the modified memory can be used to quickly clear the complete memory.
参见附图2,图2示出了根据本说明书另一个实施例提供的一种内存管理方法的流程图,具体包括以下步骤:Referring to accompanying drawing 2, Fig. 2 shows a flow chart of a memory management method provided according to another embodiment of this specification, which specifically includes the following steps:
步骤202:接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息。Step 202: Receive a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated.
步骤204:获取空闲内存块数量和空闲内存块属性信息。Step 204: Obtain the number of free memory blocks and attribute information of the free memory blocks.
步骤206:根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块。Step 206: Allocate a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block.
可选的,根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,包括:Optionally, allocating a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block includes:
根据所述待分配内存信息和空闲内存块属性信息确定预分配空闲内存块数量;Determine the number of pre-allocated free memory blocks according to the memory information to be allocated and the attribute information of the free memory blocks;
根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。Allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks.
可选的,根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块,包括:Optionally, allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks includes:
在所述预分配空闲内存块数量小于等于所述空闲内存块数量的情况下,根据所述预分 配空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块;In the case that the number of pre-allocated free memory blocks is less than or equal to the number of free memory blocks, according to the pre-allocation Allocating the first type of free memory blocks for the target virtual machine by configuring the number of free memory blocks;
在所述预分配空闲内存块数量大于所述空闲内存块数量的情况下,根据所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。If the number of pre-allocated free memory blocks is greater than the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of free memory blocks.
可选的,在根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块之后,所述方法还包括:Optionally, after allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks, the method further includes:
根据所述待分配内存信息和所述第一类型的空闲内存块确定未分配内存信息;determining unallocated memory information according to the to-be-allocated memory information and the first type of free memory block;
在所述未分配内存信息非空的情况下,根据所述未分配内存信息为所述目标虚拟机分配第二类型的内存块。If the unallocated memory information is not empty, allocate a second type of memory block to the target virtual machine according to the unallocated memory information.
需要说明的是,本说明书实施例提供的内存管理方法与上述实施例S1002-S1006的方法一致,关于步骤202至步骤206的具体解释,参见前述实施例中的步骤S1002-S1006的详细容,在此就不再赘述。It should be noted that the memory management method provided by the embodiment of this specification is consistent with the method of S1002-S1006 in the above-mentioned embodiment. For the specific explanation of steps 202 to 206, please refer to the details of steps S1002-S1006 in the previous embodiment. I won't repeat it here.
本说明书实施例提供的内存管理方法适用于在为目标虚拟机分配内存时,优先将完整连续的内存块分配给虚拟机使用。便于在后续的内存释放中,使用修改内存的刷新配置参数来快速完整内存清零。The memory management method provided by the embodiment of this specification is suitable for allocating complete and continuous memory blocks to the virtual machine first when allocating memory for the target virtual machine. It is convenient to use the refresh configuration parameters of the modified memory to clear the memory quickly and completely in the subsequent memory release.
下述结合附图3,以本说明书提供的内存管理方法在为虚拟机M分配内存的应用为例,对所述内存管理方法进行进一步说明。其中,图3示出了本说明书一个实施例提供的一种内存管理方法的处理过程流程图,具体包括以下步骤。The memory management method will be further described below by taking the application of the memory management method provided in this specification in allocating memory for a virtual machine M as an example in conjunction with FIG. 3 . Wherein, FIG. 3 shows a flowchart of a processing process of a memory management method provided by an embodiment of this specification, which specifically includes the following steps.
步骤302:虚拟机开机。Step 302: The virtual machine is powered on.
在本说明书提供的实施例中,在宿主机中启动虚拟机M。In the embodiment provided in this specification, the virtual machine M is started in the host machine.
步骤304:申请内存。Step 304: apply for memory.
在本说明书提供的实施例中,为虚拟机M向宿主机申请内存。In the embodiment provided in this specification, the virtual machine M applies for memory from the host machine.
步骤306:判断内存是否超过单个内存块的大小。Step 306: Determine whether the memory exceeds the size of a single memory block.
在本说明书提供的实施例中,判断申请的内存大小是否超过了单个内存块的大小,若申请的内存大小超过了单个内存块的大小,则执行步骤308,反之,则执行步骤310。In the embodiment provided in this specification, it is judged whether the requested memory size exceeds the size of a single memory block. If the requested memory size exceeds the size of a single memory block, step 308 is performed; otherwise, step 310 is performed.
步骤308:确定空闲内存块,分配内存。Step 308: Determine a free memory block, and allocate memory.
在本说明书提供的实施例中,在宿主机中确定空闲内存块,并将空闲内存块分配给虚拟机M,同时监测虚拟机还未分配的内存大小,若恰好空闲内存块正好可以分配给虚拟机M,且未有剩余,则执行步骤312,内存分配完成。若虚拟机M还有剩余的内存未分配且不足一个内存块,则执行步骤310。In the embodiment provided in this specification, the free memory block is determined in the host computer, and the free memory block is allocated to the virtual machine M, and the unallocated memory size of the virtual machine is monitored at the same time. If the free memory block happens to be allocated to the virtual machine machine M, and there is no remaining memory, execute step 312, and the memory allocation is completed. If the virtual machine M has remaining unallocated memory and less than one memory block, step 310 is executed.
步骤310:确定第二类型的内存块,分配内存。Step 310: Determine the memory block of the second type, and allocate memory.
在本说明书提供的实施例中,确定第二类型的内存块并将第二类型的内存块中的空闲内存分配给虚拟机M。In the embodiment provided in this specification, the memory block of the second type is determined and the free memory in the memory block of the second type is allocated to the virtual machine M.
步骤312:内存分配完成。Step 312: memory allocation is completed.
在本说明书提供的实施例中,当虚拟机M所需的内存全部被分配完成后,完成了虚拟机M的内存分配工作。In the embodiment provided in this specification, when all the memory required by the virtual machine M is allocated, the memory allocation work of the virtual machine M is completed.
本说明书实施例提供的内存管理方法适用于在为目标虚拟机分配内存时,优先将完整 连续的内存块分配给虚拟机使用。便于在后续的内存释放中,使用修改内存的刷新配置参数来快速完整内存清零。The memory management method provided by the embodiment of this manual is applicable to when allocating memory for the target virtual machine, the complete A contiguous block of memory is allocated for use by the virtual machine. It is convenient to use the refresh configuration parameters of the modified memory to clear the memory quickly and completely in the subsequent memory release.
下述结合附图4,以本说明书提供的内存管理方法在为虚拟机M的内存释放清零的应用为例,对所述内存管理方法进行进一步说明。其中,图4示出了本说明书一个实施例提供的一种内存管理方法的处理过程流程图,具体包括以下步骤。The following describes the memory management method further by taking the application of the memory management method provided in this specification in releasing and clearing the memory of the virtual machine M as an example in conjunction with FIG. 4 . Wherein, FIG. 4 shows a flowchart of a processing process of a memory management method provided by an embodiment of this specification, which specifically includes the following steps.
步骤402:关闭虚拟机。Step 402: Shut down the virtual machine.
在本说明书提供的实施例中,在宿主机中关闭虚拟机M。In the embodiment provided in this specification, the virtual machine M is shut down in the host machine.
步骤404:申请释放内存。Step 404: apply for memory release.
在本说明书提供的实施例中,申请释放虚拟机M所占用的内存。In the embodiment provided in this specification, an application is made to release the memory occupied by the virtual machine M.
步骤406:判断是否是第一类待释放内存块。Step 406: Determine whether it is the first type of memory block to be released.
在本说明书提供的实施例中,判断虚拟机M占用的内存块中是否为第一类待释放内存块。若是,则执行步骤410-414,若否,则执行步骤408。In the embodiment provided in this specification, it is judged whether the memory block occupied by the virtual machine M is the first type of memory block to be released. If yes, execute steps 410-414; if not, execute step 408.
步骤408:CPU清零。Step 408: CPU is cleared.
在本说明书提供的实施例中,对于第第二类待释放内存块,通过的是使用CPU往内存地址中写入0的方式来完成内存释放清零的处理。In the embodiment provided in this specification, for the second type of memory block to be released, the process of memory release and clearing is completed by using the CPU to write 0 into the memory address.
步骤410:调用PASR内存控制器驱动调整第一类待释放内存块的刷新配置参数为禁用。Step 410: calling the PASR memory controller driver to adjust the refresh configuration parameter of the first type of memory block to be released to disabled.
在本说明书提供的实施例中调用PASR内存控制器驱动调整第一类待释放内存块的刷新配置参数为禁用,并统计禁用时长。In the embodiment provided in this manual, the driver of the PASR memory controller is called to adjust the refresh configuration parameter of the first type of memory block to be released to disabled, and count the disabled duration.
步骤412:等待T毫秒。Step 412: Wait for T milliseconds.
在本说明书提供的实施例中,T毫秒为内存块保存数据的时长,当超过T毫秒之后,内存块中保存的数据就会丢失。In the embodiment provided in this specification, T milliseconds is the duration for storing data in the memory block, and when T milliseconds are exceeded, the data stored in the memory block will be lost.
步骤414:调用PASR内存控制器驱动调整第一类待释放内存块的刷新配置参数为启用。Step 414: Call the PASR memory controller driver to adjust the refresh configuration parameter of the first type of memory block to be released to enable.
在本说明书提供的实施例中,当禁用时长超过T毫秒之后,再调用PASR内存控制器驱动调整第一类待释放内存块的刷新配置参数为启用。In the embodiment provided in this specification, after the disable time exceeds T milliseconds, the PASR memory controller driver is called to adjust the refresh configuration parameter of the first type of memory block to be released to enable.
步骤416:内存释放完成。Step 416: memory release is completed.
在本说明书提供的实施例中,至此,虚拟机M的内存释放完成。In the embodiment provided in this specification, so far, the memory release of the virtual machine M is completed.
本说明书提供的内存管理方法,接收针对目标虚拟机的内存释放请求;响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块;通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。本说明书提供的内存管理方法,通过调整内存块的刷新配置参数,可以在毫秒级时间内快速完成大规格的内存释放清零,极大减少了对资源的争抢,避免对新调度的虚拟机抢占资源、影响新调度虚拟机的启动。通过修改内存释放机制,对于连续完整的内存块,通过调整刷新配置参数的方式快速完成清零。 The memory management method provided in this specification receives a memory release request for a target virtual machine; determines at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determines the memory block corresponding to each memory block to be released Memory block attribute information; determine that the memory block attribute information is the first type of memory block to be released as the first type of memory block to be released; release the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released Frees memory for a memory block. The memory management method provided in this manual can quickly complete large-scale memory release and reset within milliseconds by adjusting the refresh configuration parameters of memory blocks, which greatly reduces the competition for resources and avoids Preempting resources and affecting the startup of newly scheduled virtual machines. By modifying the memory release mechanism, for continuous and complete memory blocks, clearing can be quickly completed by adjusting the refresh configuration parameters.
与上述方法实施例相对应,本说明书还提供了内存管理装置实施例,图5示出了本说明书一个实施例提供的一种内存管理装置的结构示意图。如图5所示,该装置包括:Corresponding to the foregoing method embodiments, this specification also provides an embodiment of a memory management device. FIG. 5 shows a schematic structural diagram of a memory management device provided by an embodiment of this specification. As shown in Figure 5, the device includes:
接收模块502,被配置为接收针对目标虚拟机的内存释放请求;The receiving module 502 is configured to receive a memory release request for the target virtual machine;
响应模块504,被配置为响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;The response module 504 is configured to determine at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determine memory block attribute information corresponding to each memory block to be released;
确定模块506,被配置为确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块,其中,第一类型的待释放内存块为完整内存块;The determining module 506 is configured to determine that the memory block whose attribute information is the first type to be released is the first type of memory block to be released, wherein the first type of memory block to be released is a complete memory block;
释放模块508,被配置为通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。The release module 508 is configured to release the memory of the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released.
可选的,所述释放模块508,进一步被配置为:Optionally, the release module 508 is further configured to:
将所述第一类待释放内存块的刷新配置参数设置为禁用,并统计禁用时长;Setting the refresh configuration parameter of the first type of memory block to be released to disabled, and counting the duration of the disabled;
在所述禁用时长大于预设阈值的情况下,将所述第一类待释放内存块的刷新配置参数设置为启用,其中,所述预设阈值为内存块保存数据的数据保存时长。When the disabled duration is greater than a preset threshold, the refresh configuration parameter of the first type of memory block to be released is set to enable, wherein the preset threshold is the data storage duration of the memory block to save data.
可选的,所述响应模块504,进一步被配置为:Optionally, the response module 504 is further configured to:
响应于所述内存释放请求确定所述目标虚拟机对应的虚拟机物理地址区间;determining a virtual machine physical address range corresponding to the target virtual machine in response to the memory release request;
确定所述虚拟机物理地址区间对应的内存块为待释放内存块。Determine the memory block corresponding to the physical address range of the virtual machine as the memory block to be released.
可选的,所述确定模块506,进一步被配置为:Optionally, the determining module 506 is further configured to:
在所述至少一个待释放内存块中确定目标待释放内存块;determining a target memory block to be released in the at least one memory block to be released;
确定所述目标待释放内存块的内存块物理地址区间;Determine the physical address range of the memory block of the target memory block to be released;
判断所述内存块物理地址区间中是否存在不属于所述虚拟机物理地址区间的内存块物理地址;Judging whether there is a memory block physical address in the physical address range of the memory block that does not belong to the physical address range of the virtual machine;
若否,则确定所述目标待释放内存块的内存块属性信息为第一类型;If not, then determine that the memory block attribute information of the target memory block to be released is the first type;
若是,则确定所述目标待释放内存块的内存块属性信息为第二类型。If yes, determine that the memory block attribute information of the target memory block to be released is the second type.
可选的,所述装置还包括:Optionally, the device also includes:
所述确定模块506,还被配置为确定内存块属性信息为第二类型的待释放内存块为第二类待释放内存块,其中,第二类型的待释放内存块为共享内存块;The determination module 506 is further configured to determine that the memory block attribute information is that the memory block to be released of the second type is the memory block to be released of the second type, wherein the memory block to be released of the second type is a shared memory block;
地址获取模块,被配置为获取每个第二类待释放内存块对应的待释放物理地址区间;The address obtaining module is configured to obtain the to-be-released physical address range corresponding to each second type of memory block to be released;
清零模块,被配置为将每个待释放物理地址区间的内存清零。The clearing module is configured to clear the memory of each physical address range to be released.
可选的,所述装置还包括:Optionally, the device also includes:
分配请求接收模块,被配置为接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息;An allocation request receiving module configured to receive a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
信息获取模块,被配置为获取空闲内存块数量和空闲内存块属性信息;An information acquisition module configured to acquire the number of free memory blocks and attribute information of the free memory blocks;
分配模块,被配置为根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块。An allocation module configured to allocate a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block.
可选的,所述分配模块,进一步被配置为: Optionally, the allocation module is further configured to:
根据所述待分配内存信息和空闲内存块属性信息确定预分配空闲内存块数量;Determine the number of pre-allocated free memory blocks according to the memory information to be allocated and the attribute information of the free memory blocks;
根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。Allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks.
可选的,所述分配模块,进一步被配置为:Optionally, the allocation module is further configured to:
在所述预分配空闲内存块数量小于等于所述空闲内存块数量的情况下,根据所述预分配空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块;When the number of pre-allocated free memory blocks is less than or equal to the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of pre-allocated free memory blocks;
在所述预分配空闲内存块数量大于所述空闲内存块数量的情况下,根据所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。If the number of pre-allocated free memory blocks is greater than the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of free memory blocks.
可选的,所述分配模块,进一步被配置为:Optionally, the allocation module is further configured to:
根据所述待分配内存信息和所述第一类型的空闲内存块确定未分配内存信息;determining unallocated memory information according to the to-be-allocated memory information and the first type of free memory block;
在所述未分配内存信息非空的情况下,根据所述未分配内存信息为所述目标虚拟机分配第二类型的内存块。If the unallocated memory information is not empty, allocate a second type of memory block to the target virtual machine according to the unallocated memory information.
本说明书提供的内存管理装置,接收针对目标虚拟机的内存释放请求;响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块;通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。本说明书提供的内存管理装置,通过调整内存块的刷新配置参数,可以在毫秒级时间内快速完成大规格的内存释放清零,极大减少了对资源的争抢,避免对新调度的虚拟机抢占资源、影响新调度虚拟机的启动。通过修改内存释放机制,对于连续完整的内存块,通过调整刷新配置参数的方式快速完成清零。The memory management device provided in this specification receives a memory release request for a target virtual machine; determines at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determines the memory block corresponding to each memory block to be released Memory block attribute information; determine that the memory block attribute information is the first type of memory block to be released as the first type of memory block to be released; release the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released Frees memory for a memory block. The memory management device provided in this manual can quickly complete large-scale memory release and reset within milliseconds by adjusting the refresh configuration parameters of memory blocks, which greatly reduces the competition for resources and avoids Preempting resources and affecting the startup of newly scheduled virtual machines. By modifying the memory release mechanism, for continuous and complete memory blocks, clearing can be quickly completed by adjusting the refresh configuration parameters.
另外,在虚拟机分配时,以优先分配完整连续的内存块供虚拟机使用,便于在后续的内存释放中,使用修改内存的刷新配置参数来快速完整内存清零。In addition, when the virtual machine is allocated, a complete and continuous memory block is allocated first for the virtual machine to use, so that in the subsequent memory release, the refresh configuration parameters of the modified memory can be used to quickly clear the complete memory.
上述为本实施例的一种内存管理装置的示意性方案。需要说明的是,该内存管理装置的技术方案与上述的内存管理方法的技术方案属于同一构思,内存管理装置的技术方案未详细描述的细节内容,均可以参见上述内存管理方法的技术方案的描述。The foregoing is a schematic solution of a memory management device in this embodiment. It should be noted that the technical solution of the memory management device and the above-mentioned technical solution of the memory management method belong to the same idea, and details of the technical solution of the memory management device that are not described in detail can be found in the description of the technical solution of the above-mentioned memory management method .
与上述方法实施例相对应,本说明书还提供了内存管理装置实施例,图6示出了本说明书另一个实施例提供的一种内存管理装置的结构示意图。如图6所示,该装置包括:Corresponding to the foregoing method embodiments, this specification also provides an embodiment of a memory management device. FIG. 6 shows a schematic structural diagram of a memory management device provided by another embodiment of this specification. As shown in Figure 6, the device includes:
分配请求接收模块602,被配置为接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息;The allocation request receiving module 602 is configured to receive a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
信息获取模块604,被配置以为获取空闲内存块数量和空闲内存块属性信息;The information obtaining module 604 is configured to obtain the number of free memory blocks and attribute information of free memory blocks;
分配模块606,被配置为根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块。The allocation module 606 is configured to allocate a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block.
可选的,所述分配模块606,进一步被配置为:Optionally, the allocation module 606 is further configured to:
根据所述待分配内存信息和空闲内存块属性信息确定预分配空闲内存块数量;Determine the number of pre-allocated free memory blocks according to the memory information to be allocated and the attribute information of the free memory blocks;
根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。Allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks.
可选的,所述分配模块606,进一步被配置为: Optionally, the allocation module 606 is further configured to:
在所述预分配空闲内存块数量小于等于所述空闲内存块数量的情况下,根据所述预分配空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块;When the number of pre-allocated free memory blocks is less than or equal to the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of pre-allocated free memory blocks;
在所述预分配空闲内存块数量大于所述空闲内存块数量的情况下,根据所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。If the number of pre-allocated free memory blocks is greater than the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of free memory blocks.
可选的,所述分配模块606,进一步被配置为:Optionally, the allocation module 606 is further configured to:
根据所述待分配内存信息和所述第一类型的空闲内存块确定未分配内存信息;determining unallocated memory information according to the to-be-allocated memory information and the first type of free memory blocks;
在所述未分配内存信息非空的情况下,根据所述未分配内存信息为所述目标虚拟机分配第二类型的内存块。If the unallocated memory information is not empty, allocate a second type of memory block to the target virtual machine according to the unallocated memory information.
本说明书实施例提供的内存管理装置适用于在为目标虚拟机分配内存时,优先将完整连续的内存块分配给虚拟机使用。便于在后续的内存释放中,使用修改内存的刷新配置参数来快速完整内存清零。The memory management device provided by the embodiment of this specification is suitable for allocating complete and continuous memory blocks to the virtual machine with priority when allocating memory for the target virtual machine. It is convenient to use the refresh configuration parameters of the modified memory to clear the memory quickly and completely in the subsequent memory release.
上述为本实施例的一种内存管理装置的示意性方案。需要说明的是,该内存管理装置的技术方案与上述的内存管理方法的技术方案属于同一构思,内存管理装置的技术方案未详细描述的细节内容,均可以参见上述内存管理方法的技术方案的描述。The foregoing is a schematic solution of a memory management device in this embodiment. It should be noted that the technical solution of the memory management device and the above-mentioned technical solution of the memory management method belong to the same idea, and details of the technical solution of the memory management device that are not described in detail can be found in the description of the technical solution of the above-mentioned memory management method .
图7示出了根据本说明书一个实施例提供的一种计算设备700的结构框图。该计算设备700的部件包括但不限于存储器710和处理器720。处理器720与存储器710通过总线730相连接,数据库750用于保存数据。FIG. 7 shows a structural block diagram of a computing device 700 provided according to an embodiment of this specification. Components of the computing device 700 include, but are not limited to, memory 710 and processor 720 . The processor 720 is connected to the memory 710 through the bus 730, and the database 750 is used for saving data.
计算设备700还包括接入设备740,接入设备740使得计算设备700能够经由一个或多个网络760通信。这些网络的示例包括公用交换电话网(PSTN)、局域网(LAN)、广域网(WAN)、个域网(PAN)或诸如因特网的通信网络的组合。接入设备740可以包括有线或无线的任何类型的网络接口(例如,网络接口卡(NIC))中的一个或多个,诸如IEEE802.11无线局域网(WLAN)无线接口、全球微波互联接入(Wi-MAX)接口、以太网接口、通用串行总线(USB)接口、蜂窝网络接口、蓝牙接口、近场通信(NFC)接口,等等。Computing device 700 also includes an access device 740 that enables computing device 700 to communicate via one or more networks 760 . Examples of these networks include the Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or a combination of communication networks such as the Internet. Access device 740 may include one or more of any type of network interface (e.g., a network interface card (NIC)), wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, Worldwide Interoperability for Microwave Access ( Wi-MAX) interface, Ethernet interface, Universal Serial Bus (USB) interface, cellular network interface, Bluetooth interface, Near Field Communication (NFC) interface, etc.
在本说明书的一个实施例中,计算设备700的上述部件以及图7中未示出的其他部件也可以彼此相连接,例如通过总线。应当理解,图7所示的计算设备结构框图仅仅是出于示例的目的,而不是对本说明书范围的限制。本领域技术人员可以根据需要,增添或替换其他部件。In an embodiment of the present specification, the above-mentioned components of the computing device 700 and other components not shown in FIG. 7 may also be connected to each other, for example, through a bus. It should be understood that the structural block diagram of the computing device shown in FIG. 7 is only for the purpose of illustration, rather than limiting the scope of this description. Those skilled in the art can add or replace other components as needed.
计算设备700可以是任何类型的静止或移动计算设备,包括移动计算机或移动计算设备(例如,平板计算机、个人数字助理、膝上型计算机、笔记本计算机、上网本等)、移动电话(例如,智能手机)、可佩戴的计算设备(例如,智能手表、智能眼镜等)或其他类型的移动设备,或者诸如台式计算机或PC的静止计算设备。计算设备700还可以是移动式或静止式的服务器。Computing device 700 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile telephones (e.g., smartphones), ), wearable computing devices (eg, smart watches, smart glasses, etc.), or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. Computing device 700 may also be a mobile or stationary server.
其中,处理器720用于执行如下计算机可执行指令,该计算机可执行指令被处理器 执行时实现上述数据处理方法的步骤。上述为本实施例的一种计算设备的示意性方案。需要说明的是,该计算设备的技术方案与上述的内存管理方法的技术方案属于同一构思,计算设备的技术方案未详细描述的细节内容,均可以参见上述内存管理方法的技术方案的描述。Wherein, the processor 720 is used to execute the following computer-executable instructions, which are executed by the processor During execution, the steps of the above data processing method are realized. The foregoing is a schematic solution of a computing device in this embodiment. It should be noted that the technical solution of the computing device and the above-mentioned technical solution of the memory management method belong to the same concept, and details not described in detail in the technical solution of the computing device can refer to the description of the technical solution of the above-mentioned memory management method.
本说明书一实施例还提供一种计算机可读存储介质,其存储有计算机可执行指令,该计算机可执行指令被处理器执行时实现上述内存管理方法的步骤。An embodiment of the present specification also provides a computer-readable storage medium, which stores computer-executable instructions, and implements the steps of the memory management method above when the computer-executable instructions are executed by a processor.
上述为本实施例的一种计算机可读存储介质的示意性方案。需要说明的是,该存储介质的技术方案与上述的内存管理方法的技术方案属于同一构思,存储介质的技术方案未详细描述的细节内容,均可以参见上述内存管理方法的技术方案的描述。The foregoing is a schematic solution of a computer-readable storage medium in this embodiment. It should be noted that the technical solution of the storage medium and the above-mentioned technical solution of the memory management method belong to the same idea, and details not described in detail in the technical solution of the storage medium can refer to the description of the technical solution of the above-mentioned memory management method.
本说明书一实施例还提供一种计算机程序,其中,当所述计算机程序在计算机中执行时,令计算机执行上述内存管理方法的步骤。An embodiment of the present specification further provides a computer program, wherein, when the computer program is executed in a computer, the computer is caused to execute the steps of the memory management method above.
上述为本实施例的一种计算机程序的示意性方案。需要说明的是,该计算机程序的技术方案与上述的内存管理方法的技术方案属于同一构思,计算机程序的技术方案未详细描述的细节内容,均可以参见上述内存管理方法的技术方案的描述。The foregoing is a schematic solution of a computer program in this embodiment. It should be noted that the technical solution of the computer program and the above-mentioned technical solution of the memory management method belong to the same idea, and details not described in detail in the technical solution of the computer program can refer to the description of the technical solution of the above-mentioned memory management method.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of this specification. Other implementations are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. Multitasking and parallel processing are also possible or may be advantageous in certain embodiments.
所述计算机指令包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,所述计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。The computer instructions include computer program code, which may be in source code form, object code form, executable file or some intermediate form or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM, Read-Only Memory) , Random Access Memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, computer-readable media Excludes electrical carrier signals and telecommunication signals.
需要说明的是,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本说明书实施例并不受所描述的动作顺序的限制,因为依据本说明书实施例,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本说明书实施例所必须的。It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are expressed as a series of action combinations, but those skilled in the art should know that the embodiments of this specification are not limited by the described action sequences. Because according to the embodiment of the present specification, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of the specification.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.
以上公开的本说明书优选实施例只是用于帮助阐述本说明书。可选实施例并没有详尽叙述所有的细节,也不限制该发明仅为所述的具体实施方式。显然,根据本说明书实施例的内容,可作很多的修改和变化。本说明书选取并具体描述这些实施例,是为了更好地解释本说明书实施例的原理和实际应用,从而使所属技术领域技术人员能很好地理解和利用本说明书。本说明书仅受权利要求书及其全部范围和等效物的限制。 The preferred embodiments of the present specification disclosed above are only for helping to explain the present specification. Alternative embodiments are not exhaustive in all detail, nor are the inventions limited to specific implementations described. Obviously, many modifications and changes can be made according to the contents of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that those skilled in the art can well understand and use this specification. This specification is to be limited only by the claims, along with their full scope and equivalents.

Claims (14)

  1. 一种内存管理方法,包括:A memory management method, comprising:
    接收针对目标虚拟机的内存释放请求;Receive a memory release request for the target virtual machine;
    响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;Determining at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determining memory block attribute information corresponding to each memory block to be released;
    确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块,其中,第一类型的待释放内存块为完整内存块;Determining that the memory block attribute information is the first type of memory block to be released is the first type of memory block to be released, wherein the first type of memory block to be released is a complete memory block;
    通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。The memory of the first type of memory block to be released is released by adjusting the refresh configuration parameters of the first type of memory block to be released.
  2. 如权利要求1所述的内存管理方法,通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存,包括:The memory management method according to claim 1, releasing the memory of the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released, comprising:
    将所述第一类待释放内存块的刷新配置参数设置为禁用,并统计禁用时长;Setting the refresh configuration parameter of the first type of memory block to be released to disabled, and counting the duration of the disabled;
    在所述禁用时长大于预设阈值的情况下,将所述第一类待释放内存块的刷新配置参数设置为启用,其中,所述预设阈值为内存块保存数据的数据保存时长。When the disabled duration is greater than a preset threshold, the refresh configuration parameter of the first type of memory block to be released is set to enable, wherein the preset threshold is the data storage duration of the memory block to save data.
  3. 如权利要求1所述的内存管理方法,响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,包括:The memory management method according to claim 1, determining at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, comprising:
    响应于所述内存释放请求确定所述目标虚拟机对应的虚拟机物理地址区间;determining a virtual machine physical address range corresponding to the target virtual machine in response to the memory release request;
    确定所述虚拟机物理地址区间对应的内存块为待释放内存块。Determine the memory block corresponding to the physical address range of the virtual machine as the memory block to be released.
  4. 如权利要求3所述的内存管理方法,确定每个待释放内存块对应的内存块属性信息,包括:The memory management method according to claim 3, determining the memory block attribute information corresponding to each memory block to be released, comprising:
    在所述至少一个待释放内存块中确定目标待释放内存块;determining a target memory block to be released in the at least one memory block to be released;
    确定所述目标待释放内存块的内存块物理地址区间;Determine the physical address range of the memory block of the target memory block to be released;
    判断所述内存块物理地址区间中是否存在不属于所述虚拟机物理地址区间的内存块物理地址;Judging whether there is a memory block physical address in the physical address range of the memory block that does not belong to the physical address range of the virtual machine;
    若否,则确定所述目标待释放内存块的内存块属性信息为第一类型;If not, then determine that the memory block attribute information of the target memory block to be released is the first type;
    若是,则确定所述目标待释放内存块的内存块属性信息为第二类型。If yes, determine that the memory block attribute information of the target memory block to be released is the second type.
  5. 如权利要求1所述的内存管理方法,所述方法还包括:The memory management method according to claim 1, said method further comprising:
    确定内存块属性信息为第二类型的待释放内存块为第二类待释放内存块,其中,第二类型的待释放内存块为共享内存块;Determining that the memory block attribute information is that the second type of memory block to be released is the second type of memory block to be released, wherein the second type of memory block to be released is a shared memory block;
    获取每个第二类待释放内存块对应的待释放物理地址区间;Obtain the to-be-released physical address range corresponding to each second type of memory block to be released;
    将每个待释放物理地址区间的内存清零。Clear the memory of each physical address range to be released.
  6. 如权利要求1所述的内存管理方法,在接收针对目标虚拟机的内存释放请求之前,所述方法还包括:The memory management method according to claim 1, before receiving the memory release request for the target virtual machine, the method further comprises:
    接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息; receiving a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
    获取空闲内存块数量和空闲内存块属性信息;Obtain the number of free memory blocks and attribute information of free memory blocks;
    根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块。Allocating a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block.
  7. 一种内存管理方法,包括:A memory management method, comprising:
    接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息;receiving a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
    获取空闲内存块数量和空闲内存块属性信息;Obtain the number of free memory blocks and attribute information of free memory blocks;
    根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,其中,第一类型的空闲内存块为完整内存块。Allocating a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block, wherein the first type of free memory block is a complete memory block .
  8. 如权利要求7所述的内存管理方法,根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,包括:The memory management method according to claim 7, allocating a first type of free memory block for the target virtual machine according to the memory information to be allocated, the number of free memory blocks and the attribute information of the free memory block, comprising:
    根据所述待分配内存信息和空闲内存块属性信息确定预分配空闲内存块数量;Determine the number of pre-allocated free memory blocks according to the memory information to be allocated and the attribute information of the free memory blocks;
    根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。Allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks.
  9. 如权利要求8所述的内存管理方法,根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块,包括:The memory management method according to claim 8, allocating a first type of free memory block for the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks, comprising:
    在所述预分配空闲内存块数量小于等于所述空闲内存块数量的情况下,根据所述预分配空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块;When the number of pre-allocated free memory blocks is less than or equal to the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of pre-allocated free memory blocks;
    在所述预分配空闲内存块数量大于所述空闲内存块数量的情况下,根据所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块。If the number of pre-allocated free memory blocks is greater than the number of free memory blocks, allocate a first type of free memory blocks to the target virtual machine according to the number of free memory blocks.
  10. 如权利要求8所述的内存管理方法,在根据所述预分配空闲内存块数量和所述空闲内存块数量为所述目标虚拟机分配第一类型的空闲内存块之后,所述方法还包括:The memory management method according to claim 8, after allocating a first type of free memory block to the target virtual machine according to the number of pre-allocated free memory blocks and the number of free memory blocks, the method further comprises:
    根据所述待分配内存信息和所述第一类型的空闲内存块确定未分配内存信息;determining unallocated memory information according to the to-be-allocated memory information and the first type of free memory blocks;
    在所述未分配内存信息非空的情况下,根据所述未分配内存信息为所述目标虚拟机分配第二类型的内存块。If the unallocated memory information is not empty, allocate a second type of memory block to the target virtual machine according to the unallocated memory information.
  11. 一种内存管理装置,包括:A memory management device, comprising:
    接收模块,被配置为接收针对目标虚拟机的内存释放请求;a receiving module configured to receive a memory release request for the target virtual machine;
    响应模块,被配置为响应于所述内存释放请求确定所述目标虚拟机对应的至少一个待释放内存块,并确定每个待释放内存块对应的内存块属性信息;A response module configured to determine at least one memory block to be released corresponding to the target virtual machine in response to the memory release request, and determine memory block attribute information corresponding to each memory block to be released;
    确定模块,被配置为确定内存块属性信息为第一类型的待释放内存块为第一类待释放内存块,其中,第一类型的待释放内存块为完整内存块;The determining module is configured to determine that the attribute information of the memory block is that the first type of memory block to be released is the first type of memory block to be released, wherein the first type of memory block to be released is a complete memory block;
    释放模块,被配置为通过调整所述第一类待释放内存块的刷新配置参数释放所述第一类待释放内存块的内存。The release module is configured to release the memory of the first type of memory block to be released by adjusting the refresh configuration parameters of the first type of memory block to be released.
  12. 一种内存管理装置,包括:A memory management device, comprising:
    分配请求接收模块,被配置为接收针对目标虚拟机的内存分配请求,其中,所述内存分配请求中携带有待分配内存信息; An allocation request receiving module configured to receive a memory allocation request for the target virtual machine, wherein the memory allocation request carries memory information to be allocated;
    信息获取模块,被配置以为获取空闲内存块数量和空闲内存块属性信息;An information acquisition module configured to acquire the number of free memory blocks and attribute information of the free memory blocks;
    分配模块,被配置为根据所述待分配内存信息、所述空闲内存块数量和所述空闲内存块属性信息为所述目标虚拟机分配第一类型的空闲内存块,其中,第一类型的空闲内存块为完整内存块。An allocation module configured to allocate a first type of free memory block to the target virtual machine according to the memory information to be allocated, the number of free memory blocks, and the attribute information of the free memory block, wherein the first type of free memory block A memory block is a complete memory block.
  13. 一种计算设备,包括:A computing device comprising:
    存储器和处理器;memory and processor;
    所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令,该计算机可执行指令被处理器执行时实现权利要求1至6或7至10任意一项所述内存管理方法的步骤。The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the memory described in any one of claims 1 to 6 or 7 to 10 is implemented. The steps of the management method.
  14. 一种计算机可读存储介质,其存储有计算机可执行指令,该计算机可执行指令被处理器执行时实现权利要求1至6或7至10任意一项所述内存管理方法的步骤。 A computer-readable storage medium, which stores computer-executable instructions, and implements the steps of the memory management method described in any one of claims 1-6 or 7-10 when the computer-executable instructions are executed by a processor.
PCT/CN2023/075100 2022-02-25 2023-02-09 Memory management methods and apparatuses WO2023160397A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210180906.0A CN114579304A (en) 2022-02-25 2022-02-25 Memory management method and device
CN202210180906.0 2022-02-25

Publications (1)

Publication Number Publication Date
WO2023160397A1 true WO2023160397A1 (en) 2023-08-31

Family

ID=81774414

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/075100 WO2023160397A1 (en) 2022-02-25 2023-02-09 Memory management methods and apparatuses

Country Status (2)

Country Link
CN (1) CN114579304A (en)
WO (1) WO2023160397A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114579304A (en) * 2022-02-25 2022-06-03 阿里巴巴(中国)有限公司 Memory management method and device
CN116010113B (en) * 2023-03-27 2023-08-15 紫光同芯微电子有限公司 Method for managing memory of smart card and smart card

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060288154A1 (en) * 2005-06-21 2006-12-21 Via Technologies Inc. Data clearing methods and computer systems utilizing the same
CN106445835A (en) * 2015-08-10 2017-02-22 北京忆恒创源科技有限公司 Memory allocation method and apparatus
CN107783812A (en) * 2016-08-24 2018-03-09 阿里巴巴集团控股有限公司 Virutal machine memory management method and device
CN114579304A (en) * 2022-02-25 2022-06-03 阿里巴巴(中国)有限公司 Memory management method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060288154A1 (en) * 2005-06-21 2006-12-21 Via Technologies Inc. Data clearing methods and computer systems utilizing the same
CN106445835A (en) * 2015-08-10 2017-02-22 北京忆恒创源科技有限公司 Memory allocation method and apparatus
CN107783812A (en) * 2016-08-24 2018-03-09 阿里巴巴集团控股有限公司 Virutal machine memory management method and device
CN114579304A (en) * 2022-02-25 2022-06-03 阿里巴巴(中国)有限公司 Memory management method and device

Also Published As

Publication number Publication date
CN114579304A (en) 2022-06-03

Similar Documents

Publication Publication Date Title
WO2023160397A1 (en) Memory management methods and apparatuses
US10901802B2 (en) Method and apparatus for implementing virtual GPU and system
US9110669B2 (en) Power management of a storage device including multiple processing cores
JP5165960B2 (en) Balancing resource sharing and application latency in data processing systems
US10649889B2 (en) Method and apparatus for managing kernel memory of data processing systems
US9601180B2 (en) Automatic partial array self-refresh
US10089266B2 (en) Power saving feature for storage subsystems
WO2023103296A1 (en) Write data cache method and system, device, and storage medium
CN109801659B (en) DRAM bank activation management
EP3869318B1 (en) Storage devices configured to support multiple hosts and operation methods thereof
WO2017107816A1 (en) Method of processing data on virtualization platform and device
US10521371B2 (en) Cache system and associated method
CN110795323A (en) Load statistical method, device, storage medium and electronic equipment
CN112306652A (en) Wake-up and scheduling with context-aware functionality
Lee et al. Efficient hybrid polling for ultra-low latency storage devices
CN103927203A (en) Computer system and control method
WO2023160359A1 (en) Resource scheduling method and device
WO2024021485A1 (en) Processor performance adjustment method and apparatus, electronic device and storage medium
WO2016041156A1 (en) Method and apparatus for scheduling cpu
US10452553B1 (en) Systems and methods for distributing cache space
JP6217008B2 (en) Electronic device, control method, and program
US20100083256A1 (en) Temporal batching of i/o jobs
US10324752B2 (en) Response times based on application states
CN111143055A (en) Virtual cloud host pre-allocation method and device, readable storage medium and electronic equipment
Wu et al. APP: Enabling soft real-time execution on densely-populated hybrid memory system

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

Country of ref document: EP

Kind code of ref document: A1