A VCPU Thread Scheduling Method and System in Cloud Computing

By dynamically binding VCPU threads with frequent VM Exit and high CPU occupancy to the same physical CPU or logical Core in cloud computing, the resource waste problem caused by frequent VCPU thread scheduling is solved, and server performance and load balancing are improved.

CN118502947BActive Publication Date: 2025-08-05BEIJING DIGITAL INFORMATION CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410672231.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2025-08-05
Estimated Expiration
2044-05-28

AI Technical Summary

Technical Problem

In cloud computing, frequent scheduling of VCPU threads leads to waste of resources in initialization operations, and existing binding methods lack flexibility and cannot be dynamically adjusted to deal with load changes.

Method used

By obtaining the CPU information of the physical server, we determine whether hyperthreading is supported, count the VM Exit frequency and CPU occupancy rate of the VCPU thread, dynamically bind VCPU threads with frequent VM Exit and high CPU occupancy rate to the same physical CPU or logical Core, and balance the load.

Benefits of technology

Improves the overall performance of the server, reduces resource waste caused by frequent VM Exit, and has high flexibility and dynamic adjustment capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118502947B_ABST
    Figure CN118502947B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for VCPU thread scheduling in cloud computing. All physical CPUs in a physical server are obtained, and it is determined whether each physical CPU supports and enables hyper-threading. If so, the logical Core is used as the target Core; otherwise, the physical Core of the physical server is used as the target Core. The frequency of VM Exit occurring during the execution of VCPU threads and the average CPU occupancy rate of VCPU threads are statistically analyzed within a preset time. When the frequency of VM Exit occurring for a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server, and the CPU occupancy rate of the VCPU thread is greater than the average CPU occupancy rate of VCPU threads, it is used as a VCPU thread to be bound. The VCPU threads to be bound belonging to the same virtual machine are bound to one or more target Cores belonging to the same physical CPU. The present invention uses the VCPU threads with frequent VM Exit and high CPU occupancy rate as the VCPU threads to be bound. On the one hand, it ensures the flexibility of host scheduling, and on the other hand, it can reduce the performance degradation of the host caused by frequent VM Exit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing, and particularly to a VCPU thread scheduling method and system in cloud computing. Background Art

[0002] Cloud Computing is to gather numerous servers together to provide users with resources such as computing and storage. Virtualization is the foundation of cloud computing. Virtualization means generating virtual hosts in a server. Users can perform various operations through virtual machines, such as installing various operating systems and various software, just as on a physical machine, and users cannot feel the difference from a physical machine. There is a problem of double scheduling in cloud computing. That is, the programs running in the guest operating system will be scheduled by the guest operating system. Since the virtual machine is also a process in the host, it will be scheduled by the host or the Hypervisor, so that it can be truly executed by the CPU on the physical server.

[0003] However, VCPU threads are different from ordinary threads. During the execution of a VCPU thread, if a VCPU thread is rescheduled to a physical Core, many initialization operations need to be performed, such as flushing VM-related content from the cache to the memory, etc. If it is still executed on the same physical Core, these operations can be avoided. In order to improve the overall efficiency of the server, some practices are to bind the VCPU thread to the Core on the host. However, the load of the VM is constantly changing. Manually binding the VCPU and the Core may result in some Cores being too busy and some Cores being too idle. If scheduling the VCPUs on the hosts in a cloud computing cluster is the key to improving the efficiency of the hosts and the entire cloud computing cluster. Summary of the Invention

[0004] In order to make full use of the physical servers in a cloud cluster, the present invention provides a VCPU thread scheduling method in cloud computing, which is applied in a Hypervisor. The method includes the following steps:

[0005] S1, obtain all physical CPUs in the physical server, and determine whether each physical CPU supports and enables hyper-threading. If so, use the logical Core as the target Core; otherwise, use the physical Core of the physical server as the target Core;

[0006] S2. Statistically calculate the frequency of VM Exit occurring during the execution of each VCPU thread within a preset time period and the average CPU occupancy rate of the VCPU thread. When the frequency of VM Exit of a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server and the CPU occupancy rate of the VCPU thread is greater than the average CPU occupancy rate of VCPU threads, then the VCPU thread is regarded as a VCPU thread to be bound.

