WO2015035928A1 - 划分高速缓存的方法及装置 - Google Patents

划分高速缓存的方法及装置 Download PDF

Info

Publication number
WO2015035928A1
WO2015035928A1 PCT/CN2014/086341 CN2014086341W WO2015035928A1 WO 2015035928 A1 WO2015035928 A1 WO 2015035928A1 CN 2014086341 W CN2014086341 W CN 2014086341W WO 2015035928 A1 WO2015035928 A1 WO 2015035928A1
Authority
WO
WIPO (PCT)
Prior art keywords
virtual machine
cache
vms
failure rate
group
Prior art date
Application number
PCT/CN2014/086341
Other languages
English (en)
French (fr)
Inventor
隋秀峰
任睿
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015035928A1 publication Critical patent/WO2015035928A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0844Multiple simultaneous or quasi-simultaneous cache accessing
    • G06F12/0846Cache with multiple tag or data arrays being simultaneously accessible
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/123Replacement control using replacement algorithms with age lists, e.g. queue, most recently used [MRU] list or least recently used [LRU] list
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/15Use in a specific computing environment
    • G06F2212/152Virtualized environment, e.g. logically partitioned system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/60Details of cache memory
    • G06F2212/601Reconfiguration of cache memory

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for dividing a cache.
  • Virtualization technology is one of the hot technologies in today's enterprises. It has been widely used in research fields such as server consolidation, system migration, and load isolation.
  • the current virtualization technology can strictly divide the physical resources such as multi-core processor, memory, and input/output I/O, eliminate the competition of physical resources between virtual machines, and ensure the function and performance isolation of virtual machines.
  • the shared hardware resources such as the on-chip multi-level cache
  • the current virtualization technology is not divided, and the implicit competition between the virtual machines for these hardware resources may cause the performance of some virtual machines to degrade.
  • some virtualized applications on a virtual machine are sensitive to the capacity of the LLC (Last-Level Cache). When the capacity of the LLC that the virtual machine can use is reduced due to competition, the performance of the virtual machine will follow. Reduced.
  • the researchers proposed a shared cache partitioning mechanism.
  • the cache is divided by the modified LRU (Least Recently Used) and the page coloring method to limit the shared cache capacity used by different virtual machines, thereby reducing the contention conflict on the shared cache.
  • LRU Least Recently Used
  • the prior art has at least the following problem: in a multi-tenant data center, the effect of each user performing different management operations on the virtual machine is superimposed, for example, in the process of starting a virtual machine and performing a copy operation using a virtual machine, when a large number of virtual When the machine starts up 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, the performance of the virtual machine is seriously degraded due to the superposition of operational effects.
  • the cache partitioning method in the prior art is started in the virtual machine. When moving and copying, the performance of the virtual machine is not improved well, and the performance of the virtual machine is low.
  • Embodiments of the present invention provide a method and apparatus for partitioning a cache, which can solve the problem that the performance of the virtual machine is low when the virtual machine performs startup and replication.
  • an embodiment of the present invention provides a method for dividing a cache, including:
  • the least recently used cache data belonging to the second virtual machine in the cache group is replaced.
  • the method before the determining the virtual machine management operation state VMS of the first virtual machine, the method further includes:
  • a virtual machine VM register is added, the data structure of the VM register including: the VMS and a virtual machine identification VMID.
  • the method further includes:
  • VMS of the first virtual machine Setting the VMS of the first virtual machine to a first state when the first virtual machine performs a startup operation or a copy operation; setting the first when the first virtual machine does not perform a startup operation or a copy operation
  • the VMS of the virtual machine is in the second state.
  • the method before the VMS of the first virtual machine is in the first state, before replacing the least-used cache data belonging to the second virtual machine in the cache group, the method further includes:
  • the method further includes:
  • the tag bit of the extended cache address is added to the tag bit, and the cache data in the cache address belongs to a virtual machine corresponding to the VMID.
  • the method further includes:
  • the second virtual machine is configured to control physical input and output I/O resources of the virtual environment, and the first virtual machine Interacting to start the first virtual machine.
  • an embodiment of the present invention provides an apparatus for dividing a cache, including:
  • a determining unit configured to determine, when the cache data of the cache group accessed by the first virtual machine is missed, the virtual machine management operation state VMS of the first virtual machine
  • a replacement unit 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.
  • the device further includes:
  • a adding unit configured to add a virtual machine VM register, where the data structure of the VM register includes: the VMS and a virtual machine identifier VMID.
  • the device further includes: a setting unit, configured to execute when the first virtual machine is executed Setting a VMS of the first virtual machine to a first state when starting an operation or a copying operation; and setting a VMS of the first virtual machine when the first virtual machine does not perform a startup operation or a copy operation Is the second state.
  • a setting unit configured to execute when the first virtual machine is executed Setting a VMS of the first virtual machine to a first state when starting an operation or a copying operation; and setting a VMS of the first virtual machine when the first virtual machine does not perform a startup operation or a copy operation Is the second state.
  • the determining unit is further configured to determine whether a cache failure rate of the second virtual machine is greater than a failure rate threshold; and the replacing unit is further configured to: when the cache failure rate of the second virtual machine is greater than the failure When the threshold is exceeded, the least recently used cache data in the cache group is replaced; the device further includes:
  • a determining unit configured to determine, when the cache failure rate of the second virtual machine is not greater than the failure rate threshold, the number of cache blocks belonging to the second virtual machine in the cache group.
  • the device further includes:
  • an extension unit configured to: expand a tag bit of the cache address, add the VMID added by the adding unit to the tag bit, and the cache data in the cache address belongs to a virtual machine corresponding to the VMID.
  • the determining unit is further configured to determine whether the number of cache blocks of the second virtual machine is smaller than the number threshold determined by the determining unit; the replacing unit is further configured to be used by the second virtual machine. Replacing the least recently used cache data in the cache group when the number of cache blocks is less than the number threshold determined by the determining unit; the replacing unit is further configured to: when the number of cache blocks of the second virtual machine is not less than When the number of thresholds determined by the determining unit is determined, the least recently used cache data belonging to the second virtual machine in the cache group is replaced.
  • the replacing 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.
  • the second virtual machine is configured to control physical input and output I/O resources of the virtual environment, and the first virtual machine Interacting to start the first virtual machine.
  • the method and device for dividing the last-level shared cache provided by the embodiment of the present invention, and the prior art, when the virtual machine performs startup and replication, the performance of the virtual machine cannot be improved well, and the performance of the virtual machine is low.
  • the last-level shared cache between the first virtual machine and the second virtual machine is divided, and the cache capacity occupied by the second virtual machine is reduced. Since the second virtual machine is insensitive to the capacity of the cache, even if the cache failure rate is high, the impact on the performance is not large. Therefore, by reducing the buffer capacity occupied by the second virtual machine, the cache occupied by the first virtual machine is increased. Capacity to reduce the competition between caches between virtual machines, thereby improving the performance of virtual machines when they are started or copied.
  • FIG. 1 is a flowchart of a method according to an embodiment of the present invention
  • FIG. 3 is a structural diagram of a memory access address according to another embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a cache structure according to another embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a cache structure after replacing with conventional LRU data according to another embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a cache structure after replacement using improved LRU data according to another embodiment of the present invention.
  • FIG. 7 and FIG. 8 are schematic structural diagrams of a device according to another embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a device according to another embodiment of the present invention.
  • An embodiment of the present invention provides a method for dividing a cache, where 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 the virtual machine monitor.
  • a virtual machine which can control physical I/O resources and simultaneously interact with the first virtual machine.
  • the first virtual machine is a guest virtual machine, and multiple first virtual machines can be started by multiple second virtual machines.
  • the method includes:
  • the cache controller determines the VMS (Virtual Management State) of the first virtual machine when the cache data of the cache group accessed by the first virtual machine is missed.
  • VMS Virtual Management State
  • a virtual machine VM register is added for each processor core, and the VM register structure includes: a VMS and a VMID (Virtual Machine Identifier). Then, the tag bit of the cache address is expanded, and the VMID is added to the tag bit, wherein the cache data in the cache address belongs to the virtual machine corresponding to the VMID.
  • 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.
  • the virtual machine monitor sets the VMS at the current state to the first state; when the first virtual machine does not perform the startup operation or the copy operation, the virtual machine monitor sets the current time. VMS is in the second state.
  • the cache controller judges the state of the VMS at this time.
  • the cache group mentioned in the embodiment of the present invention is a cache group determined according to the memory access address when the virtual machine performs a memory access operation.
  • the cache controller replaces the least recently used cache data belonging to the second virtual machine in the cache group.
  • the cache controller determines the state of the VMS, and when determining that the VMS is in the second state, replaces the least recently used cache data in the cache group.
  • the cache controller acquires the cache failure rate of the second virtual machine, and then determines whether the cache failure rate of the second virtual machine is greater than the failure rate threshold. If the cache failure rate of the second virtual machine is greater than the failure rate threshold, replacing 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.
  • the cache controller after determining, by the cache controller, the number of cache blocks belonging to the second virtual machine in the cache group, determining whether the number of cache blocks of the second virtual machine is less than a threshold. If the number of cache blocks of the second virtual machine is less than the number threshold, replacing 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, replacing the cached group belonging to the second virtual machine The least recently used cached data.
  • the failure 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 value may be based on the specific operation of the virtual machine and the needs of the user.
  • the embodiment of the present invention is not limited to the implementation manner in which the cache controller obtains the cache failure rate of the second virtual machine, and may be any implementation well known to those skilled in the art, for example, through the MPKI of the second virtual machine (Misses). Per 1K Instructions, the missing rate for every 1000 instructions).
  • the performance of the virtual machine is not improved well, and the performance of the virtual machine is low.
  • the virtual machine when the virtual machine performs startup and replication, Dividing the last-level shared cache between the second virtual machine and the first virtual machine, reducing the capacity of the second virtual machine to occupy the cache. Since the second virtual machine is insensitive to the capacity of the cache, even if the cache failure rate is high, the impact on the performance is not large. Therefore, by reducing the buffer capacity occupied by the second virtual machine, the cache occupied by the first virtual machine is increased. Capacity to reduce each virtual machine The competition between the caches solves the problem of cache competition between virtual machines in the prior art and degrades the performance of the virtual machine. By solving the above technical problems, it is possible to improve the performance when the virtual machine is started or copied.
  • Yet another embodiment of the present invention provides a method for partitioning a last-level shared cache for use in a virtualized environment.
  • N the maximum number of virtual machines that can be run
  • Domain 0 is a privileged virtual machine running on the hypervisor hypervisor, which can control physical I/O resources.
  • the guest virtual machine needs to be started by Domain 0.
  • the cache block size in the virtual machine shared cache is 8 bytes, and the 4-way group is associated with 16 groups.
  • the method includes:
  • the processor includes a plurality of processor cores, and a virtual machine VM register is added for each processor core.
  • the data structure in the VM register includes: a virtual machine management operation state VMS and a virtual machine identifier VMID.
  • the VMID is used to identify different virtual machines, and the number of VMID bits is determined by the maximum number of virtual machines that can be run on the platform.
  • the maximum number of virtual machines that can be run on a virtual platform is N
  • the number of bits in the VMID is log2(N).
  • the VMID of the Domain 0 is 000.
  • This embodiment does not limit the value of N.
  • the method of this embodiment is also applicable when N is another value.
  • VMID is added to the flag bit of the cache address.
  • VMID is used to mark which virtual machine the cache block in the cache address belongs to. When the cache block data is replaced, it will be in the register at this time. The VMID value is written to the VMID in the cache address.
  • the virtual machine monitor sets a failure rate threshold of Domain 0 and a threshold number of cache blocks belonging to Domain 0 in the cache group.
  • the failure rate threshold of Domain 0 is based on the experimental results.
  • the failure rate threshold is also set by the user, and the maximum value cannot exceed the value of the cache block in the cache group.
  • the number of cache blocks in each group is 4, and the maximum value of the threshold number of cache blocks is 4.
  • the cache group mentioned in this step is a cache group determined according to the memory access address when the virtual machine performs a memory access operation.
  • the virtual machine monitor sets a state of the virtual machine management operation state VMS.
  • the virtual machine monitor sets the state of the VMS according to the operation content of the virtual machine.
  • the cache controller determines whether the cache data of the cache group accessed by the guest virtual machine is missed. If none of the cache data is missed, step 206 is performed; if not, the process ends.
  • the virtual machine monitor sets the state of the VMS
  • the virtual machine accesses the cache according to the memory access address. If the virtual machine accesses the cache, the cached data of the cache group is missed. In this case, the memory needs to be accessed, and the corresponding memory is searched for. The data is then replaced with the data in the cache, and the cache controller judges the state of the VMS at this time; if the virtual machine accesses the cache, there is a cached data hit in the cache group, then no data replacement is required, and the process ends.
  • the memory access address is 16 bits, and then the memory address is accessed.
  • the structure is shown in Figure 3, where the tag bit Tag is the first nine bits of the memory access address.
  • the tag bit in the cache block matches the tag bit in the memory address and the valid bit in the cache block is 1, the buffer is cached. Hit; the cache group set is the tenth to thirteenth bits of the memory access address, used to determine the cache group to be accessed, and the offset bit Offset is the last three digits of the memory access address, which is used to determine the cache block to be accessed. byte.
  • the flag bits of the memory access address in the cache group 1010 are expanded by: 000000001111, 010000000011, 000000000001, and 011000100001, wherein the first three bits of the flag bit are extended VMIDs, indicating that the cache block belongs to this time.
  • the virtual machine, the last nine bits are the tag bits of the address of each cache block.
  • the tag bit of the virtual machine's memory access address is 000100011. It can be seen that the four cache blocks are not hit. In this case, the memory needs to be accessed to find the corresponding The data is then replaced with the data in the cache, and step 206 is performed.
  • the cache controller determines whether the VMS state is 1. If the VMS state is 1, step 207 is performed; otherwise, the traditional LRU replacement policy is used.
  • step 204 the state of the VMS has been set in step 204, at which point it is determined to determine the replacement strategy to be used in data replacement.
  • the replacement strategy includes a traditional LRU replacement policy and an improved LRU replacement strategy in the embodiment of the present invention.
  • the LRU replacement policy is improved in the embodiment of the present invention, that is, steps 207 to 211 are performed; when the VMS state is 0, the traditional LRU replacement policy is used, that is, the least recently used cache in the cache group is replaced. data.
  • the cache controller obtains the cache failure rate of the domain 0 at this time.
  • the cache failure rate is equal to the number of cache accesses lost by the number of cache accesses.
  • the implementation manner of the cache controller to obtain the cache failure rate of the domain 0 is not limited, and may be any implementation manner well known to those skilled in the art. For example, MPKI via Domain 0.
  • the cache controller determines whether the cache failure rate is greater than the failure rate threshold. If the failure rate threshold is not greater than the failure rate threshold, step 209 is performed; otherwise, the traditional LRU replacement policy is used.
  • the traditional LRU replacement policy is used, that is, the least recently used cache data in the cache group is replaced; if the cache failure rate of the domain 0 is not greater than the failure rate threshold, Then step 209 is performed.
  • the cache controller determines the number of cache blocks belonging to Domain 0 in the cache group.
  • the cache controller may determine, according to the extended VMID in the cache tag bit, which virtual machine belongs to each cache block in the cache group, thereby determining the number of cache blocks belonging to Domain 0.
  • the cache controller determines whether the number of cache blocks is less than a threshold. If the threshold is less than the threshold, step 211 is performed; otherwise, the traditional LRU replacement policy is used.
  • step 211 is performed.
  • the cache controller replaces the least recently used cache block belonging to Domain 0 in the cache group.
  • a further embodiment of the present invention provides a device 30 for dividing a cache. As shown in FIG. 7, the device 30 includes:
  • the determining unit 31 is configured to determine, when the cache data of the cache group accessed by the first virtual machine is missed, the virtual machine management operation state VMS of the first virtual machine;
  • the replacing unit 32 is configured to replace, when the VMS of the first virtual machine is in the first state, the least recently used cache data belonging to the second virtual machine in the cache group.
  • the device 30 may further include:
  • the adding unit 33 is configured to add a virtual machine VM register, and the data structure of the VM register includes: the VMS and the virtual machine identifier VMID.
  • the device 30 may further include:
  • the expansion unit 34 is configured to expand a 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 a virtual machine corresponding to the VMID.
  • the device 30 may further include:
  • a setting unit 35 configured to: when the first virtual machine performs a startup operation or a copy operation, set a 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 And setting the VMS of the first virtual machine to a second state.
  • replacing unit 32 is further configured to:
  • the determining unit 31 is further configured to determine whether a cache failure rate of the second virtual machine is greater than a failure rate threshold;
  • the replacing 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. It can also include:
  • the determining unit 36 is configured to determine, when the cache failure rate of the second virtual machine is not greater than the failure rate threshold, the number of cache blocks belonging to the second virtual machine in the cache group.
  • the determining unit 31 is further configured to determine whether the number of cache blocks of the second virtual machine is smaller than the threshold of the number determined by the determining unit 36;
  • the replacing 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 determining unit 36;
  • the replacing unit 32 is further configured to replace the least recently used one of the cache groups belonging to the second virtual machine 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.
  • the performance of the virtual machine is not improved well, and the performance of the virtual machine is low.
  • the virtual machine when the virtual machine performs startup and replication, Dividing the last-level shared cache between the second virtual machine and the first virtual machine, reducing the capacity of the second virtual machine to occupy the cache. Since the second virtual machine is not sensitive to the capacity of the cache, Even if the cache failure rate is high, the impact on the performance is not large. Therefore, by reducing the cache capacity occupied by the second virtual machine and increasing the cache capacity occupied by the first virtual machine, the cache competition between the virtual machines is reduced. The problem of cache competition between virtual machines in the prior art is solved, and the performance of the virtual machine is degraded. By solving the above technical problems, it is possible to improve the performance when the virtual machine is started or copied.
  • a further embodiment of the present invention provides a device 40 for dividing a cache. As shown in FIG. 9, the device 40 includes:
  • the processor 41 is configured to determine, when the cache data of the cache group accessed by the first virtual machine is missed, the virtual machine management operation state VMS of the first virtual machine; and, for the first virtual machine When the VMS is in the first state, the least recently used cache data belonging to the second virtual machine in the cache group is replaced.
  • the processor 41 is further configured to add a virtual machine VM register, where the data structure of the VM register includes: the VMS and a virtual machine identifier VMID.
  • the processor 41 is further configured to expand a tag bit of the cache address, add the VMID to the tag bit, and the cache data in the cache address belongs to a virtual machine corresponding to the VMID.
  • the processor 41 is further configured to: when the first virtual machine performs a startup operation or a copy operation, set a VMS of the first virtual machine to a first state; and, for, when the first virtual When the machine does not perform the startup operation or the copy operation, the VMS of the first virtual machine is set to the second state.
  • 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.
  • the processor 41 is further configured to determine whether a cache failure rate of the second virtual machine is greater than a failure rate threshold; and, when the cache failure rate of the second virtual machine is greater than the failure rate threshold. Replacing the least recently used cached data in the cache group; and, when used When the cache failure rate of the second virtual machine is not greater than the failure rate threshold, determine the number of cache blocks belonging to the second virtual machine in the cache group.
  • the processor 41 is further configured to determine whether the number of cache blocks of the second virtual machine is less than a threshold; and, if, if the number of cache blocks of the second virtual machine is less than the threshold, 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 recent of the cache groups belonging to the second virtual machine The cached data used.
  • the performance of the virtual machine is not improved well, and the performance of the virtual machine is low.
  • the virtual machine when the virtual machine performs startup and replication, Dividing the last-level shared cache between the second virtual machine and the first virtual machine, reducing the capacity of the second virtual machine to occupy the cache. Because the second virtual machine is insensitive to the capacity of the cache, even if the cache failure rate is high, the impact on the performance is not large. Therefore, by reducing the buffer capacity occupied by the second virtual machine, the buffer capacity occupied by the first virtual machine is increased. In order to reduce the competition for cache between virtual machines, the problem of cache competition between virtual machines in the prior art and the performance of the virtual machine are reduced. By solving the above technical problems, it is possible to improve the performance when the virtual machine is started or copied.
  • An apparatus for accessing a partitioning cache provided by the embodiment of the present invention may implement the foregoing method embodiment.
  • a method and apparatus for partitioning a cache provided by an embodiment of the present invention may be applied to a virtualized environment, but is not limited thereto.
  • the cache mentioned in the embodiment of the present invention can be applied to the last-level shared cache, and is not limited to this.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

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为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。该方法及装置适用于虚拟化环境。

