CN108874534B - Method and device for scheduling PCPU (physical packet Unit) resources - Google Patents

Method and device for scheduling PCPU (physical packet Unit) resources Download PDF

Info

Publication number
CN108874534B
CN108874534B CN201810350475.1A CN201810350475A CN108874534B CN 108874534 B CN108874534 B CN 108874534B CN 201810350475 A CN201810350475 A CN 201810350475A CN 108874534 B CN108874534 B CN 108874534B
Authority
CN
China
Prior art keywords
pcpu
quota
vcpu
cpu
resources
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810350475.1A
Other languages
Chinese (zh)
Other versions
CN108874534A (en
Inventor
卢玥
周坤
余思
龚骏辉
汤晨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201810350475.1A priority Critical patent/CN108874534B/en
Publication of CN108874534A publication Critical patent/CN108874534A/en
Application granted granted Critical
Publication of CN108874534B publication Critical patent/CN108874534B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5077Logical partitioning of resources; Management or configuration of virtualized resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

The application discloses a method for scheduling PCPU resources, which comprises the following steps: monitoring PCPU resources consumed by a plurality of VCPUs of a VM running on a plurality of PCPUs, wherein the VM obtains a cycle quota of the PCPU resources once in a scheduling cycle; and carrying out PCPU resource scheduling according to the PCPU resource state consumed by the VCPU of the VM. By the method, when the VCPUs of the same VM are deployed on a plurality of PCPUs, the PCPU resources actually consumed by the VCPUs included in the VM can be limited within the PCPU resource quota configured for the VM by a user, so that the weight proportion set for the VM by the user is met, the key service can ensure that enough PCPU resources are obtained, and the user experience is improved. In addition, the application also discloses a scheduling device of the PCPU resources.

Description

Method and device for scheduling PCPU (physical packet Unit) resources
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method and an apparatus for scheduling PCPU resources.
Background
In a virtualized environment, a Virtual Machine (VM) may perform a super-division multiplexing on Physical Central Processing Unit (PCPU) resources. In order to avoid PCPU resource competition caused by super-division multiplexing, the key service is ensured to obtain enough PCPU resources, and the PCPU resources can be scheduled to enable each VM in a running state to share the PCPU resources according to the weight proportion configured by a user, so that the execution time of the task of each VM executed by the PCPU is in accordance with the weight proportion configured by the user for each VM. In a VM, the execution time of the PCPU to execute the task of each VM may be represented as the running time of a Virtual Central Processing Unit (VCPU) of the VM on the PCPU.
In a Kernel-based Virtual Machine (KVM) or other scenario, PCPU resource scheduling may be performed for a VCPU runtime of a VM deployed on a PCPU according to a weight of the VM, so that the runtime of the VCPU on the PCPU conforms to the weight. However, in a scenario with multiple PCPUs, since multiple VCPUs of the same VM may be deployed on multiple PCPUs and the PCPUs cannot schedule PCPU resources for VCPUs running on other PCPUs, it is difficult to ensure that the running time of the VCPUs conforms to the weight ratio configured for the VM by the user, which may cause that the critical service cannot obtain sufficient PCPU resources, and affect user experience.
Disclosure of Invention
The technical problem to be solved in the embodiments of the present application is to provide a method and an apparatus for scheduling PCPU resources, so as to implement a situation that a VCPU of a same VM runs on multiple PCPUs, and ensure that a running time of the VM called by a PCPU meets a weight proportion configured for the VM by a user, thereby ensuring that a key service obtains sufficient CPU resources, and improving user experience.
In a first aspect, an embodiment of the present application provides a method for scheduling PCPU resources, including: monitoring PCPU resources consumed by a plurality of VCPUs of a VM running on a plurality of PCPUs, wherein the VM obtains a cycle quota of the PCPU resources once in a scheduling cycle; and carrying out PCPU resource scheduling according to the PCPU resource state consumed by the VCPU of the VM. In the above embodiment of the present application, when the VCPU of the same VM is deployed on multiple PCPUs, the PCPU resource actually consumed by the VCPU included in the VM may be limited within the PCPU resource quota configured for the VM by the user, so as to meet the weight proportion set for the VM by the user, and thus, the key service can ensure that enough PCPU resources are obtained, and the user experience is improved.
In a possible implementation manner of the embodiment of the present application, the performing PCPU resource scheduling according to the PCPU resource state consumed by the VCPU of the VM may include: when the resources of a second PCPU are in an idle state, migrating a target VCPU meeting preset conditions from the first PCPU to the second PCPU; wherein the target VCPU is a VCPU of the VM, and the first PCPU is a PCPU of the plurality of PCPUs. In the implementation manner of the embodiment of the application, the PCPU in the idle state can migrate the VCPUs in other PCPUs to the local operation, so that the idle PCPU resources can be fully utilized, and the problem of unbalanced resource use on different PCPUs is avoided, thereby making the PCPU resources more fully utilized.
In a possible implementation manner of the embodiment of the present application, the preset condition may include: the PCPU resources of the VM remain. In the implementation manner of the embodiment of the application, the PCPU in the idle state selects the VCPU of the VM with the remaining PCPU resource quota from other PCPUs for migration, so that the PCPU resource actually consumed by the VCPU included in the VM can be within the PCPU quota allocated by the VM, and thus the weight proportion set by the user for the VM is met.
In a possible implementation manner of the embodiment of the present application, the preset condition may include: the first VM has exhausted physical CPU resources and obtains an additional quota of physical CPU resources. In the implementation manner of the embodiment of the application, the PCPU in the idle state selects the VCPU of the VM that has obtained the extra quota when the resource quota of the PCPU is exhausted from other PCPUs to migrate, so that the idle PCPU resource can be used by the VCPU of the VM that has exhausted the resource quota of the PCPU, thereby avoiding the problem of unbalanced resource usage on different PCPUs, and enabling the PCPU resource to be more fully utilized.
In a possible implementation manner of the embodiment of the present application, the additional quota and the period quota may be in a preset proportion. In the implementation manner of the embodiment of the application, when the VM is supplemented with the additional quota of the PCPU resource, the additional quota is determined based on the cycle quota, so that the PCPU resource obtained by the VM can meet the weight proportion configured for the VM by the user as much as possible.
In a possible implementation manner of the embodiment of the present application, the preset condition further includes: the first VM obtains PCPU resource quotas in the current scheduling period for the least times; wherein the physical CPU resource quota comprises the cycle quota and/or the extra quota. In the foregoing implementation manner of the embodiment of the application, the PCPU in the idle state selects the VCPU of the VM that supplements the PCPU quota for the minimum number of times from other PCPUs to perform migration, so that the VCPUs of the VMs can be migrated more evenly, and a situation that the VCPUs of some VMs occupy excessive PCPU resources is avoided.
In a second aspect, an embodiment of the present application provides a scheduling apparatus for PCPU resources, including: the monitoring unit is used for monitoring PCPU resources consumed by a plurality of VCPUs of the VM running on a plurality of PCPUs; the VM obtains a period quota of a PCPU resource once in a scheduling period; and the scheduling unit is used for scheduling the PCPU resources according to the PCPU resource quota state consumed by the VCPU of the VM. In the above embodiment of the present application, when the VCPU of the same VM is deployed on multiple PCPUs, the PCPU resource actually consumed by the VCPU included in the VM may be limited within the PCPU resource quota configured for the VM by the user, so as to meet the weight proportion set for the VM by the user, and thus, the key service can ensure that enough PCPU resources are obtained, and the user experience is improved.
In a second aspect of the present application, the constituent elements of the scheduling apparatus of the CPU resource may further execute the steps described in the foregoing first aspect and various possible implementations, for details, see the foregoing description of the first aspect and various possible implementations.
In a third aspect, an embodiment of the present application further provides a computer device, where the computer device includes: a processor, a memory, a communication interface and a bus; the processor, the communication interface and the memory are communicated with each other through the bus; the communication interface is used for receiving and sending data; the memory is to store instructions; the processor is configured to execute the instructions in the memory to perform the method according to any of the implementations of the first aspect. In the above embodiment of the present application, when the VCPU of the same VM is deployed on multiple PCPUs, the PCPU resource actually consumed by the VCPU included in the VM may be limited within the PCPU resource quota configured for the VM by the user, so as to meet the weight proportion set for the VM by the user, and thus, the key service can ensure that enough PCPU resources are obtained, and the user experience is improved.
In a fourth aspect, the present application provides a computer-readable storage medium, which stores instructions that, when executed on a computer, cause the computer to perform the method according to any one of the implementation manners of the first aspect.
In a fifth aspect, the present application provides a computer program product containing instructions, which when executed on a computer, causes the computer to perform the method according to any one of the implementation manners of the first aspect.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments will be briefly introduced below.
FIG. 1 is a block diagram of a computer system framework involved in an application scenario according to an embodiment of the present application;
FIG. 2 is a schematic flowchart illustrating a method for scheduling CPU resources in a physical central processing unit according to an embodiment of the present application;
FIG. 3 is a schematic flowchart illustrating a method for scheduling CPU resources in a physical central processing unit according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a method for scheduling CPU resources of a physical central processing unit according to an embodiment of the present application;
FIG. 5 is a schematic flowchart illustrating a method for scheduling CPU resources in a physical central processing unit according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating a method for scheduling CPU resources of a physical central processing unit according to an embodiment of the present application;
FIG. 7 is a schematic diagram illustrating an example of the migration of a VCPU between PCPUs in an embodiment of the present application;
FIG. 8 is a schematic diagram illustrating an example of supplementing a VM with a runnable time in an embodiment of the present application;
FIG. 9 is a schematic diagram of an example of a VCPU scheduling PCPU resource in an embodiment of the present application;
fig. 10 is a schematic structural diagram of an apparatus 1000 for scheduling CPU resources of a physical central processing unit according to an embodiment of the present application;
fig. 11 is a schematic hardware structure diagram of a computer device in an embodiment of the present application.
Detailed Description
In KVM technology, the PCPU may know the running time of the locally deployed VCPU, so that the CPU resource scheduling can be performed for the locally running VCPU. However, in a scenario of multiple PCPUs, if multiple VCPUs of the same VM are deployed on multiple PCPUs, each PCPU cannot know the running time of the VCPU in which the VM runs on other PCPUs, so that each PCPU cannot perform CPU resource scheduling on the VCPU in which the VM runs on other PCPUs, that is, the PCPU cannot know the called running time of the VM as a whole, and thus the PCPU cannot perform CPU resource scheduling on the VM, which makes it difficult to ensure that the running time of the VM conforms to the weight proportion configured for the VM by the user.
In order to solve the above problem, in the embodiment of the present invention, in the scheduling period, a period quota of the PCPU resource is allocated to the VM according to the CPU resource configuration parameter of the VM. Specifically, the period quota of the PCPU resources may be runnable. The embodiment of the invention takes the cycle quota of the PCPU resource as the operable time as an example for description. The runtime of the VM will be consumed while any of the VCPUs of the VM are running on the PCPU. When the VM's operational time is exhausted, the VM's VCPUs will not be able to run on any one PCPU, and thus, the VM's PCPU resources cannot be scheduled. Therefore, for the same VM, the VCPUs of the VM run on multiple PCPUs, and the total running time of the VCPUs included in the VM, which are actually executed by the PCPUs, can be limited within the available running time allocated to the VM according to the CPU resource configuration parameters of the VM, so as to conform to the CPU resource allocation parameters of the VM, that is, to conform to the weight proportion set for the VM by the user. Therefore, the embodiment of the invention can carry out PCPU resource scheduling on the VM, so that the running time of the VCPU of the VM can accord with the weight proportion configured for the VM by a user, the key service can ensure to obtain enough PCPU resources, and the user experience is improved.
In the embodiment of the present invention, VM 1, VM2, and VM 3 are deployed in the computer system, the scheduling period is 60 seconds, and since PCPU1, PCPU 2, and PCPU3 are included in the computer system, the total running time that the PCPU can provide in the CPU resource allocation period is 180 seconds. The computer system includes PCPU1, PCPU 2, and PCPU3, which may mean that one server in the computer system includes PCPU1, PCPU 2, and PCPU3, or two servers, where one server includes PCPU1 and PCPU 2, another server includes PCPU3, or three servers, and each server includes a PCPU. The user-configured weighting ratios assign the runable times to VM 1, VM2, and VM 3, respectively, 30 seconds, 60 seconds, and 90 seconds, respectively. For any one VM, the runtime of the VM is consumed when any one VCPU of the VM is scheduled to run by a PCPU, and all VCPUs of the VM cannot be scheduled to run by any PCPU when the runtime of the VM is exhausted. Thus, in this scheduling period, the runtime of VM 1, VM2, and VM 3 is limited to 30 seconds, 60 seconds, and 90 seconds, respectively, so that it can conform to the user-configured weight ratio 1: 2: 3.
in one exemplary scenario, embodiments of the present invention may be applied to a computer system as shown in FIG. 1. The computer system includes PCPU101 and PCPU 102. VM 103 is deployed in the computer system, and VCPU 104 and VCPU105 are included in VM 103, where VCPU 104 may be scheduled by PCPU101 to run, and VCPU105 may be scheduled by PCPU102 to execute. A CPU share management unit 106 is also deployed in the computer system, a Complete Fair Scheduler (CFS) 107 is locally deployed in the PCPU101, and a CFS108 is locally deployed in the PCPU 2. The CPU share management unit 106 is configured to record and manage the executable time of the VM 103, the local CFS107 of the PCPU101 is configured to control the VCPU scheduled to be executed by the PCPU101, and the local CFS108 of the PCPU102 is configured to control the VCPU scheduled to be executed by the PCPU 102. In a specific implementation, the CPU share management unit 106, the local CFS107 and the local CFS108 may be located in a kernel of an operating system of the server, or may be software modules independent of the kernel of the operating system, or in another implementation, may be hardware modules, such as a Field Programmable Gate Array (FPGA) or other hardware.
In one scheduling cycle, CPU share management unit 106 may supplement the runtime of VM 103 with a runtime determined based on CPU resource configuration parameters of VM 103. When a VCPU 104 in a VM 103 waits on a PCPU101 to schedule execution, a local CFS107 of the PCPU101 acquires a runnable time of the VM 103 from a CPU share management unit 106 and determines whether the runnable time of the VM 103 has a remainder. When the runnable time of the VM 103 has a remainder, the CFS107 allows the PCPU101 to schedule execution of the VCPU 104, and the runnable time of the VM 103 recorded by the CPU share management unit 106 is updated to deduct the time after the PCPU101 schedules execution of the VCPU 104. When the available runtime of VM 103 is exhausted, CFS107 denies PCPU1 to schedule the execution of VCPU 104.
Various specific implementations of the embodiments of the present invention are described in detail below by way of embodiments with reference to the accompanying drawings.
Fig. 2 is a schematic flowchart of a method for scheduling PCPU resources in an embodiment of the present application, including:
201. monitoring physical CPU resources consumed by a plurality of virtual CPUs of a virtual machine VM running on a plurality of physical CPUs; and the VM obtains the cycle quota of the physical CPU resource once in a scheduling cycle.
In specific implementation, the CPU share management unit may use a timer to replenish the cycle quota of the PCPU resource for the VM in a scheduling cycle. When multiple VCPUs of the VM run on multiple PCPUs, the CPU share management unit may monitor, based on the PCPU resource quotas obtained by the VM, the PCPU resources consumed by the VCPUs running on the multiple PCPUs. When any VCPU of the VM runs on a PCPU, the PCPU resources in the quota of the VM are all consumed.
In this embodiment, the PCPU resource may be specifically represented as a running time of the VCPU scheduled by the PCPU. The resource quota of the PCPU obtained by the VM may be specifically expressed as the available running time supplemented by the VM, and each VCPU of the VM, scheduled by the PCPU, consumes the available running time of the VM. The period quota of PCPU resources obtained by the VM may specifically represent the available runtime that is periodically replenished for the VM, i.e., the available runtime that is replenished for the VM once per scheduling period.
Taking the PCPU resource as the runtime, the CPU share management unit can supplement the VM with the available runtime in one scheduling cycle. When multiple VCPUs of the VM run on multiple PCPUs, the CPU share management unit may monitor the runtime consumed by the VCPUs of the VM when running on the multiple PCPUs, thereby determining a condition in which the runtime of the VM is consumed. Wherein the runtime of the VM is consumed when any one of the VCPUs of the VM is running on a PCPU.
In this embodiment, the period quota of the PCPU resource obtained by the VM may be determined by the CPU resource configuration parameter of the target VM. The CPU resource configuration parameter of the VM may reflect a weight proportion configured for the VM by a user, so that a resource quota obtained by the VM may conform to the weight proportion configured by the user. For example, the CPU resource configuration parameter of the VM may be a QoS (Quality of Service) configuration parameter set for the VM by a user. The QoS configuration parameters may include a weight proportion, an upper limit value, and/or a reserved value of CPU resources occupied by the VM.
In specific implementation, the period quota of the PCPU resources obtained by the VM may be calculated based on the total PCPU resource amount provided by the computer system in a scheduling period and the CPU resource configuration parameter of the VM, where the total PCPU resource amount may be calculated based on the PCPU resource amount provided by the computer system and the PCPU resource amount provided by a single PCPU in a scheduling period.
For example, for a host with 30 PCPUs, 4 VMs are deployed on the host, and the weight ratio configured by the user for each VM is 1: 2: 3: 4. assuming that one scheduling cycle is 100 ms, the total number of PCPU resources provided by the host is 30 × 100 — 3000 ms, and the cycle quotas of the PCPU resources obtained by each VM are 300 ms, 600 ms, 900 ms, and 1200 ms, respectively, that is, the available operating time of each VM can be supplemented by 300 ms, 600 ms, 900 ms, and 1200 ms in one scheduling cycle.
202. And scheduling the physical CPU resource according to the physical CPU resource state consumed by the virtual CPU of the virtual machine VM.
In specific implementation, the PCPU resource status consumed by the VCPU of the VM is monitored based on the PCPU resource quota of the VM, and the PCPU resource status can be used for PCPU resource scheduling for the VCPU of the VM. When any VCPU of the VM runs on a PCPU, the PCPU resources in the VM's quota will be consumed. When the PCPU resources of the VM in the quota are exhausted, the VCPU of the VM cannot run on any PCPU, and thus cannot schedule the PCPU resources of the VM.
In some embodiments, when scheduling the PCPU resources, in order to make the CPU resources more fully utilized, the PCPU may migrate the VCPU waiting to be scheduled on another PCPU to the local under the condition of having idle resources, so that the VCPU may run on the PCPU, and thus the load task on the PCPU with a larger load may be migrated to the PCPU with a smaller load, so that each PCPU may achieve the effect of load balancing. Specifically, step 202 may include: when the resources of the second physical CPU are in an idle state, migrating a target virtual CPU meeting preset conditions from the first physical CPU to the second physical CPU; the target virtual CPU is a virtual CPU of the VM, and the first physical CPU is one of the physical CPUs. In a specific implementation, when no VCPU's running task needs to be scheduled in the second PCPU's running queue, the local CFS of the second PCPU may search the running queues of the VCPUs waiting to be scheduled in the other PCPU's running queues, and determine a VCPU that meets the preset condition from among the VCPUs. When the target VCPU waiting for scheduling on the first PCPU is found to meet the preset condition, the local CFS of the second PCPU can transfer the running task of the target VCPU from the running queue of the first PCPU to the running queue of the second PCPU.
It can be understood that among the VCPUs waiting to run on other PCPUs, the VCPU satisfying the preset condition can be selected to migrate to the PCPU having a free resource.
As an example, in order to enable the PCPU resources occupied by the VM to conform to the weight proportion configured by the user, the VCPU of the VM can be scheduled by the PCPU resources in the case that the PCPU resources in the quota of the VM are left, and the VCPU of the VM cannot be scheduled by the PCPU resources in the case that the PCPU resources in the quota of the VM are exhausted, based on which the preset condition may include: there is a remainder of the VM's physical CPU resources. That is, the target VCPU migrated from the first PCPU to the second PCPU belongs to a VM with the remaining PCPU resources in the quota. In this way, the target VCPU can run on the first PCPU after being migrated onto the first PCPU.
As another example, when the second PCPU has a free resource, sometimes all VCPUs waiting to run on other PCPUs belong to VMs whose resources in the quota are exhausted, at this time, in order to enable the free PCPU resources to be fully utilized, a quota of the PCPU resources may be additionally supplemented for a VM whose resources in the quota are exhausted, so that a quota of the VM which additionally supplements the quota of the PCPU resources has remaining PCPU resources, and the VCPU of the VM may be migrated to the second PCPU to run, that is, the preset condition may include: the VM's physical CPU resources are exhausted and an additional quota of physical CPU resources is obtained. In a specific implementation, when the second PCPU has a free resource, and when all VCPUs waiting to run on other PCPUs belong to VMs whose PCPU resources in the quota are exhausted, one VM may be selected and an additional quota of PCPU resources is supplemented for the VM, so that the PCPU resources in the quota of the VM have a remainder, and a target VCPU of the VM may be migrated from the first PCPU to the second PCPU.
It should be noted that, in the above two examples of the preset conditions, it may happen that the VMs of multiple VCPUs satisfy the preset conditions. For example, where the second PCPU has free resources, the multiple VCPUs waiting to run on the other PCPUs belong to VMs with remaining PCPU resources in the multiple quotas. As another example, in the case where the second PCPU has free resources, all VCPUs waiting to run on other PCPUs belong to VMs with exhausted PCPU resources in multiple quotas. In these cases, in order to select a target VCPU from VCPUs of multiple VMs waiting to run on other PCPUs, in some embodiments, the preset condition may further include: the preset conditions further include: the VM to which the target VCPU belongs obtains the physical CPU resource quota in the current scheduling period for the least times; wherein the physical CPU resource quota comprises the cycle quota and/or the extra quota. In this way, each VM can be migrated to the VCPU more evenly and/or can be replenished with extra credit more evenly, so that each VM can occupy PCPU resources more evenly. In specific implementation, when the second PCPU has an idle resource, when a plurality of VCPUs waiting to run on other PCPUs all belong to VMs having remaining PCPU resources in the quota, the VCPU of the VM that has obtained the lowest number of times of the PCPU resource quota within the scheduling period may be selected as the target VCPU, and the target VCPU is migrated from the first PCPU to the second PCPU. Under the condition that the second PCPU has idle resources, when all VCPUs waiting to run on other PCPUs belong to VMs with exhausted PCPU resources in the quota, the VM with the least number of times of obtaining the PCPU resource quota in the scheduling period can be selected for supplementing the extra quota, the VCPU of the VM with the supplemented extra quota is taken as a target VCPU, and therefore the target VCPU is migrated from the first PCPU to the second PCPU.
It can be understood that, for a VM, the above-mentioned extra quota of PCPU resources is supplemented to the VM on the basis of the period quota of PCPU resources already supplemented to the VM in a scheduling period. In order to enable the PCPU resource occupied by the VM to be close to the weight proportion configured by the user as much as possible, in some embodiments, an extra quota for the same VM may be in a preset proportion with a period quota, that is, the extra quota may be determined by the period quota and the preset proportion. The preset ratio may represent a ratio between the extra quota of each VM and the cycle quota, that is, in one scheduling cycle, the extra quota of each VM and the cycle quota of each VM are in the same ratio. For example, in the case that the preset ratio is 5%, if the period quota of VM 1 is 900 msec of available time and the period quota of VM2 is 500 msec of available time, the additional quota of VM 1 is 45 msec of available time, and the additional quota of VM2 is 25 msec of available time, that is, the ratio between the additional quota of VM 1 and the period quota and the ratio between the additional quota of VM2 and the period quota both conform to the same preset ratio.
In this embodiment, when the VCPU of the same VM is deployed on multiple PCPUs, the PCPU resources actually consumed by the VCPU included in the VM may be limited within the PCPU resource quota configured by the user for the VM, so as to meet the weight ratio set by the user for the VM, and thus, the key service can ensure that sufficient PCPU resources are obtained, and the user experience is improved.
Fig. 3 is a flowchart illustrating a method for scheduling PCPU resources in an embodiment of the present invention, including:
301. supplementing a first running time for a target VM in a scheduling period; wherein the first runtime is determined by a CPU resource configuration parameter of the target VM.
In this embodiment, the target VM may be any one of the VMs in the computer system.
In particular implementations, the CPU share management unit 105 supplements the target VM with a first runtime during a scheduling cycle using a timer.
For example, when the first runtime is 300 ms, the runtime of the target VM after the replenishment is 300 ms.
It will be appreciated that the first runtime represents a runable time that is replenished for the target VM once per scheduling cycle, which may be determined by the CPU resource configuration parameters of the target VM. The CPU resource configuration parameters of the target VM may reflect a weight ratio configured by the user for the target VM, so that the available runtime obtained by the target VM may conform to the weight ratio configured by the user. For example, the CPU resource configuration parameter of the target VM may be a Quality of Service (QoS) configuration parameter set by the user for the target VM. The QoS configuration parameters may include a weight proportion, an upper limit value, and/or a reserved value of the PCPU resource occupied by the target VM.
In a specific implementation, the first runtime may be calculated based on the total number of PCPU resources provided by the computer system in the scheduling period and the CPU resource configuration parameter of the target VM, where the total number of PCPU resources may be calculated based on the number of PCPU resources provided by the computer system and the number of PCPU resources provided by a single PCPU in the scheduling period.
For example, for a host with 30 PCPUs, 4 VMs are deployed on the host, and the weight ratio configured by the user for each VM is 1: 2: 3: 4. assuming that the scheduling period is 100 ms, the total number of PCPU resources provided by the host is 30 × 100 — 3000 ms, and the first runtime for each VM is 300 ms, 600 ms, 900 ms, and 1200 ms, respectively, that is, the runtime of each VM can be supplemented with 300 ms, 600 ms, 900 ms, and 1200 ms in one scheduling period.
302. And if the target VCPU in the target VM waits to run on the first PCPU, judging whether the runnable time of the target VM has the residue.
In this embodiment, the target VCPU may represent any one of the VCPUs included in the target VM.
In specific implementation, when the running task of the target VCPU can be added to the running Queue (Run Queue) of the first PCPU, the target VCPU is in a state of waiting to Run on the first PCPU. When the local CFS of the first PCPU reads the running task of the target VCPU from the running queue of the first PCPU, the local CFS of the first PCPU may read the runnable time of the target VCPU recorded in the CPU share management unit, so that it may be determined whether the runnable time of the target VM has a remainder.
303. If the target VM has a residual runtime, allowing the target VCPU to run on the first PCPU, and deducting the time of the target VCPU running on the first PCPU in the target VM's runtime.
In this embodiment, the first PCPU may represent any one PCPU in the computer system.
In a specific implementation, after the local CFS of the first PCPU reads the runtime of the target VM, if the read runtime is greater than 0, the runtime of the target VM has a remainder, and at this time, the local CFS of the first PCPU may allow the first PCPU to run the target VCPU. During the running of the target VCPU by the first PCPU, the local CFS of the first PCPU records the running time of the target VCPU on the first PCPU and provides the recorded running time to the CPU share management unit, so that the CPU share management unit can deduct the running time of the target VCPU on the first PCPU from the runnable time of the target VM.
For example, assuming that the local CFS of the first PCPU reads a runtime of 50 milliseconds to the target VM, after which the target VCPU is run by the first PCPU for 10 milliseconds, the runtime of the target VM is modified to 40 milliseconds.
304. If the target VM's uptime does not have a remainder, denying the target VCPU to run on the first PCPU.
In a specific implementation, after the local CFS of the first PCPU reads the runtime of the target VM, if the read runtime is 0, the runtime of the target VM does not have a remainder, and at this time, the local CFS of the first PCPU may run the target VCPU on the first PCPU.
It is understood that for a target VM, any VCPU included in the target VM is consumed by any PCPU when the target VM is run at runtime. If the runtime of the target VM is consumed to the point where no more is left, then none of the PCPUs will run any of the VCPUs included in the target VM. Thus, the runtime of the target VM occupying the PCPU resource may be limited to a runable time determined according to the configuration parameters provided by the user for the target VM, thereby conforming to the weight proportion configured by the user for the target VM.
In this embodiment, in order to make the CPU resources fully used, the PCPU may run any one of the VCPUs deployed in the computer system.
As an example, a PCPU may schedule execution of a VCPU deployed locally to the PCPU. Specifically, in this embodiment, the target VCPU may be a VCPU deployed locally to the first PCPU. In this case, when the target VCPU requests scheduling of PCPU resources, the target VCPU's run task appears in the first PCPU's run queue. When the local CFS of the first PCPU reads the running task of the target VCPU from the running queue of the first PCPU, the local CFS of the first PCPU may control whether the first PCPU runs the target VCPU according to the foregoing 302 to 304.
As another example, in order to make the PCPU resources more fully utilized, the PCPU may migrate the VCPU, which is deployed on another PCPU and waits to run, to its local location in an idle state, and then run the VCPU migrated to the local location, so that the load task on the PCPU with a larger load may be migrated to the PCPU with a smaller load, and each PCPU may achieve the effect of load balancing. Specifically to this embodiment, the target VCPU may be a VCPU deployed at the second PCPU and migrated from the second PCPU to the first PCPU. In this case, as shown in fig. 4, the present embodiment may further include, before 302:
401. if the first PCPU does not have a VCPU waiting to run, searching VCPUs meeting the migration condition in VCPUs waiting to run on other PCPUs; the migration conditions include: the runnable time of the VM to which the VCPU belongs has a remainder.
In a specific implementation, when no VCPU's running task needs to run in the first PCPU's running queue, the local CFS of the first PCPU may search for a running task of a VCPU waiting to run in the other PCPU's running queue, and determine, from the VCPUs, a VCPU that satisfies the migration condition for use in migration.
402. And if the target VCPU is found to wait for running on a second PCPU and the migration condition is met, migrating the target VCPU from the second PCPU to the first PCPU so that the target VCPU runs on the first PCPU.
In a specific implementation, when the local CFS of the first PCPU finds the running task of the target VCPU in the running queue of the second PCPU and determines that the target VCPU meets the migration condition, the local CFS of the first PCPU may migrate the running task of the target VCPU from the running queue of the second PCPU to the running queue of the first PCPU, so that the target VCPU runs on the first PCPU. It can be understood that, since there is no VCPU waiting to run on the first PCPU, after the target VCPU is migrated from the second PCPU to the first PCPU, the first PCPU may run the target VCPU, so that the target VCPU does not need to wait for the second PCPU to run, and as a result, the VCPU waiting to run on the PCPU with a larger load may be migrated to the PCPU that is idle originally to be scheduled and executed, so that the PCPU resources may be used more fully.
It should be noted that the VCPU to be searched in 401, i.e., the target VCPU mentioned in 402, is used to migrate from other PCPUs to the first PCPU. For this reason, the VCPU needs to satisfy the migration condition. In this embodiment, in order to enable the runtime of each VM occupying the PCPU resource to conform to the weight ratio configured by the user, for any VM, the VCPU of the VM can schedule the PCPU resource to be executed by the PCPU if the runtime of the VM has a remainder, and the VCPU of the VM cannot schedule the PCPU resource to be executed by the PCPU if the runtime of the VM has no remainder. Thus, the migration condition may include that the runnable time of the VM to which the VCPU belongs has a remainder. That is, the VCPU that the first PCPU is looking for in 401, i.e., the target VCPU mentioned in 402, satisfies at least two conditions. Wherein one condition is that the VCPU waits to run on a PCPU other than the first PCPU; another condition is that the VM to which the VPCU belongs has a remaining uptime.
Taking an exemplary scenario as an example, there are no VCPUs waiting to run on PCPU1, PCPU 2 is running VCPU1, and VCPU2 and VCPU 3 wait to run on PCPU 2. If VCPU2 belongs to VM 1 and VCPU 3 belongs to VM2, and VM 1 currently has the remaining operable time and VM2 currently does not have the remaining operable time, VCPU2 can be found by searching VCPUs satisfying the migration condition among VCPUs waiting to be operated on other PCPUs, so that VCPU2 can be migrated from PCPU 2 to PCPU1, so that PCPU1 operates VCPU 2.
It will be appreciated that in some cases, VCPUs that satisfy the migration condition are not found among VCPUs waiting to run on other PCPUs, via 401. For example, all VCPUs waiting to run on other PCPUs belong to VMs that do not have a remaining runnable time, i.e., do not satisfy the migration condition. In these cases, VCPUs waiting to run from other PCPUs cannot be migrated to the first PCPU in the idle state. In order to avoid that the first PCPU is idle and thus the PCPU resources can be more fully utilized, a possible implementation is that for a VM with no remaining runtime, the VM is supplemented with the runtime again in the same scheduling cycle, so that after the VM has the remaining runtime after the supplementation, the VCPU in the VM satisfies the migration condition, and the VCPU in the VM can be migrated to the first PCPU in the idle state to run while waiting for the runtime on the other PCPUs. In particular to the present embodiment, the target VM may be supplemented with a single uptime without a remaining uptime before the target VCPU is migrated from the second PCPU to the first PCPU. In this case, as shown in fig. 5, the present embodiment may further include, after 401:
501. if the VCPUs meeting the migration condition in the VCPUs waiting to run on other PCPUs cannot be searched, searching the VMs meeting the supplement condition; the supplementary conditions include: the runnable time of the VM has no remainder.
In a specific implementation, when the local CFS of the first PCPU finds no VCPU that satisfies the migration condition in the run queues of other PCPUs, the CPU share management unit may find a VM that satisfies the supplementation condition, so as to supplement the runnable time for the VM.
502. If the target VM is found to meet the supplement condition, supplementing a second operation time in the operable time of the target VM; the second runtime is determined by the first runtime.
In a specific implementation, when the CPU share management unit finds that the target VM meets the replenishment condition, the CPU allocation management unit may replenish the target VM with the operable time once again in the scheduling period. After supplementing the target VM with the runnable time in 502, the execution may return to 401, so that, after the target VM is supplemented with the runnable time, if a VCPU in the target VM waits to run on another PCPU, the VCPU may be migrated from the another PCPU to the first PCPU, so that the first PCPU runs the VCPU, thereby avoiding the first PCPU from being in an idle state for a long time.
It is appreciated that 502 supplements the target VM's runtime with a second runtime after the target VM's runtime has been supplemented with the first runtime in the same scheduling cycle. In some embodiments, the second operation time may be determined by the first operation time and a preset ratio. The preset ratio may represent a ratio between the second runtime and the first runtime of each VM, that is, the second runtime of each VM is in the same ratio with the first runtime of each VM in the same scheduling period. For example, in the case of the predetermined ratio of 5%, if the first runtime of VM 1 is 900 milliseconds and the first runtime of VM2 is 500 milliseconds, the second runtime of VM 1 is 45 milliseconds, and the second runtime of VM2 is 25 milliseconds, that is, the ratio between the second runtime and the first runtime of VM 1 and the ratio between the second runtime and the first runtime of VM2 both correspond to the same predetermined ratio. The first running time mentioned in this embodiment may correspond to the period quota mentioned in the foregoing embodiment, and the second running time mentioned in this embodiment may correspond to the additional quota mentioned in the foregoing embodiment.
It will be appreciated that the VM sought in 501, the target VM referenced in 502, is used to supplement the runnable time again when the first PCPU is in an idle state and there are no VCPUs on other PCPUs that can migrate to the first PCPU. Under the condition that the first PCPU is in the idle state, if all VCPUs waiting to run on other PCPUs do not have the remaining runnable time and cannot be migrated to the first PCPU because the VM to which the VCPU belongs does not have the remaining runnable time, the CPU share management unit may select the VM which does not currently have the remaining runnable time and supplement the VM with the runnable time once again in the scheduling period, so that the VCPU in the target VM can satisfy the migration condition, so that the VCPU in the target VM can be migrated to the first PCPU when waiting to run on other VCPUs, and thus the first PCPU can be prevented from being in the idle state for a long time, and thus PCPU resources can be more fully utilized. Thus, the supplemental conditions mentioned in 501 may include that the runnable time of the VM has no residuals.
Taking an exemplary scenario as an example, there are no VCPUs waiting to run on PCPU1, PCPU 2 is running VCPU1, and VCPU2 waits to run on PCPU 2. If VCPU2 belongs to VM 1 and VM 1 does not currently have any remaining available time, the available time of VM 1 may be supplemented if VCPU that meets the migration condition is not found, and VCPU2 meets the migration condition after the supplementation, so that VCPU2 may be migrated from PCPU 2 to PCPU1, so that PCPU1 operates VCPU 2.
In many cases, there are multiple VMs that do not have a remaining runnable time, in the case where there are no VCPUs found that satisfy the migration condition among the VCPUs waiting to run on other PCPUs. In this case, in order to enable more balanced occupation of PCPU resources by each VM, a possible implementation manner is that the supplementary conditions specifically include: the runnable time of the VM has no remainder and the VM supplements the runnable time a minimum number of times within the scheduling period. That is, the VM to be looked up in 501, i.e., the target VM mentioned in 502, satisfies at least two conditions. Wherein one condition is that the VM has no remaining runable time; the other condition is that the VM has the least supplement times of the runnable time in the scheduling period among all VMs meeting the first two conditions.
Taking an exemplary scenario as an example, there are no VCPUs waiting to run on PCPU1, PCPU 2 is running VCPU1, and VCPU2, VCPU 3, and VCPU 4 are waiting to run on PCPU 2. If VCPU2 belongs to VM 1, VCPU 3 belongs to VM2 and VCPU 4 belongs to VM 3, neither VM 1 nor VM2 currently has the remaining operable time but VM 3 does not currently have the remaining operable time, the operable time of VM 1 has been supplemented twice in the current scheduling cycle, and the operable time of VM2 has been supplemented once in the current scheduling cycle, the operable time of VM2 can be supplemented under the condition that the VCPU meeting the migration condition cannot be found, and the VCPU 3 meets the migration condition after the supplementation, so that the VCPU 3 can be migrated from PCPU 2 to PCPU1, and the PCPU1 can operate the VCPU 3.
It will be appreciated that in order for the CPU share management unit to be able to find the VM with the least number of times that it can supplement the uptime in the scheduling cycle, the CPU share management unit may record, for each VM, the number of times that it can supplement the uptime in the scheduling cycle. For the target VM, in the current scheduling period, the CPU share management unit correspondingly increases the times of supplementing the operable time for the target VM in the current scheduling period when supplementing the operable time for the target VM each time. When the current scheduling cycle is changed to the next scheduling cycle, the CPU share management unit may clear the number of times that each VM supplements the runnable time in the current scheduling cycle, so as to record the number of times that each VM supplements the runnable time in the next scheduling cycle again.
In some embodiments, the number of times that the VM supplements the runnable time in the scheduling period may be used for the migration condition mentioned in 401, in addition to the supplementary condition mentioned in 502, that is, may be used for searching for VCPUs that can be migrated to the first PCPU. In many cases, there are VCPUs on other PCPUs that are waiting to run where VMs to which multiple VCPUs belong have remaining runnable time. In this case, in order to enable the occupation of PCPU resources by each VM to be more balanced, one possible implementation manner is that the migration condition may specifically include: the runnable time of the VM to which the VCPU belongs has a surplus, and the number of times the VM to which the VCPU belongs supplements the runnable time in the scheduling period is the least. That is, the VCPU that the first PCPU is looking for in 401, i.e., the target VCPU mentioned in 402, satisfies at least three conditions. Wherein one condition is that the VCPU waits to run on other PCPUs; another condition is that the VM to which the VCPU belongs has a remaining runnable time; yet another condition is that of all VCPUs satisfying the first two conditions, the VM to which the VCPU belongs has the least number of times to supplement the available runtime in the current scheduling period.
Taking an exemplary scenario as an example, there are no VCPUs waiting for cloud tops on PCPU1, PCPU 2 is running VCPU1, and VCPU2, VCPU 3, and VCPU 4 are waiting to run on PCPU 2. If VCPU2 belongs to VM 1, VCPU 3 belongs to VM2, and VCPU 4 belongs to VM 3, both VM 1 and VM2 currently have remaining operable time and VM 3 currently does not have remaining operable time, VCPU in VM 1 has been supplemented with operable time twice in this scheduling period, and VCPU in VM2 has been supplemented with operable time once in this scheduling period, PCPU1 can find VCPU 3 by searching VCPU satisfying the migration condition among VCPUs waiting to operate on other PCPUs, so that VCPU 3 can be migrated from PCPU 2 to PCPU1, so that PCPU1 operates VCPU 3.
In this embodiment, in the scheduling period, the VM is supplemented with the runnable time according to the CPU resource configuration parameters of the VM. The runtime of a VM will be consumed while any VCPU of the VM is running on a PCPU. When the VM's operational time is exhausted, the VM's VCPUs will not be able to run on any one PCPU, and thus, the VM's PCPU resources cannot be scheduled. Therefore, for the same VM, when the VCPU of the VM runs on multiple PCPUs, the total running time of the VCPU of the VM actually run by the PCPU can be limited within the available running time allocated to the VM according to the CPU resource configuration parameters of the VM, so as to conform to the CPU resource allocation parameters of the VM, that is, to conform to the weight proportion set for the VM by the user. Therefore, the embodiment can perform PCPU resource scheduling on the VM, so that the running time of the VCPU of the VM on the PCPU can meet the weight proportion configured for the VM by the user, and thus the key service can ensure that enough PCPU resources are obtained, and the user experience is improved.
In order to make it easier for those skilled in the art to understand the implementation manner of the embodiments of the present application in a specific application, a scenario is taken as an example to describe the implementation manner of the embodiments of the present application. In this exemplary scenario, the host includes PCPU1, PCPU 2, PCPU3 and VM 1, VM2, VM 3, VM 4, VM 1 includes VCPU 11 and VCPU 12, VM2 includes VCPU21 and VCPU 22, VM 3 includes VCPU 31 and VCPU 32, and VM 4 includes VCPU 41 and VCPU 42.
Fig. 6 is a flowchart illustrating a method for scheduling PCPU resources in an embodiment of the present application. In this embodiment, the method may include, for example:
601. the CPU share management unit supplements the first runtime of each VM once in the available runtime of each VM in each scheduling cycle using a timer.
Wherein the CPU share management unit may implement the transition of the scheduling period by using a timer. The timer can send a prompt to the CPU share management unit once every other scheduling period, where the time is the ending time of the previous scheduling period and the starting time of the next scheduling period. That is, at the start of each scheduling cycle, the CPU share management unit may supplement the runnable time of each VM once with the first runtime of each VM.
The first running time of each VM may be determined according to the proportional weight configured by the user for each VM and the duration of the scheduling period. Assume that the proportional weight configured by the user for each VM is VM 1: VM 2: VM 3: VM 4 ═ 1: 2: 3: 4, the duration of the scheduling cycle is 1000 ms, the total number of PCPU resources provided by PCPU1, PCPU 2, and PCPU3 on the host in one scheduling cycle is 3000 ms, the first runtime of VM 1 is 300 ms, the first runtime of VM2 is 600 ms, the first runtime of VM 3 is 900 ms, and the first runtime of VM 4 is 1200 ms.
602. The local CFS of the PCPU determines whether there is a VCPU waiting to run in the run queue of the PCPU, if not, then 603 is entered, and if yes, then 606 is entered.
During specific implementation, the PCPU1, the PCPU 2, and the PCPU3 may respectively determine whether each running queue has a VCPU waiting to run, that is, determine whether each running queue is empty.
603. And the local CFS of the PCPU searches the VCPUs meeting the migration condition in the running queues of other PCPUs, if the VCPUs are found, the step is carried out 604, and if the VCPUs are not found, the step is carried out, and the step is carried out, the step is carried out 605.
In a specific implementation, for any one PCPU of PCPU1, PCPU 2, and PCPU3, when the run queue of the PCPU is empty, the local CFS of the PCPU may search whether a currently migratable VCPU exists in the run queues of other PCPUs. Wherein a currently migratable VCPU indicates that the VM to which the VCPU belongs currently has a remaining runnable time. If the currently migratable VCPU exists, the local CFS of the PCPU may determine, from the found currently migratable VCPU, a VCPU that satisfies the migration condition. The VCPU satisfying the migration condition indicates that, among all currently migratable VCPUs, the VM to which the VCPU belongs supplements the runnable time in the current scheduling period for the minimum number of times.
604. The local CFS of the PCPU migrates the found VCPU from the run queues of other PCPUs to the run queue of the PCPU, and then returns to execute 602.
Taking the case shown in fig. 7 as an example, the run queue of PCPU1 is empty, the VCPU waiting to run in the run queue of PCPU 2 includes VCPU 11, VCPU21, and VCPU 31, and the VCPU waiting to run in the run queue of PCPU3 includes VCPU 12 and VCPU 22, where the VMs to which VCPU21, VCPU 31, and VCPU 22 belong all have remaining runnable times, the VMs to which VCPU21 and VCPU 22 belong are all supplemented with 3 runnable times in the current scheduling period, and the VM to which VCPU 31 belongs is supplemented with 2 runnable times in the current scheduling period. At this time, the local CFS of the PCPU1 may find the VCPU 31 by searching the VCPU that satisfies the migration condition from the run queues of the PCPU 2 and the PCPU3, so that the VCPU 31 is migrated from the run queue of the PCPU 2 to the run queue of the PCPU1, and thus the PCPU1 may run the VCPU 31.
605. The CPU share management unit searches for a VM satisfying the replenishment condition and replenishes the second runtime of the found VM in the runtime of the found VM, and then returns to 602.
In a specific implementation, the CPU share management unit may search the VMs that can currently supplement the runtime. Wherein a VM is currently replenishable with runtime that does not currently have remaining runtime available. If the VM at the current replenishable time exists, the CPU share management unit may determine, from the searched VMs at the current replenishable runtime, a VM that satisfies the replenishment condition. The VM meeting the supplementation condition indicates that, among all VMs capable of supplementing the current runtime, the VM supplements the available runtime in the current scheduling period for the minimum number of times.
Wherein the second runtime of each VM may be determined according to the first runtime of each VM and the fixed supplement ratio. Assuming that the first runtime of VM 1 is 300 msec, the first runtime of VM2 is 600 msec, the first runtime of VM 3 is 900 msec, the first runtime of VM 4 is 1200 msec, and the fixed replenishment ratio is 5%, the second runtime of VM 1 is 15 msec, the second runtime of VM2 is 30 msec, the second runtime of VM 3 is 45 msec, and the second runtime of VM 4 is 60 msec.
Taking the case shown in fig. 8 as an example, the operation queue of PCPU 2 is empty, no migratable VCPU exists in the operation queues of PCPU1 and PCPU3, and neither VM 1 nor VM 4 has a remaining operable time, where VM 1 is supplemented with 3 operable times in the current scheduling cycle, and VM 4 is supplemented with 2 operable times in the current scheduling cycle. At this time, the CPU share managing unit may find the VM 4 by looking up the VM satisfying the supplement condition, thereby supplementing the second runtime of the VM 4 in the runtime of the VM 4, so that the runtime of the VM 4 has a remainder, and the VCPU 41 in the VM 4 may be added to the running queue of the PCPU 2 to be run by the PCPU 2.
606. The local CFS of the PCPU selects a VCPU waiting to run from the run queue of the PCPU, determines whether the VM to which the VCPU belongs has a remaining available run time, if so, enters 607, and if not, enters 608.
Taking the situation shown in fig. 9 as an example, VCPU 11 in the run queue of PCPU1 is waiting to run, VCPU 22 in the run queue of PCPU 2 is waiting to run, and VCPU 41 in the run queue of PCPU3 is waiting to run. At this time, the PCPU1 may select the VCPU 11, and determine whether the VM 1 to which the VCPU 11 belongs has the remaining available running time. PCPU 2 may select VCPU 22 to determine whether VM2 to which VCPU 22 belongs has remaining up time. The PCPU3 may select the VCPU 41 and determine whether the VM 4 to which the VCPU 41 belongs has a remaining available runtime.
607. The local CFS of a PCPU allows the PCPU to run the VCPU and deducts the time that the VCPU is run from the uptime of the VM to which the VCPU belongs.
608. The PCPU's local CFS denies the PCPU to run the VCPU.
In this embodiment, not only can the PCPU resource scheduling be performed for the VM, but also the running time of the VCPU of the VM, which is run by the PCPU, can conform to the weight proportion configured for the VM by the user, and the PCPU resource can be prevented from being idle as much as possible, so that the PCPU resource can be more fully utilized.
Fig. 10 is a schematic structural diagram of an apparatus for scheduling CPU resources of a physical central processing unit according to an embodiment of the present application. The apparatus 1000 may include:
a monitoring unit 1001 configured to monitor physical CPU resources consumed by a plurality of virtual CPUs of a virtual machine VM running on the plurality of physical CPUs; the VM obtains a cycle quota of a physical CPU resource once in a scheduling cycle;
the scheduling unit 1002 is configured to perform physical CPU resource scheduling according to a physical CPU resource state consumed by the virtual CPU of the virtual machine VM.
In some embodiments, the scheduling unit is specifically configured to: when the resources of the second physical CPU are in an idle state, migrating a target virtual CPU meeting preset conditions from the first physical CPU to the second physical CPU; the target virtual CPU is a virtual CPU of the VM, and the first physical CPU is one of the physical CPUs.
In some embodiments, the preset conditions include: there is a remainder of the VM's physical CPU resources.
In some embodiments, the preset conditions include: the VM's physical CPU resources are exhausted and an additional quota of physical CPU resources is obtained.
In some embodiments, the additional quota is a preset ratio to the cycle quota.
In some embodiments, the preset conditions further include: the VM obtains the physical CPU resource quota in the current scheduling period for the least times; wherein the physical CPU resource quota comprises the cycle quota and/or the extra quota.
In this embodiment, when the VCPU of the same VM is deployed on multiple PCPUs, the PCPU resources actually consumed by the VCPU included in the VM may be limited within the PCPU resource quota configured by the user for the VM, so as to meet the weight ratio set by the user for the VM, and thus, the key service can ensure that sufficient PCPU resources are obtained, and the user experience is improved.
It should be noted that, because the contents of information interaction, execution process, and the like between the modules/units of the apparatus are based on the same concept as the method embodiment of the present application, the technical effect brought by the contents is the same as the method embodiment of the present application, and specific contents may refer to the description in the foregoing method embodiment of the present application, and are not described herein again.
Next, a computer device provided in an embodiment of the present application is introduced, where the computer device includes: a processor, a memory, a communication interface and a bus; the processor, the communication interface and the memory are communicated with each other through the bus; the communication interface is used for receiving and sending data; the memory is to store instructions; the processor is used for executing the instructions in the memory and executing the scheduling method of the CPU resources of the physical central processing unit.
Referring to fig. 11, the computer device 1100 includes: a receiver 1101, a transmitter 1102, a processor 1103 and a memory 1104 (wherein the number of processors 1103 in the computer device 1100 may be one or more, for example one processor in fig. 11). The communication interface may include a receiver 1101, a transmitter 1102, among others. In some embodiments of the present application, the receiver 1101, the transmitter 1102, the processor 1103 and the memory 1104 may be connected by a bus or other means, wherein fig. 11 illustrates the connection by a bus. In another implementation, the communication Interface may also be a Network Interface Card (NIC) or the like.
The memory 1104, which may include both read-only memory and random-access memory, provides instructions and data to the processor 1103. A portion of Memory 1104 may also include Non-Volatile Random Access Memory (NVRAM). The memory 1104 stores an operating system and operating instructions, executable modules or data structures, or a subset or an expanded set thereof, wherein the operating instructions may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various basic services and for handling hardware-based tasks.
The processor 1103 controls the operation of the network device 1100, and the processor 1103 may also be referred to as a Central Processing Unit (CPU). In a particular application, the various components are coupled together by a bus system that may include a power bus, a control bus, a status signal bus, etc., in addition to a data bus. For clarity of illustration, the various buses are referred to in the figures as a bus system.
The method disclosed in the embodiments of the present application can be applied to the processor 1103 or implemented by the processor 1103. The processor 1103 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in software form in the processor 1103. The processor 1103 may be a hardware such as a general-purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), and so on. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 1104, and the processor 1103 reads the information in the memory 1104 and completes the steps of the method in combination with the hardware.
The receiver 1101 may be configured to receive input numeric or character information and generate signal inputs related to related settings and function control of the network device 1100, the transmitter 1102 may include a display device such as a display screen, and the transmitter 1102 may be configured to output numeric or character information through an external interface.
In this embodiment, the processor 1103 is configured to execute the foregoing scheduling method for CPU resources of the physical central processing unit.
In this embodiment, when the VCPU of the same VM is deployed on multiple PCPUs, the PCPU resources actually consumed by the VCPU included in the VM may be limited within the PCPU resource quota configured by the user for the VM, so as to meet the weight ratio set by the user for the VM, and thus, the key service can ensure that sufficient PCPU resources are obtained, and the user experience is improved.
In addition, an embodiment of the present application provides a computer-readable storage medium, which stores instructions that, when executed on a computer, cause the computer to execute the foregoing scheduling method for CPU resources of a physical central processing unit.
Furthermore, the present application provides a computer program product containing instructions, which when run on a computer, causes the computer to execute the foregoing scheduling method for CPU resources of a physical central processing unit.
In the embodiments of the present application, the "first" in the names of "first PCPU", "first runtime", and the like is used for name identification only, and does not represent the first in sequence. The same applies to "second" etc.
It is clear to those skilled in the art that all or part of the steps in the method of the above embodiments can be implemented by software plus a general hardware platform. The technical solution in the embodiments of the present invention may be embodied in the form of a software product, where the computer software product may be stored in a storage medium, such as a read-only memory (ROM)/RAM, a magnetic disk, an optical disk, and the like, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the method in each embodiment or some parts of the embodiments of the present application.
The same and similar parts in the various embodiments in this specification may be referred to each other. In particular, apparatus embodiments, device embodiments, media embodiments, and computer program product embodiments are described in relative terms that are substantially similar to method embodiments, as may be found in some descriptions of method embodiments. The above-described apparatus embodiments and device embodiments are only illustrative, wherein modules described as separate parts may or may not be physically separate, and parts shown as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.