[0007] S3. Bind the VCPU threads to be bound that belong to the same virtual machine to one or more target Cores that belong to the same physical CPU.

[0008] Preferably, the step of binding the VCPU threads to be bound that belong to the same virtual machine to one or more target Cores that belong to the same physical CPU is specifically as follows:

[0009] S31. Obtain the number of virtual machines containing the VCPU threads to be bound and the number of physical CPUs of the physical server. Divide the virtual machines containing the VCPU threads to be bound into N groups, and establish the corresponding relationship between each group of virtual machines and each physical CPU, where N is a positive integer.

[0010] S32. For each physical CPU, perform the following operations: Obtain the VCPU threads to be bound in the group of virtual machines corresponding to each physical CPU, allocate the VCPU threads to be bound to the target Cores in the physical CPU according to the VM Exit frequency of each VCPU thread to be bound, and establish the binding relationship between the VCPU threads to be bound and the target Cores.

[0011] Preferably, the step of dividing the virtual machines containing the VCPU threads to be bound into N groups and establishing the corresponding relationship between each group of virtual machines and each physical CPU is specifically as follows:

[0012] If the number of physical CPUs is 1, then divide the virtual machines containing the VCPU threads to be bound into one group and establish the corresponding relationship between the virtual machine and the physical CPU.

[0013] If the number of physical CPUs is greater than 1, then obtain the CPU utilization rate of the virtual machines containing the VCPU threads to be bound and the utilization rate of each physical CPU, sort them in descending order according to the CPU utilization rate of the virtual machines, and sequentially allocate the virtual machines to the physical CPU with the lowest utilization rate, and establish the corresponding relationship between the virtual machines and the physical CPUs according to the allocation results.

[0014] Preferably, the step of binding the VCPU threads to be bound that belong to the same virtual machine to one or more target Cores that belong to the same physical CPU is specifically as follows:

[0015] Obtain the CPU resources occupied by the VM process containing the to-be-bound VCPU thread in the physical server, balance the load of the VM process to the physical CPUs according to the CPU resources occupied in the physical server, and establish the corresponding relationship between the physical CPUs and the VM process containing the to-be-bound VCPU thread;

[0016] If the target Core in the physical CPU is a physical Core, bind the VCPU thread to the target Core according to the physical Core and the CPU resource occupancy rate of the to-be-bound VCPU thread; otherwise, bind the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs.

[0017] Preferably, the binding of the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs is specifically as follows:

[0018] Calculate the product of the utilization rate of the logical Core and the utilization rate of the physical Core to which the logical Core belongs, take the product as the actual utilization rate of the logical Core, and balance the load of the to-be-bound VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread and the actual utilization rate.

[0019] In addition, the present invention also provides a VCPU thread scheduling system in cloud computing. The system is located in the Hypervisor and is characterized in that the system includes the following modules:

[0020] Target Core acquisition module, used to acquire all physical CPUs in the physical server and determine whether each physical CPU supports and enables hyper-threading. If so, regard the logical Core as the target Core; otherwise, regard the physical Core of the physical server as the target Core;

[0021] To-be-bound VCPU thread acquisition module, used to count the frequency of VM Exit occurring during the execution of each VCPU thread and the average CPU occupancy rate of the VCPU thread within a preset time. When the frequency of VM Exit of a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server and the CPU occupancy rate of the VCPU thread is greater than the average CPU occupancy rate of VCPU threads, regard the VCPU thread as the to-be-bound VCPU thread;

[0022] Binding module, used to bind the to-be-bound VCPUs belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU.

[0023] Preferably, binding the VCPUs to be bound belonging to the same virtual machine to one or more target cores belonging to the same physical CPU is specifically as follows:

[0024] Obtain the number of virtual machines containing the VCPU threads to be bound, and the number of physical CPUs of the physical server, divide the virtual machines containing the VCPU threads to be bound into N groups, and establish the corresponding relationship between each group of virtual machines and each physical CPU, where N is a positive integer;

[0025] For each physical CPU, perform the following operations: obtain the VCPU threads to be bound in the virtual machine group corresponding to each physical CPU, allocate the VCPU threads to be bound to the target cores in the physical CPU according to the VM Exit frequency of each VCPU thread to be bound, and establish the binding relationship between the VCPU threads to be bound and the target cores.

