CPU adjustment method, server and computer readable storage medium

By dynamically adjusting the CPU resources between the host partition and the VM partition, the problem of low usage flexibility caused by static CPU resource partitioning is solved, and the CPU resource utilization rate and cloud computing efficiency are improved.

CN110704195BActive Publication Date: 2024-11-19TENCENT CLOUD COMPUTING (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910974237.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-14
Publication Date
2024-11-19
Estimated Expiration
2039-10-14

AI Technical Summary

Technical Problem

In the prior art, CPU resource partitions are statically divided in cloud computing, resulting in low flexibility in CPU usage and cannot be dynamically adjusted during operation, affecting resource utilization efficiency.

Method used

By obtaining the CPU usage information in the host partition, calculate the CPU usage rate, and dynamically adjust the CPU resource allocation between the host partition and the VM partition according to the usage rate, including dividing the CPU of the VM partition to Host partition, or divide the CPU of the host partition into the VM partition when the usage rate is below a certain threshold.

Benefits of technology

It improves the flexibility of CPU usage and resource utilization, and can dynamically adjust CPU resource partitions according to the needs of host partitions, improving the efficiency of cloud computing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110704195B_ABST
    Figure CN110704195B_ABST
Patent Text Reader

Abstract

This invention discloses a CPU adjustment method, a server, and a computer-readable storage medium. The method is applied to a server, which includes CPU resources, including a host partition and a virtual machine partition. The method includes: obtaining CPU usage information in the host partition; calculating the CPU utilization rate in the host partition based on the CPU usage information; and adjusting the CPU usage between the host partition and the virtual machine partition based on the CPU utilization rate. This invention can improve the flexibility of CPU usage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a CPU adjustment method, device and computer-readable storage medium. Background Art

[0002] In cloud computing, central processing unit (CPU) resources are one of the most important system resources. Reasonable use of CPU resources can improve the efficiency of cloud computing. On cloud servers running virtual machines (VMs), CPU resource isolation is usually performed to reduce interference between VMs and hosts. That is, all CPU resources on the host are partitioned, and the management threads on the VM and the host are placed in independent partitions so that they do not interfere with each other, which can improve the stability of the VM and the host. However, the above CPU resource partitions are usually statically divided, that is, after the CPU resource partitions are divided, they will not be dynamically modified during operation, which reduces the flexibility of CPU use. Summary of the invention

[0003] The embodiment of the present invention discloses a CPU adjustment method, a server and a computer-readable storage medium, which are used to improve the use flexibility of the CPU.

[0004] A first aspect discloses a CPU adjustment method, which is applied to a server, wherein the server includes CPU resources, and the CPU resources include host partitions and VM partitions, including:

[0005] Obtaining CPU usage information in the host partition;

[0006] Calculate the CPU usage in the host partition according to the usage information;

[0007] The CPU between the host partition and the VM partition is adjusted according to the usage rate.

[0008] As a possible implementation manner, the usage information includes a CPU usage time and a number of threads in an executable state, and calculating the CPU usage rate in the host partition according to the usage information includes:

[0009] Calculating the CPU occupancy rate in the host partition according to the usage time;

[0010] Calculating the CPU load in the host partition according to the number of threads;

[0011] The utilization rate of the CPU in the host partition is calculated according to the occupancy rate and the load.

[0012] As a possible implementation manner, the usage information further includes a wake-up time and an execution time of a first thread and a number of thread switches, the first thread being any thread in an executable state on a CPU in the host partition, and calculating the usage rate of the CPU in the host partition according to the occupancy rate and the load includes:

[0013] Calculate the thread scheduling delay according to the wake-up time and execution time of the first thread;

[0014] The utilization rate of the CPU in the host partition is calculated according to the occupancy rate, the load, the scheduling delay and the number of thread switching times.

[0015] As a possible implementation manner, adjusting the CPU between the host partition and the VM partition according to the usage rate includes:

[0016] When the usage rate is greater than a first threshold, part of the CPUs in the VM partition are allocated to the host partition.

[0017] As a possible implementation manner, adjusting the CPU between the host partition and the VM partition according to the usage rate further includes:

[0018] When the usage rate is less than a second threshold, part of the CPUs in the host partition are divided into the VM partition, and the second threshold is less than the first threshold.

[0019] As a possible implementation manner, the partitioning of part of the CPUs in the VM partition to the host partition includes:

[0020] Calculating the number of CPUs required to make the CPU usage in the host partition between the second threshold and the first threshold;

[0021] The required number of CPUs in the VM partition is divided into the host partition.

[0022] As a possible implementation, the dividing the required number of CPUs in the VM partition into the host partition includes:

[0023] Determine whether the number of available CPUs in the VM partition is less than the required number of CPUs;

[0024] When it is determined that the number of available CPUs in the VM partition is less than the required number of CPUs, migrating some VMs in the VM partition to another server;

[0025] The required number of CPUs and available CPUs in the VM partition are divided into the host partition.

[0026] A second aspect discloses a server, the server comprising CPU resources, the CPU resources comprising a host partition and a VM partition, including:

[0027] An acquisition unit, used for acquiring CPU usage information in the host partition;

[0028] A calculation unit, configured to calculate a CPU usage rate in the host partition according to the usage information;

[0029] An adjusting unit is used to adjust the CPU between the host partition and the VM partition according to the usage rate.

[0030] As a possible implementation manner, the usage information includes the CPU usage time and the number of threads in an executable state, and the computing unit is specifically used for:

[0031] Calculating the CPU occupancy rate in the host partition according to the usage time;

[0032] Calculating the CPU load in the host partition according to the number of threads;

[0033] The utilization rate of the CPU in the host partition is calculated according to the occupancy rate and the load.

[0034] As a possible implementation manner, the usage information further includes a wake-up time and an execution time of a first thread and a number of thread switches, the first thread being any thread in an executable state on a CPU in the host partition, and the calculation unit calculating the usage rate of the CPU in the host partition according to the occupancy rate and the load includes:

[0035] Calculate the thread scheduling delay according to the wake-up time and execution time of the first thread;

[0036] The utilization rate of the CPU in the host partition is calculated according to the occupancy rate, the load, the scheduling delay and the number of thread switching times.

[0037] As a possible implementation manner, the adjustment unit is specifically configured to allocate part of the CPUs in the VM partition to the host partition when the usage rate is greater than a first threshold.

[0038] As a possible implementation manner, the adjustment unit is further configured to allocate part of the CPUs in the host partition to the VM partition when the usage rate is less than a second threshold, and the second threshold is less than the first threshold.

[0039] As a possible implementation manner, the adjusting unit partitioning part of the CPUs in the VM partition to the host partition includes:

[0040] Calculating the number of CPUs required to make the CPU usage in the host partition between the second threshold and the first threshold;

[0041] The required number of CPUs in the VM partition is divided into the host partition.

[0042] As a possible implementation manner, the adjusting unit divides the required number of CPUs in the VM partition into the host partition, including:

[0043] Determine whether the number of available CPUs in the VM partition is less than the required number of CPUs;

[0044] When it is determined that the number of available CPUs in the VM partition is less than the required number of CPUs, migrating some VMs in the VM partition to another server;

[0045] The required number of CPUs and available CPUs in the VM partition are divided into the host partition.

[0046] In a third aspect, a server is disclosed, wherein the communication device includes a processor, a memory, an input interface, and an output interface, wherein the memory is used to store a set of computer program codes, the input interface is used to receive information from other devices outside the device, and the output interface is used to output information to other devices outside the device. When the processor is used to call the computer program code stored in the memory, the processor executes the CPU adjustment method disclosed in the first aspect or any possible implementation manner of the first aspect.

[0047] The fourth aspect discloses a computer-readable storage medium having a computer program or computer instructions stored thereon. When the computer program or computer instructions are executed, the CPU adjustment method disclosed in the first aspect or any possible implementation manner of the first aspect is implemented.

[0048] A fifth aspect discloses a computer program product, which, when executed on a computer, enables the computer to execute the CPU adjustment method disclosed in the first aspect or any possible implementation manner of the first aspect.

[0049] In an embodiment of the present invention, the server obtains CPU usage information in the host partition, calculates the CPU usage rate in the host partition based on the usage information, and adjusts the CPU between the host partition and the VM partition based on the usage rate. It can be seen that the CPU between the host partition and the VM partition can be adjusted according to the CPU usage rate in the host partition. After the CPU resource partitions are divided, the CPU between the host partition and the VM partition can be dynamically modified according to the needs of the host partition during operation, which can improve the flexibility of CPU use and improve the CPU utilization rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 This is a schematic diagram of CPU resource partitioning disclosed in an embodiment of the present invention;

[0051] Figure 2 It is a flowchart of a CPU adjustment method disclosed in an embodiment of the present invention;

[0052] Figure 3 It is a schematic diagram of reducing the number of CPUs in a VM partition and increasing the number of CPUs in a host partition disclosed in an embodiment of the present invention;

[0053] Figure 4 It is a schematic diagram of migrating part of VMs in a VM partition to another server disclosed in an embodiment of the present invention;

[0054] Figure 5 It is a structural schematic diagram of a server disclosed in an embodiment of the present invention;

[0055] Figure 6 It is a structural schematic diagram of another server disclosed in an embodiment of the present invention;

[0056] Figure 7 It is a structural diagram of another server disclosed in an embodiment of the present invention. DETAILED DESCRIPTION

[0057] The embodiments of the present invention disclose a CPU adjustment method, a server and a computer-readable storage medium, which are used to improve the flexibility of CPU usage. Detailed descriptions are given below.

[0058] In order to better understand the CPU adjustment method, server and computer-readable storage medium disclosed in the embodiment of the present invention, the application scenario of the embodiment of the present invention is described below. In a cloud server, in order to avoid mutual interference between VMs and hosts, it is usually necessary to isolate CPU resources so that different services can run in different CPU partitions. Figure 1 , Figure 1 Schematic diagram of CPU resource partitioning disclosed in an embodiment of the present invention. Figure 1As shown, the CPU resources in the server may include host partitions, VM partitions, data plane development kit (DPDK) partitions, and storage performance development kit (SPDK) partitions. In cloud servers, DPDK threads / SPDK threads are usually used to improve input and output (IO) processing efficiency. In order to avoid interference with the operation of DPDK threads / SPDK threads by other threads, such as host threads and VM threads, DPDK threads / SPDK threads need to run on isolated CPUs, so CPU resources may include DPDK partitions and SPDK partitions. The host partition is the CPU resource partition where the management thread on the server is located, the VM partition is the CPU resource partition where the VM thread is located, the DPDK partition is the CPU resource partition where the DPDK thread is located, and the SPDK partition is the CPU resource partition where the SPDK thread is located. Among them, the CPUs of the DPDK partition and the SPDK partition remain unchanged.

[0059] See also Figure 2 , Figure 2 1 is a flow chart of a CPU adjustment method disclosed in an embodiment of the present invention. The CPU adjustment method is applied to a server, and the server may include CPU resources, and the CPU resources may include host partitions and VM partitions, and the CPU resources may also include DPDK partitions and SPDK partitions. Figure 2 As shown, the CPU adjustment method may include the following steps.

[0060] 201. Obtain CPU usage information in the host partition.

[0061] The server may periodically obtain the CPU usage information in the host partition. The CPU usage information in the host partition may include the CPU usage time and the number of threads in a runnable state. The CPU usage time is the usage time of each CPU in the CPU included in the host partition within a cycle, and the number of threads in a runnable state is the number of threads in a runnable state on the CPU in the host partition within a cycle. The CPU usage information in the host partition may also include the wake-up time and execution time of the first thread. The first thread is any thread in a runnable state on the CPU in the host partition within a cycle. The CPU usage information in the host partition may also include the number of thread switching times. The number of thread switching times is the number of thread switching times on each CPU in the CPU included in the host partition within a cycle. The CPU usage information in the host partition may also include the sleep time and wake-up time of the second thread. The second thread is any thread on the CPU in the host partition that goes to sleep due to inability to access shared resources and is awakened due to access to shared resources within a cycle. The shared resources may be memory resources or other resources that can be shared.

[0062] 202. Calculate the CPU usage rate in the host partition according to the CPU usage information in the host partition.

[0063] After obtaining the CPU usage information in the host partition, the CPU usage rate in the host partition may be calculated according to the CPU usage information in the host partition.

[0064] In the case where the CPU usage information in the host partition includes the CPU usage time and the number of threads in an operable state, the CPU occupancy rate in the host partition can be calculated first according to the CPU usage time, and the CPU load in the host partition can be calculated according to the number of threads in an operable state, and then the CPU usage rate in the host partition can be calculated according to the CPU usage rate in the host partition and the CPU load in the host partition. Among them, the CPU usage rate in the host partition can be the sum or weighted sum of the CPU usage rate in the host partition and the CPU load in the host partition. The occupancy rate of each CPU in the CPU included in the host partition can be calculated according to the CPU usage time, and then the average value of the occupancy rates of all CPUs included in the host partition is determined as the CPU occupancy rate in the host partition. The occupancy rate of the first CPU can be obtained by dividing the usage time of the first CPU by the cycle time, and the first CPU is any CPU in the host partition. The load of each CPU in the CPU included in the host partition can be calculated according to the number of threads in an operable state, and then the average value of the loads of all CPUs included in the host partition is determined as the CPU load in the host partition.

[0065] In the case where the CPU usage information in the host partition includes the CPU usage time, the number of threads in the runnable state, and the CPU usage information in the host partition also includes the wake-up time and execution time of the first thread, the number of thread switching times, and the sleep time and wake-up time of the second thread, the CPU occupancy rate in the host partition can be calculated according to the CPU usage time, the CPU load in the host partition can be calculated according to the number of threads in the runnable state, the thread scheduling delay can be calculated according to the wake-up time and execution time of the first thread, and the thread blocking delay can be calculated according to the sleep time and wake-up time of the second thread. Then, the CPU usage rate in the host partition can be calculated according to the CPU occupancy rate and load in the host partition, and the thread scheduling delay, the thread blocking delay, and the number of thread switching times. The scheduling delay of the first thread can be calculated according to the wake-up time and execution time of the first thread, that is, the time difference between the execution time and the wake-up time of the first thread is calculated, and then the average scheduling delay of all threads in the runnable state on the CPU in the host partition in the previous cycle can be determined as the thread scheduling delay. The blocking delay of the second thread may be calculated based on the sleep time and wake-up time of the second thread, that is, the time difference between the wake-up time and the sleep time of the second thread is calculated, and then the average blocking delay of all second threads on the CPU in the host partition in the previous cycle is determined as the blocking delay of the thread. The number of thread switching times of each CPU in the host partition in the previous cycle may be calculated first, and then the average number of thread switching times of all CPUs in the host partition is used to calculate the CPU usage in the host partition.

[0066] 203. Adjust the CPU between the host partition and the VM partition according to the CPU usage in the host partition.

[0067] After calculating the CPU usage rate in the host partition according to the CPU usage information in the host partition, the CPU between the host partition and the VM partition can be adjusted according to the CPU usage rate.

[0068] A range can be preset. When the CPU usage in the host partition is within this range, the CPU of the host partition and the CPU of the VM partition can remain unchanged, that is, the CPU between the host partition and the VM partition does not need to be adjusted. The upper limit of this range is the first threshold and the lower limit is the second threshold. The first threshold and the second threshold can be preset as needed. When the CPU usage in the host partition is greater than the first threshold, it indicates that the CPU pressure in the host partition is high. Some CPUs in the VM partition can be allocated to the host partition, that is, the number of CPUs in the VM partition is reduced and the number of CPUs in the host partition is increased. See Figure 3 , Figure 3Schematic diagram of reducing the number of CPUs in a VM partition and increasing the number of CPUs in a host partition disclosed in an embodiment of the present invention. Figure 3 As shown, the number of CPUs reduced in the VM partition is added to the host partition.

[0069] When allocating some CPUs in a VM partition to a host partition, you can first calculate the number of CPUs required to make the CPU usage in the host partition between the second threshold and the first threshold, and then allocate the required number of CPUs in the VM partition to the host partition. You can also first determine whether the number of available CPUs in the VM partition is less than the required number of CPUs. If it is determined that the number of available CPUs in the VM partition is less than the required number of CPUs, you can first migrate some VMs in the VM partition to another server, and then allocate the required number of available CPUs in the VM partition to the host partition. See Figure 4 , Figure 4 FIG. 1 is a schematic diagram of migrating part of VMs in a VM partition to another server disclosed in an embodiment of the present invention. Figure 4 As shown, VM6 can be migrated to another server first, and then the number of CPUs used by VM6 can be divided into host partitions. When it is determined that the number of available CPUs in the VM partition is greater than or equal to the required number of CPUs, the required number of CPUs in the VM partition and the available CPUs can be directly divided into the host partition without migrating the VMs in the VM partition to another server. The available CPUs in the VM partition are the CPUs that have not been sold.

[0070] When the CPU usage in the host partition is less than the second threshold, it indicates that the pressure on the CPU in the host partition is small, and part of the CPU in the host partition can be allocated to the VM partition, that is, the number of CPUs in the host partition is reduced and the number of CPUs in the VM partition is increased. The number of remaining CPUs that make the CPU usage in the host partition between the second threshold and the first threshold can be calculated first, and then the remaining number of CPUs in the host partition can be allocated to the VM partition.

[0071] Making the CPU usage in the host partition between the second threshold and the first threshold may be making the CPU usage in the host partition equal to the average of the first threshold and the second threshold, or making the CPU usage in the host partition equal to the average of the average and the first threshold, or may be other values ​​between the second threshold and the first threshold.

[0072] exist Figure 2In the described CPU adjustment method, the server obtains the usage information of the CPU in the host partition, calculates the usage rate of the CPU in the host partition according to the usage information, and adjusts the CPU between the host partition and the VM partition according to the usage rate. It can be seen that the CPU between the host partition and the VM partition can be adjusted according to the usage rate of the CPU in the host partition. After the CPU resource partitions are divided, the CPU between the host partition and the VM partition can be dynamically modified according to the needs of the host partition during operation, which can improve the flexibility of CPU use and improve the CPU utilization rate.

[0073] See also Figure 5 , Figure 5 Schematic diagram of the structure of a server disclosed in an embodiment of the present invention. Figure 5 As shown, the server may include a CPU resource isolation module, a monitoring module, a resource management module, and a VM scheduling module. The CPU resource isolation module is responsible for isolating the CPU resources in the server and dividing all CPU resources on the server into different subsets corresponding to different CPU resource partitions, such as Figure 1 The typical implementation of the CPU resource isolation module is Cpuset in the Linux system. Cpuset is a CPU resource management mechanism in the Linux system, representing a collection of CPU resources. The typical implementation process of the CPU resource isolation module is:

[0074] 1. Start the operating system and initialize the basic resources and interfaces required for CPU resource isolation. Taking Cpuset as an example, you can initialize the corresponding data of Cpuset in the operating system kernel, mount and create the corresponding VM file system interface.

[0075] 2. Call the corresponding interface provided by the operating system to create different CPU resource partitions for tasks with different purposes, such as host partitions, VM partitions, DPDK partitions, and SPDK partitions.

[0076] 3. Allocate corresponding CPU resources to different partitions according to specific scenario requirements. For example, allocate 4 logical CPUs to the host partition, 4 logical CPUs to the DPDK partition and 4 logical CPUs to the SPDK partition respectively, and put all the remaining logical CPUs into the VM partition for sale.

[0077] 4. Complete other related configurations according to specific scenario requirements. Different partitions may have different related configurations due to different work natures. For example, DPDK partitions / SPDK partitions require that threads in the partitions be bound to CPU cores one by one, and thread scheduling between CPUs needs to be disabled, while host partitions and VM partitions usually do not require this.

[0078] 5. Call the corresponding interface provided by the operating system to put the processes / threads corresponding to different tasks into the corresponding CPU resource partitions. For example, the virtual CPU threads contained in the VM are placed in the VM partition; the host management threads are placed in the host partition; the DPDK and SPDK working threads are placed in the DPDK partition and SPDK partition respectively.

[0079] The monitoring module is responsible for monitoring the CPU resource utilization of the host partition, and combines various CPU resource-related monitoring indicators to abstract the "CPU usage rate" indicator to provide reference and guidance for the "resource management module" to manage CPU resources. The typical implementation process of the monitoring module is:

[0080] 1. Regularly collect various CPU-related statistical data of the host partition through the interface provided by the operating system, such as CPU occupancy (including user state and kernel state), CPU load, and other related indicators, such as thread scheduling delay, thread blocking delay, thread context switching times, etc.

[0081] 2. Through a certain algorithm, various statistical data are abstracted into the "CPU usage rate" indicator of the host partition.

[0082] 3. Store relevant data.

[0083] For the monitored statistical data, a typical application example is as follows: on the cloud server host, run the background monitoring program and regularly collect CPU usage pressure-related indicators through system tools, such as: the average CPU occupancy rate in the last minute. If the occupancy rate exceeds 50% (this threshold may be different in different scenarios), it means that the current CPU pressure is relatively high; the load in the last minute, if the load exceeds 1.5 times the number of logical CPUs (1.5 may also change according to the scenario), it means that the CPU pressure is relatively high; the number of thread switches, if the average number of switches in the last minute exceeds the clock frequency * 60 * the number of threads running in the host partition * the coefficient (may change according to scenario 2), it means that the CPU pressure is high.

[0084] The typical abstract way of the "CPU usage" indicator is: "CPU usage" = CPU occupancy * occupancy weight + CPU load * load weight + other optional indicators * optional indicator weight. Other optional indicators can be customized, such as "thread scheduling delay", "thread blocking delay", and "number of thread switches".

[0085] The resource management module is responsible for the dynamic allocation and adjustment of CPU resources. It relies on the abstract "CPU usage rate" indicator provided by the monitoring module, and dynamically allocates CPU resources based on this indicator. Specifically, it includes two main logics:

[0086] 1. Increase VM partition resources and improve sellable resources;

[0087] 2. Reduce VM partition resources to keep the host stable.

[0088] The specific logic for adding VM partition resources is as follows:

[0089] 1. During the operation of the host, the CPU pressure of the host partition is monitored through the monitoring module;

[0090] 2. When the CPU pressure of the host partition is low, dynamically reduce the CPU resources of the host partition through the interface provided by the operating system;

[0091] 3. At the same time, dynamically increase CPU resources for the VM partition through the interface provided by the operating system (the increased CPU resources come from the host partition);

[0092] 4. After the CPU resources of the VM partition are increased, more VMs can be scheduled or allocated to the host through the VM scheduling module, thereby improving the resource utilization of the host.

[0093] The specific logic for reducing VM partition resources is as follows:

[0094] 1. During the operation of the host, the CPU pressure of the host partition is monitored through the monitoring module;

[0095] 2. When the CPU pressure of the host partition is high, dynamically reduce the CPU resources of the VM partition through the interface provided by the operating system; if the CPU resources on the current host are relatively tight, some VMs can be hot migrated (scheduled) to other servers through the VM scheduling module;

[0096] 3. At the same time, the corresponding CPU resources are added to the host partition through the interface provided by the operating system. This completes the compression of the CPU resources of the VM partition, ensures the CPU resource supply of the host partition, and guarantees the stability of the host.

[0097] The VM scheduling module is responsible for the scheduling and deployment of VMs, and mainly completes the following two logics:

[0098] 1. When there are surplus VM partition resources on this server, allocate or schedule new VMs to run on this server to improve resource utilization of this server.

[0099] 2. When the VM partition resources of this server are tight, migrate the specified VM on this server to other servers to reduce the pressure on this server and improve server stability.

[0100] The server can provide the following main interfaces:

[0101] 1. VM creation. Create a VM based on the specified parameters, such as the number of CPUs and cores. The specific implementation method is to call the corresponding interfaces provided by the operating system and virtualization components.

[0102] 2. VM destruction. Destroy the specified VM. The specific implementation method is to call the corresponding interface provided by the operating system and virtualization component.

[0103] 3. VM hot migration. Migrate the specified VM to another server while keeping the business running in the VM. The specific implementation method is to call the corresponding interface provided by the operating system and virtualization components.

[0104] See also Figure 6 , Figure 6 1 is a schematic diagram of another server structure disclosed in an embodiment of the present invention. The server includes CPU resources, and the CPU resources include host partitions and VM partitions. Figure 6 As shown, the server may include:

[0105] An acquisition unit 601 is used to acquire CPU usage information in a host partition;

[0106] A calculation unit 602 is used to calculate the CPU usage rate in the host partition according to the CPU usage information in the host partition;

[0107] The adjusting unit 603 is used to adjust the CPU between the host partition and the VM partition according to the CPU usage in the host partition.

[0108] In one embodiment, the CPU usage information in the host partition includes the CPU usage time and the number of threads in the runnable state. The calculation unit 602 is specifically used to:

[0109] Calculate the CPU usage in the host partition based on the CPU usage time;

[0110] Calculate the CPU load in the host partition based on the number of threads in the runnable state;

[0111] Calculate the CPU usage of the host partition based on the CPU occupancy and load of the host partition.

[0112] In one embodiment, the CPU in the host partition also includes the wake-up time and execution time of the first thread and the number of thread switching times, the first thread is any thread in an executable state on the CPU in the host partition, and the calculation unit 602 calculates the CPU usage in the host partition according to the CPU occupancy and load in the host partition, including:

[0113] Calculate the thread scheduling delay according to the wake-up time and execution time of the first thread;

[0114] The CPU usage in the host partition is calculated according to the CPU occupancy rate in the host partition, the CPU load in the host partition, the thread scheduling delay, and the number of thread switching times.

[0115] In one embodiment, the adjusting unit 603 is specifically configured to allocate part of the CPUs in the VM partition to the host partition when the CPU usage in the host partition is greater than a first threshold.

[0116] In one embodiment, the adjusting unit 603 is further configured to allocate part of the CPUs in the host partition to the VM partition when the CPU usage in the host partition is less than a second threshold, and the second threshold is less than the first threshold.

[0117] In one embodiment, the adjusting unit 603 divides part of the CPUs in the VM partition into the host partition, including:

[0118] Calculate the number of CPUs required to make the CPU usage in the host partition between the second threshold and the first threshold;

[0119] Divide the required number of CPUs in the VM partition into the host partition.

[0120] In one embodiment, the adjusting unit 603 divides the required number of CPUs in the VM partition into the host partition, including:

[0121] Determine whether the number of available CPUs in the VM partition is less than the required number of CPUs;

[0122] When it is determined that the number of available CPUs in the VM partition is less than the required number of CPUs, some VMs in the VM partition are migrated to another server;

[0123] Divide the required number of available CPUs in the VM partition into the host partition.

[0124] For detailed description of the acquisition unit 601, the calculation unit 602 and the adjustment unit 603, please refer to the above Figure 2 The relevant description in the illustrated method embodiment is directly obtained and will not be repeated here.

[0125] See also Figure 7 , Figure 7 is a structural diagram of another server disclosed in an embodiment of the present invention. The server includes CPU resources, and the CPU resources include host partitions and VM partitions. Figure 7As shown, the server may include a processor 701, a memory 702, an input interface 703, an output interface 704, and a connection line 705. The memory 702 may exist independently, and the connection line 705 is connected to the processor 701. The memory 702 may also be integrated with the processor 701. The connection line 705 may include a path to transmit information between the above components. Among them, the memory 702 stores program instructions, and the processor 701 is used to execute the program instructions stored in the memory 702. Among them:

[0126] A set of computer programs is stored in the memory 702, and the processor 701 is used to call the computer programs stored in the memory 702 to perform the following operations:

[0127] Get CPU usage information in the host partition;

[0128] Calculate the CPU usage rate in the host partition according to the CPU usage information in the host partition;

[0129] Adjust the CPU between the host partition and the VM partition according to the CPU usage in the host partition.

[0130] In one embodiment, the CPU usage information in the host partition includes the CPU usage time and the number of threads in an executable state, and the processor 701 calculates the CPU usage rate in the host partition according to the CPU usage information in the host partition, including:

[0131] Calculate the CPU usage in the host partition based on the CPU usage time;

[0132] Calculate the CPU load in the host partition based on the number of threads in the runnable state;

[0133] Calculate the CPU usage of the host partition based on the CPU occupancy and load of the host partition.

[0134] In one embodiment, the CPU usage information in the host partition further includes the wake-up time and execution time of the first thread and the number of thread switching times, the first thread is any thread in an executable state on the CPU in the host partition, and the processor 701 calculates the CPU usage in the host partition according to the CPU occupancy and load in the host partition, including:

[0135] Calculate the thread scheduling delay according to the wake-up time and execution time of the first thread;

[0136] The CPU usage in the host partition is calculated according to the CPU occupancy rate in the host partition, the CPU load in the host partition, the thread scheduling delay, and the number of thread switching times.

[0137] In one embodiment, the processor 701 adjusts the CPU usage between the host partition and the VM partition according to the CPU usage in the host partition, including:

[0138] When the CPU usage in the host partition is greater than a first threshold, part of the CPU in the VM partition is allocated to the host partition.

[0139] In one embodiment, the processor 701 adjusts the CPU usage between the host partition and the VM partition according to the CPU usage in the host partition, further comprising:

[0140] When the CPU usage in the host partition is less than a second threshold, part of the CPU in the host partition is divided into the VM partition, and the second threshold is less than the first threshold.

[0141] In one embodiment, the processor 701 divides part of the CPU in the VM partition into the host partition, including:

[0142] Calculate the number of CPUs required to make the CPU usage in the host partition between the second threshold and the first threshold;

[0143] Divide the required number of CPUs in the VM partition into the host partition.

[0144] In one embodiment, the processor 701 divides the required number of CPUs in the VM partition into the host partition including:

[0145] Determine whether the number of available CPUs in the VM partition is less than the required number of CPUs;

[0146] When it is determined that the number of available CPUs in the VM partition is less than the required number of CPUs, some VMs in the VM partition are migrated to another server;

[0147] Divide the required number of available CPUs in the VM partition into the host partition.

[0148] In one embodiment, the input interface is used to receive information from other devices other than the server;

[0149] The output interface is used to output information to other devices outside the server.

[0150] Among them, steps 201 to 203 can be executed by the processor 701 and the memory 702 in the server.

[0151] The acquisition unit 601 , the calculation unit 602 and the adjustment unit 603 may be implemented by a processor 701 and a memory 702 in the server.

[0152] The above-mentioned server can also be used to execute various methods executed in the aforementioned method embodiments, which will not be described in detail.

[0153] The embodiment of the present invention also discloses a storage medium on which a program is stored. When the program is executed, the following is achieved: Figure 2 CPU adjustment method shown.

[0154] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the present application in detail. It should be understood that the above description is only the specific implementation methods of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the present application should be included in the scope of protection of the present application.

Claims

1. A method for adjusting a central processing unit (CPU), characterized in that: The method is applied to a server, the server includes CPU resources, the CPU resources include host partitions and virtual machine partitions, and includes: Obtaining CPU usage information in the host partition; Calculate the CPU usage in the host partition according to the usage information; Adjusting the CPU between the host partition and the virtual machine partition according to the usage rate; The usage information includes the CPU usage time and the number of threads in an executable state, and calculating the CPU usage rate in the host partition according to the usage information includes: Calculating the CPU occupancy rate in the host partition according to the usage time; Calculating the CPU load in the host partition according to the number of threads; Calculate the CPU usage in the host partition according to the occupancy rate and the load; Wherein, adjusting the CPU between the host partition and the virtual machine partition according to the usage rate includes: When the usage rate is greater than the first threshold, calculating the number of CPUs required to make the usage rate of the CPUs in the host partition between a second threshold and the first threshold, the second threshold being less than the first threshold; Determine whether the number of available CPUs in the virtual machine partition is less than the required number of CPUs; When it is determined that the number of available CPUs in the virtual machine partition is less than the required number of CPUs, migrating some virtual machines in the virtual machine partition to another server; The required number of available CPUs in the virtual machine partition is divided into the host partition.

2. The method according to claim 1, characterized in that The usage information also includes a wake-up time and an execution time of a first thread and a number of thread switching times, wherein the first thread is any thread in an executable state on a CPU in the host partition, and the calculating the usage rate of the CPU in the host partition according to the occupancy rate and the load includes: Calculate the thread scheduling delay according to the wake-up time and execution time of the first thread; The utilization rate of the CPU in the host partition is calculated according to the occupancy rate, the load, the scheduling delay and the number of thread switching times.

3. The method according to claim 1, characterized in that The adjusting the CPU between the host partition and the virtual machine partition according to the usage rate further includes: When the usage rate is less than a second threshold, part of the CPUs in the host partition are allocated to the virtual machine partition.

4. A server, characterized in that: The server includes a central processing unit (CPU) resource, and the CPU resource includes a host partition and a virtual machine partition, including: An acquisition unit, used to acquire CPU usage information in the host partition; A calculation unit, configured to calculate a CPU usage rate in the host partition according to the usage information; An adjustment unit, configured to adjust the CPU between the host partition and the virtual machine partition according to the usage rate; The usage information includes the CPU usage time and the number of threads in an executable state. The computing unit is specifically used for: Calculating the CPU occupancy rate in the host partition according to the usage time; Calculating the CPU load in the host partition according to the number of threads; Calculate the CPU usage in the host partition according to the occupancy rate and the load; Wherein, the adjustment unit is specifically used for: When the usage rate is greater than the first threshold, calculating the number of CPUs required to make the usage rate of the CPUs in the host partition between a second threshold and the first threshold, the second threshold being less than the first threshold; Determine whether the number of available CPUs in the virtual machine partition is less than the required number of CPUs; When it is determined that the number of available CPUs in the virtual machine partition is less than the required number of CPUs, migrating some virtual machines in the virtual machine partition to another server; The required number of available CPUs in the virtual machine partition is divided into the host partition.

5. A server, characterized in that: It includes a processor, a memory, an input interface and an output interface, the memory is used to store a set of computer program codes, the input interface is used to receive information from other devices outside the server, the output interface is used to output information to other devices outside the server, and the processor is used to call the computer program code stored in the memory to implement the central processing unit CPU adjustment method as described in any one of claims 1-3.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or a computer instruction. When the computer program or the computer instruction is executed, the central processing unit (CPU) adjustment method according to any one of claims 1 to 3 is implemented.