Description

划分高速缓存的方法及装置
本申请要求于2013年9月16日提交中国专利局、申请号为201310422795.0、发明名称为“划分高速缓存的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及计算机技术领域,尤其涉及一种划分高速缓存的方法及装置。
背景技术
虚拟化技术是当今企业热门技术之一,它已经被广泛地应用于服务器整合、系统迁移、负载隔离等研究领域中。目前的虚拟化技术能够对多核处理器、内存及输入输出I/O等物理资源进行严格地划分,消除虚拟机间对物理资源的竞争,保证了虚拟机的功能和性能隔离性。但是对于片上多级高速缓存等共享的硬件资源,当前的虚拟化技术没有划分,各虚拟机之间对这些硬件资源的隐式竞争会导致部分虚拟机性能下降。例如,虚拟机上的某些虚拟化应用对LLC(Last-Level Cache,末级共享高速缓存)的容量很敏感,当虚拟机能够使用的LLC容量由于竞争原因减少时,虚拟机的性能会随之降低。
为了改变上述情况,提高虚拟机的性能,研究人员提出了共享高速缓存划分机制。现有技术中,通过修改的LRU(Least Recently Used,最近最少使用算法)和页着色方法对缓存进行划分,限制不同虚拟机所使用的共享缓存容量,从而减少在共享缓存上的竞争冲突。
现有技术至少存在如下问题:在多租户数据中心,每个用户对虚拟机执行的不同管理操作的效果会叠加,例如,在启动虚拟机和使用虚拟机执行复制操作的过程中,当大量虚拟机在短时间内同时启动,或者虚拟机复制的磁盘镜像的规模较大、所需时间较长的时候,由于操作效果的叠加,会导致虚拟机性能严重下降。而现有技术中的缓存划分方法,在虚拟机启 动和复制时,不能很好的提升虚拟机的性能,虚拟机性能较低。
发明内容
本发明的实施例提供一种划分高速缓存的方法及装置,能够解决在虚拟机执行启动和复制时,虚拟机性能较低的问题。
为达到上述目的,本发明的实施例采用如下技术方案:
第一方面,本发明的实施例提供一种划分高速缓存的方法,包括:
当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;
当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
结合第一方面,在第一种可能的实现方式中,所述判断所述第一虚拟机的虚拟机管理操作状态VMS之前,所述方法还包括:
添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。
进一步的,所述判断所述第一虚拟机的虚拟机管理操作状态VMS之前,所述方法还包括:
当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。
可选的,当所述第一虚拟机的VMS为第一状态时,在替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据之前,所述方法还包括:
判断所述第二虚拟机的缓存失效率是否大于失效率阈值;
如果所述第二虚拟机的缓存失效率大于所述失效率阈值,则替换所述缓存组中最近最少使用的缓存数据;
如果所述第二虚拟机的缓存失效率不大于所述失效率阈值,则确定所述缓存组中属于所述第二虚拟机的缓存块数目。
结合第一种可能的实现方式,在第二种可能的实现方式中,所述添加虚拟机VM寄存器之后,所述方法还包括:
扩展缓存地址的标记位,将所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。
可选的,在所述确定所述缓存组中属于所述第二虚拟机的缓存块数目之后,所述方法还包括:
判断所述第二虚拟机的缓存块数目是否小于数目阈值;
如果所述第二虚拟机的缓存块数目小于所述数目阈值,则替换所述缓存组中最近最少使用的缓存数据;
如果所述第二虚拟机的缓存块数目不小于所述数目阈值,则替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
结合第一方面或第一方面的第一种可能的实现方式,在第三种可能的实现方式中,当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。
结合第一方面或任一种可能的实现方式,在第四种可能的实现方式中,所述第二虚拟机用于控制虚拟环境的物理输入输出I/O资源,与所述第一虚拟机进行交互,启动所述第一虚拟机。
第二方面,本发明的实施例提供一种划分高速缓存的装置,包括:
判断单元,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;
替换单元,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
结合第二方面,在第一种可能的实现方式中,所述装置还包括:
添加单元,用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。
进一步的,所述装置还包括:设置单元,用于当所述第一虚拟机执行 启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;以及,用于当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。
可选的,所述判断单元还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;所述替换单元还用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;所述装置还包括:
确定单元,用于当所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。
结合第一种可能的实现方式,在第二种可能的实现方式中,所述装置还包括:
扩展单元,用于扩展缓存地址的标记位,将所述添加单元添加的所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。
可选的,所述判断单元还用于判断所述第二虚拟机的缓存块数目是否小于所述确定单元确定的所述数目阈值;所述替换单元还用于当所述第二虚拟机的缓存块数目小于所述确定单元确定的所述数目阈值时,替换所述缓存组中最近最少使用的缓存数据;所述替换单元还用于当所述第二虚拟机的缓存块数目不小于所述确定单元确定的所述数目阈值时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
结合第二方面或第二方面的第一种可能的实现方式,在第三种可能的实现方式中,所述替换单元还用于:当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。
结合第二方面或任一种可能的实现方式,在第四种可能的实现方式中,所述第二虚拟机用于控制虚拟环境的物理输入输出I/O资源,与所述第一虚拟机进行交互,启动所述第一虚拟机。
本发明实施例提供的划分末级共享高速缓存的方法及装置,与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,虚拟机性能较低的问题相比,本发明中,在虚拟机执行启动和复制时,对第一虚拟机和第二虚拟机之间的末级共享缓存进行划分,减少第二虚拟机占用的缓存容量。由于第二虚拟机对缓存的容量不敏感,即使缓存的失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,从而提升虚拟机启动或复制时的性能。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。
图1为本发明一实施例提供的方法流程图;
图2为本发明又一实施例提供的方法流程图;
图3为本发明又一实施例提供的访存地址结构图;
图4为本发明又一实施例提供的缓存结构图;
图5为本发明又一实施例提供的使用传统LRU数据替换后的缓存结构图;
图6为本发明又一实施例提供的使用改进LRU数据替换后的缓存结构图;
图7、图8为本发明又一实施例提供的装置结构示意图;
图9为本发明又一实施例提供的装置结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进 行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。
本发明一实施例提供一种划分高速缓存的方法,用于虚拟化环境,第一虚拟机和第二虚拟机运行于同一虚拟平台,第二虚拟机为运行在虚拟机监视器之上的特权虚拟机,它可以控制物理I/O资源,并且同时与第一虚拟机进行交互,第一虚拟机为客户虚拟机,可通过多个第二虚拟机来启动多个第一虚拟机。如图1所示,所述方法包括:
101、当第一虚拟机访问的缓存组的缓存数据均未命中时,缓存控制器判断第一虚拟机的VMS(Virtual Management State,虚拟机管理操作状态)。
需要说明的是,在处理器中,为每个处理器核添加虚拟机VM寄存器,VM寄存器结构包括:VMS和VMID(Virtual Machine Identifier,虚拟机标识)。然后,扩展缓存地址的标记位,将VMID添加到标记位中,其中,缓存地址中的缓存数据属于与所述VMID对应的虚拟机。
其中,虚拟机监控器响应虚拟机的管理操作,根据虚拟机的操作内容来设置VMS的状态。当是第一虚拟机执行启动操作或者复制操作时,虚拟机监控器设置此时的VMS为第一状态;当不是第一虚拟机执行启动操作或者复制操作时,虚拟机监控器设置此时的VMS为第二状态。
进一步的,当第一虚拟机对缓存进行访问,如果第一虚拟机访问缓存时,缓存组的缓存数据均未命中,此时需要访问内存,从中查找相应的数据,然后用缓存中数据进行替换,则缓存控制器对此时VMS的状态进行判断。
需要说明的是,本发明实施例中提到的缓存组,为在虚拟机进行访存操作时,根据访存地址确定的缓存组。
102、当第一虚拟机的VMS为第一状态时,缓存控制器替换缓存组中属于第二虚拟机的最近最少使用的缓存数据。
需要说明的是,缓存控制器对VMS的状态进行判断,当判断VMS为第二状态时,替换缓存组中最近最少使用的缓存数据。
其中,当第一虚拟机的VMS为第一状态时,缓存控制器获取第二虚拟机的缓存失效率,然后判断第二虚拟机的缓存失效率是否大于失效率阈值。如果第二虚拟机的缓存失效率大于失效率阈值,则替换缓存组中最近最少使用的缓存数据;如果第二虚拟机的缓存失效率不大于所述失效率阈值,则缓存控制器确定缓存组中属于第二虚拟机的缓存块数目。
进一步的,缓存控制器确定缓存组中属于第二虚拟机的缓存块数目后,判断第二虚拟机的缓存块数目是否小于数目阈值。如果第二虚拟机的缓存块数目小于数目阈值,则替换缓存组中最近最少使用的缓存数据;如果第二虚拟机的缓存块数目不小于数目阈值,则替换缓存组中属于第二虚拟机的最近最少使用的缓存数据。
需要说明的是,第二虚拟机的失效率阈值和缓存组中属于第二虚拟机的缓存块的数目阈值,均为事先设置的,其值可以根据虚拟机具体的运行情况和用户的需求自行设置;本发明实施例对缓存控制器获取第二虚拟机的缓存失效率的实现方式不做限定,可以是本领域技术人员所熟知的任意实现方式,例如,通过第二虚拟机的MPKI(Misses Per 1K Instructions,每1000条指令的缺失率)来计算。
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对第二虚拟机和第一虚拟机之间的末级共享缓存进行划分,减少了第二虚拟机占用缓存的容量。由于第二虚拟机对缓存的容量不敏感,即使缓存的失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之 间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。
本发明又一实施例提供一种划分末级共享高速缓存的方法,用于虚拟化环境。在虚拟环境下,本实施例的虚拟平台上,可运行的虚拟机最大个数N=8,Domain 0为运行在虚拟机监控器hypervisor上的特权虚拟机,它可以控制物理I/O资源,并且同时与客户虚拟机进行交互,客户虚拟机需要通过Domain 0才能启动,虚拟机共享缓存中缓存块大小为8字节,4路组相联,共16个组。如图2所示,所述方法包括:
201、添加虚拟机VM寄存器。
其中,处理器中包含多个处理器核,为每个处理器核添加虚拟机VM寄存器,VM寄存器中的数据结构包括:虚拟机管理操作状态VMS和虚拟机标识VMID。
需要说明的是,VMS有0和1两种状态,用于区分此时客户虚拟机执行操作的类型:如果VMS=0,表示此时客户虚拟机不是执行启动操作或者复制操作;如果VMS=1,表示此时客户虚拟机执行启动操作或者复制操作。VMID用于标识不同的虚拟机,VMID的位数由平台上可运行虚拟机的最大数目来确定。
例如,如果虚拟平台上可运行虚拟机的最大数目为N,则VMID的位数为log2(N)。本发明实施例中,可运行的虚拟机最大个数N=8,那么VMID的位数有log2(N)=3位,Domain 0的VMID为000。本实施例不对N的值进行限定,当N为其他值时本实施例的方法同样适用。
202、扩展缓存地址的标记位。
其中,在缓存地址的标记位中增加VMID。此处VMID用来标记该缓存地址中的缓存块属于哪个虚拟机,在缓存块数据替换时,将此时寄存器中 的VMID值写入到缓存地址中的VMID中即可。
203、虚拟机监控器设置Domain 0的失效率阈值和缓存组中属于Domain0的缓存块数目阈值。
其中,Domain 0的失效率阈值是根据实验结果得出的。在客户虚拟机执行启动操作或者复制操作时,虽然Domain 0能够在失效率很高的情况下,保持很好的性能,但是当失效率超过一定值时,Domain 0的性能有可能会下降。为了保证Domain 0能够保持很好的性能,用户可根据实验中的结果,自行设定失效率阈值。缓存组中属于Domain 0的缓存块数目阈值也为用户自行设定,最大值不能超过缓存组中缓存块的值。
例如,本发明实施例中,每组中缓存块个数为4,则缓存块的数目阈值的最大值为4。
需要说明的是,此步骤中提到的缓存组,为在虚拟机进行访存操作时,根据访存地址确定的缓存组。
204、虚拟机监控器设置虚拟机管理操作状态VMS的状态。
其中,虚拟机监控器根据虚拟机的操作内容来设置VMS的状态。当虚拟机监控器响应的是客户虚拟机执行启动操作或者复制操作时,设置VMS=1;当虚拟机监控器响应的不是客户虚拟机执行启动操作或者复制操作时,设置VMS=0。
205、缓存控制器判定客户虚拟机访问的缓存组的缓存数据是否均未命中,若均未命中,则执行步骤206;若不是均未命中,则结束流程。
其中,在虚拟机监控器设置VMS的状态后,虚拟机根据访存地址对缓存进行访问,如果虚拟机访问缓存时,缓存组的缓存数据均未命中,此时需要访问内存,从中查找相应的数据,然后用缓存中数据进行替换,则缓存控制器对此时VMS的状态进行判断;如果虚拟机访问缓存时,缓存组中有缓存数据命中,则不需要数据替换,结束此过程。
需要说明的是,本发明实施例中,访存地址为16位,那么访存地址的 结构如图3所示,其中标记位Tag为访存地址的前九位,当缓存块中的标记位和访存地址中的标记位匹配时并且缓存块中的有效位置为1,则表示缓存命中;缓存组位Set为访存地址的第十到第十三位,用来确定要访问的缓存组,偏移位Offset为访存地址的最后三位,用来确定缓存块中要访问的字节。
例如,Xen响应VMID=101的虚拟机命令,虚拟机监控器设置VMS的状态。然后,VMID=101的虚拟机访问缓存,设该虚拟机此次的访存地址为0001000111010011,那么,从该访存地址中能找出要访问缓存的组号Set=1010,如图4所示。该访存地址在缓存组1010中的四个缓存块扩展后的标记位依次为:000000001111、010000000011、000000000001和011000100001,其中,标记位的前三位为扩展的VMID,表示此缓存块此时所属的虚拟机,后九位为各缓存块的地址的Tag位,本次虚拟机的访存地址的Tag位是000100011,可知四个缓存块均不命中,此时需要访问内存,从中查找相应的数据,然后用缓存中数据进行替换,执行步骤206。
206、缓存控制器判定VMS状态是否为1,若VMS状态为1,执行步骤207;否则使用传统LRU替换策略。
需要说明的是,VMS的状态已经在步骤204中设置,此时对其进行判定,以便确定数据替换时要使用的替换策略。
其中,替换策略包括传统LRU替换策略和本发明实施例中改进的LRU替换策略。当VMS状态为1时,使用本发明实施例中改进的LRU替换策略,即执行步骤207至步骤211;当VMS状态为0时,使用传统LRU替换策略,即替换缓存组中最近最少使用的缓存数据。
例如,在本发明实施例中,VMID=101的虚拟机对缓存进行访问时,客户虚拟机要访问的缓存组的缓存块均未命中。如果此时VMS状态为1,则执行步骤207;如果此时VMS状态为0,则执行传统LRU替换策略进行数据替换。如图4所示,假设此时第1010缓存组中,第4个缓存块为最近最少被使用的缓存块,由其VMID=011可知,此缓存块属于VMID=011的虚拟机, 而判定结果为VMS状态为0,则选用第4个缓存块,将该缓存块中的数据替换为VMID=101的虚拟机从内存中访问的数据,所得结果如图5所示。
207、缓存控制器获取此时Domain 0的缓存失效率。
其中,缓存失效率等于缓存访问缺失次数除以缓存访问次数,本发明实施例对缓存控制器获取Domain 0的缓存失效率的实现方式不做限定,可以是本领域技术人员所熟知的任意实现方式,例如,通过Domain 0的MPKI。
208、缓存控制器判定缓存失效率是否大于失效率阈值,若不大于失效率阈值,则执行步骤209;否则使用传统LRU替换策略。
其中,如果此时Domain 0的缓存失效率大于失效率阈值,则使用传统LRU替换策略,即替换缓存组中最近最少使用的缓存数据;如果Domain 0的缓存失效率不大于所述失效率阈值,则执行步骤209。
209、缓存控制器确定缓存组中属于Domain 0的缓存块数目。
其中,缓存控制器可以根据缓存标记位中扩展的VMID,得出此时缓存组中的各缓存块属于哪个虚拟机,从而确定属于Domain 0的缓存块数目。
例如,本发明实施例中,如图4所示,缓存组1010中,根据各缓存块的VMID可得:第1个和第3个缓存块属于Domain 0,第2个缓存块属于VMID=010的虚拟机,第4个缓存块属于VMID=011的虚拟机,则可确定属于Domain 0的缓存块数目为2。
210、缓存控制器判定缓存块数目是否小于数目阈值,若小于数目阈值,则执行步骤211;否则使用传统LRU替换策略。
其中,如果缓存组中属于Domain 0的缓存块数目小于所述数目阈值,则使用传统LRU替换策略,即替换缓存组中最近最少使用的缓存数据;如果缓存组中属于Domain 0的缓存块数目不小于数目阈值,则执行步骤211。
211、缓存控制器选用缓存组中属于Domain 0的最近最少使用的缓存块替换。
例如,本发明实施例中,如图4所示,此时第1010组中,第1个和第3个 缓存块均属于Domain 0,假设第3个缓存块为最近最少被使用的属于Domain0的缓存块,选用第3个缓存块,将该缓存块中的数据替换为VMID=101的虚拟机从内存中访问的数据,所得结果如图6所示。
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对Domain 0和客户虚拟机之间的末级共享缓存进行划分,减少了Domain 0占用缓存的容量。由于Domain 0对缓存的容量不敏感,即使缓存的失效率很高,对其性能的影响也不大,所以通过减少Domain 0占用的缓存容量,增大客户虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。
本发明又一实施例提供一种划分高速缓存的装置30,如图7所示,所述装置30包括:
判断单元31,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;
替换单元32,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
进一步的,如图8所示,所述装置30还可以包括:
添加单元33,用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。
进一步的,如图8所示,所述装置30还可以包括:
扩展单元34,用于扩展缓存地址的标记位,将所述添加单元33添加的所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。
进一步的,如图8所示,所述装置30还可以包括:
设置单元35,用于当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。
进一步的,所述替换单元32还用于:
当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。
进一步的,所述判断单元31还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;
所述替换单元32还用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;如图8所示,所述装置30还可以包括:
确定单元36,用于当所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。
进一步的,所述判断单元31还用于判断所述第二虚拟机的缓存块数目是否小于所述确定单元36确定的所述数目阈值;
所述替换单元32还用于当所述第二虚拟机的缓存块数目小于所述确定单元36确定的所述数目阈值时,替换所述缓存组中最近最少使用的缓存数据;
所述替换单元32还用于当所述第二虚拟机的缓存块数目不小于所述确定单元36确定的所述数目阈值时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对第二虚拟机和第一虚拟机之间的末级共享缓存进行划分,减少了第二虚拟机占用缓存的容量。由于第二虚拟机对缓存的容量不敏感, 即使缓存失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。
本发明又一实施例提供一种划分高速缓存的装置40,如图9所示,所述装置40包括:
处理器41,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;以及,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
进一步的,所述处理器41还用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。
进一步的,所述处理器41还用于扩展缓存地址的标记位,将所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。
进一步的,所述处理器41还用于当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;以及,用于当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。
进一步的,所述处理器41还用于当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。
可选的,所述处理器41还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;以及,用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;以及,用于当 所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。
可选的,所述处理器41还用于判断所述第二虚拟机的缓存块数目是否小于数目阈值;以及,用于如果所述第二虚拟机的缓存块数目小于所述数目阈值,则替换所述缓存组中最近最少使用的缓存数据;以及,用于如果所述第二虚拟机的缓存块数目不小于所述数目阈值,则替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
与现有技术中,在虚拟机执行启动和复制时,不能很好的提升虚拟机的性能,使虚拟机性能较低的问题相比,本发明实施例中,在虚拟机执行启动和复制时,对第二虚拟机和第一虚拟机之间的末级共享缓存进行划分,减少了第二虚拟机占用缓存的容量。由于第二虚拟机对缓存的容量不敏感,即使缓存失效率很高,对其性能的影响也不大,所以通过减少第二虚拟机占用的缓存容量,增大第一虚拟机占用的缓存容量,来降低各虚拟机之间对缓存的竞争,解决了现有技术中各虚拟机之间对缓存竞争,使虚拟机性能下降的问题。通过解决上述技术问题,能够使提高虚拟机启动或复制时的性能。
本发明实施例提供的一种访问划分高速缓存的装置可以实现上述提供的方法实施例,具体功能实现请参见方法实施例中的说明,在此不再赘述。本发明实施例提供的一种划分高速缓存的方法及装置可以适用于虚拟化环境,但不仅限于此。
需要说明的是,本发明实施例中提到的缓存可适用于末级共享高速缓存,大不仅限于此。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于设备实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random Access Memory,RAM)等。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。