[0026] Preferably, dividing the virtual machines containing the VCPU threads to be bound into N groups and establishing the corresponding relationship between each group of virtual machines and each physical CPU is specifically as follows:

[0027] If the number of physical CPUs is 1, divide the virtual machines containing the VCPU threads to be bound into one group, and establish the corresponding relationship between the virtual machines and the physical CPU;

[0028] If the number of physical CPUs is greater than 1, obtain the CPU utilization rate of the virtual machines containing the VCPU threads to be bound and the utilization rate of each physical CPU, sort them in descending order according to the CPU utilization rate of the virtual machines, and allocate the virtual machines to the physical CPU with the lowest utilization rate in turn, and establish the corresponding relationship between the virtual machines and the physical CPU according to the allocation results.

[0029] Preferably, binding the VCPUs to be bound belonging to the same virtual machine to one or more target cores belonging to the same physical CPU is specifically as follows:

[0030] Obtain the CPU resources occupied by the VM process containing the VCPU threads to be bound in the physical server, balance the load of the VM process to the physical CPUs according to the CPU resources occupied in the physical server, and establish the corresponding relationship between the physical CPUs and the VM process containing the VCPU threads to be bound;

[0031] If the target Core in the physical CPU is a physical Core, bind the VCPU thread to the target Core according to the physical Core and the CPU resource occupancy rate of the to-be-bound VCPU thread; otherwise, bind the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs.

[0032] Preferably, the step of binding the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs is specifically as follows:

[0033] Calculate the product of the utilization rate of the logical Core and the utilization rate of the physical Core to which the logical Core belongs, use the product as the actual utilization rate of the logical Core, and evenly load the to-be-bound VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread and the actual utilization rate.

[0034] Finally, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described above is run.

[0035] In the present invention, for VCPU threads that frequently perform VM Exit and occupy a large amount of physical server CPU resources, binding them to the target Core has at least the following advantages:

[0036] 1. It has high flexibility. Instead of manual binding, during the execution of the cloud computing server, the binding is adjusted in a timely manner according to the situation of the VCPU thread and the CPU utilization of the physical server.

[0037] [[ID=1⑧]]2. For VCPU threads with frequent VM Exit, after binding to the Core, it reduces the operation of re-initializing the VCPU thread by scheduling to a new Core due to the frequent scheduling of the VCPU thread caused by the VM itself, and improves the overall performance of the server. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0039] Figure 1 It is a flowchart of the first embodiment of the present invention;

[0040] Figure 2 It is a VM-Host structure diagram;

[0041] Figure 3 It is another flowchart of the first embodiment of the present invention;

[0042] Figure 4 It is a schematic structural diagram of the second embodiment of the present invention. Detailed implementation manners

[0043] The embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and are only used to explain the present invention and should not be construed as a limitation of the present invention. On the contrary, the embodiments of the present invention include all changes, modifications, and equivalents falling within the spirit and scope of the appended claims.

[0044] In the description of the present invention, it should be noted that unless otherwise clearly specified and limited, the terms "connected" and "coupled" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations. In addition, in the description of the present invention, unless otherwise stated, the meaning of "plural" is two or more.

[0045] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of executable instructions including one or more steps for implementing a specific logical function or process. The scope of the preferred embodiments of the present invention includes additional implementations, where the functions can be executed in a manner simultaneous according to the involved functions or in the reverse order instead of the order shown or discussed, which should be understood by those skilled in the art of the embodiments of the present invention.

[0046] Term explanation:

[0047] Physical CPU: A physical CPU refers to a physical entity CPU, that is, a CPU that can be touched;

[0048] Physical Core: A physical Core is a core that actually exists in a physical CPU;

[0049] Hyper-threading: Hyper-threading (Super-Threading or Hyper-Threading) is an architecture developed by Intel that enables a physical Core to process multiple threads within a single unit of time;

[0050] VM process: In virtualization technology, a virtual machine is a process of the physical host (Host machine) operating system (Host OS);

[0051] VCPU thread: A CPU in each virtual machine is a VCPU thread in the Host OS. That is, a VM process includes one or more VCPU threads. Of course, a VM process also includes other threads, such as IO threads, network threads, etc.;

[0052] Embodiment 1

[0053] The present invention provides a method for scheduling VCPU threads in cloud computing, which is applied in a Hypervisor. The method includes the following steps, as Figure 1 shown:

