Core binding method for virtual machine, and computing device
By using the host operating system to perform one-to-one binding between the physical CPU and the virtual CPU in the virtual machine, the stability problem caused by resource competition in the virtual machine is solved and the stability of the target application is improved.
Patent Information
- Application Number
- PCT/CN2024/128800
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-27
- Filing Date
- 2024-10-31
- Publication Date
- 2025-10-02
AI Technical Summary
When the target virtual CPU shares physical CPU resources with other virtual CPUs in a virtual machine, application software stability is reduced.
The host operating system determines the binding operation of the target virtual machine and performs a one-to-one binding between the target physical CPU and the target virtual CPU to ensure that resources are allocated to the target virtual CPU and avoid competition for resources with other virtual CPUs.
Improves the stability of applications on the target virtual CPU and avoids stability issues caused by resource competition.
Smart Images

Figure CN2024128800_02102025_PF_FP_ABST
Abstract
Description
A virtual machine core binding method and computing device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on March 27, 2024, with application number 202410362760.0 and application name “A method for binding a core of a virtual machine and a computing device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of server technology, and in particular to a method for binding a core to a virtual machine and a computing device. Background Art
[0003] With the popularization of virtual machine (VM) technology, a common method for binding a core to a virtual machine is to map the central processing unit (CPU) in the host machine where the VM is located to a virtual CPU in the VM; then, a first application software installed on the VM is bound to the virtual CPU in the VM (i.e., the target virtual CPU) so that the first application software runs on the target virtual CPU.
[0004] However, when the physical CPU pool corresponding to the target virtual CPU in the VM on the host machine has overlapping CPUs (referred to as: overlapping physical CPUs) with the physical CPU pools corresponding to other virtual CPUs in the VM on the host machine, when the above-mentioned first application software runs on the target virtual CPU, the second application software running on other virtual CPUs will compete with the first application software for CPU resources in the above-mentioned overlapping physical CPUs, thereby reducing the stability of the first application software.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a virtual machine core binding method and a computing device for improving the stability of a target application running on a target virtual CPU.
[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0008] In the first aspect, an embodiment of the present application provides a method for binding a virtual machine core, the method comprising: determining whether a first binding operation exists in a target virtual machine; the target virtual machine is any one of a plurality of virtual machines running in a host machine; the first binding operation is used to specify a target virtual CPU from a plurality of virtual CPUs of the above-mentioned target virtual machine, and the target virtual CPU is used to run a target application; in the case that the first binding operation exists in the above-mentioned target virtual machine, determining a physical CPU pool corresponding to the target virtual CPU in the host machine; the physical CPU pool includes a physical CPU; performing a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU; wherein, the target physical CPU is any one or more physical CPUs in the above-mentioned physical CPU pool, and after the above-mentioned second binding operation, all resources of the target physical CPU are allocated to the target virtual CPU for use.
[0009] An embodiment of the present application provides a method for binding a virtual machine core, the method comprising: the host machine's OS determines whether a first binding operation exists in the target virtual machine, the first binding operation being used to specify a target virtual CPU in the target virtual machine for running a target application; in the case where the first binding operation exists in the target virtual machine, the host machine's OS determines a physical CPU pool corresponding to the target virtual CPU in the host machine; the physical CPU pool includes a physical CPU; the host machine's OS performs a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU, so that all resources of the target physical CPU after the second binding operation are allocated to the target virtual CPU for use, so that other virtual CPUs no longer occupy the CPU resources in the target physical CPU, thereby improving the stability of the target application running on the target virtual CPU.
[0010] In one possible implementation, the above-mentioned determination of the physical CPU pool corresponding to the target virtual CPU in the host machine includes: determining the physical CPU pool corresponding to the target virtual CPU in the host machine based on a first mapping relationship; the first mapping relationship includes a mapping relationship between the virtual CPU in the target virtual machine and the physical CPU in the host machine; the first mapping relationship is used to allocate physical CPU resources in the host machine to the virtual CPU in the virtual machine.
[0011] In one possible implementation, the above-mentioned second binding operation of the target physical CPU and the target virtual CPU in the physical CPU pool includes: updating the first mapping relationship based on the target physical CPU to obtain a second mapping relationship; wherein, in the second mapping relationship, the target physical CPU and the target virtual CPU are a one-to-one mapping relationship.
[0012] An embodiment of the present application includes the following steps: when a target virtual machine obtains a first binding operation of a user on a target application, and in response to the first binding operation, binds the target application to a target virtual CPU; then, the host machine's OS obtains the first binding operation and determines a physical CPU pool corresponding to the target virtual CPU based on a first mapping relationship, and thereafter, the host machine's OS determines a target physical CPU from the physical CPU pool that has no mapping relationship with other virtual CPUs; finally, all CPU resources of the target physical CPU are allocated to the target virtual CPU for use, and the physical CPU to which the target virtual CPU belongs is made the target physical CPU; thereby, other virtual CPUs no longer compete with the target virtual CPU for CPU resources in the physical CPU pool, thereby improving the stability of the target application running on the target virtual CPU.
[0013] In one possible implementation, before performing the second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU, the method further includes: determining the target physical CPU from the physical CPU pool; wherein, in the first mapping relationship, there is no mapping relationship between the target physical CPU and other virtual CPUs.
[0014] The above embodiment determines the physical CPU in the physical CPU pool that has no mapping relationship with other virtual CPUs in the target virtual machine as the target physical CPU, and gives all the CPU resources of the target physical CPU to the above target virtual machine for use, so that the physical CPU to which the target virtual CPU belongs is the target physical CPU (that is, there is a one-to-one mapping relationship between the target CPU and the target physical CPU). Therefore, the problem of reducing the stability of other applications in the target virtual machine due to updating the above first mapping relationship is solved.
[0015] In a possible implementation, the determining whether the first binding operation exists in the target virtual machine includes: intercepting the first binding operation in the target virtual machine.
[0016] In one possible implementation, intercepting the first binding operation in the target virtual machine includes: intercepting the first binding operation in the target virtual machine based on a hook function; the hook function is injected into an access point of the kernel of the target virtual machine, and the access point is used to identify the first binding operation of the target virtual machine; the hook function is implemented based on ebpf or kprobe.
[0017] The above embodiment intercepts the first binding operation through ebpf or kprobe, so there is no need to rewrite the kernel code of the virtual machine, thereby reducing the workload of code maintenance.
[0018] In one possible implementation, the above-mentioned interception of the first binding operation in the target virtual machine based on the hook function includes: obtaining the above-mentioned first binding operation in the kernel of the target virtual machine based on the above-mentioned hook function; transmitting the first binding operation information to the kernel of the host machine through the communication interface between the above-mentioned target virtual machine and the host machine operating system; or, transmitting the first binding operation information to the user state of the host machine through a simulation device; wherein, the simulation device is a virtual device simulated by the above-mentioned host machine.
[0019] In one possible implementation, the method further includes: determining whether there is an unbinding operation in the target virtual machine; the unbinding operation is used to release the binding relationship between the target application and the target virtual CPU; and in the event that there is an unbinding operation in the target virtual machine, releasing the target virtual CPU from using at least part of the resources of the target physical CPU.
[0020] In the above embodiment, when it is determined that an unbinding operation occurs in the target virtual machine, the target virtual CPU releases at least a portion of the resources of the target physical CPU to allow other virtual CPUs to occupy them, thereby improving the stability of other applications in the target virtual machine.
[0021] In a possible implementation, releasing the target virtual CPU from using at least a portion of the resources of the target physical CPU includes: updating the second mapping relationship to the first mapping relationship.
[0022] In a second aspect, an embodiment of the present application provides a virtual machine core binding device, which includes: a determination unit and a binding unit. The determination unit is used to determine whether a first binding operation exists in a target virtual machine; the target virtual machine is any one of multiple virtual machines running in a host machine; the first binding operation is used to specify a target virtual CPU from multiple virtual CPUs of the target virtual machine, and the target virtual CPU is used to run a target application; the determination unit is also used to determine the physical CPU pool corresponding to the target virtual CPU in the host machine when the first binding operation exists in the target virtual machine; the physical CPU pool includes a physical CPU; the binding unit is used to perform a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU; wherein the target physical CPU is any one or more physical CPUs in the physical CPU pool, and all resources of the target physical CPU after the second binding operation are allocated to the target virtual CPU for use.
[0023] In one possible implementation, the determination unit is used to determine the physical CPU pool corresponding to the target virtual CPU in the host machine based on a first mapping relationship; the first mapping relationship includes a mapping relationship between the virtual CPU in the target virtual machine and the physical CPU in the host machine; the first mapping relationship is used to allocate physical CPU resources in the host machine to the virtual CPU in the virtual machine.
[0024] In one possible implementation, the computing device further includes an updating unit configured to update the first mapping relationship based on the target physical CPU to obtain a second mapping relationship, wherein in the second mapping relationship, the target physical CPU and the target virtual CPU are in a one-to-one mapping relationship.
[0025] In a possible implementation, the determining unit is configured to determine a target physical CPU from a physical CPU pool; wherein, in the first mapping relationship, there is no mapping relationship between the target physical CPU and other virtual CPUs.
[0026] In one possible implementation, the above-mentioned virtual machine core binding device also includes: a transceiver unit; the transceiver unit is used to intercept the first binding operation in the target virtual machine; the determination unit is used to determine that the first binding operation exists in the target virtual machine when the first binding operation is intercepted in the target virtual machine; and determine that the first binding operation does not exist in the target virtual machine when the first binding operation is not intercepted in the target virtual machine.
[0027] In one possible implementation, the transceiver unit is used to intercept the first binding operation in the target virtual machine based on a hook function; the hook function is injected into an access point of the kernel of the target virtual machine, and the access point is used to identify the first binding operation of the target virtual machine; the hook function is implemented based on ebpf or kprobe.
[0028] In one possible implementation, the transceiver unit is used to obtain a first binding operation in the kernel of the target virtual machine based on a hook function; the transceiver unit is also used to transmit the first binding operation information to the kernel of the host machine through the communication interface between the target virtual machine and the host machine operating system; or, transmit the first binding operation information to the user state of the host machine through a simulation device; wherein the simulation device is a virtual device simulated by the host machine.
[0029] In one possible implementation, the above-mentioned virtual machine core binding device also includes: an unbinding unit; a determination unit for determining whether an unbinding operation exists in the target virtual machine; the unbinding operation is used to release the binding relationship between the target application and the target virtual CPU; the unbinding unit is used to release the target virtual CPU from using at least part of the resources of the target physical CPU when an unbinding operation exists in the target virtual machine.
[0030] In a possible implementation, the updating unit is configured to update the second mapping relationship to the first mapping relationship.
[0031] In a third aspect, a computing device is provided, which includes a processor and a memory, which is electrically connected to the processor; the memory is used to store program instructions, and the processor executes the program instructions to implement the virtual machine core binding method of the first aspect and its possible implementation methods.
[0032] In a fourth aspect, a computer-readable storage medium is provided, which stores computer instructions. When the computer instructions in the computer-readable storage medium are executed by a computing device, the computing device executes the virtual machine core binding method of the first aspect and its possible implementation methods.
[0033] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computing device, enables the computing device to execute the virtual machine core binding method of the first aspect and its possible implementation methods.
[0034] It should be understood that the beneficial effects achieved by the technical solutions of the second to fifth aspects of the embodiments of the present application and the corresponding possible implementation methods can be referred to the technical effects of the first aspect and its corresponding possible implementation methods mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] FIG1 is a schematic diagram of resource virtualization of a host machine provided in an embodiment of the present application;
[0036] FIG2 is a schematic diagram of resource virtualization of another host machine provided in an embodiment of the present application;
[0037] FIG3 is a schematic diagram of the hardware structure of a computing device provided in an embodiment of the present application;
[0038] FIG4 is a flow chart of a method for binding a virtual machine core provided in an embodiment of the present application;
[0039] FIG5 is a flow chart of another method for binding a virtual machine core provided in an embodiment of the present application;
[0040] FIG6 is a flow chart of another method for binding a virtual machine core provided in an embodiment of the present application;
[0041] FIG7 is a schematic diagram of the structure of a virtual machine core binding device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The term "and / or" in this article is merely a description of the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0043] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0044] In the description of the embodiments of the present application, unless otherwise specified, "a plurality" means two or more than two. For example, a plurality of virtual machines refers to two or more virtual machines.
[0045] First, some concepts involved in a virtual machine core binding method and a computing device provided in an embodiment of the present application are explained as follows:
[0046] A virtual machine (VM) is a computer system with complete hardware and software that is simulated through software. Any tasks that can be performed on a physical computer can also be performed on a VM. When creating a VM, a portion of the physical machine's hard drive and memory capacity is used as the VM's hard drive and memory capacity. Each VM has its own independent hard drive and operating system, allowing users to operate the VM just like a physical machine.
[0047] As described in the background technology, when the first application software runs on the target virtual CPU, the second application software running on other virtual CPUs will compete with the first application software for the CPU resources in the above-mentioned overlapping physical CPU, thereby reducing the stability of the first application software; in order to solve this problem, an embodiment of the present application provides a virtual machine core binding method, the method comprising: the host machine's OS determines whether there is a first binding operation in the target virtual machine, and the first binding operation is used to specify the target virtual CPU in the target virtual machine for running the target application; when the first binding operation exists in the target virtual machine, the host machine's OS determines the physical CPU pool corresponding to the target virtual CPU in the host machine; the physical CPU pool includes a physical CPU; the host machine's OS performs a second binding operation on the target physical CPU in the physical CPU pool with the target virtual CPU, so that all resources of the target physical CPU after the second binding operation are allocated to the target virtual CPU for use, so that other virtual CPUs no longer occupy the CPU resources in the target physical CPU, thereby improving the stability of the target application running on the target virtual CPU.
[0048] The virtual machine core binding method provided in the embodiment of the present application is applied in a host machine 101 as shown in FIG1 ; a virtual machine 102 is running on the host machine 101 .
[0049] The host machine 101 includes M physical CPUs. The host machine 101 maps the physical CPUs to virtual CPUs, so that the virtual machine 102 can schedule CPU resources on the physical CPU corresponding to the virtual CPU through the mapped virtual CPU.
[0050] Exemplarily, as shown in FIG1 , the host machine 101 includes M physical CPUs, and the host machine 101 maps the M physical CPUs to N virtual CPUs in the virtual machine 102 .
[0051] The virtual machines (such as virtual machine 102 ) on the host machine 101 above all run on the operating system of the host machine 101 , and the virtual machines 102 and the host machine 101 can communicate based on a virtual serial port or a fixed module (such as a hypercall interface or a writemsr interface).
[0052] It should be understood that the host machine 101 can run one virtual machine or multiple virtual machines, and the multiple virtual machines can be virtual machines with a Windows operating system or a Linux operating system. Specifically, the host machine 101 can be a computing device with computing and storage capabilities, such as a desktop computer, a laptop, or a server.
[0053] It should be noted that the virtual machine core binding method provided in the embodiment of the present application is applied in the scenario where the application software (such as APP_1) in the virtual machine 102 is bound to the virtual CPU. After APP_1 is bound to a virtual CPU (such as Vcpu_1) in the virtual machine 102, the APP_1 will only run in the Vcpu_1.
[0054] For example, as shown in Figure 2, when APP_1 in the virtual machine 102 is bound to Vcpu_1 in the virtual machine 102, based on the virtual machine core binding method provided in the embodiment of the present application, the host machine allocates all the resources of the physical CPU (i.e., cpu_1) corresponding to the Vcpu_1 to Vcpu_1, so that there is no mapping relationship between the cpu_1 and other virtual machine CPUs in the virtual machine 102, thereby ensuring the stability of APP_1 running on Vcpu_1.
[0055] For example, FIG3 is a schematic diagram of the hardware structure of a computing device of the host machine 101. Taking a server as an example, the computing device can be a high-density server, a rack server, or a whole cabinet server in terms of form; and can be a general-purpose server, a GPU (graphics processing unit) server, or an artificial intelligence (AI) server in terms of performance.
[0056] The hardware of the computing device includes a CPU, an out-of-band controller, and a memory, while the software includes an out-of-band management module and an operating system (OS).
[0057] The out-of-band management module runs within the out-of-band controller, and the OS runs within the processor (as shown in FIG3 ). The out-of-band management module may be a management unit for a non-business module. For example, the out-of-band management module may remotely maintain and manage the computing device via a dedicated data channel. The out-of-band management module is completely independent of the computing device's operating system and may communicate with the OS via the computing device's out-of-band management interface. The OS may include virtual machines, specifically virtual machine 102.
[0058] Exemplarily, the out-of-band management module may include a management unit for computing device operating status, a management system in a management chip outside the in-band controller, a system management module (SMM), etc. It should be noted that the embodiments of the present application do not limit the specific form of the out-of-band management module, and the above description is merely exemplary.
[0059] Among them, the memory, also known as internal memory or main memory, is installed in the memory slot on the motherboard of the computing device. The memory communicates with the memory controller through a memory channel.
[0060] It should be noted that the system architecture and application scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0061] An embodiment of the present application provides a method for binding a core to a virtual machine, as shown in FIG4 , the method includes: S110 - S130 .
[0062] S110: Determine whether a first binding operation exists in the target virtual machine.
[0063] The target virtual machine is any one of the multiple virtual machines running in the host machine; for example, as shown in FIG. 2 , the target virtual machine is the virtual machine 102 running in the host machine 101 .
[0064] It should be noted that there are multiple virtual CPUs in the target virtual machine, wherein the multiple virtual CPUs are mapped from the physical CPUs in the host machine, and the target virtual machine schedules the CPU resources of the physical CPU on the host machine through the virtual CPUs thereon.
[0065] The above-mentioned first binding operation is used to specify the target virtual CPU for running the target application from the multiple virtual CPUs of the above-mentioned target virtual machine; that is, the above-mentioned first binding operation is an operation for specifying which virtual CPU in the target virtual machine the target application runs on; wherein, the first binding operation includes the identifier of the target virtual CPU.
[0066] It should be understood that when the user triggers the first binding operation, the target virtual machine calls the scheduler in the target virtual machine through the core binding interface to bind the target application to the target virtual CPU in the target virtual machine.
[0067] It should be noted that when an application on a virtual machine is bound to the virtual CPU on the virtual machine, the application will only run on the virtual CPU to which it is bound; for example, as shown in Figure 2, when APP_1 in virtual machine 102 is bound to the virtual machine CPU (i.e., Vcpu_1) in virtual machine 102, the APP_1 will only run on Vcpu_1 during runtime and will not run on other virtual CPUs.
[0068] The implementation method of the above-mentioned S110 includes: the OS of the host machine uses an interceptor to intercept the above-mentioned first binding operation in the target virtual machine; wherein, when the interceptor intercepts the first binding operation, the OS of the above-mentioned host machine determines that the above-mentioned first binding operation exists in the target virtual machine; when the interceptor does not intercept the first binding operation, the OS of the above-mentioned host machine determines that the above-mentioned first binding operation does not exist in the target virtual machine.
[0069] In one implementation, the interceptor is a hook function injected into an access point in the kernel of the target virtual machine, where the access point is used to identify a first binding operation in the target virtual machine; wherein the hook function is implemented based on an extended Berkeley packet filter (eBPF) or a kprobe.
[0070] The access point in the above-mentioned kernel is a special access point, such as the access point is the core binding interface in the kernel of the target virtual machine; the core binding interface is used to implement the binding of the application on the virtual machine with the virtual CPU on the virtual machine; that is, when the above-mentioned first binding operation is triggered, the target virtual machine will call the core binding interface to implement the binding of the application with the above-mentioned virtual CPU; and the embodiment of the present application injects a hook function into the core binding interface to obtain the first binding operation.
[0071] It should be understood that after the above-mentioned hook function intercepts the above-mentioned first binding operation on the target virtual machine, it needs to send the first binding operation to the host machine. The specific implementation method can be that the hook function sends the information of the first binding operation to the kernel state of the host machine by calling the communication interface between the virtual machine and the host machine OS (such as: hypercall interface or writemsr interface). The information of the first binding operation is used to describe the first binding operation. The first binding operation can also be sent to the user state of the host machine through a simulation device, wherein the simulation device is a virtual device simulated by the host machine. The information of the first binding operation can also be sent to the host machine by calling the host machine's IP address. The specific embodiments of this application do not specifically limit it.
[0072] The specific implementation of the above-mentioned hook function-based sending of the above-mentioned first binding operation (including: the identifier of the target virtual CPU and the operation identifier) to the kernel state (i.e., the kernel) on the host machine includes: the target virtual machine intercepts the above-mentioned first binding operation from the core binding interface in the kernel of the target virtual machine based on the extended Berkeley Packet Filter (ebpf) or kprobe; then, the target virtual machine sends the first binding operation to the KVM module in the kernel of the host machine by calling the communication interface between the virtual machine and the OS of the host machine (such as: hypercall interface or writemsr interface), and the KVM module parses the first binding operation; finally, the core binding processing module in the kernel of the host machine obtains the parsed first binding operation from the KVM module, so that the kernel of the host machine obtains the first binding operation.
[0073] It should be understood that, when the target virtual machine intercepts the above-mentioned first binding operation based on the eBPF in its kernel, it is necessary to load the running logic of the eBPF hook function from the user state to the kernel (i.e., kernel state) of the target virtual machine through the user state processing module in the user state of the target virtual machine; then, the target virtual machine sends the first binding operation to the KVM module in the above-mentioned host machine kernel based on the communication interface called in the hook function.
[0074] The specific implementation of sending the first bind operation to the host's user state via the host machine's simulated device includes: the target virtual machine intercepts the first bind operation from the kernel binding interface in the target virtual machine's kernel based on eBPF; then, the target virtual machine sends the binding information to the KVM module in the host machine's kernel via a simulated driver; finally, the simulated device in the host machine's user state retrieves the parsed first bind operation from the KVM, thereby allowing the host machine's user state to obtain the first bind operation. The simulated device is a virtual device (such as a virtual serial port or virtual PCI) simulated by the host machine via a virtual operating system emulator (Quick EMUlator, QEMU), and the simulated driver is the driver used by the target virtual machine to operate the simulated device.
[0075] It should be noted that the above-mentioned interceptor can be triggered before the above-mentioned target application is bound to the target virtual CPU, or it can be triggered after the target application is bound to the target virtual CPU, and the specific embodiments of this application do not specifically limit it.
[0076] The above embodiment intercepts the first binding operation through ebpf or kprobe, so there is no need to rewrite the kernel code of the virtual machine, thereby reducing the workload of code maintenance.
[0077] When the OS of the host machine determines that the first binding operation does not exist in the target virtual machine, an ending action is performed to end the current method flow.
[0078] When the OS of the host machine determines that the first binding operation exists in the target virtual machine, the OS of the host machine executes the following S120 - S130 .
[0079] S120: Determine the physical CPU pool corresponding to the target virtual CPU in the host machine.
[0080] The physical CPU pool includes a physical CPU that has a mapping relationship with the target virtual CPU. That is, the physical CPU to which the target virtual CPU belongs is the physical CPU.
[0081] The implementation method of the above-mentioned S120 includes: the OS of the host machine obtains the above-mentioned physical CPU pool according to the identifier of the target virtual CPU. Specifically, the OS of the host machine determines the physical CPU corresponding to the identifier of the target virtual CPU in the first mapping relationship as the above-mentioned physical CPU pool; wherein, the first mapping relationship includes the mapping relationship between the virtual CPU in the above-mentioned target virtual machine and the physical CPU in the host machine.
[0082] It should be noted that the above-mentioned first mapping relationship can be a mapping table of virtual CPU resources and physical CPU resources. The first mapping relationship is used by the virtual machine to schedule the physical CPU resources in the host machine, that is, the first mapping relationship is used to allocate the physical CPU resources in the host machine to the virtual CPU in the virtual machine; that is, the first mapping relationship records the mapping relationship between each virtual CPU in the target virtual machine and the physical CPU in the host machine, so that when the virtual machine needs to use CPU resources, it calls the physical CPU resources corresponding to the virtual CPU through the virtual CPU.
[0083] For example, assume that the first mapping relationship is as shown in Table 1 below, including three virtual CPUs and three physical CPUs. The three virtual CPUs include Vcpu_1, Vcpu_2, and Vcpu_3; and the three physical CPUs include cpu_1, cpu_2, and cpu_3. The physical CPUs corresponding to Vcpu_1 include cpu_1 and cpu_2; the physical CPUs corresponding to Vcpu_2 include cpu_1, cpu_2, and cpu_3; and the physical CPUs corresponding to Vcpu_3 include cpu_2 and cpu_3.
[0084] When the target virtual CPU is Vcpu_1, the physical CPU pool includes cpu_1 and cpu_2; when the target virtual CPU is Vcpu_2, the physical CPU pool includes cpu_1, cpu_2 and cpu_3; when the target virtual CPU is Vcpu_3, the physical CPU pool includes cpu_2 and cpu_3.
[0085] Table 1
[0086] S130: Perform a second binding operation on the target physical CPU and the target virtual CPU in the physical CPU pool.
[0087] The above-mentioned target physical CPU can be any one or more physical CPUs in the physical CPU pool, or one or more physical CPUs specified in the physical CPU pool; it can also be a physical CPU in the above-mentioned physical CPU pool that has no mapping relationship with other virtual CPUs in the target virtual machine. The specific embodiments of this application do not specifically limit it.
[0088] All CPU resources in the target physical CPU after the second binding operation is performed are allocated to the target virtual CPU for use.
[0089] It should be noted that when the target physical CPU is a physical CPU in the physical CPU pool that has no mapping relationship with other virtual CPUs in the target virtual machine, the specific implementation of determining the target physical CPU is described in S350 below and will not be repeated here.
[0090] In the case where the target physical CPU is a designated physical CPU in the physical CPU pool (e.g., the first physical CPU in the physical CPU pool) or any physical CPU, the implementation of S130 is as follows:
[0091] The host machine's OS determines a target physical CPU from the physical CPU pool, and then updates the first mapping relationship based on the target physical CPU to obtain an updated first mapping relationship (hereinafter referred to as a second mapping relationship); the target virtual CPU in the second mapping relationship has a one-to-one mapping relationship with the target physical CPU. In other words, the host machine's OS removes the mapping relationship between the target virtual CPU in the first mapping relationship and the physical CPUs other than the target physical CPU in the physical CPU pool, and removes the mapping relationship between the target physical CPU and the virtual CPUs other than the target virtual CPU in the target virtual machine, so that the target virtual CPU in the second mapping relationship has a one-to-one mapping relationship with the target physical CPU.
[0092] For example, assuming the first mapping relationship is as shown in Table 1 above, and further assuming the target virtual CPU is Vcpu_1 and the target physical CPU is cpu_2, the host OS updates the first mapping relationship to obtain the second mapping relationship shown in Table 2 below. In this second mapping relationship, the physical CPU corresponding to Vcpu_1 is cpu_2, the physical CPUs corresponding to Vcpu_2 are cpu_1 and cpu_3, and the physical CPU corresponding to Vcpu_3 is cpu_3. At this point, the CPU resources in cpu_2 are exclusively occupied by Vcpu_1.
[0093] Table 2
[0094] In the case where the target physical CPUs are any multiple physical CPUs in the physical CPU pool or multiple specified physical CPUs, the implementation of S130 is as follows:
[0095] The host machine OS updates the first mapping relationship to obtain a second mapping relationship; the target physical CPU in the second mapping relationship only has a mapping relationship with the target virtual CPU, and the target virtual CPU also only has a mapping relationship with the target physical CPU.
[0096] For example, assuming the first mapping relationship is as shown in Table 1 above, and further assuming the target virtual CPU is Vcpu_1, and the target physical CPUs are cpu_1 and cpu_2, the host OS updates the first mapping relationship to obtain the second mapping relationship shown in Table 3 below. In this second mapping relationship, the physical CPUs corresponding to Vcpu_1 include cpu_1 and cpu_2, and the physical CPUs corresponding to Vcpu_2 and Vcpu_3 are both cpu_3. At this time, the CPU resources in cpu_1 and cpu_2 are occupied solely by Vcpu_1.
[0097] Table 3
[0098] In the case where the target physical CPU is a physical CPU in the physical CPU pool that has no mapping relationship with other virtual CPUs, the implementation method of the above S130 and the type of implementation method of the S130 when the target physical CPU is any one or more physical CPUs in the physical CPU pool are not repeated here.
[0099] The above embodiment determines a physical CPU in the physical CPU pool that has no mapping relationship with other virtual CPUs in the target virtual machine as the target physical CPU, and uses all the CPU resources of the target physical CPU for the above target virtual machine, so that the physical CPU to which the target virtual CPU belongs is the target physical CPU (that is, there is a one-to-one mapping relationship between the target CPU and the target physical CPU). Therefore, the problem of reducing the stability of other applications in the target virtual machine due to updating the above first mapping relationship is solved.
[0100] An embodiment of the present application provides a method for binding a virtual machine core, the method comprising: the host machine's OS determines whether a first binding operation exists in the target virtual machine, the first binding operation being used to specify a target virtual CPU in the target virtual machine for running a target application; in the case where the first binding operation exists in the target virtual machine, the host machine's OS determines a physical CPU pool corresponding to the target virtual CPU in the host machine; the physical CPU pool includes a physical CPU; the host machine's OS performs a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU, so that all resources of the target physical CPU after the second binding operation are allocated to the target virtual CPU for use, so that other virtual CPUs no longer occupy the CPU resources in the target physical CPU, thereby improving the stability of the target application running on the target virtual CPU.
[0101] Optionally, after the above 130, when it is necessary to unbind the binding relationship between the above target application and the above target virtual CPU, the virtual machine core binding method provided in the embodiment of the present application further includes: S210-S220 as shown in FIG5 .
[0102] S210: Determine whether there is an unbinding operation in the target virtual machine.
[0103] The above-mentioned unbinding operation is an operation used to release the binding relationship between the above-mentioned target application and the target virtual CPU; wherein, the unbinding operation can be triggered by the user on the target virtual machine, or it can be triggered automatically by the target virtual machine. The specific embodiment of this application does not limit the subject that triggers the unbinding operation.
[0104] When the above-mentioned unbinding operation is automatically triggered by the target virtual machine, the triggering condition may be that the load pressure of the target application is less than the preset load pressure, thereby triggering the unbinding operation; or the target application may be in an idle state (i.e., a state where no task is executed) for a time period greater than a preset time period, thereby triggering the unbinding operation; specifically, the embodiments of the present application do not limit the conditions for triggering the unbinding operation.
[0105] It should be noted that the implementation method of the above-mentioned S210 includes: the host machine's OS uses an interceptor to intercept the above-mentioned unbinding operation in the target virtual machine, wherein the interceptor is a hook function injected into the unbinding interface of the target virtual machine, and the unbinding interface is used to release the binding relationship between the application and the virtual CPU on the target virtual machine; its specific implementation method of S210 is similar to the implementation method of the above-mentioned S110. For the specific description of S210, please refer to the above-mentioned description of S110, which will not be repeated here.
[0106] In the case that there is no unbinding operation in the target virtual machine, the OS of the host machine executes an ending action to end the current method flow.
[0107] When an unbinding operation occurs in the target virtual machine, the following S220 is executed.
[0108] S220: Release the target virtual CPU from using at least a portion of the resources of the target physical CPU.
[0109] In one implementation, the implementation of the above S220 includes: the OS of the host machine updates the second mapping relationship to the above first mapping relationship; specifically, the OS of the host machine backs up the above first mapping relationship before the above S130, and when it is determined that there is an unbinding operation in the target virtual machine, uses the backed up first mapping relationship to replace the above second mapping relationship currently existing in the host machine.
[0110] Exemplarily, assuming that the second mapping relationship of the above S130 is as shown in Table 2 above, and the first mapping relationship of the host machine's OS backup is as shown in Table 1 above, at this time, the host machine's OS uses the first mapping relationship shown in Table 1 above to replace the second mapping relationship in the host machine.
[0111] In another implementation, the implementation of S220 includes: the host machine's OS updates the physical CPU to which the target virtual CPU belongs (i.e., the target physical CPU) so that the physical CPU to which the updated target virtual CPU belongs is a CPU in the physical CPU pool in S120. Specifically, the host machine's OS stores the identifiers of all physical CPUs in the physical CPU pool determined in S120 before S130; and when it is determined that an unbinding operation has occurred in the target virtual machine, updates the second mapping relationship based on the identifiers of the physical CPUs in the physical CPU pool so that the physical CPU corresponding to the target virtual CPU in the updated second mapping relationship (referred to as the third mapping relationship) is a physical CPU in the physical CPU pool.
[0112] For example, assume that the physical CPU identifiers in the physical CPU pool stored by the host machine's OS include cpu_1 and cpu_2; and further assume that the second mapping relationship in the current host machine is as shown in Table 2 above. Then, the host machine's OS updates the second mapping relationship shown in Table 2 above based on cpu_1 and cpu_2, resulting in a third mapping relationship as shown in Table 4 below. In this third mapping relationship, the physical CPUs corresponding to Vcpu_1 include cpu_1 and cpu_2, the physical CPUs corresponding to Vcpu_2 include cpu_1 and cpu_3, and the physical CPU corresponding to Vcpu_3 includes cpu_3.
[0113] Table 4
[0114] In yet another implementation, the implementation of S220 includes: the host machine OS updates the second mapping relationship so that the target physical CPU in the second mapping relationship (abbreviated as: fourth mapping relationship) corresponds to multiple virtual CPUs.
[0115] For example, assuming that the current second mapping relationship in the host machine is as shown in Table 2 above, and assuming that the target physical CPU corresponding to the above-mentioned target virtual CPU is cpu_2; then, at this time, the OS of the host machine adds the mapping relationship between cpu_2 and Vcpu_3 to the second mapping relationship shown in Table 2, and obtains the fourth mapping relationship shown in Table 5 below, in which the physical CPU corresponding to Vcpu_1 includes cpu_2, the physical CPU corresponding to Vcpu_2 includes cpu_1 and cpu_3, and the physical CPU corresponding to Vcpu_3 includes cpu_2 and cpu_3.
[0116] Table 5
[0117] In the above embodiment, when it is determined that an unbinding operation occurs in the target virtual machine, the target virtual CPU releases at least a portion of the resources of the target physical CPU to allow other virtual CPUs to occupy them, thereby improving the stability of other applications in the target virtual machine.
[0118] Based on the virtual machine core binding method shown in FIG4 , an embodiment of the present application provides a specific implementation method, as shown in FIG6 , the method includes: S310 - S360 .
[0119] S310: The target virtual machine obtains a first binding operation of the user on the target application.
[0120] It should be understood that the description of the above-mentioned target virtual machine, target application and first binding operation is consistent with the description of the target virtual machine, target application and first binding operation in the above-mentioned S110. For the specific description of the target virtual machine, target application and first binding operation in S310, please refer to the above-mentioned description of S110, which will not be repeated here.
[0121] The target virtual machine can obtain the first binding operation from the configuration file of the virtual machine, or from the binding interface displayed by the display device, or from the configuration file of the target application; that is, the user can configure the first binding operation in the configuration file of the target virtual machine or the configuration file of the target application, and then the target virtual machine obtains the first binding operation from the configuration file during initialization or operation; or the user can input the first binding operation in the binding interface, and then the target virtual machine obtains the first binding operation from the binding interface, wherein the binding interface includes the identifier of the target application and the identifier of the virtual CPU to be bound in the target virtual machine. The specific embodiment of the present application does not specifically limit the implementation method of the above S310.
[0122] S320: The target virtual machine binds the target virtual CPU to the target application in response to the first binding operation.
[0123] The target application after being bound to the target virtual CPU will only run in the target virtual CPU.
[0124] The specific implementation of the above S320 includes: the target virtual machine establishes a correspondence between the target virtual CPU and the target application, that is, the virtual CPU corresponding to the target application is the target virtual CPU; when the subsequent target application is run, the target virtual machine runs the target application on the target virtual CPU based on the correspondence.
[0125] S330: The host OS obtains a first binding operation in the target virtual machine.
[0126] The host OS may intercept the first binding operation when the target virtual machine obtains the first binding operation (ie, S110), or may intercept the first binding operation when the target virtual machine executes S320. Specifically, the embodiment of the present application does not limit the timing of intercepting the first binding operation.
[0127] It should be noted that the implementation method of the above S330 is consistent with the implementation method of S110. For the specific description of S330, please refer to the above description of S310, which will not be repeated here.
[0128] S340: The host OS determines the physical CPU pool corresponding to the target virtual CPU in the host based on the first mapping relationship.
[0129] It should be noted that the implementation method of the above S340 is consistent with the implementation method of S120. For the specific description of S340, please refer to the above description of S120, which will not be repeated here.
[0130] S350: The host OS determines a target physical CPU from the physical CPU pool.
[0131] The target physical CPU is a CPU in the physical CPU pool that has no mapping relationship with other virtual CPUs; the other virtual CPUs are virtual CPUs other than the target virtual CPU in the first mapping relationship.
[0132] The specific implementation of S350 includes: the host machine OS determines the number of virtual CPUs corresponding to each physical CPU in the physical CPU pool, and then the host machine OS determines the physical CPU with the number of corresponding virtual CPUs being 1 as the target physical CPU.
[0133] Exemplarily, assume that the above-mentioned first mapping relationship is as shown in Table 6 below, including 3 virtual CPUs and 4 physical CPUs; the 3 virtual CPUs include Vcpu_1, Vcpu_2 and Vcpu_3; the 4 physical CPUs include: cpu_1, cpu_2, cpu_3 and cpu_4; among them, the physical CPUs corresponding to Vcpu_1 include: cpu_1, cpu_2 and cpu_4, the physical CPUs corresponding to Vcpu_2 include: cpu_1, cpu_2 and cpu_3, and the physical CPUs corresponding to Vcpu_3 include: cpu_2 and cpu_3.
[0134] Assume that the target virtual CPU is Vcpu_1; then the above-mentioned physical CPU pool includes: cpu_1, cpu_2 and cpu_4; at this time, the host machine's OS determines that the number of virtual CPUs corresponding to cpu_1 is 2 (i.e.: Vcpu_1 and Vcpu_2), the number of virtual CPUs corresponding to cpu_2 is 3 (i.e.: Vcpu_1 to Vcpu_3), the number of virtual CPUs corresponding to cpu_3 is 2 (i.e.: Vcpu_2 and Vcpu_3), and the number of virtual CPUs corresponding to cpu_4 is 1 (i.e.: Vcpu_1); then, the host machine's OS determines cpu_4 as the target physical CPU.
[0135] Table 6
[0136] S360: The host OS updates the first mapping relationship to obtain a second mapping relationship.
[0137] It should be noted that the implementation method of the above S360 is consistent with the implementation method of S130. For the specific description of S360, please refer to the above description of S130, which will not be repeated here.
[0138] It should be understood that the above-mentioned target virtual machine can execute the above-mentioned S320 before the host machine's OS executes the above-mentioned S330-S360; or the host machine's OS can execute the above-mentioned S330-S360 first, and then the target virtual machine executes the above-mentioned S320; or the target virtual machine can execute S320 while the host machine's OS executes S330-S360; specifically, the embodiments of the present application do not limit the execution order of S320 and the above-mentioned S330-S360.
[0139] An embodiment of the present application includes the following steps: when a target virtual machine obtains a first binding operation of a user on a target application, and in response to the first binding operation, binds the target application to a target virtual CPU; then, the host machine's OS obtains the first binding operation and determines a physical CPU pool corresponding to the target virtual CPU based on a first mapping relationship, and thereafter, the host machine's OS determines a target physical CPU from the physical CPU pool that has no mapping relationship with other virtual CPUs; finally, all CPU resources of the target physical CPU are allocated to the target virtual CPU for use, and the physical CPU to which the target virtual CPU belongs is made the target physical CPU; thereby, other virtual CPUs no longer compete with the target virtual CPU for CPU resources in the physical CPU pool, thereby improving the stability of the target application running on the target virtual CPU.
[0140] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of method. In order to realize the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a hardware or computer software driven hardware manner depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0141] The embodiment of the present application can divide the computing device into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. In actual implementation, there may be other division methods.
[0142] In the case of dividing each functional module into corresponding functional modules, a virtual machine core binding device is shown in FIG7 . As shown in FIG7 , the virtual machine core binding device includes: a determining unit 701 and a binding unit 702 .
[0143] The determining unit 701 is configured to determine whether a first binding operation exists in the target virtual machine; for example, by executing step S110 in the above method embodiment.
[0144] The determining unit 701 is configured to determine the physical CPU pool corresponding to the target virtual CPU in the host machine when the first binding operation occurs in the target virtual machine; for example, executing step S120 in the above method embodiment.
[0145] The binding unit 702 is configured to perform a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU; for example, executing step S130 in the above method embodiment.
[0146] Optionally, the determining unit 701 is configured to determine a physical CPU pool corresponding to the target virtual CPU in the host machine based on the first mapping relationship; for example, executing step S340 in the above method embodiment.
[0147] Optionally, the above-mentioned virtual machine core binding device further includes: an updating unit 703; the updating unit 703 is used to update the first mapping relationship based on the target physical CPU to obtain a second mapping relationship; for example, execute step S360 in the above-mentioned method embodiment.
[0148] Optionally, the determining unit 701 is configured to determine a target physical CPU from a physical CPU pool; for example, executing step S350 in the above method embodiment.
[0149] Optionally, the virtual machine core binding apparatus further includes a transceiver unit 704 configured to intercept the first binding operation in the target virtual machine. The determination unit 701 is configured to, if the first binding operation is intercepted in the target virtual machine, determine that the first binding operation exists in the target virtual machine; and the determination unit 701 is further configured to, if the first binding operation is not intercepted in the target virtual machine, determine that the first binding operation does not exist in the target virtual machine.
[0150] Optionally, the transceiver unit 704 is configured to intercept the first binding operation in the target virtual machine based on a hook function.
[0151] Optionally, the transceiver unit 704 is configured to obtain the first binding operation in the kernel of the target virtual machine based on the hook function. The transceiver unit 704 is further configured to transmit the first binding operation information to the kernel of the host machine via a communication interface between the target virtual machine and the host machine operating system; or to transmit the first binding operation information to the user state of the host machine via an emulated device.
[0152] Optionally, the above-mentioned virtual machine core binding device further includes: an unbinding unit 705; a determining unit 701 is used to determine whether an unbinding operation exists in the target virtual machine; for example, executing step S210 in the above-mentioned method embodiment.
[0153] The unbinding unit 705 is configured to release the target virtual CPU from using at least a portion of the resources of the target physical CPU when an unbinding operation occurs in the target virtual machine; for example, executing step S220 in the above method embodiment.
[0154] Optionally, the updating unit 703 is configured to update the second mapping relationship to the first mapping relationship.
[0155] Each unit of the above-mentioned virtual machine core binding device can also be used to perform other actions in the above-mentioned method embodiment. All relevant contents of each step involved in the above-mentioned method embodiment can be referred to the functional description of the corresponding functional unit and will not be repeated here.
[0156] An embodiment of the present application also provides a computing device, including a memory and a processor, wherein the memory is electrically connected to the processor; the memory is used to store program instructions, and the processor executes the program instructions to implement the virtual machine core binding method in the above-mentioned embodiments and possible implementation schemes thereof.
[0157] An embodiment of the present application also provides a computer-readable storage medium having computer instructions stored thereon. When the computer instructions are executed on a computing device, the computing device executes the virtual machine core binding method in the above-mentioned embodiments and possible implementation schemes thereof.
[0158] For explanations of the relevant contents and descriptions of the beneficial effects of any of the computer-readable storage media provided above, reference may be made to the corresponding embodiments described above, and no further details will be given here.
[0159] An embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the virtual machine core binding method in the above-mentioned embodiments and possible implementations thereof.
[0160] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using a software program, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions in accordance with the embodiments of the present application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a magnetic medium (eg, a floppy disk, a magnetic disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state drive (SSD)).
[0161] Through the description of the above embodiments, those skilled in the art will clearly understand that for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working processes of the above-described systems, devices, and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0162] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0163] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0164] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0165] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash memory, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk.
[0166] The above is only a specific embodiment of the present application, but the scope of protection of this application is not limited to this. Any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A method for binding a core to a virtual machine, characterized in that: The method comprises: Determining whether a first binding operation exists in a target virtual machine; the target virtual machine is any one of a plurality of virtual machines running in a host machine; the first binding operation is used to specify a target virtual CPU from a plurality of virtual CPUs of the target virtual machine, the target virtual CPU being used to run a target application; In a case where the first binding operation exists in the target virtual machine, determining a physical CPU pool corresponding to the target virtual CPU in the host machine; the physical CPU pool includes a physical CPU; Performing a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU; The target physical CPU is any one or more physical CPUs in the physical CPU pool, and after the second binding operation, all resources of the target physical CPU are allocated to the target virtual CPU for use.
2. The method according to claim 1, characterized in that Determining the physical CPU pool corresponding to the target virtual CPU in the host machine includes: Based on the first mapping relationship, determine the physical CPU pool corresponding to the target virtual CPU in the host machine; the first mapping relationship includes a mapping relationship between the virtual CPU in the target virtual machine and the physical CPU in the host machine; the first mapping relationship is used to allocate physical CPU resources in the host machine to the virtual CPU in the virtual machine.
3. The method according to claim 2, characterized in that The performing a second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU includes: Based on the target physical CPU, updating the first mapping relationship to obtain a second mapping relationship; Wherein, in the second mapping relationship, the target physical CPU and the target virtual CPU are in a one-to-one mapping relationship.
4. The method according to claim 2 or 3, characterized in that Before performing the second binding operation on the target physical CPU in the physical CPU pool and the target virtual CPU, the method further includes: The target physical CPU is determined from the physical CPU pool; wherein, in the first mapping relationship, there is no mapping relationship between the target physical CPU and other virtual CPUs.
5. The method according to any one of claims 1 to 4, characterized in that Determining whether a first binding operation exists in the target virtual machine includes: The first binding operation is intercepted in the target virtual machine.
6. The method according to claim 5, characterized in that The intercepting the first binding operation in the target virtual machine includes: The first binding operation is intercepted in the target virtual machine based on a hook function; the hook function is injected into an access point of the kernel of the target virtual machine, and the access point is used to identify the first binding operation of the target virtual machine; the hook function is implemented based on ebpf or kprobe.
7. The method according to claim 5 or 6, characterized in that The intercepting the first binding operation in the target virtual machine based on the hook function includes: Obtaining the first binding operation in the kernel of the target virtual machine based on the hook function; Transmitting the first binding operation information to the kernel of the host machine through a communication interface between the target virtual machine and the host machine operating system; or, The first binding operation information is transmitted to the user state of the host machine through a simulation device; wherein the simulation device is a virtual device simulated by the host machine.
8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: Determine whether an unbinding operation exists in the target virtual machine; the unbinding operation is used to release the binding relationship between the target application and the target virtual CPU; In a case where an unbinding operation occurs in the target virtual machine, the target virtual CPU is released from using at least a portion of the resources of the target physical CPU.
9. The method according to claim 8, characterized in that The releasing, by the target virtual CPU, of at least a portion of the resources of the target physical CPU, includes: The second mapping relationship is updated to the first mapping relationship.
10. A computing device, characterized in that The computing device includes a memory and a processor; The memory is electrically connected to the processor; The memory is used to store program instructions, The processor is used to execute the program instructions so that the computing device implements the virtual machine core binding method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Cloud platform virtual CPU hot binding method and device and computer readable storage medium
CN112711462A
Processor affinity management method and device of process and electronic equipment
CN116560791A
Virtual machine core binding method and computing device
CN118210593A
Resource pooling in a virtualized cloud container environment
US20180329757A1