Claims (16)

  1. 一种划分高速缓存的方法,其特征在于,包括:
    当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;
    当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
  2. 根据权利要求1所述的方法,其特征在于,在所述判断所述第一虚拟机的虚拟机管理操作状态VMS之前,所述方法还包括:
    添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。
  3. 根据权利要求2所述的方法,其特征在于,在所述添加虚拟机VM寄存器之后,所述方法还包括:
    扩展缓存地址的标记位,将所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID对应的虚拟机。
  4. 根据权利要求1所述的方法,其特征在于,在所述判断所述第一虚拟机的虚拟机管理操作状态VMS之前,所述方法还包括:
    当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。
  5. 根据权利要求1或4所述的方法,其特征在于,所述方法还包括:
    当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。
  6. 根据权利要求1所述的方法,其特征在于,当所述第一虚拟机的VMS为第一状态时,在替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据之前,所述方法还包括:
    判断所述第二虚拟机的缓存失效率是否大于失效率阈值;
    如果所述第二虚拟机的缓存失效率大于所述失效率阈值,则替换所述缓存组中最近最少使用的缓存数据;
    如果所述第二虚拟机的缓存失效率不大于所述失效率阈值,则确定所述缓存组中属于所述第二虚拟机的缓存块数目。
  7. 根据权利要求6所述的方法,其特征在于,在所述确定所述缓存组中属于所述第二虚拟机的缓存块数目之后,所述方法还包括:
    判断所述第二虚拟机的缓存块数目是否小于数目阈值;
    如果所述第二虚拟机的缓存块数目小于所述数目阈值,则替换所述缓存组中最近最少使用的缓存数据;
    如果所述第二虚拟机的缓存块数目不小于所述数目阈值,则替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
  8. 根据权利要求1-7任一项所述的方法,其特征在于,所述第二虚拟机用于控制虚拟环境的物理输入输出I/O资源,与所述第一虚拟机进行交互,启动所述第一虚拟机。
  9. 一种划分高速缓存的装置,其特征在于,包括:
    判断单元,用于当第一虚拟机访问的缓存组的缓存数据均未命中时,判断所述第一虚拟机的虚拟机管理操作状态VMS;
    替换单元,用于当所述第一虚拟机的VMS为第一状态时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
  10. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    添加单元,用于添加虚拟机VM寄存器,所述VM寄存器的数据结构包括:所述VMS和虚拟机标识VMID。
  11. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    扩展单元,用于扩展缓存地址的标记位,将所述添加单元添加的所述VMID添加到所述标记位中,所述缓存地址中的缓存数据属于与所述VMID 对应的虚拟机。
  12. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    设置单元,用于当所述第一虚拟机执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第一状态;以及,用于当所述第一虚拟机未执行启动操作或者复制操作时,设置所述第一虚拟机的VMS为第二状态。
  13. 根据权利要求9或12所述的装置,其特征在于,所述替换单元还用于:
    当所述第一虚拟机的VMS为第二状态时,替换所述缓存组中最近最少使用的缓存数据。
  14. 根据权利要求9所述的装置,其特征在于,所述判断单元还用于判断所述第二虚拟机的缓存失效率是否大于失效率阈值;
    所述替换单元还用于当所述第二虚拟机的缓存失效率大于所述失效率阈值时,替换所述缓存组中最近最少使用的缓存数据;所述装置还包括:
    确定单元,用于当所述第二虚拟机的缓存失效率不大于所述失效率阈值时,确定所述缓存组中属于所述第二虚拟机的缓存块数目。
  15. 根据权利要求14所述的装置,其特征在于,所述判断单元还用于判断所述第二虚拟机的缓存块数目是否小于所述确定单元确定的所述数目阈值;
    所述替换单元还用于当所述第二虚拟机的缓存块数目小于所述确定单元确定的所述数目阈值时,替换所述缓存组中最近最少使用的缓存数据;
    所述替换单元还用于当所述第二虚拟机的缓存块数目不小于所述确定单元确定的所述数目阈值时,替换所述缓存组中属于第二虚拟机的最近最少使用的缓存数据。
  16. 根据权利要求9-15任一项所述的装置,其特征在于,所述第二虚拟机用于控制虚拟环境的物理输入输出I/O资源,与所述第一虚拟机进行交互,启动所述第一虚拟机。