[0054] S1. Obtain all physical CPUs in the physical server and determine whether each physical CPU supports and enables hyper-threading. If so, use the logical Core as the target Core; otherwise, use the physical Core of the physical server as the target Core;

[0055] Hyper-threading technology brings higher processing performance to the processor. When hyper-threading is enabled, a physical Core is simulated as multiple logical Cores. Logical Cores are only simulated by the system and do not exist in the real physical CPU.

[0056] S2. Statistically analyze the frequency of VM Exit occurring during the execution of each VCPU thread and the average CPU occupancy rate of the VCPU thread within a preset time. When the frequency of VM Exit of a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server and the CPU occupancy rate of the VCPU thread is greater than the average CPU occupancy rate of VCPU threads, use the VCPU thread as the VCPU thread to be bound;

[0057] A VM Exit means that the virtual machine exits the VM mode and enters the VMM (Hypervisor), which is then executed by the VMM. For example, when a page fault occurs in a VCPU thread on the Host, the execution of the VCPU thread will pause on the Core of the Host, and the Core of the Host will schedule other threads to execute. When a VCPU thread is scheduled again, it may be scheduled to the previous Core or to another Core. Since some initialization operations will be performed in the newly scheduled Core, this will seriously waste resources. Currently, the common method is to bind the VCPU to the Core. However, if binding is done, the Host lacks intelligence and cannot perform dynamic scheduling based on the load. In this invention, a VCPU thread with a VM Exit frequency greater than the average scheduling frequency of non-VCPU threads and a CPU occupancy rate greater than the average CPU occupancy rate of VCPU threads is used as the VCPU thread to be bound to achieve binding with the target Core. In this invention, unless otherwise specified, VMM and Hypervisor have the same meaning.

[0058] For virtual machines of the I / O intensive type, their corresponding VCPU threads will frequently perform VM Exit. If not bound to the Core of the Host, frequent initialization will seriously waste resources. In addition, the greater the CPU occupancy rate of a VCPU thread, the greater the role this VCPU plays in the VM for the VM. In practice, the greater the impact on the user of the VM. Using a VCPU thread with a VM Exit frequency greater than the average scheduling frequency of non-VCPU threads in the physical server and a CPU occupancy rate greater than the average CPU occupancy rate of VCPU threads as the VCPU thread to be bound has a great impact on both the performance improvement of the physical server and the user of the VM. Here, the CPU occupancy rate of the VCPU thread refers to the CPU situation of the physical server occupied by the VCPU thread.

[0059] It should be noted that the VM process and VCPU threads are processes and threads on the physical server, that is, the host, which are different from the processes and threads inside the VM. As Figure 2 shown, there are also many processes and threads inside the VM. The processor of the VM is the VCPU, and there is one or more VCPUs in the virtual machine.

[0060] S3, Bind the VCPU threads to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU.

[0061] The processing power of the physical CPUs in the physical server is generally relatively strong. One CPU contains multiple physical Cores and logical Cores. Moreover, the physical server may also have multiple physical CPUs. As Figure 2As shown, since each VCPU thread belongs to a VM process, the VCPU threads belonging to the same virtual machine need to be bound to a physical CPU. Among them, binding the VCPU to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU is specifically as follows: Figure 3 As shown:

[0062] S31. Obtain the number of virtual machines containing the VCPU threads to be bound and the number of physical CPUs of the physical server. Divide the virtual machines containing the VCPU threads to be bound into N groups, and establish the corresponding relationship between each group of virtual machines and each physical CPU, where N is a positive integer;

[0063] Among them, dividing the virtual machines containing the VCPU threads to be bound into N groups means dividing the virtual machines into N groups, so that all the VCPU threads to be bound belonging to one virtual machine will be assigned to one group, avoiding fragmenting different VCPU threads to be bound belonging to the same virtual machine in different physical CPUs. For example, there are 3 virtual machines, that is, 3 VM processes, and each VM process includes three VCPU threads to be bound. The virtual machines are divided into two groups, where virtual machine 1 and virtual machine 3 are assigned to group A, and virtual machine 2 is assigned to group B. In this way, the 6 VCPU threads to be bound corresponding to virtual machine 1 and virtual machine 3 are corresponding to group A. Similarly, the 3 VCPU threads to be bound corresponding to virtual machine 2 are corresponding to group B.