Claims (6)

1. A method for scheduling physical CPU resources, comprising:
monitoring physical CPU resources consumed by a plurality of virtual CPUs of the same virtual machine VM running on a plurality of physical CPUs; the virtual machine VM obtains a cycle quota of a physical CPU resource in a scheduling cycle;
according to the physical CPU resource state consumed by the virtual CPU of the virtual machine VM, the physical CPU resource scheduling is carried out, when the resources of the second physical CPU are in an idle state, the physical CPU resources of the virtual machine VM are exhausted and an extra quota of the physical CPU resources is obtained, the target virtual CPU meeting the preset condition is migrated from the first physical CPU to the second physical CPU, wherein the preset condition includes that the number of times that the virtual machine VM obtains the physical CPU resource quota in the current scheduling period is minimum, the target virtual CPU is a virtual CPU of the virtual machine VM, the first physical CPU is a physical CPU of the plurality of physical CPUs, a preset ratio is formed between an additional quota of the same virtual machine VM and the period quota, and in a scheduling period, the extra quota of each virtual machine VM is in the same proportion with the period quota of the virtual machine VM.
2. The method of claim 1,
wherein the physical CPU resource quota comprises the cycle quota and/or the extra quota.
3. An apparatus for scheduling physical CPU resources, comprising:
the monitoring unit is used for monitoring physical CPU resources consumed by a plurality of virtual CPUs of the same virtual machine VM running on a plurality of physical CPUs; the virtual machine VM obtains a cycle quota of a physical CPU resource in a scheduling cycle;
a scheduling unit for performing physical CPU resource scheduling according to the physical CPU resource status consumed by the virtual CPU of the virtual machine VM, when the resources of the second physical CPU are in an idle state, the physical CPU resources of the virtual machine VM are exhausted and an extra quota of the physical CPU resources is obtained, the target virtual CPU meeting the preset condition is migrated from the first physical CPU to the second physical CPU, wherein the preset condition further includes that the number of times that the virtual machine VM obtains the physical CPU resource quota in the current scheduling period is minimum, the target virtual CPU is a virtual CPU of the virtual machine VM, the first physical CPU is a physical CPU of the plurality of physical CPUs, an extra quota of the same virtual machine VM is in a preset proportion with the cycle quota, and in a scheduling period, the extra quota of each virtual machine VM is in the same proportion with the period quota of the virtual machine VM.
4. The apparatus of claim 3, wherein the quota of physical CPU resources comprises the cycle quota and/or the additional quota.
5. A computer system comprising a plurality of physical CPUs in communication between the plurality of physical CPUs, wherein at least one physical CPU performs the following:
monitoring physical CPU resources consumed by a plurality of virtual CPUs of the same virtual machine VM running on a plurality of physical CPUs; the virtual machine VM obtains a cycle quota of a physical CPU resource in a scheduling cycle;
according to the physical CPU resource state consumed by the virtual CPU of the virtual machine VM, the physical CPU resource scheduling is carried out, when the resources of the second physical CPU are in an idle state, the physical CPU resources of the virtual machine VM are exhausted and an extra quota of the physical CPU resources is obtained, the target virtual CPU meeting the preset condition is migrated from the first physical CPU to the second physical CPU, wherein the preset condition further includes that the number of times that the virtual machine VM obtains the physical CPU resource quota in the current scheduling period is minimum, the target virtual CPU is a virtual CPU of the virtual machine VM, the first physical CPU is a physical CPU of the plurality of physical CPUs, an extra quota of the same virtual machine VM is in a preset proportion with the cycle quota, and in a scheduling period, the extra quota of each virtual machine VM is in the same proportion with the period quota of the virtual machine VM.
6. The computer system of claim 5, wherein the quota of physical CPU resources comprises the cycle quota and/or the additional quota.
CN201810350475.1A 2018-04-18 2018-04-18 Method and device for scheduling PCPU (physical packet Unit) resources Active CN108874534B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810350475.1A CN108874534B (en) 2018-04-18 2018-04-18 Method and device for scheduling PCPU (physical packet Unit) resources

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810350475.1A CN108874534B (en) 2018-04-18 2018-04-18 Method and device for scheduling PCPU (physical packet Unit) resources