PCT/CN2014/086341 2013-09-16 2014-09-12 划分高速缓存的方法及装置 WO2015035928A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310422795.0A CN104461928B (zh) 2013-09-16 2013-09-16 划分高速缓存的方法及装置
CN201310422795.0 2013-09-16

Publications (1)

Publication Number Publication Date
WO2015035928A1 true WO2015035928A1 (zh) 2015-03-19

Family

ID=52665083

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/086341 WO2015035928A1 (zh) 2013-09-16 2014-09-12 划分高速缓存的方法及装置

Country Status (2)

Country Link
CN (1) CN104461928B (zh)
WO (1) WO2015035928A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111880726A (zh) * 2020-06-19 2020-11-03 浙江工商大学 一种提升cnfet缓存性能的方法

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106484539A (zh) * 2016-10-13 2017-03-08 东北大学 一种处理器缓存特性的检测分析方法
CN108228351B (zh) * 2017-12-28 2021-07-27 上海交通大学 Gpu的性能均衡调度方法、存储介质及电子终端

Citations (4)

* Cited by examiner, † Cited by third party
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 (zh) * 2008-04-29 2009-11-04 国际商业机器公司 用于替换缓存块的方法和系统
CN102483718A (zh) * 2009-08-25 2012-05-30 国际商业机器公司 虚拟化环境中的高速缓存分区
CN102999444A (zh) * 2012-11-13 2013-03-27 华为技术有限公司 一种用于替换缓存模块中数据的方法及装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
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
US7076609B2 (en) * 2002-09-20 2006-07-11 Intel Corporation Cache sharing for a chip multiprocessor or multiprocessing system
US8990582B2 (en) * 2010-05-27 2015-03-24 Cisco Technology, Inc. Virtual machine memory compartmentalization in multi-core architectures
US20130219125A1 (en) * 2012-02-21 2013-08-22 Microsoft Corporation Cache employing multiple page replacement algorithms

Patent Citations (4)

* Cited by examiner, † Cited by third party
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 (zh) * 2008-04-29 2009-11-04 国际商业机器公司 用于替换缓存块的方法和系统
CN102483718A (zh) * 2009-08-25 2012-05-30 国际商业机器公司 虚拟化环境中的高速缓存分区
CN102999444A (zh) * 2012-11-13 2013-03-27 华为技术有限公司 一种用于替换缓存模块中数据的方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111880726A (zh) * 2020-06-19 2020-11-03 浙江工商大学 一种提升cnfet缓存性能的方法
CN111880726B (zh) * 2020-06-19 2022-05-10 浙江工商大学 一种提升cnfet缓存性能的方法

Also Published As

Publication number Publication date
CN104461928B (zh) 2018-11-16
CN104461928A (zh) 2015-03-25

Similar Documents

Publication Publication Date Title
EP3121731B1 (en) Memory management method and device
JP5969550B2 (ja) パフォーマンスカウンタの仮想化
EP2313832B1 (en) Direct memory access filter for virtualized operating systems
US8954959B2 (en) Memory overcommit by using an emulated IOMMU in a computer system without a host IOMMU
US10877793B2 (en) Extending the base address register by modifying the number of read-only bits associated with a device to be presented to a guest operating system
US9772962B2 (en) Memory sharing for direct memory access by a device assigned to a guest operating system
WO2020010556A1 (zh) 增强用户空间与内核空间的隔离性的方法和装置
US7823151B2 (en) Method of ensuring the integrity of TLB entries after changing the translation mode of a virtualized operating system without requiring a flush of the TLB
US9703566B2 (en) Sharing TLB mappings between contexts
US20120072619A1 (en) Memory Overcommit by Using an Emulated IOMMU in a Computer System with a Host IOMMU
US20150095585A1 (en) Consistent and efficient mirroring of nonvolatile memory state in virtualized environments
KR101821079B1 (ko) 가상 컴퓨팅을 위한 장치 및 방법
TWI641947B (zh) 用於管理位址轉換和快取記憶體儲存的方法及裝置
US10552345B2 (en) Virtual machine memory lock-down
US20150095576A1 (en) Consistent and efficient mirroring of nonvolatile memory state in virtualized environments
US9471226B2 (en) Reverse copy on write for better cache utilization
WO2012163017A1 (zh) 分布式虚拟机访问异常的处理方法以及虚拟机监控器
US9921875B2 (en) Zero copy memory reclaim for applications using memory offlining
TWI648625B (zh) 管理位址獨立的頁面屬性
WO2015035928A1 (zh) 划分高速缓存的方法及装置
JP2006155272A (ja) 仮想計算機の制御方法及びプログラム
US9904567B2 (en) Limited hardware assisted dirty page logging
US10140148B1 (en) Copy based IOMMU emulation for out-of-process emulated devices
KR101790728B1 (ko) 가상화 환경의 하이퍼바이저에서의 데이터 입출력 방법 및 이를 기록한 기록 매체
EP3053040A1 (en) Consistent and efficient mirroring of nonvolatile memory state in virtualized environments

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14843576

Country of ref document: EP

Kind code of ref document: A1