[0064] S32. For each physical CPU, perform the following operations: Obtain the VCPU threads to be bound in the virtual machine group corresponding to each physical CPU, and allocate the VCPU threads to be bound to the target Cores in the physical CPU according to the VM Exit frequency of each VCPU thread to be bound, and establish the binding relationship between the VCPU threads to be bound and the target Cores.

[0065] If there are 5 VCPU threads to be bound in the virtual machine group corresponding to a physical CPU, and the target Cores corresponding to this physical CPU are 3, then calculate the VM Exit frequencies of these 5 VCPU threads to be bound are 10, 20, 10, 20, 30 respectively. The average VM Exit frequency evenly distributed to 3 target Cores is: 30. Then a specific allocation method is that the 1st and 2nd VCPU threads to be bound are assigned to the 1st target Core, the 3rd and 4th VCPU threads to be bound are assigned to the 2nd target Core, and the 5th VCPU thread to be bound is assigned to the 3rd target Core.

[0066] In another embodiment, if the number of VCPUs to be bound is less than the target Core, the VCPU to be bound with the highest VM Exit frequency is allocated to the target Core with the lowest utilization rate. The present invention does not specifically limit the allocation of the VCPUs to be bound to the target Cores in the physical CPU according to the VMExit frequency of each VCPU thread to be bound.

[0067] When there are multiple physical CPUs, if the VCPUs to be bound are only concentratedly allocated to one physical CPU, it will cause the problem of load imbalance. Therefore, the virtual machine containing the VCPUs to be bound is divided into N groups, and the corresponding relationship between each group of virtual machines and each physical CPU is established, specifically:

[0068] If the number of physical CPUs is 1, the virtual machine containing the VCPUs to be bound is divided into one group, and the corresponding relationship between the virtual machine and the physical CPU is established;

[0069] If the number of physical CPUs is greater than 1, obtain the CPU utilization rate of the virtual machine containing the VCPUs to be bound and the utilization rate of each physical CPU, sort them in descending order according to the CPU utilization rate of the virtual machine, and allocate the virtual machines to the physical CPU with the lowest utilization rate in turn, and establish the corresponding relationship between the virtual machine and the physical CPU according to the allocation result.

[0070] The CPU utilization rate of the virtual machine with the VCPUs to be bound is the CPU utilization rate in the virtual machine corresponding to the VCPUs to be bound. For example, if the VCPU to be bound thread 1 is a thread in the virtual machine (VM1) process, the CPU utilization rate of the virtual machine with the VCPUs to be bound is the CPU utilization rate of the virtual machine (VM1), which is viewed through the CPU utilization rate viewing command in the Guest OS. The system running on the physical server is the Host OS, the system running in the virtual machine is the Guest OS, and the physical server is also called the host.

[0071] In another embodiment, binding the VCPUs to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU is specifically:

[0072] Obtain the CPU resources occupied by the VM process containing the VCPUs to be bound threads in the physical server, balance the load of the VM process to the physical CPU according to the CPU resources occupied in the physical server, and establish the corresponding relationship between the physical CPU and the VM process containing the VCPUs to be bound threads;

[0073] VCPU threads and VM processes are threads and processes on the physical server, i.e., on the Host OS. To balance the load of physical CPUs, VM processes are allocated to physical CPUs according to the CPU resources occupied by the VM processes. Further, all threads in the VM process will run on this physical CPU. By the CPU resources occupied by the VM process on the physical server, it is more possible to balance the load of the physical CPU and prevent some physical CPUs from being busy while some are idle.

[0074] If the target Core in the physical CPU is a physical Core, the VCPU thread is bound to the target Core according to the physical Core and the CPU resource occupancy rate of the to-be-bound VCPU thread; otherwise, the VCPU thread is bound to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs.

[0075] The logical Core does not actually exist. The actual operation of the logical Core still runs on the physical Core. When the target Core is a logical Core, when allocating the to-be-bound VCPU thread, it is necessary to consider both the utilization rate of the logical Core and the utilization of the physical Core to which the logical Core belongs. In a specific embodiment, the binding of the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs is specifically as follows:

