CN104461928B - Divide the method and device of cache - Google Patents
Divide the method and device of cache Download PDFInfo
- Publication number
- CN104461928B CN104461928B CN201310422795.0A CN201310422795A CN104461928B CN 104461928 B CN104461928 B CN 104461928B CN 201310422795 A CN201310422795 A CN 201310422795A CN 104461928 B CN104461928 B CN 104461928B
- Authority
- CN
- China
- Prior art keywords
- virtual machine
- cache
- vms
- state
- group
- Prior art date
- Legal status (The legal status 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 status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000005516 engineering process Methods 0.000 abstract description 6
- 230000010076 replication Effects 0.000 description 7
- 238000010586 diagram Methods 0.000 description 6
- 230000008569 process Effects 0.000 description 5
- 230000007423 decrease Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000002955 isolation Methods 0.000 description 2
- 230000015556 catabolic process Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004040 coloring Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000006731 degradation reaction Methods 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005192 partition Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000013509 system migration Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0844—Multiple simultaneous or quasi-simultaneous cache accessing
- G06F12/0846—Cache with multiple tag or data arrays being simultaneously accessible
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/12—Replacement control
- G06F12/121—Replacement control using replacement algorithms
- G06F12/123—Replacement control using replacement algorithms with age lists, e.g. queue, most recently used [MRU] list or least recently used [LRU] list
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/10—Providing a specific technical effect
- G06F2212/1016—Performance improvement
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/15—Use in a specific computing environment
- G06F2212/152—Virtualized environment, e.g. logically partitioned system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2212/00—Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
- G06F2212/60—Details of cache memory
- G06F2212/601—Reconfiguration of cache memory
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
本发明实施例公开了一种划分高速缓存的方法及装置,涉及计算机技术领域,能够在虚拟机启动和复制时,提高虚拟机的性能。本发明的方法包括:当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。本发明适用于虚拟化环境。
The embodiment of the invention discloses a method and device for dividing a high-speed cache, relates to the field of computer technology, and can improve the performance of a virtual machine when the virtual machine is started and copied. The method of the present invention includes: when none of the cache data in the cache group accessed by the first virtual machine hits, judging the virtual machine management operation state VMS of the first virtual machine; when the VMS of the first virtual machine is the first state, replace the least recently used cache data belonging to the second virtual machine in the cache group. The invention is suitable for virtualization environment.
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种划分高速缓存的方法及装置。The invention relates to the field of computer technology, in particular to a method and device for dividing cache memory.
背景技术Background technique
虚拟化技术是当今企业热门技术之一,它已经被广泛地应用于服务器整合、系统迁移、负载隔离等研究领域中。目前的虚拟化技术能够对多核处理器、内存及输入输出I/O等物理资源进行严格地划分,消除虚拟机间对物理资源的竞争,保证了虚拟机的功能和性能隔离性。但是对于片上多级高速缓存等共享的硬件资源,当前的虚拟化技术没有划分,各虚拟机之间对这些硬件资源的隐式竞争会导致部分虚拟机性能下降。例如,虚拟机上的某些虚拟化应用对LLC(Last-Level Cache,末级共享高速缓存)的容量很敏感,当虚拟机能够使用的LLC容量由于竞争原因减少时,虚拟机的性能会随之降低。Virtualization technology is one of the popular technologies in today's enterprises, and it has been widely used in research fields such as server integration, system migration, and load isolation. The current virtualization technology can strictly divide physical resources such as multi-core processors, memory, and input/output I/O, eliminate competition for physical resources among virtual machines, and ensure the isolation of virtual machine functions and performance. However, the current virtualization technology does not divide shared hardware resources such as on-chip multi-level caches, and implicit competition among virtual machines for these hardware resources will lead to performance degradation of some virtual machines. For example, some virtualization applications on a virtual machine are sensitive to the capacity of the LLC (Last-Level Cache, last-level shared cache). When the LLC capacity available to the virtual machine decreases due to competition, the performance of the virtual machine lowered.
为了改变上述情况,提高虚拟机的性能,研究人员提出了共享高速缓存划分机制。现有技术中,通过修改的LRU(Least Recently Used,最近最少使用算法)和页着色方法对缓存进行划分,限制不同虚拟机所使用的共享缓存容量,从而减少在共享缓存上的竞争冲突。In order to change the above situation and improve the performance of the virtual machine, the researchers proposed a shared cache partition mechanism. In the prior art, the modified LRU (Least Recently Used, least recently used algorithm) and page coloring method are used to divide the cache to limit the shared cache capacity used by different virtual machines, thereby reducing competition conflicts on the shared cache.
现有技术至少存在如下问题:在多租户数据中心,每个用户对虚拟机执行的不同管理操作的效果会叠加,例如,在启动虚拟机和使用虚拟机执行复制操作的过程中,当大量虚拟机在短时间内同时启动,或者虚拟机复制的磁盘镜像的规模较大、所需时间较长的时候,由于操作效果的叠加,会导致虚拟机性能严重下降。而现有技术中的缓存划分方法,在虚拟机启动和复制时,不能很好的提升虚拟机的性能,虚拟机性能较低。The prior art has at least the following problems: In a multi-tenant data center, the effects of different management operations performed by each user on virtual machines will be superimposed, for example, in the process of starting virtual machines and performing replication operations using virtual machines, when a large number of virtual machines When the virtual machines are started at the same time in a short period of time, or the disk image copied by the virtual machine is large and takes a long time, due to the superposition of operation effects, the performance of the virtual machine will be severely degraded. However, the cache division method in the prior art cannot improve the performance of the virtual machine well when the virtual machine is started and copied, and the performance of the virtual machine is low.
发明内容Contents of the invention
本发明的实施例提供一种划分高速缓存的方法及装置,能够解决在虚拟机执行启动和复制时,虚拟机性能较低的问题。Embodiments of the present invention provide a method and device for dividing a cache, which can solve the problem of low performance of a virtual machine when the virtual machine is started and copied.
为达到上述目的,本发明的实施例采用如下技术方案:In order to achieve the above object, embodiments of the present invention adopt the following technical solutions:
第一方面,本发明的实施例提供一种划分高速缓存的方法,包括:In a first aspect, embodiments of the present invention provide a method for dividing a cache, including:
当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;When none of the cache data in the cache group accessed by the first virtual machine hits, determine the virtual machine management operation state VMS of the first virtual machine;
当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。When the VMS of the first virtual machine is in the first state, replace the least recently used cache data belonging to the second virtual machine in the cache group.
结合第一方面,在第一种可能的实现方式中,所述判断所述第一虚拟机的虚拟机管理操作状态VMS之前,所述方法还包括:With reference to the first aspect, in a first possible implementation manner, before determining the virtual machine management operation status VMS of the first virtual machine, the method further includes:
添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。A virtual machine VM register is added, and the data structure of the VM register includes: the VMS and a virtual machine identifier VMID.
进一步的,所述判断所述第一虚拟机的虚拟机管理操作状态VMS之前,所述方法还包括:Further, before determining the virtual machine management operation status VMS of the first virtual machine, the method further includes:
当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。When the first virtual machine performs a startup operation or a copy operation, set the VMS of the first virtual machine to a first state; when the first virtual machine does not perform a startup operation or a copy operation, set the first The VMS of the virtual machine is in the second state.
可选的,当所述第一虚拟机的VMS为第一状态时,在替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据之前,所述方法还包括:Optionally, when the VMS of the first virtual machine is in the first state, before replacing the least recently used cache data belonging to the second virtual machine in the cache group, the method further includes:
判断所述第二虚拟机的缓存失效率是否大于失效率阈值;judging whether the cache failure rate of the second virtual machine is greater than a failure rate threshold;
如果所述第二虚拟机的缓存失效率大于所述失效率阈值,则替换所述缓存组中最近最少使用的缓存数据;If the cache failure rate of the second virtual machine is greater than the failure rate threshold, replace the least recently used cache data in the cache group;
如果所述第二虚拟机的缓存失效率不大于所述失效率阈值,则确定所述缓存组中属于所述第二虚拟机的缓存块数目。If the cache failure rate of the second virtual machine is not greater than the failure rate threshold, then determine the number of cache blocks belonging to the second virtual machine in the cache group.
结合第一种可能的实现方式,在第二种可能的实现方式中,所述添加虚拟机VM寄存器之后,所述方法还包括:With reference to the first possible implementation, in the second possible implementation, after adding the virtual machine VM register, the method further includes:
扩展缓存地址的标记位,将所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。The flag bit of the cache address is extended, and the VMID is added to the flag bit, and the cache data in the cache address belongs to the virtual machine corresponding to the VMID.
可选的,在所述确定所述缓存组中属于所述第二虚拟机的缓存块数目之后,所述方法还包括:Optionally, after the determination of the number of cache blocks belonging to the second virtual machine in the cache group, the method further includes:
判断所述第二虚拟机的缓存块数目是否小于数目阈值;judging whether the number of cache blocks of the second virtual machine is less than a number threshold;
如果所述第二虚拟机的缓存块数目小于所述数目阈值,则替换所述缓存组中最近最少使用的缓存数据;If the number of cache blocks of the second virtual machine is less than the number threshold, replace the least recently used cache data in the cache group;
如果所述第二虚拟机的缓存块数目不小于所述数目阈值,则替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。If the number of cache blocks of the second virtual machine is not less than the number threshold, replace the least recently used cache data belonging to the second virtual machine in the cache group.
结合第一方面或第一方面的第一种可能的实现方式,在第三种可能的实现方式中,当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。With reference to the first aspect or the first possible implementation of the first aspect, in a third possible implementation, when the VMS of the first virtual machine is in the second state, replace the least recent The cached data to use.
结合第一方面或任一种可能的实现方式,在第四种可能的实现方式中,所述第二虚拟机用于控制虚拟环境的物理输入输出I/O资源,与所述第一虚拟机进行交互,启动所述第一虚拟机。With reference to the first aspect or any possible implementation manner, in a fourth possible implementation manner, the second virtual machine is used to control the physical input and output I/O resources of the virtual environment, and the first virtual machine Interact and start the first virtual machine.
第二方面,本发明的实施例提供一种划分高速缓存的装置,包括:In a second aspect, an embodiment of the present invention provides a device for dividing a cache, including:
判断单元,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;A judging unit, configured to judge the virtual machine management operation state VMS of the first virtual machine when none of the cache data in the cache group accessed by the first virtual machine hits;
替换单元,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。The replacement unit is configured to replace the least recently used cache data belonging to the second virtual machine in the cache group when the VMS of the first virtual machine is in the first state.
结合第二方面,在第一种可能的实现方式中,所述装置还包括:With reference to the second aspect, in a first possible implementation manner, the device further includes:
添加单元,用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:The adding unit is used to add a virtual machine VM register, and the data structure of the VM register includes:
所述VMS和虚拟机标识VMID。The VMS and virtual machine identifier VMID.
进一步的,所述装置还包括:设置单元,用于当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;以及,用于当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。Further, the apparatus further includes: a setting unit, configured to set the VMS of the first virtual machine to a first state when the first virtual machine performs a startup operation or a copy operation; When the first virtual machine does not execute the start operation or the copy operation, set the VMS of the first virtual machine to the second state.
可选的,所述判断单元还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;所述替换单元还用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;所述装置还包括:Optionally, the judging unit is further configured to judge whether the cache failure rate of the second virtual machine is greater than a failure rate threshold; the replacement unit is also configured to determine whether the cache failure rate of the second virtual machine is greater than the failure rate threshold. rate threshold, replace the least recently used cache data in the cache group; the device also includes:
确定单元,用于当所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。A determining unit, configured to determine the number of cache blocks belonging to the second virtual machine in the cache group when the cache failure rate of the second virtual machine is not greater than the failure rate threshold.
结合第一种可能的实现方式,在第二种可能的实现方式中,所述装置还包括:With reference to the first possible implementation manner, in a second possible implementation manner, the device further includes:
扩展单元,用于扩展缓存地址的标记位,将所述添加单元添加的所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。The extension unit is configured to extend the flag bit of the cache address, and add the VMID added by the adding unit to the flag bit, and the cache data in the cache address belongs to the virtual machine corresponding to the VMID.
可选的,所述判断单元还用于判断所述第二虚拟机的缓存块数目是否小于所述确定单元确定的所述数目阈值;所述替换单元还用于当所述第二虚拟机的缓存块数目小于所述确定单元确定的所述数目阈值时,替换所述缓存组中最近最少使用的缓存数据;所述替换单元还用于当所述第二虚拟机的缓存块数目不小于所述确定单元确定的所述数目阈值时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。Optionally, the judging unit is further configured to judge whether the number of cache blocks of the second virtual machine is smaller than the number threshold determined by the determining unit; When the number of cache blocks is less than the number threshold determined by the determination unit, replace the least recently used cache data in the cache group; the replacement unit is also configured to when the number of cache blocks of the second virtual machine is not less than the specified When the number threshold determined by the determining unit is exceeded, replace the least recently used cache data belonging to the second virtual machine in the cache group.
结合第二方面或第二方面的第一种可能的实现方式,在第三种可能的实现方式中,所述替换单元还用于:当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。With reference to the second aspect or the first possible implementation manner of the second aspect, in a third possible implementation manner, the replacement unit is further configured to: when the VMS of the first virtual machine is in the second state, Replaces the least recently used cache data in the cache group.
结合第二方面或任一种可能的实现方式,在第四种可能的实现方式中,所述第二虚拟机用于控制虚拟环境的物理输入输出I/O资源,与所述第一虚拟机进行交互,启动所述第一虚拟机。With reference to the second aspect or any possible implementation manner, in a fourth possible implementation manner, the second virtual machine is used to control the physical input and output I/O resources of the virtual environment, and the first virtual machine Interact and start the first virtual machine.
本发明实施例提供的划分末级共享高速缓存的方法及装置,与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,虚拟机性能较低的问题相比,本发明中,在虚拟机执行启动和复制时,对第一虚拟机和第二虚拟机之间的末级共享缓存进行划分,减少第二虚拟机占用的缓存容量。由于第二虚拟机对缓存的容量不敏感,即使缓存的失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,从而提升虚拟机启动或复制时的性能。The method and device for dividing the last-level shared cache provided by the embodiments of the present invention are similar to the problems in the prior art that the performance of the virtual machine cannot be well improved when the virtual machine is started and copied, and the performance of the virtual machine is low. In contrast, in the present invention, when the virtual machine is started and copied, the last-level shared cache between the first virtual machine and the second virtual machine is divided to reduce the cache capacity occupied by the second virtual machine. Since the second virtual machine is not sensitive to the cache capacity, even if the cache failure rate is high, its performance is not greatly affected, so by reducing the cache capacity occupied by the second virtual machine, increase the cache occupied by the first virtual machine Capacity, to reduce the contention for the cache among the virtual machines, thereby improving the performance of the virtual machine startup or replication.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the accompanying drawings that need to be used in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For Those of ordinary skill in the art can also obtain other drawings based on these drawings without making creative efforts.
图1为本发明一实施例提供的方法流程图;Fig. 1 is a flow chart of a method provided by an embodiment of the present invention;
图2为本发明又一实施例提供的方法流程图;Fig. 2 is the flow chart of the method provided by another embodiment of the present invention;
图3为本发明又一实施例提供的访存地址结构图;FIG. 3 is a memory access address structure diagram provided by another embodiment of the present invention;
图4为本发明又一实施例提供的缓存结构图;FIG. 4 is a cache structure diagram provided by another embodiment of the present invention;
图5为本发明又一实施例提供的使用传统LRU数据替换后的缓存结构图;FIG. 5 is a cache structure diagram provided by another embodiment of the present invention after using traditional LRU data replacement;
图6为本发明又一实施例提供的使用改进LRU数据替换后的缓存结构图;FIG. 6 is a cache structure diagram provided by another embodiment of the present invention after using improved LRU data replacement;
图7、图8为本发明又一实施例提供的装置结构示意图;Fig. 7 and Fig. 8 are schematic diagrams of the device structure provided by another embodiment of the present invention;
图9为本发明又一实施例提供的装置结构示意图。Fig. 9 is a schematic structural diagram of a device provided by another embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本发明一实施例提供一种划分高速缓存的方法,用于虚拟化环境,第一虚拟机和第二虚拟机运行于同一虚拟平台,第二虚拟机为运行在虚拟机监视器之上的特权虚拟机,它可以控制物理I/O资源,并且同时与第一虚拟机进行交互,第一虚拟机为客户虚拟机,可通过多个第二虚拟机来启动多个第一虚拟机。如图1所示,所述方法包括:An embodiment of the present invention provides a method for dividing high-speed cache, which is used in a virtualization environment. The first virtual machine and the second virtual machine run on the same virtual platform, and the second virtual machine is a privilege running on a virtual machine monitor. A virtual machine, which can control physical I/O resources and interact with a first virtual machine at the same time. The first virtual machine is a guest virtual machine, and multiple first virtual machines can be started by multiple second virtual machines. As shown in Figure 1, the method includes:
101、当第一虚拟机访问的缓存组的缓存数据均未命中时,缓存控制器判断第一虚拟机的VMS(Virtual Management State,虚拟机管理操作状态)。101. When none of the cached data in the cache group accessed by the first virtual machine is hit, the cache controller judges a VMS (Virtual Management State, virtual machine management operation state) of the first virtual machine.
需要说明的是,在处理器中,为每个处理器核添加虚拟机VM寄存器,VM寄存器结构包括:VMS和VMID(Virtual Machine Identifier,虚拟机标识)。然后,扩展缓存地址的标记位,将VMID添加到标记位中,其中,缓存地址中的缓存数据属于与所述VMID对应的虚拟机。It should be noted that, in the processor, a virtual machine VM register is added for each processor core, and the VM register structure includes: VMS and VMID (Virtual Machine Identifier, virtual machine identifier). Then, the flag bit of the cache address is extended, and the VMID is added to the flag bit, wherein the cache data in the cache address belongs to the virtual machine corresponding to the VMID.
其中,虚拟机监控器响应虚拟机的管理操作,根据虚拟机的操作内容来设置VMS的状态。当是第一虚拟机执行启动操作或者复制操作时,虚拟机监控器设置此时的VMS为第一状态;当不是第一虚拟机执行启动操作或者复制操作时,虚拟机监控器设置此时的VMS为第二状态。Wherein, the virtual machine monitor responds to the management operation of the virtual machine, and sets the state of the VMS according to the operation content of the virtual machine. When the first virtual machine performs a startup operation or a copy operation, the virtual machine monitor sets the VMS at this time as the first state; when it is not the first virtual machine that performs a startup operation or a copy operation, the virtual machine monitor sets the current VMS VMS is the second state.
进一步的,当第一虚拟机对缓存进行访问,如果第一虚拟机访问缓存时,缓存组的缓存数据均未命中,此时需要访问内存,从中查找相应的数据,然后用缓存中数据进行替换,则缓存控制器对此时VMS的状态进行判断。Furthermore, when the first virtual machine accesses the cache, if the first virtual machine accesses the cache, none of the cached data in the cache group is hit. At this time, it is necessary to access the memory, find the corresponding data, and then replace it with the data in the cache , the cache controller judges the state of the VMS at this time.
需要说明的是,本发明实施例中提到的缓存组,为在虚拟机进行访存操作时,根据访存地址确定的缓存组。It should be noted that the cache group mentioned in the embodiment of the present invention is a cache group determined according to a memory access address when a virtual machine performs a memory access operation.
102、当第一虚拟机的VMS为第一状态时,缓存控制器替换缓存组中属于第二虚拟机的最近最少使用的缓存数据。102. When the VMS of the first virtual machine is in the first state, the cache controller replaces the least recently used cache data belonging to the second virtual machine in the cache group.
需要说明的是,缓存控制器对VMS的状态进行判断,当判断VMS为第二状态时,替换缓存组中最近最少使用的缓存数据。It should be noted that the cache controller judges the state of the VMS, and when it is judged that the VMS is in the second state, replaces the least recently used cache data in the cache group.
其中,当第一虚拟机的VMS为第一状态时,缓存控制器获取第二虚拟机的缓存失效率,然后判断第二虚拟机的缓存失效率是否大于失效率阈值。如果第二虚拟机的缓存失效率大于失效率阈值,则替换缓存组中最近最少使用的缓存数据;如果第二虚拟机的缓存失效率不大于所述失效率阈值,则缓存控制器确定缓存组中属于第二虚拟机的缓存块数目。Wherein, when the VMS of the first virtual machine is in the first state, the cache controller obtains the cache miss rate of the second virtual machine, and then determines whether the cache miss rate of the second virtual machine is greater than a miss rate threshold. If the cache failure rate of the second virtual machine is greater than the failure rate threshold, replace the least recently used cache data in the cache group; if the cache failure rate of the second virtual machine is not greater than the failure rate threshold, the cache controller determines the cache group The number of cache blocks belonging to the second virtual machine in .
进一步的,缓存控制器确定缓存组中属于第二虚拟机的缓存块数目后,判断第二虚拟机的缓存块数目是否小于数目阈值。如果第二虚拟机的缓存块数目小于数目阈值,则替换缓存组中最近最少使用的缓存数据;如果第二虚拟机的缓存块数目不小于数目阈值,则替换缓存组中属于第二虚拟机的最近最少使用的缓存数据。Further, after determining the number of cache blocks belonging to the second virtual machine in the cache group, the cache controller determines whether the number of cache blocks of the second virtual machine is smaller than a threshold value. If the number of cache blocks of the second virtual machine is less than the number threshold, replace the least recently used cache data in the cache group; if the number of cache blocks of the second virtual machine is not less than the number threshold, then replace the cache data belonging to the second virtual machine The least recently used cached data.
需要说明的是,第二虚拟机的失效率阈值和缓存组中属于第二虚拟机的缓存块的数目阈值,均为事先设置的,其值可以根据虚拟机具体的运行情况和用户的需求自行设置;本发明实施例对缓存控制器获取第二虚拟机的缓存失效率的实现方式不做限定,可以是本领域技术人员所熟知的任意实现方式,例如,通过第二虚拟机的MPKI(Misses Per1KInstructions,每1000条指令的缺失率)来计算。It should be noted that the failure rate threshold of the second virtual machine and the threshold of the number of cache blocks belonging to the second virtual machine in the cache group are all set in advance, and the values can be determined according to the specific operating conditions of the virtual machine and the needs of users. Setting; the embodiment of the present invention does not limit the implementation of the cache controller to obtain the cache failure rate of the second virtual machine, and can be any implementation known to those skilled in the art, for example, through the second virtual machine's MPKI (Misses Per1KInstructions, the miss rate per 1000 instructions) to calculate.
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对第二虚拟机和第一虚拟机之间的末级共享缓存进行划分,减少了第二虚拟机占用缓存的容量。由于第二虚拟机对缓存的容量不敏感,即使缓存的失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。Compared with the problem in the prior art that the performance of the virtual machine cannot be well improved and the performance of the virtual machine is low when the virtual machine is started and copied, in the embodiment of the present invention, when the virtual machine is started and copied , dividing the last-level shared cache between the second virtual machine and the first virtual machine, reducing the capacity of the cache occupied by the second virtual machine. Since the second virtual machine is not sensitive to the cache capacity, even if the cache failure rate is high, its performance is not greatly affected, so by reducing the cache capacity occupied by the second virtual machine, increase the cache occupied by the first virtual machine Capacity, to reduce the competition among the virtual machines for the cache, and solve the problem in the prior art that the competition between the virtual machines for the cache reduces the performance of the virtual machine. By solving the above technical problems, the performance of virtual machine startup or replication can be improved.
本发明又一实施例提供一种划分末级共享高速缓存的方法,用于虚拟化环境。在虚拟环境下,本实施例的虚拟平台上,可运行的虚拟机最大个数N=8,Domain0为运行在虚拟机监控器hypervisor上的特权虚拟机,它可以控制物理I/O资源,并且同时与客户虚拟机进行交互,客户虚拟机需要通过Domain0才能启动,虚拟机共享缓存中缓存块大小为8字节,4路组相联,共16个组。如图2所示,所述方法包括:Yet another embodiment of the present invention provides a method for dividing a last-level shared cache, which is used in a virtualization environment. In the virtual environment, on the virtual platform of the present embodiment, the maximum number of virtual machines that can run is N=8, and Domain0 is a privileged virtual machine running on the virtual machine monitor hypervisor, which can control physical I/O resources, and At the same time, it interacts with the guest virtual machine. The guest virtual machine needs to be started through Domain0. The cache block size in the virtual machine shared cache is 8 bytes, 4-way group associative, and a total of 16 groups. As shown in Figure 2, the method includes:
201、添加虚拟机VM寄存器。201. Add a virtual machine VM register.
其中,处理器中包含多个处理器核,为每个处理器核添加虚拟机VM寄存器,VM寄存器中的数据结构包括:虚拟机管理操作状态VMS和虚拟机标识VMID。Wherein, the processor includes multiple processor cores, and a virtual machine VM register is added to each processor core, and the data structure in the VM register includes: a virtual machine management operation state VMS and a virtual machine identifier VMID.
需要说明的是,VMS有0和1两种状态,用于区分此时客户虚拟机执行操作的类型:如果VMS=0,表示此时客户虚拟机不是执行启动操作或者复制操作;如果VMS=1,表示此时客户虚拟机执行启动操作或者复制操作。VMID用于标识不同的虚拟机,VMID的位数由平台上可运行虚拟机的最大数目来确定。It should be noted that VMS has two states of 0 and 1, which are used to distinguish the type of operation performed by the guest virtual machine at this time: if VMS=0, it means that the guest virtual machine is not performing a startup operation or a copy operation at this time; if VMS=1 , indicating that the guest virtual machine is performing a startup operation or a copy operation at this time. The VMID is used to identify different virtual machines, and the number of digits of the VMID is determined by the maximum number of runnable virtual machines on the platform.
例如,如果虚拟平台上可运行虚拟机的最大数目为N,则VMID的位数为log2(N)。本发明实施例中,可运行的虚拟机最大个数N=8,那么VMID的位数有log2(N)=3位,Domain0的VMID为000。本实施例不对N的值进行限定,当N为其他值时本实施例的方法同样适用。For example, if the maximum number of virtual machines that can run on the virtual platform is N, the number of bits of the VMID is log2(N). In the embodiment of the present invention, the maximum number of virtual machines that can run is N=8, then the number of digits of the VMID is log2(N)=3, and the VMID of Domain0 is 000. This embodiment does not limit the value of N, and the method of this embodiment is also applicable when N is other values.
202、扩展缓存地址的标记位。202. Extend the flag bit of the cache address.
其中,在缓存地址的标记位中增加VMID。此处VMID用来标记该缓存地址中的缓存块属于哪个虚拟机,在缓存块数据替换时,将此时寄存器中的VMID值写入到缓存地址中的VMID中即可。Wherein, the VMID is added to the tag bit of the cache address. Here, the VMID is used to mark which virtual machine the cache block in the cache address belongs to. When the cache block data is replaced, the VMID value in the register at this time can be written into the VMID in the cache address.
203、虚拟机监控器设置Domain0的失效率阈值和缓存组中属于Domain0的缓存块数目阈值。203. The virtual machine monitor sets a failure rate threshold of Domain0 and a threshold of the number of cache blocks belonging to Domain0 in the cache group.
其中,Domain0的失效率阈值是根据实验结果得出的。在客户虚拟机执行启动操作或者复制操作时,虽然Domain0能够在失效率很高的情况下,保持很好的性能,但是当失效率超过一定值时,Domain0的性能有可能会下降。为了保证Domain0能够保持很好的性能,用户可根据实验中的结果,自行设定失效率阈值。缓存组中属于Domain0的缓存块数目阈值也为用户自行设定,最大值不能超过缓存组中缓存块的值。Among them, the failure rate threshold of Domain0 is obtained according to the experimental results. When a guest virtual machine performs startup or replication operations, although Domain0 can maintain good performance when the failure rate is high, when the failure rate exceeds a certain value, the performance of Domain0 may degrade. In order to ensure that Domain0 can maintain good performance, users can set the failure rate threshold by themselves according to the experimental results. The threshold for the number of cache blocks belonging to Domain0 in the cache group is also set by the user, and the maximum value cannot exceed the value of the cache blocks in the cache group.
例如,本发明实施例中,每组中缓存块个数为4,则缓存块的数目阈值的最大值为4。For example, in the embodiment of the present invention, if the number of cache blocks in each group is 4, then the maximum value of the cache block number threshold is 4.
需要说明的是,此步骤中提到的缓存组,为在虚拟机进行访存操作时,根据访存地址确定的缓存组。It should be noted that the cache group mentioned in this step is the cache group determined according to the memory access address when the virtual machine performs a memory access operation.
204、虚拟机监控器设置虚拟机管理操作状态VMS的状态。204. The virtual machine monitor sets the state of the virtual machine management operation state VMS.
其中,虚拟机监控器根据虚拟机的操作内容来设置VMS的状态。当虚拟机监控器响应的是客户虚拟机执行启动操作或者复制操作时,设置VMS=1;当虚拟机监控器响应的不是客户虚拟机执行启动操作或者复制操作时,设置VMS=0。Wherein, the virtual machine monitor sets the state of the VMS according to the operation content of the virtual machine. When the virtual machine monitor responds to the guest virtual machine performing a startup operation or a copy operation, set VMS=1; when the virtual machine monitor responds not to the guest virtual machine performing a startup operation or a copy operation, set VMS=0.
205、缓存控制器判定客户虚拟机访问的缓存组的缓存数据是否均未命中,若均未命中,则执行步骤206;若不是均未命中,则结束流程。205. The cache controller determines whether all the cached data in the cache group accessed by the client virtual machine misses, and if none of them hits, execute step 206; if not, end the process.
其中,在虚拟机监控器设置VMS的状态后,虚拟机根据访存地址对缓存进行访问,如果虚拟机访问缓存时,缓存组的缓存数据均未命中,此时需要访问内存,从中查找相应的数据,然后用缓存中数据进行替换,则缓存控制器对此时VMS的状态进行判断;如果虚拟机访问缓存时,缓存组中有缓存数据命中,则不需要数据替换,结束此过程。Among them, after the virtual machine monitor sets the state of the VMS, the virtual machine accesses the cache according to the access address. If the virtual machine accesses the cache, the cache data of the cache group is not hit. At this time, it is necessary to access the memory to find the corresponding Then replace the data with the data in the cache, and the cache controller judges the state of the VMS at this time; if there is a cache data hit in the cache group when the virtual machine accesses the cache, data replacement is not required, and the process ends.
需要说明的是,本发明实施例中,访存地址为16位,那么访存地址的结构如图3所示,其中标记位Tag为访存地址的前九位,当缓存块中的标记位和访存地址中的标记位匹配时并且缓存块中的有效位置为1,则表示缓存命中;缓存组位Set为访存地址的第十到第十三位,用来确定要访问的缓存组,偏移位Offset为访存地址的最后三位,用来确定缓存块中要访问的字节。It should be noted that, in the embodiment of the present invention, the memory access address is 16 bits, so the structure of the memory access address is as shown in Figure 3, wherein the tag bit Tag is the first nine bits of the memory access address, when the tag bit in the cache block When it matches the flag bit in the memory access address and the effective position in the cache block is 1, it means a cache hit; the cache group bit Set is the tenth to thirteenth bits of the memory access address, which is used to determine the cache group to be accessed , the offset bit Offset is the last three bits of the memory access address, which is used to determine the byte to be accessed in the cache block.
例如,Xen响应VMID=101的虚拟机命令,虚拟机监控器设置VMS的状态。然后,VMID=101的虚拟机访问缓存,设该虚拟机此次的访存地址为0001000111010011,那么,从该访存地址中能找出要访问缓存的组号Set=1010,如图4所示。该访存地址在缓存组1010中的四个缓存块扩展后的标记位依次为:000000001111、010000000011、000000000001和011000100001,其中,标记位的前三位为扩展的VMID,表示此缓存块此时所属的虚拟机,后九位为各缓存块的地址的Tag位,本次虚拟机的访存地址的Tag位是000100011,可知四个缓存块均不命中,此时需要访问内存,从中查找相应的数据,然后用缓存中数据进行替换,执行步骤206。For example, Xen responds to a virtual machine command with VMID=101, and the virtual machine monitor sets the state of the VMS. Then, the virtual machine with VMID=101 accesses the cache, and the memory access address of the virtual machine this time is set to 0001000111010011. Then, the group number Set=1010 to access the cache can be found from the memory access address, as shown in Figure 4 . The extended tag bits of the four cache blocks in the cache group 1010 are: 000000001111, 010000000011, 000000000001, and 011000100001, where the first three digits of the tag bits are the extended VMID, indicating that the cache block belongs to The last nine bits are the Tag bits of the address of each cache block. The Tag bit of the memory access address of the virtual machine this time is 000100011. It can be seen that none of the four cache blocks are hit. At this time, it is necessary to access the memory to find the corresponding data, and then replace it with the data in the cache, go to step 206.
206、缓存控制器判定VMS状态是否为1,若VMS状态为1,执行步骤207;否则使用传统LRU替换策略。206. The cache controller determines whether the VMS status is 1, and if the VMS status is 1, execute step 207; otherwise, use the traditional LRU replacement policy.
需要说明的是,VMS的状态已经在步骤204中设置,此时对其进行判定,以便确定数据替换时要使用的替换策略。It should be noted that the status of the VMS has been set in step 204, and it is judged at this time, so as to determine the replacement strategy to be used when replacing data.
其中,替换策略包括传统LRU替换策略和本发明实施例中改进的LRU替换策略。当VMS状态为1时,使用本发明实施例中改进的LRU替换策略,即执行步骤207至步骤211;当VMS状态为0时,使用传统LRU替换策略,即替换缓存组中最近最少使用的缓存数据。Wherein, the replacement strategy includes a traditional LRU replacement strategy and an improved LRU replacement strategy in the embodiment of the present invention. When the VMS status is 1, use the improved LRU replacement strategy in the embodiment of the present invention, that is, perform steps 207 to 211; when the VMS status is 0, use the traditional LRU replacement strategy, that is, replace the least recently used cache in the cache group data.
例如,在本发明实施例中,VMID=101的虚拟机对缓存进行访问时,客户虚拟机要访问的缓存组的缓存块均未命中。如果此时VMS状态为1,则执行步骤207;如果此时VMS状态为0,则执行传统LRU替换策略进行数据替换。如图4所示,假设此时第1010缓存组中,第4个缓存块为最近最少被使用的缓存块,由其VMID=011可知,此缓存块属于VMID=011的虚拟机,而判定结果为VMS状态为0,则选用第4个缓存块,将该缓存块中的数据替换为VMID=101的虚拟机从内存中访问的数据,所得结果如图5所示。For example, in the embodiment of the present invention, when the virtual machine with VMID=101 accesses the cache, none of the cache blocks of the cache group to be accessed by the client virtual machine is hit. If the VMS status is 1 at this time, step 207 is performed; if the VMS status is 0 at this time, a traditional LRU replacement strategy is executed for data replacement. As shown in Figure 4, suppose that in the 1010th cache group at this time, the 4th cache block is the least recently used cache block, and its VMID=011 shows that this cache block belongs to the virtual machine with VMID=011, and the judgment result If the VMS state is 0, select the fourth cache block and replace the data in the cache block with the data accessed from the memory by the virtual machine with VMID=101. The result is shown in Figure 5.
207、缓存控制器获取此时Domain0的缓存失效率。207. The cache controller acquires the cache miss rate of Domain0 at this time.
其中,缓存失效率等于缓存访问缺失次数除以缓存访问次数,本发明实施例对缓存控制器获取Domain0的缓存失效率的实现方式不做限定,可以是本领域技术人员所熟知的任意实现方式,例如,通过Domain0的MPKI。Wherein, the cache failure rate is equal to the number of cache misses divided by the number of cache accesses. The embodiment of the present invention does not limit the implementation of the cache controller to obtain the cache failure rate of Domain0, and may be any implementation known to those skilled in the art. For example, MPKI via Domain0.
208、缓存控制器判定缓存失效率是否大于失效率阈值,若不大于失效率阈值,则执行步骤209;否则使用传统LRU替换策略。208. The cache controller determines whether the cache failure rate is greater than the failure rate threshold, and if not greater than the failure rate threshold, executes step 209; otherwise, uses the traditional LRU replacement strategy.
其中,如果此时Domain0的缓存失效率大于失效率阈值,则使用传统LRU替换策略,即替换缓存组中最近最少使用的缓存数据;如果Domain0的缓存失效率不大于所述失效率阈值,则执行步骤209。Wherein, if the cache failure rate of Domain0 is greater than the failure rate threshold at this time, then use the traditional LRU replacement strategy, that is, replace the least recently used cache data in the cache group; if the cache failure rate of Domain0 is not greater than the failure rate threshold, then execute Step 209.
209、缓存控制器确定缓存组中属于Domain0的缓存块数目。209. The cache controller determines the number of cache blocks belonging to Domain0 in the cache group.
其中,缓存控制器可以根据缓存标记位中扩展的VMID,得出此时缓存组中的各缓存块属于哪个虚拟机,从而确定属于Domain0的缓存块数目。Wherein, the cache controller can obtain which virtual machine each cache block in the cache group belongs to at this time according to the VMID extended in the cache tag bit, so as to determine the number of cache blocks belonging to Domain0.
例如,本发明实施例中,如图4所示,缓存组1010中,根据各缓存块的VMID可得:第1个和第3个缓存块属于Domain0,第2个缓存块属于VMID=010的虚拟机,第4个缓存块属于VMID=011的虚拟机,则可确定属于Domain0的缓存块数目为2。For example, in the embodiment of the present invention, as shown in FIG. 4, in cache group 1010, according to the VMID of each cache block, it can be obtained that: the first and third cache blocks belong to Domain0, and the second cache block belongs to VMID=010 For a virtual machine, if the fourth cache block belongs to the virtual machine with VMID=011, it can be determined that the number of cache blocks belonging to Domain0 is 2.
210、缓存控制器判定缓存块数目是否小于数目阈值,若小于数目阈值,则执行步骤211;否则使用传统LRU替换策略。210. The cache controller determines whether the number of cache blocks is less than the threshold number, and if it is smaller than the threshold number, execute step 211; otherwise, use the traditional LRU replacement policy.
其中,如果缓存组中属于Domain0的缓存块数目小于所述数目阈值,则使用传统LRU替换策略,即替换缓存组中最近最少使用的缓存数据;如果缓存组中属于Domain0的缓存块数目不小于数目阈值,则执行步骤211。Wherein, if the number of cache blocks belonging to Domain0 in the cache group is less than the number threshold, the traditional LRU replacement strategy is used, that is, the least recently used cache data in the cache group is replaced; if the number of cache blocks belonging to Domain0 in the cache group is not less than the number threshold, go to step 211.
211、缓存控制器选用缓存组中属于Domain0的最近最少使用的缓存块替换。211. The cache controller selects the least recently used cache block belonging to Domain0 in the cache group for replacement.
例如,本发明实施例中,如图4所示,此时第1010组中,第1个和第3个缓存块均属于Domain0,假设第3个缓存块为最近最少被使用的属于Domain0的缓存块,选用第3个缓存块,将该缓存块中的数据替换为VMID=101的虚拟机从内存中访问的数据,所得结果如图6所示。For example, in the embodiment of the present invention, as shown in FIG. 4 , at this time, in the 1010th group, the first and third cache blocks belong to Domain0, assuming that the third cache block is the least recently used cache belonging to Domain0 block, select the third cache block, and replace the data in the cache block with the data accessed from the memory by the virtual machine with VMID=101. The result is shown in Figure 6.
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对Domain0和客户虚拟机之间的末级共享缓存进行划分,减少了Domain0占用缓存的容量。由于Domain0对缓存的容量不敏感,即使缓存的失效率很高,对其性能的影响也不大,所以通过减少Domain0占用的缓存容量,增大客户虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。Compared with the problem in the prior art that the performance of the virtual machine cannot be well improved and the performance of the virtual machine is low when the virtual machine is started and copied, in the embodiment of the present invention, when the virtual machine is started and copied , divide the last-level shared cache between Domain0 and the guest virtual machine, and reduce the capacity of the cache occupied by Domain0. Since Domain0 is not sensitive to the cache capacity, even if the cache failure rate is high, its performance is not greatly affected. Therefore, by reducing the cache capacity occupied by Domain0 and increasing the cache capacity occupied by guest virtual machines, the virtual machine The competition for the cache among the virtual machines solves the problem in the prior art that the performance of the virtual machines decreases due to the competition for the cache among the virtual machines. By solving the above technical problems, the performance of virtual machine startup or replication can be improved.
本发明又一实施例提供一种划分高速缓存的装置30,如图7所示,所述装置30包括:Another embodiment of the present invention provides a device 30 for dividing a cache. As shown in FIG. 7, the device 30 includes:
判断单元31,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;A judging unit 31, configured to judge the virtual machine management operation status VMS of the first virtual machine when none of the cached data in the cache group accessed by the first virtual machine hits;
替换单元32,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。The replacement unit 32 is configured to replace the least recently used cache data belonging to the second virtual machine in the cache group when the VMS of the first virtual machine is in the first state.
进一步的,如图8所示,所述装置30还可以包括:Further, as shown in FIG. 8, the device 30 may also include:
添加单元33,用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。The adding unit 33 is configured to add a virtual machine VM register, the data structure of the VM register includes: the VMS and a virtual machine identifier VMID.
进一步的,如图8所示,所述装置30还可以包括:Further, as shown in FIG. 8, the device 30 may also include:
扩展单元34,用于扩展缓存地址的标记位,将所述添加单元33添加的所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。The extension unit 34 is configured to extend the flag bit of the cache address, and add the VMID added by the adding unit 33 to the flag bit, and the cache data in the cache address belongs to the virtual machine corresponding to the VMID.
进一步的,如图8所示,所述装置30还可以包括:Further, as shown in FIG. 8, the device 30 may also include:
设置单元35,用于当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。A setting unit 35, configured to set the VMS of the first virtual machine to a first state when the first virtual machine performs a startup operation or a copy operation; when the first virtual machine does not perform a startup operation or a copy operation , setting the VMS of the first virtual machine to a second state.
进一步的,所述替换单元32还用于:Further, the replacement unit 32 is also used for:
当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。When the VMS of the first virtual machine is in the second state, replace the least recently used cache data in the cache group.
进一步的,所述判断单元31还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;Further, the judging unit 31 is further configured to judge whether the cache failure rate of the second virtual machine is greater than a failure rate threshold;
所述替换单元32还用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;如图8所示,所述装置30还可以包括:The replacement unit 32 is further configured to replace the least recently used cache data in the cache group when the cache failure rate of the second virtual machine is greater than the failure rate threshold; as shown in FIG. 8 , the device 30 Can also include:
确定单元36,用于当所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。The determining unit 36 is configured to determine the number of cache blocks belonging to the second virtual machine in the cache group when the cache failure rate of the second virtual machine is not greater than the failure rate threshold.
进一步的,所述判断单元31还用于判断所述第二虚拟机的缓存块数目是否小于所述确定单元36确定的所述数目阈值;Further, the judging unit 31 is further configured to judge whether the number of cache blocks of the second virtual machine is smaller than the number threshold determined by the determining unit 36;
所述替换单元32还用于当所述第二虚拟机的缓存块数目小于所述确定单元36确定的所述数目阈值时,替换所述缓存组中最近最少使用的缓存数据;The replacement unit 32 is further configured to replace the least recently used cache data in the cache group when the number of cache blocks of the second virtual machine is less than the number threshold determined by the determination unit 36;
所述替换单元32还用于当所述第二虚拟机的缓存块数目不小于所述确定单元36确定的所述数目阈值时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。The replacing unit 32 is further configured to replace the least recently used cache block belonging to the second virtual machine in the cache group when the number of cache blocks of the second virtual machine is not less than the number threshold determined by the determining unit 36. Cache data.
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对第二虚拟机和第一虚拟机之间的末级共享缓存进行划分,减少了第二虚拟机占用缓存的容量。由于第二虚拟机对缓存的容量不敏感,即使缓存失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。Compared with the problem in the prior art that the performance of the virtual machine cannot be well improved and the performance of the virtual machine is low when the virtual machine is started and copied, in the embodiment of the present invention, when the virtual machine is started and copied , dividing the last-level shared cache between the second virtual machine and the first virtual machine, reducing the capacity of the cache occupied by the second virtual machine. Since the second virtual machine is not sensitive to the cache capacity, even if the cache failure rate is high, its performance is not greatly affected, so by reducing the cache capacity occupied by the second virtual machine, increase the cache capacity occupied by the first virtual machine , to reduce the competition among the virtual machines for the cache, and solve the problem in the prior art that the performance of the virtual machine is degraded due to the competition for the cache between the virtual machines. By solving the above technical problems, the performance of virtual machine startup or replication can be improved.
本发明又一实施例提供一种划分高速缓存的装置40,如图9所示,所述装置40包括:Yet another embodiment of the present invention provides a device 40 for dividing a cache. As shown in FIG. 9 , the device 40 includes:
处理器41,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;以及,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。The processor 41 is configured to determine the virtual machine management operation state VMS of the first virtual machine when none of the cache data in the cache group accessed by the first virtual machine hits; and, when the first virtual machine's When the VMS is in the first state, replace the least recently used cache data belonging to the second virtual machine in the cache group.
进一步的,所述处理器41还用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。Further, the processor 41 is further configured to add a virtual machine VM register, and the data structure of the VM register includes: the VMS and a virtual machine identifier VMID.
进一步的,所述处理器41还用于扩展缓存地址的标记位,将所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。Further, the processor 41 is further configured to extend the flag bit of the cache address, and add the VMID to the flag bit, and the cache data in the cache address belongs to the virtual machine corresponding to the VMID.
进一步的,所述处理器41还用于当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;以及,用于当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。Further, the processor 41 is further configured to set the VMS of the first virtual machine to the first state when the first virtual machine executes a startup operation or a copy operation; and, when the first virtual machine Set the VMS of the first virtual machine to the second state when the machine is not performing the startup operation or the copy operation.
进一步的,所述处理器41还用于当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。Further, the processor 41 is further configured to replace the least recently used cache data in the cache group when the VMS of the first virtual machine is in the second state.
可选的,所述处理器41还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;以及,用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;以及,用于当所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。Optionally, the processor 41 is further configured to determine whether the cache miss rate of the second virtual machine is greater than a miss rate threshold; and, when the cache miss rate of the second virtual machine is greater than the miss rate threshold , replace the least recently used cache data in the cache group; and, when the cache invalidation rate of the second virtual machine is not greater than the invalidation rate threshold, determine that the cache data in the cache group belongs to the second The number of cache blocks for the virtual machine.
可选的,所述处理器41还用于判断所述第二虚拟机的缓存块数目是否小于数目阈值;以及,用于如果所述第二虚拟机的缓存块数目小于所述数目阈值,则替换所述缓存组中最近最少使用的缓存数据;以及,用于如果所述第二虚拟机的缓存块数目不小于所述数目阈值,则替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。Optionally, the processor 41 is further configured to determine whether the number of cache blocks of the second virtual machine is less than a number threshold; and, if the number of cache blocks of the second virtual machine is less than the number threshold, then replacing the least recently used cache data in the cache group; and, if the number of cache blocks of the second virtual machine is not less than the number threshold, replacing the least recently used cache data belonging to the second virtual machine in the cache group The cached data to use.
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对第二虚拟机和第一虚拟机之间的末级共享缓存进行划分,减少了第二虚拟机占用缓存的容量。由于第二虚拟机对缓存的容量不敏感,即使缓存失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。Compared with the problem in the prior art that the performance of the virtual machine cannot be well improved and the performance of the virtual machine is low when the virtual machine is started and copied, in the embodiment of the present invention, when the virtual machine is started and copied , dividing the last-level shared cache between the second virtual machine and the first virtual machine, reducing the capacity of the cache occupied by the second virtual machine. Since the second virtual machine is not sensitive to the cache capacity, even if the cache failure rate is high, its performance is not greatly affected, so by reducing the cache capacity occupied by the second virtual machine, increase the cache capacity occupied by the first virtual machine , to reduce the competition among the virtual machines for the cache, and solve the problem in the prior art that the performance of the virtual machine is degraded due to the competition for the cache between the virtual machines. By solving the above technical problems, the performance of virtual machine startup or replication can be improved.
本发明实施例提供的一种访问划分高速缓存的装置可以实现上述提供的方法实施例,具体功能实现请参见方法实施例中的说明,在此不再赘述。本发明实施例提供的一种划分高速缓存的方法及装置可以适用于虚拟化环境,但不仅限于此。An apparatus for accessing a divided cache provided by an embodiment of the present invention can implement the method embodiment provided above. For specific function implementation, please refer to the description in the method embodiment, and details will not be repeated here. The method and device for dividing a cache provided by the embodiments of the present invention may be applicable to a virtualization environment, but is not limited thereto.
需要说明的是,本发明实施例中提到的缓存可适用于末级共享高速缓存,大不仅限于此。It should be noted that the cache mentioned in the embodiment of the present invention is applicable to the last-level shared cache, but is not limited thereto.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于设备实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant parts, please refer to part of the description of the method embodiment.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random AccessMemory,RAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the programs can be stored in a computer-readable storage medium. During execution, it may include the processes of the embodiments of the above-mentioned methods. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM), and the like.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Anyone skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present invention. All should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the protection scope of the claims.
Claims (14)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310422795.0A CN104461928B (en) | 2013-09-16 | 2013-09-16 | Divide the method and device of cache |
PCT/CN2014/086341 WO2015035928A1 (en) | 2013-09-16 | 2014-09-12 | Method and apparatus for dividing cache |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310422795.0A CN104461928B (en) | 2013-09-16 | 2013-09-16 | Divide the method and device of cache |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104461928A CN104461928A (en) | 2015-03-25 |
CN104461928B true CN104461928B (en) | 2018-11-16 |
Family
ID=52665083
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310422795.0A Active CN104461928B (en) | 2013-09-16 | 2013-09-16 | Divide the method and device of cache |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN104461928B (en) |
WO (1) | WO2015035928A1 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106484539A (en) * | 2016-10-13 | 2017-03-08 | 东北大学 | A kind of determination method of processor cache characteristic |
CN108228351B (en) * | 2017-12-28 | 2021-07-27 | 上海交通大学 | GPU performance balance scheduling method, storage medium and electronic terminal |
CN111880726B (en) * | 2020-06-19 | 2022-05-10 | 浙江工商大学 | A method to improve the performance of CNFET cache |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1495618A (en) * | 2002-09-20 | 2004-05-12 | 英特尔公司 | Chip multiprocessor or high-speed buffer storage share of multiprocessing system |
US7856633B1 (en) * | 2000-03-24 | 2010-12-21 | Intel Corporation | LRU cache replacement for a partitioned set associative cache |
CN102999444A (en) * | 2012-11-13 | 2013-03-27 | 华为技术有限公司 | Method and device for replacing data in caching module |
CN103218316A (en) * | 2012-02-21 | 2013-07-24 | 微软公司 | Cache employing multiple page replacement algorithms |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6587937B1 (en) * | 2000-03-31 | 2003-07-01 | Rockwell Collins, Inc. | Multiple virtual machine system with efficient cache memory design |
CN101571836A (en) * | 2008-04-29 | 2009-11-04 | 国际商业机器公司 | Method and system for replacing cache blocks |
US8745618B2 (en) * | 2009-08-25 | 2014-06-03 | International Business Machines Corporation | Cache partitioning with a partition table to effect allocation of ways and rows of the cache to virtual machine in virtualized environments |
US8990582B2 (en) * | 2010-05-27 | 2015-03-24 | Cisco Technology, Inc. | Virtual machine memory compartmentalization in multi-core architectures |
-
2013
- 2013-09-16 CN CN201310422795.0A patent/CN104461928B/en active Active
-
2014
- 2014-09-12 WO PCT/CN2014/086341 patent/WO2015035928A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7856633B1 (en) * | 2000-03-24 | 2010-12-21 | Intel Corporation | LRU cache replacement for a partitioned set associative cache |
CN1495618A (en) * | 2002-09-20 | 2004-05-12 | 英特尔公司 | Chip multiprocessor or high-speed buffer storage share of multiprocessing system |
CN103218316A (en) * | 2012-02-21 | 2013-07-24 | 微软公司 | Cache employing multiple page replacement algorithms |
CN102999444A (en) * | 2012-11-13 | 2013-03-27 | 华为技术有限公司 | Method and device for replacing data in caching module |
Non-Patent Citations (1)
Title |
---|
一种新型共享Cache动态划分机制;倪亚路,周晓方;《计算机工程》;20111130;第37卷(第22期);第2.4节 * |
Also Published As
Publication number | Publication date |
---|---|
WO2015035928A1 (en) | 2015-03-19 |
CN104461928A (en) | 2015-03-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104598303B (en) | Online moving method and device between virtual machine based on KVM | |
US20210279054A1 (en) | Implementing a micro-operation cache with compaction | |
JP5571208B2 (en) | Virtualization of performance counters | |
US9703566B2 (en) | Sharing TLB mappings between contexts | |
US20080086598A1 (en) | System and method for establishing cache priority for critical data structures of an application | |
CN105095116A (en) | Cache replacing method, cache controller and processor | |
TWI641947B (en) | Method and apparatus for managing address translation and caching | |
US20150095585A1 (en) | Consistent and efficient mirroring of nonvolatile memory state in virtualized environments | |
US9830262B2 (en) | Access tracking mechanism for hybrid memories in a unified virtual system | |
US20150095576A1 (en) | Consistent and efficient mirroring of nonvolatile memory state in virtualized environments | |
US9471226B2 (en) | Reverse copy on write for better cache utilization | |
US8041896B2 (en) | Virtualization platform with dedicated cache access | |
WO2014075428A1 (en) | Method and device for replacing data in cache module | |
CN103052945A (en) | A method of managing computer memory, corresponding computer program product | |
US10747679B1 (en) | Indexing a memory region | |
TWI648625B (en) | Managing address-independent page attributes | |
CN104461928B (en) | Divide the method and device of cache | |
WO2012163017A1 (en) | Method for processing access exception of distributed virtual machine and virtual machine monitor | |
US9921875B2 (en) | Zero copy memory reclaim for applications using memory offlining | |
JP2006155272A (en) | Control method and program for virtual computer | |
US10359969B1 (en) | Creating virtual machine snapshots without interfering with active user sessions | |
TW202427170A (en) | Using masked stream identifiers for a translation lookaside buffer | |
CN103207763B (en) | Based on the front end caching method of xen virtual disk device | |
US20130346975A1 (en) | Memory management method, information processing device, and computer-readable recording medium having stored therein memory management program | |
CN102306108A (en) | Method for realizing peripheral access control based on MMU (memory management unit) in ARM virtual machine |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |