Resource control method, device, storage medium and program product of virtual machine
By providing resource provisioning technology (RDT) capabilities for virtual machines, the problem of unreliable performance of high-priority services within virtual machines is solved. This enables resource allocation and monitoring for services of different priorities, ensuring that the performance of high-priority services is not affected by low-priority services.
Patent Information
- Application Number
- CN202510655116.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-20
- Publication Date
- 2026-11-20
AI Technical Summary
Existing virtualization products do not support Resource Provisioning Technology (RDT) within virtual machines, which makes it impossible to guarantee the performance of high-priority services in the case of mixed service deployment.
Provide virtual machines with Resource Provisioning Technology (RDT) capabilities, enabling them to control and monitor the cache and memory bandwidth resources of virtual processors, and allocate appropriate resources to services of different priorities through service category identifiers.
It enables resource allocation and monitoring of services with different priorities within a virtual machine, preventing low-priority services from consuming too many resources and affecting the performance of high-priority services, thus ensuring the performance of high-priority services.
Smart Images

Figure CN123137786A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of virtualization, and more particularly to a method, device, storage medium, and program product for controlling virtual machine resources. Background Technology
[0002] To improve server utilization, users often co-deploy services with varying resource usage on a single server. These services can be assigned different priorities. For example, co-deploying online and offline services on a single server is called co-deployment. Offline services typically involve large amounts of computation, resulting in higher CPU (Central Processing Unit) usage, as well as greater demands on cache and memory bandwidth. Offline services often have higher resource usage than online services, but online services require faster response times and therefore have a higher priority than offline services.
[0003] In the case of mixed deployment of services, in addition to limiting the CPU that low-priority services can use through kernel Cgroup functions or process schedulers, in order to avoid the impact of offline services on high-priority services in terms of cache and memory bandwidth, Resource Director Technology (RDT) can be used to limit high-priority services and low-priority services to different cache usage and memory bandwidth usage, thereby avoiding the significant performance loss of high-priority services after offline deployment.
[0004] However, currently no virtualization product supports the use of RDT within a virtual machine (VM). Therefore, in cases where services are deployed together within a VM, the performance of high-priority services cannot be guaranteed. Summary of the Invention
[0005] This application provides a method, device, storage medium, and program product for controlling virtual machine resources, in order to solve the problem that the performance of high-priority services cannot be guaranteed when services are mixed within a virtual machine.
[0006] In a first aspect, embodiments of this application provide a resource control method for a virtual machine, comprising:
[0007] The virtual machine receives processor information from the virtual machine manager, wherein the processor information includes indication information that the virtual processor supports resource provisioning technology, the correspondence between the virtual processor and the virtual resource provisioning technology domain, and at least one service category identifier available to the virtual machine, the service category identifier being used to indicate the available resources of the virtual processor corresponding to the service category identifier within the virtual resource provisioning technology domain;
[0008] The virtual machine uses resource allocation technology to control the cache and memory bandwidth resources of virtual processors in each virtual resource allocation technology domain based on the processor information. The virtual processors where services of different priorities reside in the virtual machine correspond to different service category identifiers.
[0009] In one possible implementation, the virtual machine, based on the processor information, uses resource allocation techniques to control the cache and memory bandwidth resources of virtual processors in each virtual resource allocation domain, including:
[0010] The virtual machine writes the service category identifier of the virtual processor into the first resource allocation technology register corresponding to the virtual processor;
[0011] The virtual machine writes the resource limit values of the cache and memory bandwidth resources corresponding to the service category identifier into the second resource allocation technology register corresponding to the virtual resource allocation technology domain of the virtual processor.
[0012] In one possible implementation, the processor information further includes at least one resource monitoring identifier available to the virtual machine, the resource monitoring identifier being used to monitor the resource usage of the virtual processor.
[0013] In one possible implementation, the number of resource monitoring identifiers available to the virtual machine is less than the total number of resource monitoring identifiers supported by the physical processor, and the number of service category identifiers available to the virtual machine is less than the total number of service category identifiers supported by the physical processor.
[0014] In one possible implementation, it also includes:
[0015] The virtual machine writes the resource monitoring identifier of the virtual processor into the first resource allocation technology register corresponding to the virtual processor.
[0016] In one possible implementation, it also includes:
[0017] The virtual machine reads the resource monitoring data corresponding to the resource monitoring identifier from the third resource allocation technology register corresponding to the virtual processor.
[0018] Secondly, embodiments of this application provide a resource control method for a virtual machine, comprising:
[0019] The virtual machine manager sends processor information to the virtual machine, wherein the processor information includes indication information that the virtual processor supports resource provisioning technology, the correspondence between the virtual processor and the virtual resource provisioning technology domain, and at least one service category identifier available to the virtual machine, the service category identifier being used to indicate the available resources of the virtual processor corresponding to the service category identifier within the virtual resource provisioning technology domain;
[0020] The virtual machine manager schedules virtual processors belonging to the same virtual resource allocation technology domain to physical processors belonging to the same physical resource allocation technology domain, according to the correspondence between virtual processors and virtual resource allocation technology domains.
[0021] In one possible implementation, the processor information further includes at least one resource monitoring identifier available to the virtual machine, the resource monitoring identifier being used to monitor the resource usage of the virtual processor.
[0022] In one possible implementation, the number of resource monitoring identifiers available to the virtual machine is less than the total number of resource monitoring identifiers supported by the physical processor, and the number of service category identifiers available to the virtual machine is less than the total number of service category identifiers supported by the physical processor.
[0023] In one possible implementation, it also includes:
[0024] The virtual machine manager responds to the virtual machine's write operation on any resource allocation technology register by writing the data to be written into the resource allocation technology register.
[0025] And / or,
[0026] The virtual machine manager responds to the virtual machine's read operation on any resource allocation technology register by reading data from the resource allocation technology register and sends the read data to the virtual machine.
[0027] In one possible implementation, the data to be written includes the resource monitoring identifier of the virtual processor, the service category identifier of the virtual processor, or the resource limit value corresponding to the service category identifier;
[0028] The data read by the virtual machine includes the resource monitoring data corresponding to the resource monitoring identifier.
[0029] In one possible implementation, it also includes:
[0030] The virtual machine manager sets the state of at least one resource allocation technology register to pass through the virtual processors in the virtual machine.
[0031] In one possible implementation, the virtual machine manager sets the state of at least one resource allocation technology register to pass through virtual processors in the virtual machine, including:
[0032] When the virtual machine manager determines that the virtual machine has used resource allocation technology, it sets the state of at least one resource allocation technology register to pass through the virtual processor in the virtual machine.
[0033] In one possible implementation, the virtual machine manager determines that the virtual machine has used resource provisioning techniques, including:
[0034] The virtual machine manager determines that the virtual machine has used resource allocation technology when the virtual machine has performed read and / or write operations on the resource allocation technology register.
[0035] In one possible implementation, the method further includes:
[0036] If the virtual machine manager determines that the virtual machine has used resource allocation technology, it will mark the virtual machine's status as having used resource allocation technology.
[0037] When the virtual machine restarts, the virtual machine manager will re-mark the virtual machine's state as not using resource allocation technology.
[0038] In one possible implementation, it also includes:
[0039] When the virtual machine exits, the virtual machine manager saves the resource monitoring identifier and service category identifier of the virtual processor in the first resource allocation technology register, and sets the first resource allocation technology register as the resource monitoring identifier and service category identifier of the host machine.
[0040] When a virtual machine enters, the virtual machine manager sets the first resource allocation technology register to the resource monitoring identifier and service category identifier of the virtual processor.
[0041] In one possible implementation, it also includes:
[0042] If the virtual machine exits, and the service category identifier of the virtual processor in the first resource allocation technology register has a corresponding resource limit value, the virtual machine manager saves the resource monitoring identifier and service category identifier of the virtual processor, and sets the first resource allocation technology register to the resource monitoring identifier and service category identifier of the host machine.
[0043] In one possible implementation, it also includes:
[0044] When a virtual processor is loaded, the virtual machine manager sets the resource limit value corresponding to the service category identifier of the virtual processor in the second resource allocation technology register;
[0045] When the virtual processor is released, the virtual machine manager sets the second resource allocation technology register to the resource limit value corresponding to the service category identifier of the host machine.
[0046] Thirdly, embodiments of this application provide a host machine on which virtual machines and a virtual machine manager are deployed;
[0047] The virtual machine is used to execute the method described in any of the first aspects, and the virtual machine manager is used to execute the method described in any of the second aspects.
[0048] Fourthly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0049] The memory stores computer-executed instructions;
[0050] The processor executes computer execution instructions stored in the memory, causing the processor to perform the method described in either the first aspect or the second aspect.
[0051] Fifthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in either the first or second aspect.
[0052] In a sixth aspect, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the method shown in either the first or second aspect.
[0053] This application provides a resource control method, device, storage medium, and program product for virtual machines. The VM manager provides the virtual machine with processor information including indication information for virtual processors supporting resource allocation technology, the correspondence between virtual processors and virtual resource allocation technology domains, and at least one available service category identifier for the virtual machine. The service category identifier indicates the available resources of the virtual processor corresponding to the service category identifier within the virtual resource allocation technology domain. Different service category identifiers correspond to different priority services on different virtual processors, thus providing a resource allocation technology solution for the virtual machine. This allows resource allocation technology to be applied to the virtual machine itself. Based on the service category identifier, available cache and memory bandwidth resources are allocated to services of different priorities. This prevents cache and memory bandwidth resources available to services of different priorities from being mutually occupied, avoiding performance degradation of high-priority services due to low-priority services consuming excessive resources within the virtual machine, and ensuring the performance of high-priority services. Attached Figure Description
[0054] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0055] Figure 1 This is a schematic diagram illustrating the application scenarios of RDT;
[0056] Figure 2 A flowchart illustrating a resource control method for a virtual machine provided as an exemplary embodiment of this application;
[0057] Figure 3 A flowchart illustrating another virtual machine resource control method provided for an exemplary embodiment of this application;
[0058] Figure 4 A schematic diagram of a host machine structure provided for an exemplary embodiment of this application;
[0059] Figure 5 This is a schematic diagram of the structure of an electronic device provided as an exemplary embodiment of this application. Detailed Implementation
[0060] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0062] Below, in order to facilitate understanding of the technical solution of this application, the concepts involved in this application will be explained first.
[0063] Host: The host machine generally refers to a physical machine. For one or more virtual machines running on this physical machine, this physical machine is the host machine of these virtual machines.
[0064] Guest or VM: A virtual machine is one or more virtual machines created on a physical machine, typically implemented using hardware virtualization or software binary translation. A virtual machine is a hardware and software copy of a real computer system, where a subset of virtual processor instructions is executed natively on the host, while other instructions are executed in an emulated manner.
[0065] VMM (Virtual Machine Monitor) or Hypervisor: A VM monitor, also known as a VM manager, maintains multiple efficient, isolated program environments that allow users to directly access real hardware. These program environments are called virtual machines. A hypervisor consists of a kernel-mode kernel virtual machine (KVM) and a user-mode quick emulation machine (QEMU).
[0066] vCPU: Virtual CPU, which is the CPU seen from inside a virtual machine. A vCPU is usually implemented by a thread or coroutine in the host operating system.
[0067] pCPU: Physical CPU, i.e., the actual CPU used by the physical machine. Since vCPUs are usually implemented as threads or coroutines on the host, a vCPU is scheduled by the host scheduler to run on a pCPU. Thus, at any given time, a vCPU has a corresponding pCPU. At different times, the same vCPU may be scheduled to multiple different pCPUs.
[0068] Online services: These processes real-time data streams, requiring real-time responses and result updates. They are sensitive to latency, and CPU utilization is typically set low to avoid impacting latency.
[0069] Offline tasks: Tasks that process large amounts of data in batches without real-time data input are typically not sensitive to latency and can have higher CPU utilization settings.
[0070] In a hybrid offline deployment: online and offline services are deployed in the same computing environment to improve CPU resource utilization and reduce costs.
[0071] L2 cache: The CPU's second-level cache.
[0072] LLC (Last Level Cache): The last level of cache for the CPU, usually L3 cache.
[0073] LLC domain: Multiple CPUs sharing the same LLC are called an LLC domain. In Intel processors, an LLC domain is usually a CPU socket, while in AMD processors, an LLC domain is usually a CCD.
[0074] MB (Memory Bandwidth): Memory bandwidth.
[0075] CPU core: A CPU core is an independent execution unit. A CPU core can run a program thread in parallel with other cores outside of that CPU core.
[0076] CPU Die: A die is a piece of semiconductor material (usually silicon), and a die can contain any number of cores. For mainstream CPU manufacturers, one or more CPU dies are usually packaged together to form a CPU Package.
[0077] CCD (Core Chiplet Die): AMD EPYC Zen 3 / Zen 4 architecture processors are not a single packaged large core, but are divided into multiple CCD cores, with multiple CPUs within each CCD sharing the same L3 cache.
[0078] CPU socket: also known as CPU package, is a complete physical CPU (CPU metal casing). Each physical CPU package is matched with a physical CPU socket.
[0079] RDT (Resource Director Technology): Resource allocation technology that provides the ability to monitor and allocate L2 cache, LLC, and MB for each CPU core (or logical core).
[0080] RMID (Resource Monitoring ID): An RMID is used for monitoring within the Resource Monitoring Thread (RDT). It's a software-defined ID assigned by the operating system (OS) to each software thread or CPU within the RDT. RMIDs allow for the simultaneous monitoring of independent threads running on multiple processors. Software threads can be monitored independently using individual RMIDs, or multiple software threads can share the same RMID for group monitoring. The number of available RMIDs varies for each processor and can be obtained using the CPUID instruction.
[0081] CLOSID (Class of Service ID): A service class identifier or resource control identifier used for resource allocation (control) in the RDT. Each CLOSID can define how many caches (L2, L3) or MB can be used by that CLOSID. Similar to RMID, software threads can also be assigned a CLOSID to use.
[0082] MSR (Model Specific Register): A series of registers in the processor used to control CPU operation, function switching, debugging, program execution tracing, monitoring CPU performance, etc. The RDT defines several MSRs for monitoring and controlling CPU resources, as well as an MSR for specifying the current RMID / CLOSID of the CPU.
[0083] PQR_ASSOC: There is an IA32_PQR_ASSOC MSR on each CPU, which can be used to specify the CPU's current RMID and CLOSID.
[0084] RDT domain: An RDT domain is typically an LLC domain. In Intel processors, this usually represents a CPU socket; in AMD processors, it usually represents a CCD. Multiple CPUs within an RDT domain share a portion of the RDT MSR. For example, the MSR used to control the resource limits corresponding to a CLOSID is shared by all CPUs in that RDT domain, rather than each CPU having a separate MSR.
[0085] VMExit: When a virtual machine exits and the vCPU switches from the VM runtime environment to the host runtime environment, it is called VMExit. For example, situations such as the Guest OS executing privileged instructions can cause VMExit. In this case, the system will enter the VMM, and the CPU will switch to running instructions on the host machine. The VMM will handle the VMExit according to its cause, and after processing, the Guest OS instructions can continue to run through VMEntry.
[0086] VMEntry: The process of entering a virtual machine, from executing host machine instructions to executing VM instructions, is called VMEntry. If a sensitive instruction is executed or an interrupt occurs while running the VM, a VMExit operation will be performed to switch back to the host machine running mode to run the VMM.
[0087] Trap MSR: In virtualization, when a vCPU is running, after accessing an MSR, it needs to be trapped in the VMM for processing or emulation. This MSR is called a Trap MSR. If the VM frequently accesses the Trap MSR, it will cause performance degradation for the VM.
[0088] Pass-through MSR: In virtualization, some MSRs can be specified that do not require traps, that is, the VM or vCPU can directly read and write the pCPU's MSR.
[0089] vRDT: In this application embodiment, a scheme is provided to VM with RDT capabilities. By presenting RDT capabilities to VM, VM can use the resource monitoring and resource control capabilities of RDT, which is called vRDT.
[0090] Below, in conjunction with Figure 1 This section explains the application scenarios of RDT.
[0091] Taking two services with different priorities, online and offline, as an example, such as Figure 1 As shown, for pCPUs with both online and offline services deployed, RDT (Resource Deployment Controller) can control the cache and memory bandwidth available to each service. This means RDT can allocate separate caches and memory bandwidths for online and offline services, ensuring that both utilize resources within their allocated limits and preventing offline services from consuming excessive cache and memory bandwidth, which could negatively impact the performance of online services. However, currently, RDT is not supported within VMs. This means that for mixed online and offline services deployed within VMs, RDT cannot be used to control cache and memory bandwidth usage, resulting in performance issues for online services running within VMs.
[0092] To address this, this application provides a solution for providing RDT capabilities to VMs. By providing the RDT on the pCPU to both VMs and vCPUs, VMs can use the RDT to apply appropriate caching and memory bandwidth limits to services of different priorities. Furthermore, the resource monitoring capabilities of the RDT can be utilized to observe the cache and memory bandwidth usage of the VMs.
[0093] The technical solutions shown in this application will now be described in detail through specific embodiments. It should be noted that the following embodiments may exist independently or in combination with each other; for identical or similar content, the description will not be repeated in different embodiments.
[0094] The method in this application embodiment is applied to an electronic device on which a VM is deployed, that is, the electronic device is the host of the VM, the host is equipped with a VM manager, and the host hardware supports RDT.
[0095] Figure 2 This is a flowchart illustrating a resource control method for a virtual machine, provided as an exemplary embodiment of this application. The execution subject of this method is the VM. Please refer to... Figure 2 The method may include:
[0096] S201. The VM receives CPU information from the VM manager, wherein the CPU information includes indication information that the vCPU supports RDT, the correspondence between the vCPU and the virtual RDT domain, and at least one CLOSID available to the VM. The CLOSID is used to control the available resources of the vCPU corresponding to the CLOSID within the virtual RDT domain.
[0097] During VM creation, the CPUID command is used to query CPU-related information. In related technologies, the VM manager returns information to the VM indicating that the vCPU does not support RDT. However, in this embodiment, when the VM queries CPU-related information, the VM manager returns information indicating that the virtual CPU supports RDT, and also returns the mapping between vCPUs and virtual RDT domains. The mapping between vCPUs and virtual RDT domains is similar to that between pCPUs and RDT domains; that is, a virtual RDT domain includes multiple vCPUs, and these vCPUs share cache and memory bandwidth resources, as well as sharing restrictions on their usage. A virtual RDT domain can be understood as the RDT domain seen by the VM.
[0098] In RDT, CLOSID is used to limit the use of cache and memory bandwidth resources. The total number of CLOSIDs supported by pCPU is fixed. When the VM manager indicates to the VM that the vCPU supports RDT, it also indicates to the VM the CLOSIDs available to the VM. In this way, the VM can use these available CLOSIDs to determine the cache and memory bandwidth resources that the vCPU can use.
[0099] S202. Based on CPU information, the VM uses RDT to control the cache and memory bandwidth resources of vCPUs in each virtual RDT domain. Different priority services in the VM are located on different vCPUs corresponding to different CLOSIDs.
[0100] A VM can set a corresponding CLOSID for any vCPU from its multiple available CLOSIDs. By setting the resource limit value corresponding to this CLOSID, the VM controls the resources available to that vCPU. It is understood that all vCPUs in the virtual RDT domain corresponding to this vCPU share the resource limit value for this CLOSID. The resource limit value can include cache limit value and memory bandwidth limit value. It is understood that the resource limit value can also include limit values for other types of resources; this embodiment does not limit this, but uses cache and memory bandwidth as examples for illustration.
[0101] The aforementioned practice of assigning different CLOSIDs to vCPUs hosting services of different priorities within a VM encompasses two scenarios. First, in a mixed offline / online deployment where online and offline services run on the same vCPU, the vCPU corresponds to a different CLOSID when switching between online and offline services. Resource control is achieved by setting the vCPU's CLOSID to the CLOSID of the switched service. Second, in a mixed offline / online deployment where online and offline services run on different vCPUs, different CLOSIDs can be assigned to the vCPUs hosting the online and offline services. By combining this with the cache and memory bandwidth resources corresponding to each CLOSID, control over the cache and memory bandwidth resources of each online and offline service can be achieved. In other words, different priorities within a VM correspond to different CLOSIDs, resulting in different resource limits for services of different priorities.
[0102] In this embodiment, the VM manager provides the VM with information including indication that the vCPU supports RDT, the correspondence between the vCPU and the virtual RDT domain, and CPU information including at least one CLOSID available to the VM. Based on the above information, the VM can use RDT to separately limit the cache and memory bandwidth resources used by the vCPU where services of different priorities reside, providing an RDT scheme available to the VM. This avoids the performance of high-priority services being affected by low-priority services occupying too many resources within the VM, thus ensuring the performance of high-priority services.
[0103] Figure 3 This is a flowchart illustrating another virtual machine resource control method provided for an exemplary embodiment of this application. The execution entity of this method is the VM manager. Please refer to... Figure 3 The method may include:
[0104] S301. The VM manager sends CPU information to the VM. The CPU information includes indication information that the vCPU supports RDT, the correspondence between the vCPU and the virtual RDT domain, and at least one CLOSID available to the VM. The CLOSID is used to control the available resources corresponding to the CLOSID within the virtual RDT domain.
[0105] During VM creation, the CPU information is queried using the CPUID instruction. In this embodiment, the VM manager returns to the VM an indication that the virtual CPU supports RDT, and also returns to the VM the correspondence between the vCPU and the virtual RDT domain, as well as the CLOSID available to the VM. In this way, the VM can use these available CLOSIDs to control the cache and memory bandwidth resources that the vCPU can use.
[0106] Taking the VM manager as the hypervisor as an example, during the VM creation process, QEMU sends the aforementioned CPU information to KVM, and KVM then sends the CPU information back to the VM. For the VM, the RDT-related information in the CPU information it receives is similar to that of the host machine. The VM can use the capabilities provided by RDT to control the cache and memory bandwidth used by the vCPU in a similar way to the host machine.
[0107] S302. The VM manager, according to the correspondence between vCPUs and virtual RDT domains, schedules vCPUs belonging to the same virtual RDT domain to pCPUs belonging to the same physical RDT domain.
[0108] pCPUs within the same physical RDT domain share cache and memory bandwidth. Similarly, the usage limits for cache and memory bandwidth resources for pCPUs within the same physical RDT domain are also shared. For VMs, the same logic applies: vCPUs within the same virtual RDT domain also share cache and memory bandwidth usage limits. Therefore, the VM manager needs to schedule vCPUs belonging to the same virtual RDT domain to pCPUs belonging to the same physical RDT domain, based on the mapping between vCPUs and virtual RDT domains, thus ensuring that the usage limits for cache and memory bandwidth resources are shared among vCPUs within the same virtual RDT domain.
[0109] In this embodiment, the VM manager provides the VM with CPU information including indication information that the vCPU supports RDT, the correspondence between vCPUs and virtual RDT domains, and at least one CLOSID available to the VM. According to the correspondence between vCPUs and virtual RDT domains, the VM schedules vCPUs belonging to the same virtual RDT domain to pCPUs belonging to the same physical RDT domain. This allows the VM to use RDT to limit the cache and memory bandwidth resources used by vCPUs with different priorities based on the CPU information. This provides an RDT scheme available to the VM and avoids the performance of high-priority services being affected by low-priority services occupying too many resources within the VM.
[0110] Based on the above embodiments, the CPU information may optionally include at least one RMID available to the VM, which is used to monitor the resource usage of the vCPU.
[0111] A VM can set a corresponding RMID for any vCPU from its multiple available RMIDs, thereby enabling the use of RDT's monitoring capabilities to track the resource usage of each vCPU. RDT can use hardware counters to collect resource monitoring data corresponding to each RMID in real time.
[0112] In this embodiment of the application, the VM manager can also accumulate the resource monitoring data of each RMID used by the VM at the VM level, thereby determining the resource usage of the VM.
[0113] Optionally, in the CPU information presented by the VM manager to the VM, the number of RMIDs available to the VM is less than the total number of RMIDs supported by the pCPU, and the number of CLOSIDs available to the VM is less than the total number of CLOSIDs supported by the pCPU. In this way, a portion of RMIDs and CLOSIDs are reserved for the host machine. For example, assuming there are 16 CLOSIDs (0-15) on the host machine, the VM manager can present 12 CLOSIDs (0-11) to the VM and reserve 4 CLOSIDs (12-15) for the host machine; or, the VM manager can present 15 CLOSIDs (0-14) to the VM and reserve 1 CLOSID (16) for the host machine. The number of RMIDs and CLOSIDs presented by the VM manager to the VM is configurable.
[0114] The resource monitoring and control capabilities provided by RDT are implemented through RDT registers. RDT defines MSRs for resource monitoring and control, as well as MSRs for specifying the current RMID and CLOSID of the CPU. The following explanation, in conjunction with RDT registers, illustrates how VMs use RDT to control the cache and memory bandwidth resources of vCPUs in each virtual RDT domain.
[0115] In some embodiments, the VM writes the vCPU's CLOSID to the first RDT register corresponding to the vCPU; the VM writes the resource limit values of the cache and memory bandwidth resources corresponding to the CLOSID to the second RDT register corresponding to the virtual RDT domain of the vCPU.
[0116] The first RDT register can be a PQR_ASSOC MSR, and the second RDT register is the resource control MSR defined in the RDT. All vCPUs within the same virtual RDT domain share this second RDT register. Therefore, after the VM writes the resource limit value corresponding to the CLOSID into this second RDT register, the resources available to each vCPU in this virtual RDT domain are constrained by that resource limit value. This resource limit value includes cache resource limits and / or memory bandwidth resource limits. For example, assuming vCPU0 and vCPU1 belong to the same virtual RDT domain, the resource limit value corresponding to the CLOSID set by vCPU0 has the same effect on vCPU1. When vCPU1 reads its resource limit value, the data read from the second RDT register is the resource limit value corresponding to the CLOSID set by vCPU0.
[0117] Optionally, the VM can also write the RMID of the vCPU to the first RDT register corresponding to the vCPU to set the RMID for that vCPU, thereby utilizing the monitoring capabilities of the RDT to monitor the resource monitoring data corresponding to the RMID. When the VM reads resource monitoring data, the hardware counters in the RDT collect the resource monitoring data corresponding to each RMID and write the resource monitoring data into the corresponding RDT register. For example, the resource monitoring data is written to the third RDT register corresponding to the vCPU, where the third RDT register is the MSR defined in the RDT for resource monitoring. The VM reads the resource monitoring data corresponding to the RMID from the third RDT register corresponding to the vCPU.
[0118] Optionally, the VM manager can accumulate resource monitoring data of each RMID used by the VM at the VM level. For example, the VM manager can obtain the resource monitoring data in the third RDT register corresponding to each vCPU of the VM and accumulate it. Thus, when the VM uses vRDT, the host machine can also obtain the usage of resources such as cache and memory bandwidth used by the VM.
[0119] It should be noted that the above embodiments are illustrative examples of reading and writing several RDT-related registers. The VM's reading and writing of other RDT registers is similar.
[0120] VM's read and write operations on the RDT register can be implemented using Trap, which will be explained below.
[0121] Optionally, when the VM performs a write operation on any RDT register, it traps the data to the Host. The VM manager, in response to the VM's write operation on any RDT register, writes the data to be written to the RDT register. The data to be written includes the vCPU's RMID, vCPU's CLOSID, or the resource limit value corresponding to the CLOSID. This data can be written to the respective RDT register.
[0122] Optionally, when the VM performs a read operation on any RDT register, it traps the data to the Host. The VM manager responds to the VM's read operation on any RDT register by reading data from the RDT register and sends the read data back to the VM. The data read by the VM includes resource monitoring data corresponding to the RMID.
[0123] VM read and write operations on the RDT register can also be implemented by passing the RDT register to the vCPU.
[0124] Optionally, the VM manager sets the state of at least one RDT register to pass through to the vCPU in the VM. By passing through the RDT register to the vCPU in the VM manager, the VM can directly read and write to the RDT register, avoiding the performance overhead of frequent traps to the host caused by reading and writing to the RDT register.
[0125] When the RDT register is passed directly to the vCPU, to prevent the resources used by the host machine from being restricted by the CLOSID set by the VM, the RDT register needs to be saved and restored during VMexit and VMentry. When the VM's vCPU exits (i.e., when VM exits), the VM manager saves the vCPU's RMID and CLOSID in the first RDT register and sets the first RDT register to the host's RMID and CLOSID. When the VM's vCPU exits (i.e., when VMentry is entered), the VM manager sets the first RDT register to the vCPU's RMID and CLOSID. This ensures that both the VM and the host use the correct RMID and CLOSID for resource control and monitoring.
[0126] Optionally, in the case of VMexit, if the CLOSID of the vCPU in the first RDT register has a corresponding resource limit value, the VM manager saves the RMID and CLOSID of the vCPU and sets the first RDT register to the RMID and CLOSID of the host machine. If the CLOSID used by the vCPU in the VM does not have resource limits, that is, the CLOSID does not have a corresponding resource limit value, then saving and restoring the RDT register is not required in VMexit and VMentry. If the host does not use the RDT or the host only uses the RMID and CLOSID reserved for the host, then saving and restoring the registers used for resource limits in the RDT register is also not required in VMexit and VMentry. This further reduces the impact on VM performance.
[0127] Considering the need to save and restore the pass-through registers during each VMexit and VMentry, which could potentially impact VM performance, in some implementations, the VM manager only sets the state of at least one RDT register to pass-through to the vCPU in the VM if it determines that the VM has already used the RDT. That is, when the VM is not using the RDT, the VM manager will not pass the RDT registers to the vCPU, and therefore, the VM manager does not need to save and restore the RDT registers during VMexit and VMentry. The VM manager only passes the RDT registers to the vCPU and saves and restores the RDT registers during VMexit and VMentry once the VM uses the RDT.
[0128] Optionally, the VM manager can determine that the VM is using the RDT in the following ways: the VM manager determines that the VM is using the RDT when the VM performs a read operation and / or a write operation on the RDT register. In some embodiments, the VM manager determines that the VM is using the RDT as soon as the VM performs a read operation and / or a write operation on any RDT register; before this, the VM is considered not to be using the RDT. In other embodiments, if the VM reads an RDT register, but the read operation does not modify resource monitoring or resource control, the VM manager still determines that the VM is not using the RDT until the VM performs a write operation on the RDT register, at which point the VM is determined to be using the RDT.
[0129] Optionally, if the VM manager determines that the VM has used the RDT, it marks the VM's status as RDT-used; if the VM restarts, the VM manager remarks the VM's status as RDT-unused. In other words, if the VM restarts, the VM manager needs to re-determine whether the VM has used the RDT to determine whether to pass the RDT registers to the vCPU.
[0130] The above embodiments ensure that the performance overhead of the VM is kept as low as possible, regardless of whether the VM uses RDT.
[0131] In scenarios such as vCPU rebinding, vCPU migration out of pCPU, vCPU migration into pCPU, and vCPU destruction, vCPU loading or vCPU putting is involved. When vCPU loads or puts, the data in the RDT register also needs to be set accordingly.
[0132] When a vCPU is loaded, the VM manager sets the resource limit value corresponding to the vCPU's CLOSID in the second RDT register. In other words, when a vCPU is loaded, the CLOSID limit set by the vCPU needs to be loaded. Conversely, when all vCPUs with the same CLOSID within the vRDT domain experience vCPU puts, the VM manager sets the second RDT register to the resource limit value corresponding to the host machine's CLOSID. This means that when a vCPU is put, the CLOSID limit visible to the VM needs to be reset. This ensures that the VM uses the correct resource limit values to control vCPU cache and memory bandwidth resources during both vCPU load and vCPU put scenarios.
[0133] In scenarios such as VM hot migration or VM hibernation and wake-up, it is also necessary to save and restore the relevant data of the RDT register in the VM settings. In addition, the relevant state of the RDT register in the virtual machine manager also needs to be saved and restored to ensure that the VM can still run according to the relevant data of the vCPU before the VM hot migration or VM hibernation and wake-up.
[0134] In this embodiment, by providing the pCPU's RDT capabilities to the VM and vCPU, the VM can use the RDT to impose L2, LLC, and MB resource limits on services of different priorities. Furthermore, this embodiment employs trap or pass-through conversion processing for the RDT registers used by the vCPU, and optimizes the saving and restoring of RDT registers in VMexit and VMentry scenarios, ensuring that the performance overhead on the VM is minimized regardless of whether the VM uses the RDT.
[0135] The solutions in this application can be used alone to limit resource usage by services within a VM, or they can be used in conjunction with cgroups, scheduling limits, and other solutions to minimize the impact of low-priority tasks (e.g., offline tasks) on high-priority tasks (e.g., online tasks). Furthermore, the solutions in this application provide the VM with monitoring of the usage of L2, LLC, and MB resources by services within the VM, enabling the VM to make better capacity or service planning.
[0136] It should be noted that the processing steps shown in the embodiments of this application do not constitute a specific limitation on the resource control process of the virtual machine. In other embodiments of this application, the resource control process of the virtual machine may include more or fewer steps than those in the above embodiments.
[0137] Figure 4 This is a schematic diagram of a host machine structure provided for an exemplary embodiment of this application. Please refer to... Figure 4 The host machine 40 has a virtual machine 41 and a virtual machine manager 42 deployed on it;
[0138] In this embodiment, virtual machine 41 is used to execute the method executed by the virtual machine in the above method embodiment, and virtual machine manager 42 is used to execute the method executed by the virtual machine manager in the above method embodiment.
[0139] The host machine provided in this application embodiment can execute the technical solution shown in the above method embodiment. Its implementation principle and beneficial effects are similar, and will not be repeated here.
[0140] Figure 5 This is a schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this application. Please refer to... Figure 5 The electronic device 50 may include a processor 51 and a memory 52. Exemplarily, the processor 51 and the memory 52 are interconnected via a bus 53.
[0141] The memory 52 stores computer-executed instructions;
[0142] The processor 51 executes the computer execution instructions stored in the memory 52, causing the processor 51 to perform the method as shown in the above method embodiment.
[0143] Accordingly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the above-described method embodiments.
[0144] Accordingly, embodiments of this application may also provide a computer program product, including a computer program, which, when executed by a processor, can implement the methods shown in the above-described method embodiments.
[0145] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0146] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0147] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0148] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0149] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0150] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0151] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0152] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0153] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A resource control method for a virtual machine, characterized in that, include: The virtual machine receives processor information from the virtual machine manager, wherein the processor information includes indication information that the virtual processor supports resource provisioning technology, the correspondence between the virtual processor and the virtual resource provisioning technology domain, and at least one service category identifier available to the virtual machine, the service category identifier being used to indicate the available resources of the virtual processor corresponding to the service category identifier within the virtual resource provisioning technology domain; The virtual machine uses resource allocation technology to control the cache and memory bandwidth resources of virtual processors in each virtual resource allocation technology domain based on the processor information. The virtual processors where services of different priorities reside in the virtual machine correspond to different service category identifiers.
2. The method according to claim 1, characterized in that, The virtual machine, based on the processor information, uses resource allocation technology to control the cache and memory bandwidth resources of virtual processors in each virtual resource allocation domain, including: The virtual machine writes the service category identifier of the virtual processor into the first resource allocation technology register corresponding to the virtual processor; The virtual machine writes the resource limit values of the cache and memory bandwidth resources corresponding to the service category identifier into the second resource allocation technology register corresponding to the virtual resource allocation technology domain of the virtual processor.
3. The method according to claim 1, characterized in that, The processor information also includes at least one resource monitoring identifier available to the virtual machine, which is used to monitor the resource usage of the virtual processor.
4. The method according to claim 3, characterized in that, The number of resource monitoring identifiers available to the virtual machine is less than the total number of resource monitoring identifiers supported by the physical processor, and the number of service category identifiers available to the virtual machine is less than the total number of service category identifiers supported by the physical processor.
5. The method according to claim 3, characterized in that, Also includes: The virtual machine writes the resource monitoring identifier of the virtual processor into the first resource allocation technology register corresponding to the virtual processor.
6. The method according to claim 5, characterized in that, Also includes: The virtual machine reads the resource monitoring data corresponding to the resource monitoring identifier from the third resource allocation technology register corresponding to the virtual processor.
7. A resource control method for a virtual machine, characterized in that, include: The virtual machine manager sends processor information to the virtual machine, wherein the processor information includes indication information that the virtual processor supports resource provisioning technology, the correspondence between the virtual processor and the virtual resource provisioning technology domain, and at least one service category identifier available to the virtual machine, the service category identifier being used to indicate the available resources of the virtual processor corresponding to the service category identifier within the virtual resource provisioning technology domain; The virtual machine manager schedules virtual processors belonging to the same virtual resource allocation technology domain to physical processors belonging to the same physical resource allocation technology domain, according to the correspondence between virtual processors and virtual resource allocation technology domains.
8. The method according to claim 7, characterized in that, The processor information also includes at least one resource monitoring identifier available to the virtual machine, which is used to monitor the resource usage of the virtual processor.
9. The method according to claim 8, characterized in that, The number of resource monitoring identifiers available to the virtual machine is less than the total number of resource monitoring identifiers supported by the physical processor, and the number of service category identifiers available to the virtual machine is less than the total number of service category identifiers supported by the physical processor.
10. The method according to any one of claims 7-9, characterized in that, Also includes: The virtual machine manager responds to the virtual machine's write operation on any resource allocation technology register by writing the data to be written into the resource allocation technology register. And / or, The virtual machine manager responds to the virtual machine's read operation on any resource allocation technology register by reading data from the resource allocation technology register and sends the read data to the virtual machine.
11. The method according to claim 10, characterized in that, The data to be written includes the resource monitoring identifier of the virtual processor, the service category identifier of the virtual processor, or the resource limit value corresponding to the service category identifier; The data read by the virtual machine includes the resource monitoring data corresponding to the resource monitoring identifier.
12. The method according to any one of claims 7-9, characterized in that, Also includes: The virtual machine manager sets the state of at least one resource allocation technology register to pass through the virtual processors in the virtual machine.
13. The method according to claim 12, characterized in that, The virtual machine manager sets the state of at least one resource allocation technology register to pass through the virtual processors in the virtual machine, including: When the virtual machine manager determines that the virtual machine has used resource allocation technology, it sets the state of at least one resource allocation technology register to pass through the virtual processor in the virtual machine.
14. The method according to claim 13, characterized in that, The virtual machine manager determines that the virtual machine has used resource provisioning technology, including: The virtual machine manager determines that the virtual machine has used resource allocation technology when the virtual machine has performed read and / or write operations on the resource allocation technology register.
15. The method according to claim 13, characterized in that, The method further includes: If the virtual machine manager determines that the virtual machine has used resource allocation technology, it will mark the virtual machine's status as having used resource allocation technology. When the virtual machine restarts, the virtual machine manager will re-mark the virtual machine's state as not using resource allocation technology.
16. The method according to claim 11, characterized in that, Also includes: When the virtual machine exits, the virtual machine manager saves the resource monitoring identifier and service category identifier of the virtual processor in the first resource allocation technology register, and sets the first resource allocation technology register as the resource monitoring identifier and service category identifier of the host machine. When a virtual machine enters, the virtual machine manager sets the first resource allocation technology register to the resource monitoring identifier and service category identifier of the virtual processor.
17. The method according to claim 16, characterized in that, Also includes: If the virtual machine exits, and the service category identifier of the virtual processor in the first resource allocation technology register has a corresponding resource limit value, the virtual machine manager saves the resource monitoring identifier and service category identifier of the virtual processor, and sets the first resource allocation technology register to the resource monitoring identifier and service category identifier of the host machine.
18. The method according to claim 11, characterized in that, Also includes: When a virtual processor is loaded, the virtual machine manager sets the resource limit value corresponding to the service category identifier of the virtual processor in the second resource allocation technology register; When the virtual processor is released, the virtual machine manager sets the second resource allocation technology register to the resource limit value corresponding to the host machine's service category identifier.
19. A host machine, characterized in that, The host machine has virtual machines and a virtual machine manager deployed on it; The virtual machine is used to execute the method according to any one of claims 1-6, and the virtual machine manager is used to execute the method according to any one of claims 7-18.
20. An electronic device, characterized in that, include: At least one processor; as well as A memory that is communicatively connected to the at least one processor; The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, cause the electronic device to perform the method according to any one of claims 1-18.
21. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the method as described in any one of claims 1-18.
22. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-18.