[0076] Calculate the product of the utilization rate of the logical Core and the utilization rate of the physical Core to which the logical Core belongs, and use the product as the actual utilization rate of the logical Core. Balance the load of the to-be-bound VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread and the actual utilization rate.

[0077] Embodiment 2

[0078] The present invention also provides a VCPU thread scheduling system in cloud computing. The system is located in the Hypervisor and is characterized in that the system includes the following modules, as Figure 4 shown:

[0079] A target Core acquisition module, configured to acquire all physical CPUs in the physical server and determine whether each physical CPU supports and enables hyper-threading. If so, use the logical Core as the target Core; otherwise, use the physical Core of the physical server as the target Core;

[0080] A VCPU thread acquisition module to be bound, which is used to count the frequency of VM Exit occurring during the execution of each VCPU thread within a preset time and the average CPU occupancy rate of the VCPU thread. When the frequency of VM Exit of a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server and the CPU occupancy rate of the VCPU thread is greater than the CPU occupancy rate of the average VCPU thread, the VCPU thread is taken as a VCPU thread to be bound;

[0081] A binding module, which is used to bind the VCPUs to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU.

[0082] Preferably, the binding of the VCPUs to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU is specifically as follows:

[0083] Obtain the number of virtual machines containing the VCPU threads to be bound and the number of physical CPUs of the physical server, divide the virtual machines containing the VCPU threads to be bound into N groups, and establish the corresponding relationship between each group of virtual machines and each physical CPU, where N is a positive integer;

[0084] For each physical CPU, perform the following operations: obtain the VCPU threads to be bound in the virtual machine group corresponding to each physical CPU, allocate the VCPU threads to be bound to the target Cores in the physical CPU according to the VM Exit frequency of each VCPU thread to be bound, and establish the binding relationship between the VCPU threads to be bound and the target Cores.

[0085] Preferably, the dividing the virtual machines containing the VCPU threads to be bound into N groups and establishing the corresponding relationship between each group of virtual machines and each physical CPU is specifically as follows:

[0086] If the number of physical CPUs is 1, divide the virtual machines containing the VCPU threads to be bound into one group and establish the corresponding relationship between the virtual machine and the physical CPU;

[0087] If the number of physical CPUs is greater than 1, obtain the CPU utilization rate of the virtual machines containing the VCPU threads to be bound and the utilization rate of each physical CPU, sort them in descending order according to the CPU utilization rate of the virtual machines, and allocate the virtual machines to the physical CPU with the lowest utilization rate in turn, and establish the corresponding relationship between the virtual machines and the physical CPU according to the allocation results.

[0088] Preferably, the binding of the VCPUs to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU is specifically as follows:

[0089] Obtain the CPU resources occupied by the VM process containing the to-be-bound VCPU thread in the physical server, balance the load of the VM process to the physical CPUs according to the CPU resources occupied in the physical server, and establish the corresponding relationship between the physical CPUs and the VM process containing the to-be-bound VCPU thread;

[0090] If the target Core in the physical CPU is a physical Core, bind the VCPU thread to the target Core according to the physical Core and the CPU resource occupancy rate of the to-be-bound VCPU thread; otherwise, bind the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs.

[0091] Preferably, the binding of the VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread, the utilization rate of the logical Core, and the utilization rate of the physical Core to which the logical Core belongs is specifically as follows:

[0092] Calculate the product of the utilization rate of the logical Core and the utilization rate of the physical Core to which the logical Core belongs, use the product as the actual utilization rate of the logical Core, and balance the load of the to-be-bound VCPU thread to the logical Core according to the CPU resource occupancy rate of the to-be-bound VCPU thread and the actual utilization rate.

[0093] Embodiment 3

[0094] The present invention provides a computer-readable storage medium, on which a computer program is stored, and the computer program runs the method as described in Embodiment 1 when executed by a processor.