Publications (2)

Publication Number Publication Date
CN108874534A CN108874534A (en) 2018-11-23
CN108874534B true CN108874534B (en) 2022-09-16

Family

ID=64326775

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810350475.1A Active CN108874534B (en) 2018-04-18 2018-04-18 Method and device for scheduling PCPU (physical packet Unit) resources

Country Status (1)

Country Link
CN (1) CN108874534B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124687B (en) * 2019-12-30 2022-04-22 浪潮电子信息产业股份有限公司 CPU resource reservation method, device and related equipment
CN112988399B (en) * 2021-04-30 2021-07-20 成都网安科技发展有限公司 Processor scheduling method and processor scheduling device based on virtualization technology

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101169731A (en) * 2007-12-05 2008-04-30 华为技术有限公司 Multiple-path multiple-core server and its CPU virtualization processing method
CN102317917A (en) * 2011-06-30 2012-01-11 华为技术有限公司 Hot field virtual machine cpu dispatching method and virtual machine system (vms)
CN102662763A (en) * 2012-04-11 2012-09-12 华中科技大学 Virtual machine resource scheduling method based on service quality
CN104461735A (en) * 2014-11-28 2015-03-25 杭州华为数字技术有限公司 Method and device for distributing CPU resources in virtual scene
CN106155782A (en) * 2015-04-09 2016-11-23 联想(北京)有限公司 Virtual machine migration method and device
CN106775925A (en) * 2016-11-11 2017-05-31 郑州云海信息技术有限公司 A kind of limit treating method and apparatus of virtual machine CPU

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8635615B2 (en) * 2011-05-14 2014-01-21 Industrial Technology Research Institute Apparatus and method for managing hypercalls in a hypervisor and the hypervisor thereof
US10255091B2 (en) * 2014-09-21 2019-04-09 Vmware, Inc. Adaptive CPU NUMA scheduling

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101169731A (en) * 2007-12-05 2008-04-30 华为技术有限公司 Multiple-path multiple-core server and its CPU virtualization processing method
CN102317917A (en) * 2011-06-30 2012-01-11 华为技术有限公司 Hot field virtual machine cpu dispatching method and virtual machine system (vms)
CN102662763A (en) * 2012-04-11 2012-09-12 华中科技大学 Virtual machine resource scheduling method based on service quality
CN104461735A (en) * 2014-11-28 2015-03-25 杭州华为数字技术有限公司 Method and device for distributing CPU resources in virtual scene
CN106155782A (en) * 2015-04-09 2016-11-23 联想(北京)有限公司 Virtual machine migration method and device
CN106775925A (en) * 2016-11-11 2017-05-31 郑州云海信息技术有限公司 A kind of limit treating method and apparatus of virtual machine CPU