[0095] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic expressions of the terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0096] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirits of the present invention, and the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A VCPU thread scheduling method in cloud computing, applied in a Hypervisor, characterized in that: The method comprises the following steps: S1: Get all physical CPUs in the physical server and determine whether each physical CPU supports and enables hyperthreading. If so, use the logical core as the target core; otherwise, use the physical core of the physical server as the target core. S2: Count the frequency of VM Exits occurring during the execution of each VCPU thread within a preset time and the average CPU occupancy of the VCPU thread. If the frequency of VM Exits occurring for a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server, and the CPU occupancy of the VCPU thread is greater than the average CPU occupancy of the VCPU thread, the VCPU thread is treated as a VCPU thread to be bound. S3: Bind the VCPU threads to be bound belonging to the same virtual machine to one or more target cores belonging to the same physical CPU; The method of binding the VCPU threads to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU is specifically as follows: S31, obtaining the number of virtual machines containing the VCPU threads to be bound and the number of physical CPUs of the physical server, dividing the virtual machines containing the VCPU threads to be bound into N groups, and establishing a corresponding relationship between each group of virtual machines and each physical CPU, where N is a positive integer; S32, for each physical CPU, performing the following operations: obtaining the VCPU threads to be bound in the virtual machine group corresponding to each physical CPU, allocating the VCPU threads to be bound to the target Cores in the physical CPU according to the VM Exit frequency of each VCPU thread to be bound, and establishing a binding relationship between the VCPU threads to be bound and the target Cores.

2. The method according to claim 1, wherein The virtual machines containing the to-be-bound VCPU threads are divided into N groups, and a corresponding relationship between each group of virtual machines and each physical CPU is established, specifically: If the number of the physical CPU is 1, the virtual machines containing the VCPU threads to be bound are grouped together, and a correspondence between the virtual machines and the physical CPUs is established; If the number of physical CPUs is greater than 1, the CPU utilization of the virtual machine containing the VCPU thread to be bound and the utilization of each physical CPU are obtained, and the virtual machines are sorted in descending order according to their CPU utilization. The virtual machines are allocated to the physical CPU with the lowest utilization in turn, and the corresponding relationship between the virtual machines and the physical CPUs is established based on the allocation results.

3. A VCPU thread scheduling system in cloud computing, wherein the system is located in a hypervisor and is characterized in that: The system includes the following modules: The target core acquisition module is used to obtain all physical CPUs in the physical server and determine whether each physical CPU supports and enables hyperthreading. If so, the logical core is used as the target core; otherwise, the physical core of the physical server is used as the target core; The module for obtaining VCPU threads to be bound is used to count the frequency of VMExit and the average CPU occupancy of each VCPU thread during execution within a preset time. When the frequency of VM Exit of a VCPU thread is greater than the average scheduling frequency of non-VCPU threads in the physical server, and the CPU occupancy of the VCPU thread is greater than the average CPU occupancy of the VCPU thread, the VCPU thread is used as a VCPU thread to be bound. The binding module is used to bind the VCPU threads to be bound belonging to the same virtual machine to one or more target cores belonging to the same physical CPU; The method of binding the VCPU threads to be bound belonging to the same virtual machine to one or more target Cores belonging to the same physical CPU is specifically as follows: obtaining the number of virtual machines containing the VCPU threads to be bound and the number of physical CPUs of the physical server, dividing the virtual machines containing the VCPU threads to be bound into N groups, and establishing a corresponding relationship between each group of virtual machines and each physical CPU, where N is a positive integer; for each physical CPU, performing the following operations: obtaining the VCPU threads to be bound in the virtual machine group corresponding to each physical CPU, allocating the VCPU threads to be bound to the target Cores in the physical CPU according to the VM Exit frequency of each VCPU thread to be bound, and establishing a binding relationship between the VCPU threads to be bound and the target Cores.

4. The system according to claim 3, wherein: The virtual machines containing the to-be-bound VCPU threads are divided into N groups, and a corresponding relationship between each group of virtual machines and each physical CPU is established, specifically: If the number of the physical CPU is 1, the virtual machines containing the VCPU threads to be bound are grouped together, and a correspondence between the virtual machines and the physical CPUs is established; If the number of physical CPUs is greater than 1, the CPU utilization of the virtual machine containing the VCPU thread to be bound and the utilization of each physical CPU are obtained, and the virtual machines are sorted in descending order according to their CPU utilization. The virtual machines are allocated to the physical CPU with the lowest utilization in turn, and the corresponding relationship between the virtual machines and the physical CPUs is established based on the allocation results.

Citation Information

Patent Citations

  • Mapping method between virtual CPUs (Central Processing Unit) and physical CPUs, and electronic equipment

    CN105242954A

  • Resource allocation method and device for virtual machine

    CN112181585A