Also Published As

Publication number Publication date
CN108874534A (en) 2018-11-23

Similar Documents

Publication Publication Date Title
CN106371894B (en) Configuration method and device and data processing server
CN110888743B (en) GPU resource using method, device and storage medium
US9405585B2 (en) Management of heterogeneous workloads
Park et al. Locality-aware dynamic VM reconfiguration on MapReduce clouds
US9378032B2 (en) Information processing method, information processing apparatus, recording medium, and system
US8918784B1 (en) Providing service quality levels through CPU scheduling
EP3451594A1 (en) Network function virtualization management orchestration device, method, and program
US11113782B2 (en) Dynamic kernel slicing for VGPU sharing in serverless computing systems
EP2799990A2 (en) Dynamic virtual machine sizing
US11579908B2 (en) Containerized workload scheduling
US8635615B2 (en) Apparatus and method for managing hypercalls in a hypervisor and the hypervisor thereof
US20200341789A1 (en) Containerized workload scheduling
Rani et al. Study on fundamental usage of CloudSim simulator and algorithms of resource allocation in cloud computing
CN108874534B (en) Method and device for scheduling PCPU (physical packet Unit) resources
CN111258745A (en) Task processing method and device
CN111953503B (en) NFV resource deployment arrangement method and network function virtualization orchestrator
Antoniou Performance evaluation of cloud infrastructure using complex workloads
Wu et al. Abp scheduler: Speeding up service spread in docker swarm
CN112905317A (en) Task scheduling method and system under rapid reconfigurable signal processing heterogeneous platform
KR101330609B1 (en) Method For Scheduling of Mobile Multi-Core Virtualization System To Guarantee Real Time Process
CN109189581B (en) Job scheduling method and device
CN113254143B (en) Virtualized network function network element arrangement scheduling method, device and system
Liu et al. Backfilling under two-tier virtual machines
CN116157778A (en) System and method for hybrid centralized and distributed scheduling on shared physical hosts
Liu et al. New metrics for scheduling jobs on cluster of virtual machines

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant