WO2015192381A1 - 虚拟化平台处理中断方法和相关设备 - Google Patents

虚拟化平台处理中断方法和相关设备 Download PDF

Info

Publication number
WO2015192381A1
WO2015192381A1 PCT/CN2014/080430 CN2014080430W WO2015192381A1 WO 2015192381 A1 WO2015192381 A1 WO 2015192381A1 CN 2014080430 W CN2014080430 W CN 2014080430W WO 2015192381 A1 WO2015192381 A1 WO 2015192381A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
vcpus
pcpus
vcpu
interrupt
Prior art date
Application number
PCT/CN2014/080430
Other languages
English (en)
French (fr)
Inventor
张浩宇
藏洪永
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP14894974.6A priority Critical patent/EP3147784A4/en
Priority to CN201480079053.5A priority patent/CN106462451B/zh
Priority to JP2016574176A priority patent/JP2017518589A/ja
Priority to KR1020177000348A priority patent/KR101847518B1/ko
Priority to PCT/CN2014/080430 priority patent/WO2015192381A1/zh
Publication of WO2015192381A1 publication Critical patent/WO2015192381A1/zh
Priority to US15/384,961 priority patent/US10169075B2/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4812Task transfer initiation or dispatching by interrupt, e.g. masked
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Definitions

  • Embodiments of the present invention relate to the field of communication technologies, and, more particularly, to a virtualization platform processing interrupt method and related device. Background technique
  • Virtualization technology is a decoupling technique that separates the underlying hardware devices from the upper operating system and applications.
  • virtualization technology can greatly improve the resource utilization efficiency of physical devices. Compared with the traditional physical server, the virtual machine has better isolation and encapsulation. It can save the information of the entire virtual machine to the virtual disk image (VDI, Virtual Disk Image), so that the virtual machine can be conveniently used. Operations such as snapshots, backups, clones, and distributions. Because virtualization introduces overhead, the performance of virtual machines in the same configuration is lower than that of physical machines. How to effectively improve the performance of virtual machines is a problem that needs to be solved in the field. Summary of the invention
  • the virtualization platform processing interrupt method and related device provided by the embodiments of the present invention can reduce the impact of the disconnection pin on the virtualization platform, thereby effectively improving the performance of the virtual machine.
  • a virtualization platform processing interrupt method is applied to a computing node, where the computing node includes: a physical hardware layer, a host Host running on the physical hardware layer, and running on the host At least one virtual machine VM, the at least one VM is virtualized with virtual hardware, wherein the physical hardware layer includes X physical central processing units pCPU and Y physical input and output devices, and the virtual hardware includes Z virtual central processing And the Y physical input and output devices include a jth physical input and output device, the at least one VM includes a kth VM, and the jth physical input and output device passes through the kth VM, the method is performed by the host, and the method includes The nth pCPU is determined from the U target pCPUs in the case where the ith physical interrupt occurs in the jth physical input/output device, wherein the U target pCPUs have both the i-th physical interrupt and the V target vCPUs a pCPU of the affinity
  • an affinity relationship between the U target pCPUs and the ith physical interrupt, and an affinity relationship between the U target pCPUs and the V target vCPUs And the affinity relationship between the V target vCPUs and the ith virtual interrupt is determined by: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are virtualized a vCPU on the kth VM capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1; determining corresponding to the i th The i-th physical interrupt of the virtual interrupt; determining an affinity relationship between the i-th physical interrupt and the U target pCPUs, wherein the i-th physical interrupt can be processed by the U target pCPUs.
  • an affinity relationship between the U target pCPUs and the ith physical interrupt and an affinity relationship between the U target pCPUs and the V target vCPUs
  • the determining the m vCPU from the V target vCPUs including: determining whether at least one target vCPU of the V target vCPUs is running on the nth pCPU; determining the V running on the nth pCPU In the case of at least one target vCPU in the target vCPU, determining a target vCPU running on the nth pCPU as the m vth CPU; determining that at least one target vCPU of the V target vCPUs is not running on the nth pCPU In the case of priority, a target vCPU is determined from the V target vCPUs as the mth vCPU.
  • determining whether the at least one target vCPU of the V target vCPUs is running on the nth pCPU includes And determining, according to the virtual interrupt routing information, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information includes the U target pCPUs and running on the U target pCPUs The correspondence of the target vCPU.
  • an embodiment of the present invention provides a virtualization platform processing interrupt method, which is applied to a computing node, where the computing node includes: a physical hardware layer, a host host running on the physical hardware layer, and running on the host.
  • the virtual hardware includes Z virtual CPUs vCPU, each of the Y VMs including a paravirtualized driver virtio device, the Y VMs including a kth VM, the kth VM including an i virtio device,
  • the i-irrtio device corresponds to the j-th vhost kernel thread in the Y vhost kernel threads, and the method is executed by the host, the method includes: in the case that the j-th vhost kernel thread triggers the i-th
  • an affinity relationship between the U target pCPUs and the i-th vhost thread, and an affinity relationship between the U target pCPUs and the V target vCPUs And determining, by the following manner, the affinity relationship between the V target vCPUs and the virtual interrupt of the i-th virtio device: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are a vCPU that is virtualized on the kth VM capable of processing a virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs Capable of running on the U target pCPUs, where U is equal to 1; determining an i-th vhost thread corresponding to the virtual interrupt of the i-th virtio device; determining an affinity relationship between the i-th
  • the affinity relationship between the U target pCPUs and the i-th vhost thread, and the affinity relationship between the U target pCPUs and the V target vCPUs And determining, by the following manner, an affinity relationship between the V target vCPUs and the virtual interrupt of the i-virtio device: determining an affinity relationship between the V target vCPUs and a virtual interrupt of the first virito device, wherein the V The target vCPU is a vCPU that is virtualized on the kth VM capable of processing the virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, where U a positive integer greater than 1 and less than or equal to X; determining an i-th vhost thread corresponding to the virtual interrupt of the i-th vir
  • the determining the m vCPU from the V target vCPUs including: determining whether at least one target vCPU of the V target vCPUs is running on the nth pCPU; determining the V running on the nth pCPU In the case of at least one target vCPU in the target vCPU, determining a target vCPU running on the nth pCPU as the m vth CPU; determining that at least one target vCPU of the V target vCPUs is not running on the nth pCPU In the case of priority, a target vCPU is determined from the V target vCPUs as the mth vCPU.
  • determining whether the at least one target vCPU of the V target vCPUs is running on the nth pCPU including Determining, according to the virtual interrupt routing information of the virtio device, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information of the virtio device includes the U target pCPUs and running in the The correspondence between the target vCPUs on the U target pCPUs.
  • an embodiment of the present invention provides a host Host, which is applied to a computing node, where the computing node includes: a physical hardware layer, the host running on the physical hardware layer, and at least running on the Host.
  • a virtual machine VM the at least one VM is virtualized with virtual hardware, wherein the physical hardware layer includes X physical central processing units pCPU and Y physical input and output settings
  • the virtual hardware includes Z virtual CPUs vCPU, the Y physical input and output devices include a jth physical input and output device, the at least one VM includes a kth VM, and the jth physical input and output device passes through the kth VM
  • the Host includes: a first determining unit, configured to determine an nth pCPU from the U target pCPUs in the case that the ith physical interrupt occurs in the jth physical input/output device, where the U target pCPUs are The i-th physical interrupt and the v target vCPUs each
  • the first determining unit is further configured to: determine an affinity relationship between the V target vCPUs and the ith virtual interrupt, where the V The target vCPU is a vCPU that is virtualized on the kth VM capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, where U is equal to 1; Determining an ith physical interrupt corresponding to the ith virtual interrupt; determining an affinity of the ith physical interrupt with the U target pCPUs, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the first determining unit is further configured to: determine an affinity relationship between the V target vCPUs and the ith virtual interrupt, where the V The target vCPU is a vCPU that is virtualized on the kth VM capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, where U is greater than 1 And a positive integer less than or equal to X; determining an ith physical interrupt corresponding to the ith virtual interrupt; determining an affinity relationship between the ith physical interrupt and the U target pCPUs, wherein the ith physical interrupt can be the U Target pCPU processing.
  • the fourth determining unit is specifically configured to: determine whether the V target is running on the nth pCPU At least one target vCPU in the vCPU; running the V on the nth pCPU In the case of at least one target vCPU in the target vCPU, determining a target vCPU running on the nth pCPU as the m vth CPU, so that the kth VM executes the i th virtual interrupt using the m vth CPU; or When it is determined that at least one target vCPU of the V target vCPUs is not running on the nth pCPU, determining a target vCPU from the V target vCPUs as the m vCPU according to the priority order, so as to facilitate the The kth VM executes the ith virtual interrupt using the mth vCPU.
  • the aspect of determining whether to run at least one target vCPU of the V target vCPUs on the nth pCPU is configured to determine, according to the virtual interrupt routing information, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information includes the U target pCPUs The correspondence of the target vCPUs running on the U target pCPUs.
  • an embodiment of the present invention provides a host Host, which is applied to a computing node, where the computing node includes: a physical hardware layer, the host running on the physical hardware layer, and Y running on the host. a virtual machine VM, Y virtual host vhost kernel threads running on the host, virtual virtualization hardware on the at least one VM, wherein the physical hardware layer includes X physical central processing units pCPU, the virtual hardware includes Z virtual CPUs vCPU, X, Y, Z are positive integers greater than 1, each VM of the VMs includes a paravirtualized driver virtio device, the Y VMs including a kth VM, the kth The VM includes an i-irrtio device, and the i-virtio device corresponds to the j-th vhost kernel thread of the Y vhost kernel threads, the host includes: a first determining unit, configured to trigger the i-th vhost in
  • the first determining unit is further configured to: determine an affinity relationship between the V target vCPUs and the ith virtual interrupt, where the V The target vCPU is a vCPU that is virtualized on the kth VM and is capable of processing the virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, where U Equivalent to 1; determining an i-th vhost thread corresponding to the virtual interrupt of the i-th virtio device; determining an affinity relationship between the i-th vhost thread and the U target pCPU, wherein the i-th vhost thread can be the U-target pCPU deal with.
  • the first determining unit is further configured to: determine an affinity relationship between the V target vCPUs and the ith virtual interrupt, where the V a target vCPU is a vCPU that is virtualized on the kth VM capable of processing a virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is a positive integer greater than 1 and less than or equal to X; determining an i-th vhost thread corresponding to the virtual interrupt of the i-th virtio device; determining an affinity relationship between the i-th vhost thread and the U target pCPUs, wherein the first The i vhost thread can be processed by the U target pCPUs.
  • the fourth determining unit is specifically configured to: determine whether the V target is running on the nth pCPU Determining at least one target vCPU in the vCPU; determining that at least one target vCPU of the V target CPUs is running on the nth pCPU, determining a target vCPU running on the nth pCPU as the m vCPU, so that Performing, by the kth VM, the virtual interrupt of the i th virtio device by using the m vCPU; or, if it is determined that at least one target vCPU of the V target vCPUs is not running on the nth pCPU, according to the priority
  • a target vCPU is determined from the V target vCPUs as the m-th vCPU, so that the k-th VM uses the m-th vC
  • the determining whether to run the at least one target vCPU of the V target vCPUs on the nth pCPU is specifically configured to determine, according to the virtual interrupt routing information of the virtio device, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information of the virtio device includes The correspondence between the U target pCPUs and the target vCPUs running on the U target pCPUs.
  • an embodiment of the present invention provides a computing node, where the computing node includes: Y physical input and output devices, where the Y physical input and output devices include a jth physical input and output device, and X physical central processing units, pCPU, a memory respectively connected to the X physical CPUs pCPU and Y physical input and output devices, wherein one or more of the X physical CPUs pCPU are used to call or execute an operation instruction stored in the memory, Host virtual machine VM, at least one virtual machine VM, and virtual virtual hardware on the at least one virtual machine VM, wherein the virtual hardware includes Z virtual CPUs vCPU, the at least one VM includes a kth VM, the jth physical input
  • the output device is directly connected to the kth VM, wherein the host is configured to: determine an nth pCPU from the U target pCPUs in the case that the i th physical intrusion device generates an i th physical interrupt, wherein the
  • the Host is further configured to determine, by using the following manner, an affinity relationship between the U target pCPUs and the ith physical interrupt, the U target pCPUs and An affinity relationship between the V target vCPUs and an affinity relationship between the V target vCPUs and the ith virtual interrupt: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are a vCPU that is virtualized on the kth VM capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, where U is equal to 1; An ith physical interrupt of the ith virtual interrupt; determining an affinity of the ith physical interrupt with the U target pCPUs, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the host is further configured to determine, by using the following manner, an affinity relationship between the U target pCPUs and the ith physical interrupt, the U target pCPUs and An affinity relationship of the V target vCPUs and an affinity relationship between the V target vCPUs and the ith virtual interrupt: determining affinity of the V target vCPUs with the ith virtual interrupt
  • the V target CPU is a vCPU that is virtualized on the kth VM capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs
  • U is a positive integer greater than 1 and less than or equal to X; determining an ith physical interrupt corresponding to the ith virtual interrupt; determining an affinity relationship between the ith physical interrupt and the U target pCPU, wherein the ith Physical interrupts can be handled by the U target pCPUs.
  • the Host in the determining the m vCPU from the V target vCPUs, is specifically used to: determine Whether the at least one target vCPU of the V target vCPUs is running on the nth pCPU; determining that the nth CPU is operated by the at least one target vCPU of the V target vCPUs on the nth pCPU Running a target vCPU as the m-th vCPU; determining that at least one of the V target vCPUs is not running on the n-th pCPU, determining one from the V target vCPUs according to a priority order
  • the target vCPU acts as the mth vCPU.
  • the Host specific For determining, according to the virtual interrupt routing information, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information includes the U target pCPUs and running in the U target pCPUs The corresponding relationship of the target vCPU.
  • an embodiment of the present invention provides a computing node, where the computing node includes: X physical central processing units, pCPU, and a memory connected to the X physical central processing units, pCPU, where the X physical central processing units are in the pCPU.
  • One or more pCPUs for invoking or executing operational instructions stored in the memory, host Host, Y virtual machine VMs, Y virtual host vhost kernel threads, and virtual virtual hardware on the at least one virtual machine VM,
  • the virtual hardware includes Z virtual CPUs vCPU, each of the Y VMs includes a paravirtualized driver virtio device, the Y VMs include a kth VM, and the kth VM includes an i th virtio device.
  • the i-irrtio device corresponds to the j-th vhost kernel thread in the Y vhost kernel threads, wherein the host is used to: from the U target pCPUs in the case that the j-th vhost kernel thread triggers the i-th vhost thread Determining an nth pCPU, wherein the U target pCPUs are pCPUs having affinity with the i-th vhost thread and the V target vCPUs, the V target vCPUs being virtualized on the kth VM
  • the virtual interrupt of the i virtio device has an affinity vCPU
  • the virtual interrupt of the i-irrtio device corresponds to the i-th vhost thread
  • the X pCPUs include the U target pCPUs
  • the Z vCPUs include the V target vCPUs
  • U being greater than or equal to 1 and less than or equal to X a positive
  • the host is further configured to determine an affinity relationship between the U target pCPUs and the ith physical interrupt by using the U target pCPUs and An affinity relationship between the V target vCPUs and an affinity relationship between the V target vCPUs and the ith virtual interrupt: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are a vCPU virtualized on the kth VM capable of processing a virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1; Determining an i-th vhost thread corresponding to the virtual interrupt of the i-th virtio device; determining an affinity relationship between the i-th vhost thread and the U target pCPUs, wherein
  • the host is further configured to determine an affinity relationship between the U target pCPUs and the ith physical interrupt by using the U target pCPUs and An affinity relationship between the V target vCPUs and an affinity relationship between the V target vCPUs and the ith virtual interrupt: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are a vCPU virtualized on the kth VM capable of processing a virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is greater than 1 And a positive integer less than or equal to X; determining an i-th vhost thread corresponding to the virtual interrupt of the i-th virtio device; determining an affinity relationship between the i-th vhost
  • the Host in the determining the m vCPU from the V target vCPUs, is specifically configured to: determine Whether at least one target vCPU of the V target vCPUs is running on the nth pCPU; at least one of the V target vCPUs running on the nth pCPU is determined to be determined In the case of the vCPU, determining a target vCPU running on the nth pCPU as the m vCPU; and determining that at least one of the V target vCPUs is not running on the nth pCPU, according to the priority The order of the levels, determining a target vCPU from the V target vCPUs as the mth vCPU.
  • the aspect of determining whether to run the at least one target vCPU of the V target vCPUs on the nth pCPU is specifically configured to: determine, according to the virtual interrupt routing information of the virtio device, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information of the virtio device includes the U The correspondence between the target pCPU and the target vCPU running on the U target pCPUs.
  • the nth pCPU is determined from the U target pCPUs in the case where the ith physical interrupt occurs in the jth physical input/output device, wherein the U target pCPUs are related to the ith physical interrupt And a vCPU having an affinity V relationship, wherein the V target vCPUs are vCPUs that are virtualized on the kth VM and have an affinity relationship with the ith virtual interrupt, and the ith virtual interrupt corresponds to the ith a physical interrupt, the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs; processing the ith physical interrupt using the nth pCPU; determining the ith virtual interrupt according to the ith physical interrupt Determining the m-th CPU from the V target vCPUs, so that the k-th VM uses the m-th vCPU to execute the ith virtual interrupt, it can be seen
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs are the i-th vhost
  • the thread and the V target CPUs each have an affinity pCPU
  • the V target vCPUs are vCPUs that are virtualized on the kth VM and have affinity with the virtual interrupt of the i-irrtio device, the i-virtio device
  • the virtual interrupt corresponds to the i-th vhost thread
  • the X pCPUs include the U target pCPUs
  • the Z vCPUs include the V target vCPUs
  • the i-th vhost thread is processed by the n-th pCPU; according to the i-th vhost thread Determining a virtual interrupt of the i-th virtio device; determining
  • Figure 1 is a schematic diagram of a through mode.
  • Figure 2 is a schematic illustration of a front-end mode.
  • Figure. ; "
  • FIG. 4 is a schematic diagram of a virtual interrupt, a physical interrupt, a vCPU, and a pCPU according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of another virtual interrupt, a physical interrupt, a vCPU, and a pCPU according to an embodiment of the present invention.
  • FIG. 6 is a schematic flow diagram of another virtualization platform processing interrupt method provided in accordance with the present invention.
  • FIG. 7 is a schematic diagram of a virtual interrupt, a vhost thread, a vCPU, and a pCPU of a virtio device according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of a virtual interrupt, a vhost thread, a vCPU, and a pCPU of another virtio device according to an embodiment of the present invention.
  • FIG. 10 is a structural block diagram of another host host according to an embodiment of the present invention.
  • FIG. 11 is a structural block diagram of a computing node according to an embodiment of the present invention.
  • FIG. 12 is a structural block diagram of another computing node according to an embodiment of the present invention. detailed description
  • One or more computing nodes can be simulated on a physical computing node by virtual machine software, where the physical computing nodes can be servers, desktop computers, portable computers, and the like.
  • the simulated compute nodes are called virtual machines (VMs).
  • This physical compute node is called a sink host.
  • Virtual machines can work like real compute nodes.
  • the operating system and applications can be installed on the virtual machine. Virtual machines also have access to network resources.
  • the operating system running on a virtual machine is called a virtual operating system.
  • a program running in a virtual operating system is like an operating system running on a real compute node.
  • Virtual machines can also be virtualized with virtual hardware. Specifically, this virtual virtual hardware is simulated on the VM by a host, such as a virtual central processing unit (vCPU).
  • vCPU virtual central processing unit
  • the vCPU is used to process programs running in a virtual machine.
  • One or more vCPUs may correspond to a Central Processing Unit (CPU) in the physical computing node.
  • the CPU in the physical compute node can be called a physical CPU (physical CPU, pCPU pCPU can have a guest state and a host state.
  • pCPU When the virtual machine is running, the pCPU is in the guest state. Due to special instructions or external interrupts, etc.
  • the pCPU can be switched from the guest state to the host state. This process can be called virtual machine exit (VM-Exit).
  • VM-Exit virtual machine exit
  • Virtual devices can be implemented in pass-through mode and front-end mode.
  • the direct mode also known as the assthrough mode, means that the host provides a device isolation to a particular virtual machine so that a particular physical input and output device can be used exclusively by a particular virtual machine.
  • the pass-through mode if the pCPU corresponding to the vCPU that handles the virtual interrupt does not match the pCPU that handles the physical interrupt corresponding to the virtual interrupt, it causes VM-Exit caused by an additional Inter-Processor Interrupt (IPI).
  • IPI Inter-Processor Interrupt
  • the split driver mode refers to the completion of the virtual device driver through the front-end driver and the back-end driver.
  • the front-end driver is in the virtual machine
  • the back-end driver is in the host.
  • the front and back drives drive data through shared memory.
  • the front-end driver mode has a higher level of abstraction and better performance.
  • In the front-end mode there is one device (virtio device) using a paravirtualized driver (virtio) in each virtual machine.
  • Each virtio device will have a corresponding virtual host (vhost) kernel thread, where the vhost kernel thread runs on the host.
  • the vhost kernel thread is used to process the packets of the corresponding virtio device.
  • Figure 1 is a schematic diagram of a through mode.
  • the first virtual machine 101 can monopolize the first physical input and output device 111
  • the second virtual machine 102 can monopolize the second physical input and output device 112.
  • the method shown in Figure 3 can be applied to a virtual machine using the pass-through mode shown in Figure 1.
  • Figure 2 is a schematic illustration of a front-end mode.
  • the first virtual device 211 in the computing node 200 corresponds to the first vhost thread 212
  • the second virtual device 221 in the computing node 200 corresponds to the second vhost thread 222, where the first virtual device is the first virtual
  • the virtio device in the machine the second virtio device is the virtio device 211 in the second virtual machine.
  • the method shown in Fig. 6 can be applied to a virtual machine using the front-end mode as shown in Fig. 2.
  • the method is applied to a computing node, where the computing node includes: a physical hardware layer, a host Host running on the physical hardware layer, and at least one virtual machine VM running on the host, the at least one VM being virtualized
  • the physical hardware layer includes X physical central processing units pCPU and Y physical input and output devices
  • the virtual hardware includes Z virtual central processing units vCPU
  • X, ⁇ , ⁇ are positive integers greater than 1.
  • the one physical input and output device includes a jth physical input and output device
  • the at least one VM includes a kth VM
  • the jth physical input and output device passes through the kth VM, and the method is performed by the host.
  • the pCPU includes the U target pCPUs, the Z vCPUs including the V target vCPUs, U being a positive integer greater than or equal to 1 and less than or equal to X, and V being a positive integer greater than or equal to 1 and less than or equal to Z.
  • Process the ith physical interrupt by using the nth pCPU.
  • the nth pCPU is determined from the U target pCPUs when the ith physical interrupt occurs in the jth physical input/output device, wherein the U target pCPUs are related to the ith physical interrupt and Each of the V target vCPUs has an affinity pCPU, and the V target vCPUs are vCPUs that are virtualized on the kth VM and have an affinity relationship with the ith virtual interrupt, and the ith virtual interrupt corresponds to the ith physical Interrupt, the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs; processing the ith physical interrupt using the nth pCPU; determining the ith virtual interrupt according to the ith physical interrupt; Determining the m-th CPU from the V target vCPUs, so that the k-th VM uses the m-th vCPU to execute the ith virtual interrupt,
  • the host can implement the method shown in Figure 3 through the hypervisor.
  • the hypervisor can also be called a virtual machine monitor (VMM) or a hypervisor.
  • VMMs are VMware ESX, XEN, KVM/Qemu, and others.
  • the pCPU has an affinity with the physical interrupt, which means that the pCPU can handle the physical interrupt.
  • the vCPU has an affinity with the virtual interrupt, meaning that the vCPU can handle the virtual interrupt.
  • the affinity between the pCPU and the vCPU means that the vCPU can run on the pCPU. Therefore, the nth pCPU is determined from the U target pCPUs according to the affinity relationship between the U target pCPUs and the i-th physical interrupt.
  • an affinity relationship between the U target pCPUs and the ith physical interrupt, an affinity relationship between the U target pCPUs and the V target vCPUs, and the V target vCPUs and the ith The affinity of the virtual interrupt is determined by: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are virtualized on the kth VM capable of processing the first i virtual interrupted vCPU, determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1, determining an ith physical interrupt corresponding to the ith virtual interrupt, determining the The ith physical interrupt and the U The affinity of the target pCPU, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the affinity relationship between the U target pCPUs and the ith physical interrupt, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the ith virtual interrupt may be preset Good and save, then in the case of a physical interrupt, you can find the corresponding pCPU and vCPU to handle physical interrupts and virtual interrupts based on the saved affinity.
  • an affinity relationship between the U target pCPUs and the ith physical interrupt an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and the ith virtual interrupt
  • the m-th vCPU for processing the ith virtual interrupt corresponding to the i-th physical interrupt runs on the n-th CPU that processes the i-th physical interrupt.
  • the affinity relationship of the i virtual interrupt is determined by determining the affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are virtualized on the kth VM and can process the
  • the i-virtual interrupted vCPU determines the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is a positive integer greater than 1 and less than or equal to X, and is determined to correspond to the i-th
  • the i-th physical interrupt of the virtual interrupt determines an affinity relationship between the i-th physical interrupt and the U target pCPUs, wherein the i-th physical interrupt can be processed by the U target pCPUs.
  • the affinity relationship between the U target pCPUs and the ith physical interrupt, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the ith virtual interrupt may be preset Good and save, then in the case of a physical interrupt, you can find the corresponding pCPU and vCPU to handle physical interrupts and virtual interrupts based on the saved affinity.
  • an affinity relationship between the U target pCPUs and the ith physical interrupt an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and the ith virtual interrupt
  • the m-th vCPU for processing the ith virtual interrupt corresponding to the ith physical interrupt runs on a limited number of determined pCPUs instead of any one of the physical hardware layers. Up, and possibly running on the nth pCPU that handles the ith physical interrupt.
  • determining the m vCPU from the V target vCPUs includes: determining whether the nth pCPU is running Having at least one target vCPU of the V target vCPUs, determining that at least one target vCPU of the V target CPUs is running on the nth pCPU, determining a target vCPU running on the nth pCPU as the a m vCPU, in a case where it is determined that at least one target vCPU of the V target vCPUs is not running on the nth pCPU, determining a target vCPU from the V target vCPUs as the m vCPU according to a priority order .
  • the priority order may be a priority of the V target vCPUs set in advance.
  • the selection of the priority can also be determined by the round-robin strategy, that is, the probability that each target vCPU is selected is the same.
  • determining whether the at least one target vCPU of the V target vCPUs is running on the nth pCPU includes: determining, according to the virtual interrupt routing information, whether at least one of the V target vCPUs is running on the nth pCPU The target vCPU, wherein the virtual interrupt routing information includes a correspondence between the U target pCPUs and a target vCPU running on the U target pCPUs. In this way, the Host can quickly and easily determine whether the m vCPU is running on the nth pCU.
  • FIG. 4 is a schematic diagram of a virtual interrupt, a physical interrupt, a vCPU, and a pCPU according to an embodiment of the present invention.
  • the physical interrupt No. 1 corresponds to the virtual interrupt No. 1.
  • the No. 1 virtual interrupt has an affinity with the No. 4 vCPU.
  • the No. 4 vCPU has an affinity with the No. 3 pCPU.
  • the pCPU No. 3 can be bound to the physical interrupt No. 1, so that the two have affinity.
  • the pCPU No. 3 can handle the physical interrupt No. 1.
  • the No. 4 vCPU When the No. 4 vCPU is running on the No. 3 pCPU, the No. 4 vCPU can be used directly to process the No. 1 virtual interrupt corresponding to the No. 1 physical interrupt. This way, there is no VM-Exit caused by the extra IPI caused by the pCPU running vCPU and the pCPU that is physically interrupted.
  • FIG. 5 is a schematic diagram of another virtual interrupt, a physical interrupt, a vCPU, and a pCPU according to an embodiment of the present invention.
  • the physical interrupt No. 1 corresponds to the first virtual interrupt.
  • No. 4 vCPU, No. 5 vCPU has the affinity relationship with the No. 3 pCPU and No. 4 pCPU.
  • the No. 4 vCPU and the No. 5 vCPU can run on the No. 3 pCPU or on the No. 4 pCPU.
  • the No. 4 vCPU runs on the No. 3 pCPU
  • the No. 5 vCPU runs on the No. 4 pCPU.
  • the No. 4 vCPU and the No. 5 vCPU can run simultaneously on the No. 3 pCPU.
  • the No. 4 vCPU and the No. 5 vCPU have an affinity with the No. 1 virtual interrupt. That is to say, the No. 1 virtual interrupt can be processed by the No. 4 vCPU or the No. 5 vCPU.
  • both the pCPU No. 3 and the pCPU No. 4 can be bound to the physical interrupt No. 1, so that the two have an affinity relationship.
  • the Host can select a pCPU from the pCPU No. 3 or the pCPU No. 4 to process the physical interrupt No. 1.
  • the Host finds the No. 1 virtual interrupt corresponding to the No. 1 physical interrupt and the vCPU for processing the No. 1 virtual interrupt, and uses the vCPU to process the No. 1 virtual interrupt. Since the vCPU used to handle virtual interrupts may run VM-Exit caused by the extra IPI caused by the different processing of physical interrupts.
  • FIG. 6 is a schematic flow diagram of another virtualization platform processing interrupt method provided in accordance with the present invention.
  • the method shown in FIG. 6 can be applied to a computing node, where the computing node includes: a physical hardware layer, a host Host running on the physical hardware layer, and Y virtual machine VMs running on the Host, running in Y virtual host vhost kernel threads on the host, virtual hardware is virtualized on the at least one VM, wherein the physical hardware layer includes X physical central processing units pCPU, the virtual hardware includes Z virtual central processing units vCPU X, ⁇ , ⁇ are positive integers greater than 1, each VM of the VMs includes a paravirtualized driver virtio device, the Y VMs including a kth VM, the kth VM including an i virtio device, The i-virtio device corresponds to the j-th vhost kernel thread in the Y vhost kernel threads, and the method is
  • the jth vhost kernel thread triggers the i-th vhost thread, determining an nth pCPU from the U target pCPUs, wherein the U target pCPUs have the same relationship with the i-th vhost thread and the V target vCPUs
  • the pCPU of the affinity relationship the V target vCPU is a vCPU that is virtualized on the kth VM and has a affinity relationship with the virtual interrupt of the i th virtio device, and the virtual interrupt of the i th virtio device corresponds to the i th vhost Thread
  • the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs, U being a positive integer greater than or equal to 1 and less than or equal to X, V being greater than or equal to 1 and less than or equal to Z Positive integer.
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs are the i-th vhost thread and the Vth
  • the target vCPUs each have an affinity pCPU, which is a vCPU that is virtualized on the kth VM and has an affinity relationship with the virtual interrupt of the i th virtio device, and the virtual interrupt of the i th virtio device corresponds to
  • the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs; processing the i-th vhost thread by using the n-th pCPU; determining the first according to the i-th vhost thread The virtual interrupt of the i virtio device; determining the m
  • the host can implement the method shown in Figure 6 through the hypervisor.
  • the hypervisor can also be called a Virtual Machine Monitor (VMM) or a hypervisor.
  • VMM Virtual Machine Monitor
  • Typical VMMs are VMware ESX, XEN, KVM/Qemu, and others.
  • the affinity between the pCPU and the vhost thread means that the pCPU can handle the vhost thread.
  • the affinity between the vCPU and the virtual interrupt of the virtio device means that the vCPU can handle the virtual interrupt of the virtio device.
  • the affinity between the pCPU and the vCPU means that the vCPU can run on the pCPU. Therefore, the nth pCPU is determined from the U target pCPUs according to the affinity of the U target pCPUs to the i-th physical interrupt.
  • an affinity relationship between the U target pCPUs and the i-th vhost thread, an affinity relationship between the U target pCPUs and the V target vCPUs, and the V target vCPUs and the ith The affinity of the virtual interrupt of the virtio device is determined by: determining the affinity of the V target vCPUs to the virtual interrupt of the i-irrtio device, wherein the V target vCPUs are virtualized at the kth VM
  • the vCPU capable of processing the virtual interrupt of the i-th virtio device determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, where U is equal to 1, determining corresponding to the i-th virtio
  • the i-vhost thread of the virtual interrupt of the device determines the affinity of the i-vhost thread with the U target pCPUs, wherein the i-
  • the U target pCPUs and the The affinity relationship of the i-th vhost thread, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the virtual interrupt of the i-th virtio device may be preset and saved. Then in the case of a vhost thread, the corresponding pCPU and vCPU can be found to handle the virtual interrupt of the vhost thread and the virtual device according to the saved affinity.
  • the affinity relationship between the U target pCPUs and the V target vCPUs, and the virtual interruption of the V target vCPUs and the i-th virtio device When the affinity is set well, you can find the corresponding pCPU and vCPU to handle the virtual interrupt of the corresponding vhost thread and virtio device according to these affinity relationships.
  • the m-th vCPU for processing the virtual interrupt of the i-virito device corresponding to the i-th vhost thread runs on the n-th pCPU that processes the i-th vhost thread.
  • the affinity of the virtual interrupt of the i virtio device is determined by: determining the affinity of the V target vCPUs to the virtual interrupt of the i-irrtio device, wherein the V target vCPUs are virtualized at the kth a vCPU on the VM capable of processing a virtual interrupt of the i-th virtio device, determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is greater than 1 and less than or equal to X a positive integer, determining an i-th vhost thread corresponding to the virtual interrupt of the i-irrtio device, determining an affinity relationship between
  • An affinity relationship between the U target pCPUs and the i-th vhost thread, an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and a virtual interrupt of the i-th virtio device It can be pre-set and saved, and then in the case of a vhost thread, the corresponding pCPU and vCPU can be found to handle the virtual interrupt of the vhost thread and the virtual device according to the saved affinity.
  • the affinity relationship between the U target pCPUs and the V target vCPUs, and the virtual interruption of the V target vCPUs and the i-th virtio device When the affinity relationship is set well, you can find the corresponding pCPU and vCPU to process the corresponding vhost thread and the virtual interrupt of the virtio device according to these affinity relationships.
  • the m-th vCPU for processing the virtual interrupt of the i-virito device corresponding to the i-th vhost thread runs on a limited number of determined pCPUs instead of the physical hardware layer. Any of the pCPUs, and have It may run on the nth pCPU that processes the i-vhost thread.
  • Determining the m vCPU from the V target vCPUs including: determining whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, and determining that the V target vCPUs are running on the nth pCPU In the case of at least one target vCPU, determining a target vCPU running on the nth pCPU as the m vCPU, in case that it is determined that the nth pCPU is not running at least one target vCPU of the V target vCPUs And determining, according to the priority order, a target vCPU from the V target vCPUs as the mth
  • the priority order may be a preset priority of V target vCPUs.
  • the priority selection can also be determined by the round-robin policy, that is, the probability that each target vCPU is selected is the same.
  • determining whether the at least one target vCPU of the V target vCPUs is running on the nth pCPU includes: determining, according to the virtual interrupt routing information of the virtio device, whether the V target vCPUs are running on the nth pCPU At least one target vCPU, wherein the virtual interrupt routing information of the virtio device includes a correspondence between the U target pCPUs and a target vCPU running on the U target pCPUs. In this way, the Host can quickly and easily determine whether the m vCPU is running on the nth pCU.
  • FIG. 7 is a schematic diagram of a virtual interrupt, a vhost thread, a vCPU, and a pCPU of a virtio device according to an embodiment of the present invention.
  • the first vhost thread corresponds to the virtual interrupt of the No. 1 virtio device.
  • the No. 4 vCPU has an affinity with the virtual interrupt of the No. 1 virtio device.
  • the pCPU No. 3 has an affinity with the vCPU No. 4.
  • the first vhost thread can be bound to the third pCPU, so that the two have affinity.
  • the No. 3 pCPU can process the No. 1 vhost thread.
  • the virtual interrupt of the No. 1 virtio device corresponding to the No. 1 vhost thread and the vCPU for processing the virtual interrupt of the No. 1 virtio device are found.
  • the No. 4 vCPU runs on the No. 3 pCPU
  • the No. 4 vCPU can directly use the No. 4 vCPU to process the virtual interrupt of the No. 1 virtio device corresponding to the No. 1 vhost thread.
  • VM-Exit caused by the extra IPI caused by the difference between the pCPU running the vCPU and the pCPU running the vhost thread does not occur.
  • FIG. 8 is a schematic diagram of a virtual interrupt, a vhost thread, a vCPU, and a pCPU of another virtio device according to an embodiment of the present invention.
  • the first vhost thread corresponds to the virtual interrupt of the No. 1 virtio device.
  • the 3rd pCPU and the 4th pCPU have affinity with the 4th vCPU and the 5th vCPU.
  • the No. 4 vCPU and the No. 5 vCPU can run on the No. 3 pCPU or on the No. 4 pCPU.
  • the No. 4 vCPU runs on the No. 3 pCPU, and the No.
  • the No. 4 vCPU and the No. 5 vCPU run simultaneously on the No. 3 pCPU.
  • the No. 4 vCPU and the No. 5 vCPU have an affinity with the virtual interrupt of the No. 1 virtio device. That is to say, the virtual interrupt of the No. 1 virtio device can be processed by the No. 4 vCPU or the No. 5 vCPU.
  • both the pCPU No. 3 and the pCPU No. 4 can be bound to the No. 1 vhost thread, so that the two have an affinity relationship.
  • Host can select a pCPU from the 3rd pCPU or the 4th pCPU to process the 1st vhost thread. Then, Host finds the virtual interrupt of the No. 1 virtio device corresponding to the No. 1 vhost thread and the vCPU for processing the virtual interrupt of the No. 1 virtio device, and uses the vCPU to process the virtual interrupt of the No. 1 virtio device.
  • FIG. 9 is a structural block diagram of a host Host according to an embodiment of the present invention.
  • the Host 900 shown in Figure 9 is capable of performing the various steps shown in Figure 3.
  • the Host is applied to a computing node, where the computing node includes: a physical hardware layer, the Host running on the physical hardware layer, at least one virtual machine VM running on the Host, and the at least one VM.
  • the virtual hardware has virtual hardware, wherein the physical hardware layer includes X physical central processing units pCPU and Y physical input and output devices, and the virtual hardware includes Z virtual central processing units vCPU, X, ⁇ , ⁇ are greater than 1.
  • the physical input and output device includes a jth physical input and output device
  • the at least one VM includes a kth VM
  • the jth physical input and output device passes through the kth VM
  • the host includes a first determining unit 901, The second invoking unit 902, the third determining unit 903, and the fourth determining unit 904.
  • a first determining unit 901 configured to determine an nth pCPU from the U target pCPUs when the ith physical interrupt is generated by the jth physical input/output device, where the U target pCPUs are related to the ith physical interrupt And pCPUs with V target vCPUs having affinity, the V
  • the target vCPU is a vCPU that is virtualized on the kth VM and has an affinity relationship with the ith virtual interrupt, the ith virtual interrupt corresponding to the ith physical interrupt, the X pCPUs including the U target pCPUs, the Z
  • the vCPUs include the V target vCPUs, U being a positive integer greater than or equal to 1 and less than or equal to X, and V being a positive integer greater than or equal to 1 and less than or equal to Z.
  • the second invoking unit 902 is configured to process the i th physical interrupt by using the nth pCPU.
  • the third determining unit 903 is configured to determine the ith virtual interrupt according to the ith physical interrupt.
  • a fourth determining unit 904 configured to determine an mth vCPU from the V target vCPUs, so that the kth VM executes the ith virtual interrupt by using the mth vCPU, where i, j, k, m, n are positive integers .
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs are the ith physical
  • the interrupt and the V target CPUs each have an affinity pCPU
  • the V target vCPUs are vCPUs that are virtualized on the kth VM and have affinity with the ith virtual interrupt
  • the ith virtual interrupt corresponds to the first i physical interrupt
  • the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs; processing the i-th physical interrupt using the nth pCPU; determining the i-th virtual according to the i-th physical interrupt Interrupting; determining an mth CPU from the V target vCPUs, so that the kth VM uses the mth vCPU to execute the i
  • the pCPU that is not used to process the physical interrupt corresponding to the virtual interrupt handled by the vCPU causes additional IPI-induced VM-Exit, effectively reducing the number of context switches and reducing the interference of the virtual machine to the pCPU. .
  • the first determining unit 901 is further configured to determine an affinity relationship between the V target vCPUs and the ith virtual interrupt, where the V target vCPUs are virtualized on the kth VM.
  • a vCPU capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1; determining an i th corresponding to the ith virtual interrupt Physical interruption; determining an affinity relationship between the ith physical interrupt and the U target pCPUs, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the affinity relationship between the U target pCPUs and the ith physical interrupt, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the ith virtual interrupt are It can be determined.
  • the ith physical interrupt occurs, the m-th CPU running for processing the ith virtual interrupt corresponding to the ith physical interrupt is processed in the ith physics. Broken on the nth pCPU.
  • the first determining unit 901 is further configured to determine an affinity relationship between the V target vCPUs and the ith virtual interrupt, where the V target vCPUs are virtualized at the kth VM a vCPU capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is a positive integer greater than 1 and less than or equal to X; Corresponding to the ith physical interrupt of the ith virtual interrupt; determining an affinity relationship between the ith physical interrupt and the U target pCPUs, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the affinity relationship between the U target pCPUs and the ith physical interrupt, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the ith virtual interrupt are It can be determined.
  • the m-th vCPU for processing the ith virtual interrupt corresponding to the ith physical interrupt runs on a limited number of determined pCPUs instead of any one of the physical hardware layers. Up, and possibly running on the nth pCPU that handles the ith physical interrupt.
  • the fourth determination The unit 904 is specifically configured to determine whether at least one target vCPU of the V target vCPUs is running on the nth pCPU; and determining that the nth pCPU runs at least one target vCPU of the V target vCPUs In the case, determining a target vCPU running on the nth pCPU as the mth vCPU, so that the kth VM uses the mth vCPU to execute the i th virtual interrupt; or, determining that the nth pCPU is not running In the case of at least one target vCPU of the V target vCPUs, a target vCPU is determined as the m vCPU from the V target v
  • This priority order can be the priority of the V target vCPUs that are preset.
  • the priority selection can also be determined by the round-robin strategy, that is, the probability that each target vCPU is selected is the same, so as to avoid the pCPU that is v-affinated by the vCPU is not used to process the vCPU.
  • the pCPU of the physical interrupt corresponding to the virtual interrupt causes the VM-Exit caused by the extra IPI, effectively reducing the number of context switches, and reducing the interference of the virtual machine to the pCPU.
  • the fourth determining unit 904 is configured to determine, according to the virtual interrupt routing information, whether at least one target vCPU of the V target vCPUs is running on the nth pCPU, where the virtual interrupt routing information includes the The correspondence between the U target pCPUs and the target vCPUs running on the U target pCPUs. In this way, the Host can quickly and easily determine whether the m vCPU is running on the nth pCU.
  • FIG. 10 is a structural block diagram of another host host according to an embodiment of the present invention.
  • the Host 1000 shown in Figure 10 is capable of performing the various steps shown in Figure 6.
  • the Host 1000 is applied to a computing node, where the computing node includes: a physical hardware layer, the Host running on the physical hardware layer, Y virtual machine VMs running on the Host, and Y running on the Host.
  • a virtual host vhost kernel thread the virtual hardware is virtualized on the at least one VM, wherein the physical hardware layer includes X physical central processing units pCPU, the virtual hardware includes Z virtual central processing units vCPU, X, Y, Z
  • each VM of the VMs includes a paravirtualized driver virtio device, the Y VMs including a kth VM, the kth VM including an i virtio device, the i virtio device and Corresponding to the jth vhost kernel thread of the Y vhost kernel threads
  • the Host includes a first determining unit 1001, a second invoking unit 1002, a third determining unit 1003, and a fourth determining unit 1005.
  • a first determining unit 1001 configured to determine an nth pCPU from the U target pCPUs, where the nth target pCPU is the same as the i-th vhost thread, in the case that the jth vhost kernel thread triggers the i-th vhost thread
  • Each of the V target vCPUs has an affinity pCPU, and the V target vCPUs are vCPUs that are virtualized on the kth VM and have affinity with the virtual interrupt of the i-virtio device, and the virtual interrupt of the i-irrtio device
  • the X pCPUs include the U target pCPUs
  • the Z vCPUs include the V target vCPUs
  • U is a positive integer greater than or equal to 1 and less than or equal to X
  • V is greater than or equal to a positive integer that is less than or equal to Z;
  • the second invoking unit 1002 is configured to process the i vhost thread by using the nth pCPU; the third determining unit 1003 is further configured to determine, according to the i vhost thread, a virtual interrupt of the i th virtio device;
  • the fourth determining unit 1004 is further configured to determine an mvCPU from the V target vCPUs, so that the kth VM uses the mvCPU to perform a virtual interrupt of the i th virtio device, i, j, k, m, n is a positive integer.
  • the thread is triggered in the jth vhost kernel thread.
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs are pCPUs having affinity with the i-th vhost thread and the V target vCPUs, the V target vCPUs a virtual interrupt of the i-virtio device corresponding to the i-vhost thread, the X p-CPUs including the U targets a pCPU, the Z vCPUs comprising the V target vCPUs; processing the i th vhost thread using the nth pCPU; determining, according to the i vhost thread, a virtual interrupt of the i th virtio device; determining from the V target vCPUs The m vCPU, so that the kth VM uses
  • the pCPU of the vhost thread corresponding to the virtual interrupt of the processed virtio device causes the VM-Exit caused by the IPI of the E, effectively reducing the number of context switches and reducing the interference of the virtual machine to the pCPU.
  • the first determining unit 1001 is further configured to determine an affinity relationship between the V target vCPUs and a virtual interrupt of the i-th virtio device, where the V target vCPUs are virtualized in the first a vCPU on the VM that is capable of processing the virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1; The i-vhost thread of the virtual interrupt of the i virtio device; determining the affinity of the i-vhost thread with the U target pCPUs, wherein the i-th vhost thread can be processed by the U target pCPUs.
  • An affinity relationship between the U target pCPUs and the i-th vhost thread, an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and virtual interrupts of the i-th virtio device It can be pre-set and saved, and then in the case of a vhost thread, the corresponding pCPU and vCPU can be found to handle the virtual interrupt of the vhost thread and the viritio device according to the saved affinity.
  • the affinity relationship between the U target pCPUs and the V target vCPUs, and the virtual interruption of the V target vCPUs and the i-th virtio device When the affinity is set well, you can find the corresponding pCPU and vCPU to handle the virtual interrupt of the corresponding vhost thread and virtio device according to these affinity relationships.
  • the m vCPU for processing the virtual interrupt of the i virito device corresponding to the i vhost thread runs on the nth pCPU that processes the i vhost thread.
  • the first determining unit 1001 is further configured to determine an affinity relationship between the V target vCPUs and a virtual interrupt of the i-th virtio device, where the V target vCPUs A vCPU that is virtualized on the kth VM and is capable of processing the virtual interrupt of the i-th virtio device.
  • Determining the U target pCPUs wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is a positive integer greater than 1 and less than or equal to X; determining a virtual interrupt corresponding to the i-th virtio device The i-vhost thread; determining an affinity relationship between the i-th vhost thread and the U target pCPUs, wherein the i-th vhost thread can be processed by the U target pCPUs.
  • An affinity relationship between the U target pCPUs and the i-th vhost thread, an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and virtual interrupts of the i-th virtio device It can be pre-set and saved, and then in the case of a vhost thread, the corresponding pCPU and vCPU can be found to handle the virtual interrupt of the vhost thread and the viritio device according to the saved affinity.
  • the affinity relationship between the U target pCPUs and the V target vCPUs, and the virtual interruption of the V target vCPUs and the i-th virtio device When the affinity is set well, you can find the corresponding pCPU and vCPU to handle the virtual interrupt of the corresponding vhost thread and virtio device according to these affinity relationships.
  • the m-th vCPU for processing the virtual interrupt of the i-virito device corresponding to the i-th vhost thread runs on a limited number of determined pCPUs instead of the physical hardware layer. Any of the pCPUs, and it is possible to run on the nth pCPU that processes the i-th vhost thread.
  • the determining unit 1004 is specifically configured to determine whether at least one target vCPU of the V target vCPUs is running on the nth pCPU; and determining that the nth pCPU runs at least one target vCPU of the V target vCPUs a case, determining a target vCPU running on the nth CPU as the mvCPU, so that the kth VM uses the mvCPU to perform a virtual interrupt of the i th virtio device; or, determining the first In the case that at least one target vCPU of the V target vCPUs is not running on the pCPU, a target vCPU is determined from the V target vCPU
  • the priority order may be a priority of the V target vCPUs set in advance.
  • This priority selection can also draw a round-robin strategy Determine, that is, the probability that each target vCPU is selected is the same, so as to avoid the extra pCPU caused by the vCPU that is not related to the physical interrupt corresponding to the virtual interrupt handled by the vCPU.
  • the VM-Exit caused by IPI effectively reduces the number of context switches and reduces the interference of the virtual machine to the pCPU.
  • the fourth determining unit 1004 is specifically configured to determine, according to the virtual interrupt routing information of the virtio device, the n-th CPU Whether there is at least one target V CPU of the V target vCPUs, wherein the virtual interrupt routing information of the virtio device includes a correspondence between the U target pCPUs and a target vCPU running on the U target pCPUs.
  • the Host can quickly and easily determine whether the mvCPU is running on the nth pCU. In this way, the Host can quickly and easily determine whether the mvCPU is running on the nth pCU.
  • FIG. 11 is a structural block diagram of a computing node according to an embodiment of the present invention.
  • the calculation node shown in Fig. 11 is capable of executing the steps shown in Fig. 3.
  • the computing node includes: Y physical input and output devices 1101, wherein the Y physical input and output devices include a jth physical input and output device, X physical central processing units pCPU 1102, and the X physical central processing units pCPU and Y
  • the physical input/output device is respectively connected to the memory 1103, wherein one or more pCPUs of the X physical central processing units pCPU are used to invoke or execute an operation instruction stored in the memory 1103, a host Host, at least one virtual machine VM, and
  • the at least one virtual machine VM is virtual virtual hardware, wherein the virtual hardware includes Z virtual CPUs vCPU, the at least one VM includes a kth VM, and the jth physical input and output device is directly connected to the kth VM, where This Ho
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs have a pro with the i-th physical interrupt and the V target vCPUs.
  • the V target vCPUs are vCPUs that are virtualized on the kth VM and have affinity with the i th virtual interrupt, the i th virtual interrupts corresponding to the i th physical interrupt, the X pCPUs include The U target pCPUs, the Z vCPUs including the V target vCPUs;
  • the nth pCPU is determined from the U target pCPUs when the ith physical interrupt occurs in the jth physical input/output device, wherein the U target pCPUs are the i th a physical interrupt and a VCPU having an affinity VCPU, wherein the V target vCPUs are vCPUs that are virtualized on the kth VM and have an affinity relationship with the ith virtual interrupt, the ith virtual interrupt corresponding to the The i-th physical interrupt, the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs; processing the i-th physical interrupt using the n-th pCPU; determining the i-th according to the i-th physical interrupt a virtual interrupt; determining an mth vCPU from the V target vCPUs, so that the kth VM uses the mth
  • the pCPU is not the VM-Exit caused by the extra IPI caused by the pCPU for processing the physical interrupt corresponding to the virtual interrupt handled by the vCPU, effectively reducing the number of context switches and reducing the virtual The interference of the machine to the pCPU.
  • the Host is further configured to determine, by using the following manner, an affinity relationship between the U target pCPUs and the ith physical interrupt, an affinity relationship between the U target pCPUs and the V target vCPUs, and An affinity relationship between the V target vCPUs and the ith virtual interrupt: determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are virtualized on the kth VM Processing the vCPU of the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1; determining an ith physical interrupt corresponding to the ith virtual interrupt Determining an affinity relationship between the ith physical interrupt and the U target pCPUs, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the affinity relationship between the U target pCPUs and the ith physical interrupt, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the ith virtual interrupt may be preset Good and save, then in the case of a physical interrupt, you can find the corresponding pCPU and vCPU to handle physical interrupts and virtual interrupts based on the saved affinity.
  • an affinity relationship between the U target pCPUs and the ith physical interrupt an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and the ith virtual interrupt
  • the i-th physical interrupt occurs, the m-th vCPU for processing the ith virtual interrupt corresponding to the i-th physical interrupt is processed.
  • the nth physical interrupt of the nth pCPU is a physical interrupt of the nth pCPU.
  • the Host is further configured to determine an affinity relationship between the U target pCPUs and the ith physical interrupt by using an affinity relationship between the U target pCPUs and the V target vCPUs.
  • an affinity relationship between the V target vCPUs and the ith virtual interrupt determining an affinity relationship between the V target vCPUs and the ith virtual interrupt, wherein the V target vCPUs are virtualized on the kth VM a vCPU capable of processing the ith virtual interrupt; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is a positive integer greater than 1 and less than or equal to X; An ith physical interrupt of the ith virtual interrupt; determining an affinity of the ith physical interrupt with the U target pCPUs, wherein the ith physical interrupt can be processed by the U target pCPUs.
  • the affinity relationship between the U target pCPUs and the ith physical interrupt, the affinity relationship between the U target pCPUs and the V target vCPUs, and the affinity relationship between the V target vCPUs and the ith virtual interrupt may be preset Good and save, then in the case of a physical interrupt, you can find the corresponding pCPU and vCPU to handle physical interrupts and virtual interrupts based on the saved affinity.
  • an affinity relationship between the U target pCPUs and the ith physical interrupt an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and the ith virtual interrupt
  • the m-th vCPU for processing the ith virtual interrupt corresponding to the ith physical interrupt runs on a limited number of determined pCPUs instead of any one of the physical hardware layers. Up, and possibly running on the nth pCPU that handles the ith physical interrupt.
  • the host is specifically configured to: determine whether at least one target vCPU of the V target vCPUs is running on the nth pCPU; and running the V on the nth pCPU In the case of at least one target vCPU in the target vCPU, determining a target vCPU running on the nth pCPU as the m vth CPU; determining that at least one of the V target vCPUs is not running on the nth pCPU In the case of the vCPU, a target vCPU is determined as the m-th vCPU from the V target vCPUs according to the priority
  • the pCPU that runs the vCPU does not occur and the physical interrupt occurs.
  • the priority order may be a priority of the V target vCPUs set in advance.
  • the priority selection can also be determined by the round-robin strategy, that is, the probability that each target vCPU is selected is the same, so as to avoid the pCPU that is v-affinated by the vCPU is not used to process the vCPU.
  • the pCPU of the physical interrupt corresponding to the virtual interrupt causes the VM-Exit caused by the additional IPI, effectively reducing the number of context switches and reducing the interference of the virtual machine to the pCPU.
  • the Host is specifically configured to: determine, according to the virtual interrupt routing information, whether the V targets are run on the nth pCPU At least one target vCPU in the vCPU, wherein the virtual interrupt routing information includes a correspondence between the U target pCPUs and a target vCPU running on the U target pCPUs. In this way, the Host can quickly and easily determine whether the m vCPU is running on the nth pCU.
  • FIG. 12 is a structural block diagram of another computing node according to an embodiment of the present invention.
  • the compute node 1200 shown in Figure 12 is capable of performing the various steps shown in Figure 6.
  • the compute node 1200 includes: X physical CPUs pCPU 1201, a memory 1202 coupled to the X physical CPUs pCPU, wherein one or more of the X physical CPUs pCPU are used to invoke or execute the An operation instruction stored in the memory 1202, a host Host, Y virtual machine VMs, Y virtual host vhost kernel threads, and virtual virtual hardware on the at least one virtual machine VM, wherein the virtual hardware includes Z virtual CPUs vCPU, each of the Y VMs includes a paravirtualized driver virtio device, the Y VMs including a kth VM, the kth VM including an i th virtio device, the i virtio device and the Y vhost kernels
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs have affinity with the i-th vhost thread and the V target vCPUs.
  • the V target CPU is a vCPU that is virtualized on the kth VM and has a affinity relationship with the virtual interrupt of the i-irrtio device, and the virtual interrupt of the i-virtio device corresponds to the i-th vhost thread
  • the X pCPUs include the U target pCPUs, the Z vCPUs including the V target vCPUs;
  • the vCPU executes a virtual interrupt of the i-irrtio device, where X, Y, and ⁇ are positive integers greater than 1, U is a positive integer greater than or equal to 1 and less than or equal to X, and V is greater than or equal to 1 and less than or equal to ⁇ Positive integers, i, j, k, m, n are positive integers.
  • the nth pCPU is determined from the U target pCPUs, wherein the U target pCPUs are the i-th vhost thread And a VCPU having an affinity V relationship, wherein the V target vCPUs are vCPUs that are virtualized on the kth VM and have affinity with the virtual interrupt of the i-irrtio device, and the virtual i-virtio device is virtualized
  • the interrupt corresponds to the i-th vhost thread
  • the X pCPUs include the U target pCPUs
  • the Z vCPUs include the V target vCPUs
  • the i-th vhost thread is processed by the n-th pCPU; according to the i-th vhost thread, Determining a virtual interrupt of the i-th virtio device;
  • the node can effectively avoid the VM-Exit caused by the additional CPU caused by the pCPU of the vhost thread corresponding to the virtual interrupt of the virtio device handled by the vCPU. , effectively reducing the number of context switches and reducing the virtual machine's interference to the pCPU.
  • the Host is further configured to determine, by using the following manner, an affinity relationship between the U target pCPUs and the ith physical interrupt, an affinity relationship between the U target pCPUs and the V target vCPUs, and An affinity relationship between the V target vCPUs and the ith virtual interrupt: determining an affinity relationship between the V target vCPUs and a virtual interrupt of the ith virtio device, wherein the V target vCPUs are virtualized at the kth VM a vCPU capable of processing a virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the U target pCPUs, wherein U is equal to 1; determining corresponding to the i-th virtio The i-vhost thread of the virtual interrupt of the device; determining an affinity relationship between the i-th vhost thread and the U target pC
  • An affinity relationship between the U target pCPUs and the i-th vhost thread, an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and virtual interrupts of the i-th virtio device It can be pre-set and saved, and then in the case of a vhost thread, the corresponding pCPU and vCPU can be found to handle the virtual interrupt of the vhost thread and the viritio device according to the saved affinity.
  • the affinity relationship between the U target pCPUs and the V target vCPUs, and the virtual interruption of the V target vCPUs and the i-th virtio device When the affinity is set well, you can follow these affinity relationships. Find the corresponding pCPU and vCPU to handle the corresponding vhost thread and virtual interrupt of the virtio device.
  • the m-th vCPU for processing the virtual interrupt of the i-virito device corresponding to the i-th vhost thread runs on the n-th pCPU that processes the i-th vhost thread.
  • the Host is further configured to determine an affinity relationship between the U target pCPUs and the ith physical interrupt by using an affinity relationship between the U target pCPUs and the V target vCPUs. And an affinity relationship between the V target vCPUs and the ith virtual interrupt: determining an affinity relationship between the V target vCPUs and a virtual interrupt of the ith virtio device, wherein the V target vCPUs are virtualized at the kth a vCPU on the VM capable of processing a virtual interrupt of the i-th virtio device; determining the U target pCPUs, wherein the V target vCPUs are capable of running on the plurality of target pCPUs, wherein U is greater than 1 and less than or equal to X a positive integer; determining an i-th vhost thread corresponding to the virtual interrupt of the i-irrtio device; determining an affinity relationship between the i-th
  • An affinity relationship between the U target pCPUs and the i-th vhost thread, an affinity relationship between the U target pCPUs and the V target vCPUs, and an affinity relationship between the V target vCPUs and virtual interrupts of the i-th virtio device It can be pre-set and saved, and then in the case of a vhost thread, the corresponding pCPU and vCPU can be found to handle the virtual interrupt of the vhost thread and the virtual device according to the saved affinity.
  • the affinity relationship between the U target pCPUs and the V target vCPUs, and the virtual interruption of the V target vCPUs and the i-th virtio device When the affinity relationship is set well, you can find the corresponding pCPU and vCPU to process the corresponding vhost thread and the virtual interrupt of the virtio device according to these affinity relationships.
  • the m-th vCPU for processing the virtual interrupt of the i-virito device corresponding to the i-th vhost thread runs on a limited number of determined pCPUs instead of the physical hardware layer. Any of the pCPUs, and it is possible to run on the nth pCPU that processes the i-th vhost thread.
  • the host is specifically configured to: determine whether at least one target vCPU of the V target vCPUs is running on the n-th pCPU; and running on determining the n-th pCPU In the case of at least one target vCPU of the V target vCPUs, determining a target vCPU running on the nth pCPU as the mth a vCPU, so that the kth VM uses the mvCPU to execute a virtual interrupt of the i th virtio device; or, determining that the nth pCPU is not running at least one target vCPU.
  • the vCPU for processing the virtual interrupt of the virito device runs on the pCPU for processing the vhost thread, there will be no additional IPI caused by the difference between the pCPU running the vCPU and the pCPU processing the vhost thread.
  • the selection can also be determined by the round-robin strategy, that is, the probability that each target vCPU is selected is the same, so that the pCPU that is v-affinted by the vCPU is not used to deal with the virtual interrupt handled by the vCPU.
  • the corresponding physical interrupted pCPU causes additional IPI-induced VM-Exit, effectively reducing the number of context switches and reducing the virtual machine's interference to the pCPU.
  • the Host is specifically configured to: determine, according to the virtual interrupt routing information of the virtio device, whether the nth CPU runs At least one target vCPU of the V target vCPUs, wherein the virtual interrupt routing information of the virtio device includes a correspondence between the U target pCPUs and a target vCPU running on the U target pCPUs. In this way, the Host can quickly and easily determine whether the m vCPU is running on the nth pCU.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
  • the disclosed systems, devices, and methods may be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the mutual coupling or direct connection or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in electrical, mechanical or other form.
  • the components displayed for the unit may or may not be physical units, ie may be located in one place, or may be distributed over multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and the like, which can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)
  • Pharmaceuticals Containing Other Organic And Inorganic Compounds (AREA)
  • Medicines That Contain Protein Lipid Enzymes And Other Medicines (AREA)

Abstract

本发明实施例提供虚拟化平台处理中断方法和相关设备,包括:在第j物理输入输出设备发生第i物理中断的情况下,从U个目标pCPU中确定第npCPU;使用该第npCPU处理该第i物理中断;根据该第i物理中断,确定该第i虚拟中断;从该V个目标vCPU中确定第mvCPU,以便于该第kVM使用该第mvCPU执行该第i虚拟中断。上述技术方案能够有效地避免因为vCPU所亲和的pCPU不是用于处理该vCPU所处理的虚拟中断所对应的物理中断的pCPU引起额外的IPI导致的VM-Exit,有效地减少上下文切换次数,并且降低虚拟机对pCPU的干扰。

Description

虚拟化平台处理中断方法和相关设备 技术领域
本发明实施例涉及通信技术领域, 并且更具体地, 涉及虚拟化平台处理 中断方法和相关设备。 背景技术
虚拟化技术是一种将底层硬件设备与上层操作系统、应用程序分离的去 耦合技术。 虚拟化技术作为当前流行的云计算( Cloud Computing )平台的底 层重要支撑技术之一, 可以极大的提高物理设备的资源使用效率。 与传统的 物理服务器相比, 虚拟机具有更好的隔离性和封装性, 其可以将整个虚拟机 的信息保存到虚拟磁盘镜像( VDI, Virtual Disk Image ) 中, 从而可以方便 地对虚拟机进行快照、 备份、 克隆和分发等操作。 由于虚拟化引入了开销, 因此导致在相同的配置下虚拟机的性能要低于物理机的性能。如何有效地提 高虚拟机的性能是本领域中一个需要解决的问题。 发明内容
本发明实施例提供的虚拟化平台处理中断方法和相关设备, 能够降低中 断开销对虚拟化平台的影响, 从而有效提高虚拟机的性能。
第一方面, 本发明实施例一种虚拟化平台处理中断方法, 应用于计算节 点上, 该计算节点包括: 物理硬件层、 运行在该物理硬件层之上的宿主机 Host,运行在该 Host之上的至少一个虚拟机 VM、该至少一个 VM上被虚拟 有虚拟硬件, 其中, 该物理硬件层包括 X个物理中央处理器 pCPU和 Y个 物理输入输出设备, 该虚拟硬件包括 Z个虚拟中央处理器 vCPU, 该 Y个物 理输入输出设备包括第 j物理输入输出设备, 该至少一个 VM包括第 k VM, 该第 j物理输入输出设备直通该第 k VM, 该方法由该 Host执行, 该方法包 括:在该第 j物理输入输出设备发生第 i物理中断的情况下,从 U个目标 pCPU 中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i物理中断以及 V个 目标 vCPU均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该第 k VM上的与第 i虚拟中断具有亲和关系的 vCPU,该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V 个目标 vCPU;使用该第 n pCPU处理该第 i物理中断;根据该第 i物理中断, 确定该第 i虚拟中断; 从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i虚拟中断; 其中, X、 Y、 Ζ为大于 1的 正整数, U为大于或等于 1且小于或等于 X的正整数, V为大于或等于 1且 小于或等于 Ζ的正整数, i、 j、 k、 m、 n为正整数。
结合第一方面, 在第一方面的第一种可能的实现方式中, 该 U个目标 pCPU与该第 i物理中断的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU 的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系是通过以下 方式确定的: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个目标 pCPU,其中该 V个目标 vCPU能够运行在该 U个目标 pCPU 上, 其中 U等于 1 ; 确定对应于该第 i虚拟中断的第 i物理中断; 确定该第 i 物理中断与该 U个目标 pCPU的亲和关系,其中该第 i物理中断能被该 U个 目标 pCPU处理。
结合第一方面, 在第一方面的第二种可能的实现方式中, 该 U个目标 pCPU与该第 i物理中断的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU 的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系是通过以下 方式确定的; 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个目标 pCPU,其中该 V个目标 vCPU能够运行在该多个目标 pCPU 上,其中 U为大于 1且小于或等于 X的正整数; 确定对应于该第 i虚拟中断 的第 i物理中断; 确定该第 i物理中断与该 U个目标 pCPU的亲和关系, 其 中该第 i物理中断能被该 U个目标 pCPU处理。
结合第一方面的第二种可能的实现方式,在第一方面的第三种可能的实 现方式中, 当该第 i物理中断与该 U个目标 pCPU的亲和关系为一对多的亲 和关系, 该从该 V个目标 vCPU中确定第 m vCPU, 包括: 确定该第 n pCPU 上是否运行有该 V个目标 vCPU 中的至少一个目标 vCPU; 在确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 确定 该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU;在确定该第 n pCPU 上没有运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下,根据优 先级顺序, 从该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU。 结合第一方面的第三种可能的实现方式,在第一方面的第四种可能的实 现方式中, 该确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一 个目标 vCPU, 包括: 根据虚拟中断路由信息, 确定该第 n pCPU上是否运 行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该虚拟中断路由信息 包括该 U个目标 pCPU与运行在该 U个目标 pCPU上的目标 vCPU的对应关 系。
第二方面, 本发明实施例提供一种虚拟化平台处理中断方法, 应用于计 算节点上, 该计算节点包括: 物理硬件层、 运行在该物理硬件层之上的宿主 机 Host、运行在该 Host之上的 Y个虚拟机 VM、运行在该 Host之上的 Y个 虚拟主机 vhost内核线程、 该至少一个 VM上被虚拟有虚拟硬件, 其中, 该 物理硬件层包括 X个物理中央处理器 pCPU,该虚拟硬件包括 Z个虚拟中央 处理器 vCPU, 该 Y个 VM中的每一个 VM包括一个半虚拟化驱动 virtio设 备, 该 Y个 VM包括第 k VM, 该第 k VM包括第 i virtio设备, 该第 i virtio 设备与该 Y个 vhost内核线程中的第 j vhost内核线程对应,该方法由该 Host 执行, 该方法包括: 在该第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU,其中,该 U个目标 pCPU为与该第 i vhost 线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个目标 vCPU为被 虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使用该第 n pCPU 处理该第 i vhost线程; 根据该第 i vhost线程, 确定该第 i virtio设备的虚拟 中断; 从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断; 其中, X、 Y、 Ζ为大于 1的正整 数, U为大于或等于 1且小于或等于 X的正整数, V为大于或等于 1且小于 或等于 Ζ的正整数, i、 j、 k、 m、 n为正整数。
结合第二方面, 在第二方面的第一种可能的实现方式中, 该 U个目标 pCPU与该第 i vhost线程的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU 的亲和关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关 系是通过以下方式确定的: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和 关系,其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio 设备的虚拟中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU 能够运行在该 U个目标 pCPU上, 其中 U等于 1 ; 确定对应于该第 i virtio 设备的虚拟中断的第 i vhost线程;确定该第 i vhost线程与该 U个目标 pCPU 的亲和关系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。
结合第二方面, 在第二方面的第二种可能的实现方式中, 该 U个目标 pCPU与该第 i vhost线程的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU 的亲和关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关 系是通过以下方式确定的: 确定该 V个目标 vCPU与该第 I virito设备的虚 拟中断的亲和关系,其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够 处理该第 i virtio设备的虚拟中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该多个目标 pCPU上,其中 U为大于 1且小于或 等于 X的正整数;确定对应于该第 i virtio设备的虚拟中断的第 i vhost线程; 确定该第 i vhost线程与该 U个目标 pCPU的亲和关系, 其中该第 i vhost线 程能被该 U个目标 pCPU处理。
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实 现方式中, 当该第 i vhost线程与该 U个目标 pCPU的亲和关系为一对多的 亲和关系,该从该 V个目标 vCPU中确定第 m vCPU,包括:确定该第 n pCPU 上是否运行有该 V个目标 vCPU 中的至少一个目标 vCPU; 在确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 确定 该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU;在确定该第 n pCPU 上没有运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下,根据优 先级顺序, 从该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU。
结合第二方面的第三种可能的实现方式,在第二方面的第四种可能的实 现方式中, 该确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一 个目标 vCPU,包括:根据 virtio设备的虚拟中断路由信息,确定该第 n pCPU 上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该 virtio设 备的虚拟中断路由信息包括该 U个目标 pCPU与运行在该 U个目标 pCPU 上的目标 vCPU的对应关系。
第三方面, 本发明实施例提供一种宿主机 Host, 应用于计算节点上, 该 计算节点包括: 物理硬件层、 运行在该物理硬件层之上的该 Host、 运行在该 Host之上的至少一个虚拟机 VM、 该至少一个 VM上被虚拟有虚拟硬件, 其 中, 该物理硬件层包括 X个物理中央处理器 pCPU和 Y个物理输入输出设 备, 该虚拟硬件包括 Z个虚拟中央处理器 vCPU, 该 Y个物理输入输出设备 包括第 j物理输入输出设备,该至少一个 VM包括第 k VM,该第 j物理输入 输出设备直通该第 k VM, 该 Host包括: 第一确定单元, 用于在该第 j物理 输入输出设备发生第 i物理中断的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i物理中断以及 V个目标 vCPU 均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该第 k VM上的与 第 i虚拟中断具有亲和关系的 vCPU,该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U个目标 pCPU,该 Z个 vCPU包括该 V个目标 vCPU,; 第二调用单元, 用于使用该第 n pCPU处理该第 i物理中断; 第三确定单元, 用于根据该第 i物理中断, 确定该第 i虚拟中断; 第四确定单元, 用于从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执 行该第 i虚拟中断; 其中, X、 Υ、 Ζ为大于 1的正整数, U为大于或等于 1 且小于或等于 X的正整数, V为大于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 n为正整数。
结合第三方面, 在第三方面的第一种可能的实现方式中, 该第一确定单 元, 还用于: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个目标 pCPU,其中该 V个目标 vCPU能够运行在该 U个目标 pCPU 上, 其中 U等于 1 ; 确定对应于该第 i虚拟中断的第 i物理中断; 确定该第 i 物理中断与该 U个目标 pCPU的亲和关系,其中该第 i物理中断能被该 U个 目标 pCPU处理。
结合第三方面, 在第三方面的第二种可能的实现方式中, 该第一确定单 元, 还用于: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个目标 pCPU,其中该 V个目标 vCPU能够运行在该多个目标 pCPU 上,其中 U为大于 1且小于或等于 X的正整数; 确定对应于该第 i虚拟中断 的第 i物理中断; 确定该第 i物理中断与该 U个目标 pCPU的亲和关系, 其 中该第 i物理中断能被该 U个目标 pCPU处理。
结合第三方面的第二种可能的实现方式,在第三方面的第三种可能的实 现方式中, 该第四确定单元, 具体用于: 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU;在确定该第 n pCPU上运行有该 V 个目标 vCPU中的至少一个目标 vCPU的情况下, 确定该第 n pCPU上运行 的一个目标 vCPU作为该第 m vCPU, 以便于该第 k VM使用该第 m vCPU 执行该第 i虚拟中断; 或者, 在确定该第 n pCPU上没有运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 根据优先级顺序, 从该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU,以便于该第 k VM使用该第 m vCPU执行该第 i虚拟中断。
结合第三方面的第三种可能的实现方式,在第三方面的第四种可能的实 现方式中, 在该确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一 个目标 vCPU的方面, 该第四确定单元, 具体用于根据虚拟中断路由信息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该虚拟中断路由信息包括该 U个目标 pCPU与运行在该 U个目标 pCPU 上的目标 vCPU的对应关系。
第四方面, 本发明实施例提供一种宿主机 Host, 应用于计算节点上, 该 计算节点包括: 物理硬件层、 运行在该物理硬件层之上的该 Host、 运行在该 Host之上的 Y个虚拟机 VM、 运行在该 Host之上的 Y个虚拟主机 vhost内 核线程、 该至少一个 VM上被虚拟有虚拟硬件, 其中, 该物理硬件层包括 X 个物理中央处理器 pCPU, 该虚拟硬件包括 Z个虚拟中央处理器 vCPU, X、 Y、 Z为大于 1的正整数, 该 Υ个 VM中的每一个 VM包括一个半虚拟化驱 动 virtio设备, 该 Y个 VM包括第 k VM, 该第 k VM包括第 i virtio设备, 该第 i virtio设备与该 Y个 vhost内核线程中的第 j vhost内核线程对应, 该 Host包括: 第一确定单元, 用于在该第 j vhost内核线程触发第 i vhost线程 的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU 为与该第 i vhost线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个 目标 vCPU为被虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和 关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X 个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 第 二调用单元, 用于使用该第 n pCPU处理该第 i vhost线程; 第三确定单元, 用于根据该第 i vhost线程, 确定该第 i virtio设备的虚拟中断; 第四确定单 元, 用于从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该 第 m vCPU执行该第 i virtio设备的虚拟中断; 其中, X、 Y、 Ζ为大于 1的 正整数, U为大于或等于 1且小于或等于 X的正整数, V为大于或等于 1且 小于或等于 Z的正整数, i、 j、 k、 m、 n为正整数。
结合第四方面, 在第四方面的第一种可能的实现方式中, 该第一确定单 元, 还用于: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚拟 中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在 该 U个目标 pCPU上, 其中 U等于 1 ; 确定对应于该第 i virtio设备的虚拟 中断的第 i vhost线程; 确定该第 i vhost线程与该 U个目标 pCPU的亲和关 系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。
结合第四方面的, 在第四方面的第二种可能的实现方式中, 该第一确定 单元, 还用于: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中 该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚 拟中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行 在该多个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数; 确定 对应于该第 i virtio设备的虚拟中断的第 i vhost线程; 确定该第 i vhost线程 与该 U个目标 pCPU的亲和关系,其中该第 i vhost线程能被该 U个目标 pCPU 处理。
结合第四方面的第二种可能的实现方式,在第四方面的第三种可能的实 现方式中, 该第四确定单元, 具体用于: 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU;在确定该第 n pCPU上运行有该 V 个目标 vCPU中的至少一个目标 vCPU的情况下, 确定该第 n pCPU上运行 的一个目标 vCPU作为该第 m vCPU, 以便于该第 k VM使用该第 m vCPU 执行该第 i virtio设备的虚拟中断; 或者, 在确定该第 n pCPU上没有运行有 该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 根据优先级顺序, 从 该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断。
结合第四方面的第三种可能的实现方式,在第四方面的第四种可能的实 现方式中, 在该确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一 个目标 vCPU的方面, 该第四确定单元, 具体用于根据 virtio设备的虚拟中 断路由信息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一 个目标 vCPU,其中该 virtio设备的虚拟中断路由信息包括该 U个目标 pCPU 与运行在该 U个目标 pCPU上的目标 vCPU的对应关系。 第五方面, 本发明实施例提供一种计算节点, 该计算节点包括: Y个物 理输入输出设备,其中该 Y个物理输入输出设备包括第 j物理输入输出设备, X个物理中央处理器 pCPU, 与该 X个物理中央处理器 pCPU和 Y个物理输 入输出设备分别连接的存储器,其中该 X个物理中央处理器 pCPU中的一个 或多个 pCPU用于调用或执行该存储器中存储的操作指令、 宿主机 Host、 至 少一个虚拟机 VM以及该至少一个虚拟机 VM上被虚拟的虚拟硬件,其中该 虚拟硬件包括 Z个虚拟中央处理器 vCPU, 该至少一个 VM包括第 k VM, 该第 j物理输入输出设备直通该第 k VM, 其中, 该 Host用于: 在该第 j物 理输入输出设备发生第 i物理中断的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i物理中断以及 V个目标 vCPU 均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该第 k VM上的与 第 i虚拟中断具有亲和关系的 vCPU,该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U个目标 pCPU,该 Z个 vCPU包括该 V个目标 vCPU, U为大于或等于 1且小于或等于 X的正整数, V为大于或等于 1且小于或等 于 Z的正整数; 使用该第 n pCPU处理该第 i物理中断; 根据该第 i物理中 断, 确定该第 i虚拟中断; 从该 V个目标 vCPU中确定第 m vCPU, 以便于 该第 k VM使用该第 m vCPU执行该第 i虚拟中断; 其中 i、 j、 k、 m、 n为 正整数。
结合第五方面, 在第五方面的第一种可能的实现方式中, 该 Host还用 于通过以下方式确定该 U个目标 pCPU与该第 i物理中断的亲和关系, 该 U 个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关 系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i虚拟 中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在 该 U个目标 pCPU上, 其中 U等于 1 ; 确定对应于该第 i虚拟中断的第 i物 理中断; 确定该第 i物理中断与该 U个目标 pCPU的亲和关系, 其中该第 i 物理中断能被该 U个目标 pCPU处理。
结合第五方面, 在第五方面的第二种可能的实现方式中, 该 Host还用 于通过以下方式确定该 U个目标 pCPU与该第 i物理中断的亲和关系, 该 U 个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关 系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i虚拟 中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在 该多个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数; 确定对 应于该第 i虚拟中断的第 i物理中断;确定该第 i物理中断与该 U个目标 pCPU 的亲和关系, 其中该第 i物理中断能被该 U个目标 pCPU处理。
结合第五方面的第二种可能的实现方式,在第五方面的第三种可能的实 现方式中, 在该从该 V个目标 vCPU中确定第 m vCPU的方面, 该 Host具 体用于: 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目 标 vCPU; 在确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目 标 vCPU的情况下, 确定该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU; 在确定该第 n pCPU上没有运行有该 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从该 V个目标 vCPU中确定一个目 标 vCPU作为该第 m vCPU。
结合第五方面的第三种, 在第五方面的第四种可能的实现方式中, 在该 确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一个目标 vCPU的 方面, 该 Host具体用于: 根据虚拟中断路由信息, 确定该第 n pCPU上是否 运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该虚拟中断路由信 息包括该 U个目标 pCPU与运行在该 U个目标 pCPU上的目标 vCPU的对应 关系。
第六方面, 本发明实施例提供一种计算节点, 该计算节点包括: X个物 理中央处理器 pCPU, 与该 X个物理中央处理器 pCPU连接的存储器, 其中 该 X个物理中央处理器 pCPU中的一个或多个 pCPU用于调用或执行该存储 器中存储的操作指令、 宿主机 Host、 Y个虚拟机 VM、 Y个虚拟主机 vhost 内核线程以及该至少一个虚拟机 VM上被虚拟的虚拟硬件,其中该虚拟硬件 包括 Z个虚拟中央处理器 vCPU,该 Y个 VM中的每一个 VM包括一个半虚 拟化驱动 virtio设备, 该 Y个 VM包括第 k VM, 该第 k VM包括第 i virtio 设备,该第 i virtio设备与该 Y个 vhost内核线程中的第 j vhost内核线程对应, 其中, 该 Host用于: 在该第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU,其中,该 U个目标 pCPU为与该第 i vhost 线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个目标 vCPU为被 虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU, U为大于或等于 1 且小于或等于 X的正整数, V为大于或等于 1且小于或等于 Z的正整数; 使用该第 n pCPU处理该第 i vhost线程; 根据该第 i vhost线程, 确定该第 i virtio设备的虚拟中断; 从该 V个目标 vCPU中确定第 m vCPU, 以便于该 第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断; 其中 X、 Y、 Ζ为大于 1的正整数, U为大于或等于 1且小于或等于 X的正整数, V为大 于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 n为正整数。
结合第六方面, 在第六方面的第一种可能的实现方式中, 该 Host还用 于通过以下方式确定该 U个目标 pCPU与该第 i物理中断的亲和关系, 该 U 个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关 系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio 设备的虚拟中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU 能够运行在该 U个目标 pCPU上, 其中 U等于 1 ; 确定对应于该第 i virtio 设备的虚拟中断的第 i vhost线程;确定该第 i vhost线程与该 U个目标 pCPU 的亲和关系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。
结合第六方面, 在第六方面的第二种可能的实现方式中, 该 Host还用 于通过以下方式确定该 U个目标 pCPU与该第 i物理中断的亲和关系, 该 U 个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确定该 V个目标 vCPU与该第 i虚拟中断的亲和关 系, 其中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio 设备的虚拟中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU 能够运行在该多个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整 数;确定对应于该第 i virtio设备的虚拟中断的第 i vhost线程;确定该第 i vhost 线程与该 U个目标 pCPU的亲和关系, 其中该第 i vhost线程能被该 U个目 标 pCPU处理。
结合第六方面的第二种可能的实现方式,在第六方面的第三种可能的实 现方式中, 在该从该 V个目标 vCPU中确定第 m vCPU的方面, 该 Host具 体用于: 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目 标 vCPU; 在确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目 标 vCPU的情况下, 确定该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU; 在确定该第 n pCPU上没有运行有该 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从该 V个目标 vCPU中确定一个目 标 vCPU作为该第 m vCPU。
结合第六方面的第三种可能的实现方式,在第六方面的第四种可能的实 现方式中, 在该确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一 个目标 vCPU的方面, 该 Host具体用于: 根据 virtio设备的虚拟中断路由信 息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该 virtio设备的虚拟中断路由信息包括该 U个目标 pCPU与运 行在该 U个目标 pCPU上的目标 vCPU的对应关系。
一方面, 本发明实施例中, 在第 j物理输入输出设备发生第 i物理中断 的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU 为与该第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个 目标 vCPU 为被虚拟在该第 k VM 上的与第 i虚拟中断具有亲和关系的 vCPU, 该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U个 目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使用该第 n pCPU处理 该第 i物理中断; 根据该第 i物理中断, 确定该第 i虚拟中断; 从该 V个目 标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i 虚拟中断,可见通过上述技术方案能够有效地避免因为 vCPU所亲和的 pCPU 不是用于处理该 vCPU所处理的虚拟中断所对应的物理中断的 pCPU引起额 夕卜的 IPI导致的 VM-Exit, 有效地减少上下文切换次数, 并且降低虚拟机对 pCPU的干扰。
另一方面, 本发明实施例中, 在该第 j vhost内核线程触发第 i vhost线 程的情况下,从 U个目标 pCPU中确定第 n pCPU,其中,该 U个目标 pCPU 为与该第 i vhost线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个 目标 vCPU为被虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和 关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X 个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使 用该第 n pCPU处理该第 i vhost线程;根据该第 i vhost线程,确定该第 i virtio 设备的虚拟中断;从该 V个目标 vCPU中确定第 m vCPU,以便于该第 k VM 使用该第 m vCPU执行该第 i virtio设备的虚拟中断,可见通过上述技术方案 能够有效地避免因为 vCPU所亲和的 pCPU不是用于处理该 vCPU所处理的 虚拟中断所对应的物理中断的 pCPU引起额外的 IPI导致的 VM-Exit, 有效 地减少上下文切换次数, 并且降低虚拟机对 pCPU的干扰。 附图说明
为了更清楚地说明本发明实施例的技术方案, 下面将对本发明实施例中 所需要使用的附图作简单地介绍, 显而易见地, 下面所描述的附图仅仅是本 发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的 前提下, 还可以根据这些附图获得其他的附图。
图 1是一种直通模式的示意图。
图 2是一种前后端模式的示意图。 图。 ; " 、
图 4是本发明实施例提供的虚拟中断、 物理中断、 vCPU以及 pCPU的 对应关系的示意图。
图 5是本发明实施例提供的另一虚拟中断、物理中断、 vCPU以及 pCPU 的对应关系的示意图。
图 6 是根据本发明提供的另一虚拟化平台处理中断方法的示意性流程 图。
图 7是本发明实施例提供的 virtio设备的虚拟中断、 vhost线程、 vCPU 以及 pCPU的对应关系的示意图。
图 8是本发明实施例提供的另一 virtio设备的虚拟中断、 vhost线程、 vCPU以及 pCPU的对应关系的示意图。 图 10是根据本发明实施例提供的另一宿主机 Host的结构框图。
图 11是根据本发明实施例提供的计算节点的结构框图。
图 12是根据本发明实施例提供的另一计算节点的结构框图。 具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所述的实施例是本发明的一部分实施例, 而不是 全部实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做出创造 性劳动的前提下所获得的所有其他实施例, 都应属于本发明保护的范围。
为了方便理解本发明实施例, 首先在此介绍本发明实施例描述中会引入 的几个要素。
虚拟机:
通过虚拟机软件可以在一台物理计算节点上模拟出一台或者多台的计 算节点,其中该物理计算节点可以是服务器、 台式计算机、便携式计算机等。 模拟的计算节点称为虚拟机 ( Virtual Machine, VM )。 该物理计算节点称为宿 主机。 虚拟机可以像真正的计算节点进行工作。 虚拟机上可以安装操作系统 和应用程序。 虚拟机还可访问网络资源。 虚拟机上运行的操作系统称为虚拟 操作系统。虚拟操作系统中运行的程序就像是运行在真正的计算节点的操作 系统中。 虚拟机还可以被虚拟有虚拟硬件。 具体来说, 这种被虚拟是通过宿 主机( Host )在 VM上模拟的虚拟硬件, 例如虚拟中央处理器( virtual Central Processing Unit, vCPU )。 vCPU用于处理虚拟机中运行的程序。 一个或多个 vCPU可以对应于物理计算节点中的一个中央处理器 ( Central Processing Unit, CPU )。 物理计算节点中的 CPU可以称为物理 CPU ( physical CPU, pCPU pCPU可以有客户 (guest ) 态和宿主 (host ) 态。 在虚拟机运行时, pCPU处于 guest态。 由于特殊指令或外部中断等原因, pCPU可以从 guest态切 换到 host态。 这一过程可以称为虚拟机退出 (VM-Exit )。
虚拟设备的实现方式可以有直通模式和前后端模式。
直通模式:
直通(direct )模式, 也可以称为透传 ( assthrough )模式, 是指宿主机 向一个特定的虚拟机提供一种设备隔离, 以便特定的物理输入输出设备能够 被特定的虚拟机独占使用。 在直通模式下, 如果处理虚拟中断的 vCPU所对 应的 pCPU和处理该虚拟中断对应的物理中断的 pCPU不一致, 则引起额外的 处理器间中断( Inter-Processor Interrupt, IPI )导致的 VM-Exit。
前后端模式:
前后端 (split driver )模式是指将虚拟设备驱动通过前端驱动和后端驱 动两部分配合完成, 其中该前端驱动在虚拟机中, 该后端驱动在宿主机中。 前后端驱动通过共享内存的方式进行数据传输。 与纯软件虚拟的设备相比, 前后端驱动模式的抽象层次更高, 性能也更好。 前后端模式中, 每一个虚拟 机中都会有一个使用半虚拟化驱动 (virtio ) 的设备(简称 virtio设备)。 每一 个 virtio设备都会有一个对应的虚拟主机(vhost ) 内核线程, 其中 vhost内核 线程运行在宿主机中。 vhost内核线程用于处理对应的 virtio设备的数据包。 在前后端模式中,如果用于处理 virtio设备的虚拟中断的 vCPU对应的 pCPU与 用于处理对应于该 virtio设备的虚拟中断的 vhost线程的 pCPU不一致, 则引起 额外的 IPI导致的 VM-Exit。
图 1是一种直通模式的示意图。 如图 1所示, 计算节点 100中, 第一虚 拟机 101可以独占第一物理输入输出设备 111 , 第二虚拟机 102可以独占第 二物理输入输出设备 112。 图 3所示的方法可以应用于釆用如图 1所示的直 通模式的虚拟机。
图 2是一种前后端模式的示意图。如图 2所示,计算节点 200中第一 virtio 设备 211与第一 vhost线程 212对应,计算节点 200中的第二 virtio设备 221 与第二 vhost线程 222对应, 其中第一 virtio设备是第一虚拟机中的 virtio设 备, 第二 virtio设备是第二虚拟机中的 virtio设备 211。 图 6所示的方法可以 应用于釆用如图 2所示的前后端模式的虚拟机。 图。 该方法应用于计算节点上, 该计算节点包括: 物理硬件层、 运行在该物 理硬件层之上的宿主机 Host, 运行在该 Host之上的至少一个虚拟机 VM、 该至少一个 VM上被虚拟有虚拟硬件, 其中, 该物理硬件层包括 X个物理 中央处理器 pCPU和 Y个物理输入输出设备,该虚拟硬件包括 Z个虚拟中央 处理器 vCPU, X、 Υ、 Ζ为大于 1的正整数, 该 Υ个物理输入输出设备包括 第 j物理输入输出设备,该至少一个 VM包括第 k VM,该第 j物理输入输出 设备直通该第 k VM, 该方法由该 Host执行。
301,在该第 j物理输入输出设备发生第 i物理中断的情况下,从 U个目 标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i物理中断 以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个目标 vCPU为被虚拟 在该第 k VM上的与第 i虚拟中断具有亲和关系的 vCPU,该第 i虚拟中断对 应于该第 i物理中断, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU 包括该 V个目标 vCPU, U为大于或等于 1且小于或等于 X的正整数, V为 大于或等于 1且小于或等于 Z的正整数。 302, 使用该第 n pCPU处理该第 i物理中断。
303, 根据该第 i物理中断, 确定该第 i虚拟中断。
304,从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该 第 m vCPU执行该第 i虚拟中断, i、 j、 k、 m、 n为正整数。
可见, 本发明实施例中, 在第 j物理输入输出设备发生第 i物理中断的 情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为 与该第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个目 标 vCPU为被虚拟在该第 k VM上的与第 i虚拟中断具有亲和关系的 vCPU, 该第 i虚拟中断对应于该第 i物理中断,该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使用该第 n pCPU处理该第 i物理中 断; 根据该第 i物理中断, 确定该第 i虚拟中断; 从该 V个目标 vCPU中确 定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i虚拟中断, 从而本发明实施例的方法能够有效地避免因为 vCPU所亲和的 pCPU不是用 导致的 VM-Exit, 有效地减少上下文切换次数, 并且降低虚拟机对 pCPU的 干扰。
宿主机可以通过虚拟机管理程序实现图 3所示的方法。虚拟机管理程序 也可以称为虚拟机监视器(Virtual Machine Monitor, VMM )或超级监督者 ( hypervisor )。 典型的 VMM有 VMware ESX, XEN, KVM/Qemu等。
具体来说, pCPU与物理中断具有亲和关系是指, 该 pCPU能够处理该 物理中断。 vCPU与虚拟中断具有亲和关系是指, 该 vCPU能够处理该虚拟 中断。 pCPU与 vCPU具有亲和关系是指, 该 vCPU可以运行在该 pCPU上。 因此,根据该 U个目标 pCPU与该第 i物理中断的亲和关系,从该 U个目标 pCPU中确定该第 n pCPU。
可选的, 作为一个实施例, 该 U个目标 pCPU与该第 i物理中断的亲和 关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系是通过以下方式确定的: 确定该 V个目 标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在 该第 k VM上的能够处理该第 i虚拟中断的 vCPU, 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该 U个目标 pCPU上, 其中 U等于 1, 确定对应于该第 i虚拟中断的第 i物理中断, 确定该第 i物理中断与该 U个 目标 pCPU的亲和关系, 其中该第 i物理中断能被该 U个目标 pCPU处理。 该 U个目标 pCPU与该第 i物理中断的亲和关系、该 U个目标 pCPU与该 V 个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关 系可以预先设置好并保存, 然后在发生物理中断的情况下可以根据保存的亲 和关系之间找到相应的 pCPU以及 vCPU处理物理中断和虚拟中断。 或者, 当该 U个目标 pCPU与该第 i物理中断的亲和关系、该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和 关系设置好的情况下, 可以根据这些亲和关系找到相应的 pCPU以及 vCPU 处理对应的物理中断和虚拟中断。 在此情况下, 当第 i物理中断发生时, 用 于处理对应于第 i物理中断的第 i虚拟中断的第 m vCPU运行在处理该第 i 物理中断的第 n pCPU上。
可选的, 作为另一个实施例, 该 U个目标 pCPU与该第 i物理中断的亲 和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目 标 vCPU与该第 i虚拟中断的亲和关系是通过以下方式确定的, 确定该 V个 目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟 在该第 k VM上的能够处理该第 i虚拟中断的 vCPU,确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该多个目标 pCPU上, 其中 U为大于 1 且小于或等于 X的正整数, 确定对应于该第 i虚拟中断的第 i物理中断, 确 定该第 i物理中断与该 U个目标 pCPU的亲和关系, 其中该第 i物理中断能 被该 U个目标 pCPU处理。该 U个目标 pCPU与该第 i物理中断的亲和关系、 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU 与该第 i虚拟中断的亲和关系可以预先设置好并保存, 然后在发生物理中断 的情况下可以根据保存的亲和关系之间找到相应的 pCPU以及 vCPU处理物 理中断和虚拟中断。 或者, 当该 U个目标 pCPU与该第 i物理中断的亲和关 系、该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU 与该第 i虚拟中断的亲和关系设置好的情况下, 可以根据这些亲和关系找到 相应的 pCPU以及 vCPU处理对应的物理中断和虚拟中断。 在此情况下, 当 第 i物理中断发生时, 用于处理对应于第 i物理中断的第 i虚拟中断的第 m vCPU运行在有限个确定的 pCPU上而不是该物理硬件层中的任一个 pCPU 上, 并且有可能运行在处理该第 i物理中断的第 n pCPU上。
进一步,当该 V个目标 vCPU能够运行在该多个目标 pCPU上(换言之, 当该第 i物理中断与该 U个目标 pCPU的亲和关系为一对多的亲和关系)时, 该从该 V个目标 vCPU中确定第 m vCPU, 包括: 确定该第 n pCPU上是否 运行有该 V个目标 vCPU中的至少一个目标 vCPU, 在确定该第 n pCPU上 运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 确定该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU,在确定该第 n pCPU上没 有运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下,根据优先级 顺序,从该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU。此时, 如果用于处理虚拟中断的 vCPU运行在用于处理物理中断的 pCPU上, 就不 IPI导致的 VM-Exit。 该优先级顺序可以是预先设定的 V个目标 vCPU的优 先级。该优先级的选择也可以釆取 round-robin策略确定, 即保证每一个目标 vCPU被选中的概率是相同的。
进一步, 该确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少 一个目标 vCPU, 包括: 根据虚拟中断路由信息, 确定该第 n pCPU上是否 运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该虚拟中断路由信 息包括该 U个目标 pCPU与运行在该 U个目标 pCPU上的目标 vCPU的对应 关系。 这样, Host可以方便快速地确定该第 m vCPU是否运行在该第 n pCU 上。
图 4是本发明实施例提供的虚拟中断、 物理中断、 vCPU以及 pCPU的 对应关系的示意图。 如图 4所示, 第 1号物理中断对应于第 1号虚拟中断。 第 1号虚拟中断与第 4号 vCPU具有亲和关系。第 4号 vCPU与第 3号 pCPU 具有亲和关系。 此时, 可以将第 3号 pCPU与第 1号物理中断绑定, 使得两 者具有亲和关系。 那么, 当第 1号物理中断发生时, 第 3号 pCPU就可以处 理该第 1号物理中断。 然后, 找到与第 1号物理中断对应的第 1号虚拟中断 以及用于处理第 1号虚拟中断的 vCPU。当第 4号 vCPU运行在第 3号 pCPU 上时, 可以直接使用该第 4号 vCPU处理与第 1号物理中断对应的第 1号虚 拟中断。这样,就不会发生由于运行 vCPU的 pCPU与发生物理中断的 pCPU 不同引起的额外的 IPI导致的 VM-Exit。
图 5是本发明实施例提供的另一虚拟中断、物理中断、 vCPU以及 pCPU 的对应关系的示意图。如图 5所示,第 1号物理中断对应于第 1号虚拟中断。 第 4号 vCPU、 第 5号 vCPU与第 3号 pCPU、 4号 pCPU均具有亲和关系。 换句话说, 第 4号 vCPU和 5号 vCPU可以运行在第 3号 pCPU上, 也可以 运行在第 4号 pCPU上。例如,在第一时刻,第 4号 vCPU运行在第 3号 pCPU 上, 第 5号 vCPU运行在第 4号 pCPU上。 在第二时刻, 第 4号 vCPU和第 5号 vCPU可以同时运行在第 3号 pCPU上。 此外, 第 4号 vCPU和第 5号 vCPU与第 1号虚拟中断具有亲和关系。 也就是说, 第 1号虚拟中断可以由 第 4号 vCPU或第 5号 vCPU处理。此时,可以将第 3号 pCPU和第 4号 pCPU 均与第 1号物理中断绑定, 使得两者具有亲和关系。 那么, 当第 1号物理中 断发生时, Host可以从第 3号 pCPU或第 4号 pCPU中选择一个 pCPU处理 该第 1号物理中断。 然后, Host找到与第 1号物理中断对应的第 1号虚拟中 断以及用于处理第 1号虚拟中断的 vCPU, 并使用该 vCPU处理第 1号虚拟 中断。 由于用于处理虚拟中断的 vCPU 可能会运行在用于处理物理中断的 不同引起的额外的 IPI导致的 VM-Exit。
图 6 是根据本发明提供的另一虚拟化平台处理中断方法的示意性流程 图。 图 6所示的方法可以应用于计算节点上,该计算节点包括: 物理硬件层、 运行在该物理硬件层之上的宿主机 Host, 运行在该 Host之上的 Y个虚拟机 VM、 运行在该 Host之上的 Y个虚拟主机 vhost内核线程、 该至少一个 VM 上被虚拟有虚拟硬件,其中,该物理硬件层包括 X个物理中央处理器 pCPU, 该虚拟硬件包括 Z个虚拟中央处理器 vCPU, X、 Υ、 Ζ为大于 1的正整数, 该 Υ个 VM中的每一个 VM包括一个半虚拟化驱动 virtio设备,该 Y个 VM 包括第 k VM,该第 k VM包括第 i virtio设备,该第 i virtio设备与该 Y个 vhost 内核线程中的第 j vhost内核线程对应, 该方法由该 Host执行。
601, 在该第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i vhost线程以 及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个目标 vCPU为被虚拟在 该第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X个 pCPU包括该 U个目 标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU, U为大于或等于 1且小于 或等于 X的正整数, V为大于或等于 1且小于或等于 Z的正整数。
602, 使用该第 n pCPU处理该第 i vhost线程。
603, 根据该第 i vhost线程, 确定该第 i virtio设备的虚拟中断。 604,从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该 第 m vCPU执行该第 i virtio设备的虚拟中断, i、 j、 k、 m、 n为正整数。
本发明实施例中, 在该第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU,其中,该 U个目标 pCPU为与该第 i vhost 线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个目标 vCPU为被 虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使用该第 n pCPU 处理该第 i vhost线程; 根据该第 i vhost线程, 确定该第 i virtio设备的虚拟 中断; 从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断, 可见通过上述技术方案能够有效 地避免因为 vCPU所亲和的 pCPU不是用于处理该 vCPU所处理的 virtio设 备的虚拟中断所对应的 vhost线程的 pCPU引起额外的 IPI导致的 VM-Exit, 有效地减少上下文切换次数, 并且降低虚拟机对 pCPU的干扰。
宿主机可以通过虚拟机管理程序实现图 6所示的方法。虚拟机管理程序 也可以称为虚拟机监视器 (Virtual Machine Monitor, VMM )或超级监督者 ( hypervisor )。 典型的 VMM有 VMware ESX, XEN, KVM/Qemu等。
具体来说, pCPU与 vhost线程具有亲和关系是指, 该 pCPU能够处理 该 vhost线程。 vCPU与 virtio设备的虚拟中断具有亲和关系是指, 该 vCPU 能够处理该 virtio设备的虚拟中断。 pCPU与 vCPU具有亲和关系是指, 该 vCPU可以运行在该 pCPU上。 因此, 根据该 U个目标 pCPU与该第 i物理 中断的亲和关系, 从该 U个目标 pCPU中确定该第 n pCPU。
可选的, 作为一个实施例, 该 U个目标 pCPU与该第 i vhost线程的亲 和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目 标 vCPU与该第 i virtio设备的虚拟中断的亲和关系是通过以下方式确定的: 确定该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系,其中该 V 个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚拟中 断的 vCPU, 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该 U个目标 pCPU上, 其中 U等于 1, 确定对应于该第 i virtio设备的虚拟中断 的第 i vhost线程, 确定该第 i vhost线程与该 U个目标 pCPU的亲和关系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。 该 U个目标 pCPU与该 第 i vhost线程的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和 关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系可以 预先设置好并保存, 然后在发生 vhost线程的情况下可以根据保存的亲和关 系之间找到相应的 pCPU以及 vCPU处理 vhost线程和 viritio设备的虚拟中 断。 或者, 当该 U个目标 pCPU与该第 i vhost线程的亲和关系, 该 U个目 标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系设置好的情况下, 可以根据这些亲和关系 找到相应的 pCPU以及 vCPU处理对应的 vhost线程和 virtio设备的虚拟中断。 在此情况下, 当第 i vhost线程发生时, 用于处理对应于第 i vhost线程的第 i virito设备的虚拟中断的第 m vCPU运行在处理该第 i vhost线程的第 n pCPU 上。
可选的, 作为另一个实施例, 该 U个目标 pCPU与该第 i vhost线程的 亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个 目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系是通过以下方式确定 的: 确定该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系, 其 中该 V个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio设备的 虚拟中断的 vCPU, 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运 行在该多个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数, 确 定对应于该第 i virtio设备的虚拟中断的第 i vhost线程, 确定该第 i vhost线 程与该 U个目标 pCPU的亲和关系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。该 U个目标 pCPU与该第 i vhost线程的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i virtio 设备的虚拟中断的亲和关系可以预先设置好并保存, 然后在发生 vhost线程 的情况下可以根据保存的亲和关系之间找到相应的 pCPU 以及 vCPU处理 vhost线程和 viritio设备的虚拟中断。或者,当该 U个目标 pCPU与该第 i vhost 线程的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及 该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系设置好的情况 下, 可以根据这些亲和关系找到相应的 pCPU以及 vCPU处理对应的 vhost 线程和 virtio设备的虚拟中断。 在此情况下, 当第 i vhost线程发生时, 用于 处理对应于第 i vhost线程的的第 i virito设备的虚拟中断的第 m vCPU运行 在有限个确定的 pCPU上而不是该物理硬件层中的任一个 pCPU上, 并且有 可能运行在处理该第 i vhost线程的第 n pCPU上。
进一步,在该 V个目标 vCPU能够运行在该多个目标 pCPU上的情况下 (换言之, 当该第 i vhost线程与该 U个目标 pCPU的亲和关系为一对多的 亲和关系),该从该 V个目标 vCPU中确定第 m vCPU,包括:确定该第 n pCPU 上是否运行有该 V个目标 vCPU 中的至少一个目标 vCPU, 在确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 确定 该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU,在确定该第 n pCPU 上没有运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下,根据优 先级顺序, 从该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU。 此时, 如果用于处理 virito设备的虚拟中断的 vCPU运行在用于处理 vhost 线程的 pCPU上, 就不会发生由于运行 vCPU的 pCPU与处理 vhost线程的 pCPU不同引起的额外的 IPI导致的 VM-Exit。该优先级顺序可以是预先设定 的 V个目标 vCPU的优先级。 该优先级的选择也可以釆取 round-robin策略 确定, 即保证每一个目标 vCPU被选中的概率是相同的。
进一步, 该确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少 一个目标 vCPU, 包括: 根据 virtio设备的虚拟中断路由信息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU 中的至少一个目标 vCPU, 其中该 virtio设备的虚拟中断路由信息包括该 U个目标 pCPU与运行在该 U个目标 pCPU上的目标 vCPU的对应关系。 这样, Host可以方便快速地确定该第 m vCPU是否运行在该第 n pCU上。
图 7是本发明实施例提供的 virtio设备的虚拟中断、 vhost线程、 vCPU 以及 pCPU的对应关系的示意图。 如图 7所示, 第 1号 vhost线程对应于第 1号 virtio设备的虚拟中断。第 4号 vCPU与第 1号 virtio设备的虚拟中断具 有亲和关系。 第 3号 pCPU与第 4号 vCPU具有亲和关系。 此时, 可以将第 1号 vhost线程与第 3号 pCPU绑定, 使得两者具有亲和关系。 那么, 当第 1 号 vhost线程发生时, 第 3号 pCPU就可以处理该第 1号 vhost线程。 然后, 找到与第 1号 vhost线程对应的第 1号 virtio设备的虚拟中断以及用于处理 第 1号 virtio设备的虚拟中断的 vCPU。 当第 4号 vCPU运行在第 3号 pCPU 上时, 可以直接使用该第 4号 vCPU处理与第 1号 vhost线程对应的第 1号 virtio设备的虚拟中断。 这样, 就不会发生由于运行 vCPU的 pCPU与发生 vhost线程的 pCPU不同引起的额外的 IPI导致的 VM-Exit。 图 8是本发明实施例提供的另一 virtio设备的虚拟中断、 vhost线程、 vCPU以及 pCPU的对应关系的示意图。 如图 8所示, 第 1号 vhost线程对 应于第 1号 virtio设备的虚拟中断。第 3号 pCPU、 4号 pCPU与第 4号 vCPU、 5号 vCPU均具有亲和关系。 换句话说, 第 4号 vCPU和 5号 vCPU可以运 行在第 3号 pCPU上, 也可以运行在第 4号 pCPU上。 例如, 在第一时刻, 第 4号 vCPU运行在第 3号 pCPU上,第 5号 vCPU运行在第 4号 pCPU上。 在第二时刻,第 4号 vCPU和第 5号 vCPU可以同时运行在第 3号 pCPU上。 此外, 第 4号 vCPU和第 5号 vCPU与第 1号 virtio设备的虚拟中断具有亲 和关系。 也就是说, 第 1号 virtio设备的虚拟中断可以由第 4号 vCPU或第 5号 vCPU处理。此时,可以将第 3号 pCPU和第 4号 pCPU均与第 1号 vhost 线程绑定,使得两者具有亲和关系。那么, 当第 1号 vhost线程发生时, Host 可以从第 3号 pCPU或第 4号 pCPU中选择一个 pCPU处理该第 1号 vhost 线程。 然后, Host找到与第 1号 vhost线程对应的第 1号 virtio设备的虚拟 中断以及用于处理第 1号 virtio设备的虚拟中断的 vCPU, 并使用该 vCPU 处理第 1号 virtio设备的虚拟中断。 由于用于处理 virtio设备的虚拟中断的 vCPU可能会运行在用于处理 vhost线程的 pCPU上, 因此就不会发生由于 运行 vCPU的 pCPU与发生 vhost线程的 pCPU不同引起的额外的 IPI导致的 VM-Exito
图 9是根据本发明实施例提供的宿主机 Host的结构框图。 图 9所示的 Host 900能够执行图 3所示的各个步骤。具体来说,该 Host应用于计算节点 上, 该计算节点包括: 物理硬件层、 运行在该物理硬件层之上的该 Host、 运 行在该 Host之上的至少一个虚拟机 VM、 该至少一个 VM上被虚拟有虚拟 硬件, 其中, 该物理硬件层包括 X个物理中央处理器 pCPU和 Y个物理输 入输出设备, 该虚拟硬件包括 Z个虚拟中央处理器 vCPU, X、 Υ、 Ζ为大于 1的正整数, 该 Υ个物理输入输出设备包括第 j物理输入输出设备, 该至少 一个 VM包括第 k VM , 该第 j物理输入输出设备直通该第 k VM , 该 Host 包括第一确定单元 901、 第二调用单元 902、 第三确定单元 903和第四确定 单元 904。
第一确定单元 901, 用于在该第 j物理输入输出设备发生第 i物理中断 的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU 为与该第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个 目标 vCPU 为被虚拟在该第 k VM 上的与第 i虚拟中断具有亲和关系的 vCPU, 该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U个 目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU, U为大于或等于 1且小 于或等于 X的正整数, V为大于或等于 1且小于或等于 Z的正整数。
第二调用单元 902, 用于使用该第 n pCPU处理该第 i物理中断。
第三确定单元 903, 用于根据该第 i物理中断, 确定该第 i虚拟中断。 第四确定单元 904, 用于从该 V个目标 vCPU中确定第 m vCPU, 以便 于该第 k VM使用该第 m vCPU执行该第 i虚拟中断, i、 j、 k、 m、 n为正整 数。
可见, 本发明实施例的 Host中, 在第 j物理输入输出设备发生第 i物理 中断的情况下,从 U个目标 pCPU中确定第 n pCPU,其中,该 U个目标 pCPU 为与该第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个 目标 vCPU 为被虚拟在该第 k VM 上的与第 i虚拟中断具有亲和关系的 vCPU, 该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U个 目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使用该第 n pCPU处理 该第 i物理中断; 根据该第 i物理中断, 确定该第 i虚拟中断; 从该 V个目 标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i 虚拟中断,从而图 9所示的 Host能够有效地避免因为 vCPU所亲和的 pCPU 不是用于处理该 vCPU所处理的虚拟中断所对应的物理中断的 pCPU引起额 外的 IPI导致的 VM-Exit, 有效地减少上下文切换次数, 并且降低虚拟机对 pCPU的干扰。
可选的, 作为一个实施例, 第一确定单元 901, 还用于确定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在该 第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个目标 pCPU,其 中该 V个目标 vCPU能够运行在该 U个目标 pCPU上, 其中 U等于 1 ; 确 定对应于该第 i虚拟中断的第 i物理中断; 确定该第 i物理中断与该 U个目 标 pCPU的亲和关系, 其中该第 i物理中断能被该 U个目标 pCPU处理。 这 样, 该 U个目标 pCPU与该第 i物理中断的亲和关系, 该 U个目标 pCPU与 该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲 和关系是就可以被确定好。 在此情况下, 当第 i物理中断发生时, 用于处理 对应于第 i物理中断的第 i虚拟中断的第 m vCPU运行在处理该第 i物理中 断的第 n pCPU上。
可选的, 作为另一个实施例, 第一确定单元 901, 还用于确定该 V个目 标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU为被虚拟在 该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该多个目标 pCPU上, 其中 U为大于 1 且小于或等于 X的正整数; 确定对应于该第 i虚拟中断的第 i物理中断; 确 定该第 i物理中断与该 U个目标 pCPU的亲和关系, 其中该第 i物理中断能 被该 U个目标 pCPU处理。 这样, 该 U个目标 pCPU与该第 i物理中断的亲 和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目 标 vCPU与该第 i虚拟中断的亲和关系是就可以被确定好。 在此情况下, 当 第 i物理中断发生时, 用于处理对应于第 i物理中断的第 i虚拟中断的第 m vCPU运行在有限个确定的 pCPU上而不是该物理硬件层中的任一个 pCPU 上, 并且有可能运行在处理该第 i物理中断的第 n pCPU上。
进一步,当该 V个目标 vCPU能够运行在该多个目标 pCPU上(换言之, 当该第 i物理中断与该 U个目标 pCPU的亲和关系为一对多的亲和关系)时, 第四确定单元 904, 具体用于用于确定该第 n pCPU上是否运行有该 V个目 标 vCPU中的至少一个目标 vCPU; 在确定该第 n pCPU上运行有该 V个目 标 vCPU中的至少一个目标 vCPU的情况下, 确定该第 n pCPU上运行的一 个目标 vCPU作为该第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行 该第 i虚拟中断;或者,在确定该第 n pCPU上没有运行有该 V个目标 vCPU 中的至少一个目标 vCPU的情况下, 根据优先级顺序, 从该 V个目标 vCPU 中确定一个目标 vCPU作为该第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i虚拟中断。 此时, 如果用于处理虚拟中断的 vCPU运行在 用于处理物理中断的 pCPU上, 就不会发生由于运行 vCPU的 pCPU与发生 物理中断的 pCPU不同引起的额外的 IPI导致的 VM-Exit。 该优先级顺序可 以是预先设定的 V 个目标 vCPU 的优先级。 该优先级的选择也可以釆取 round-robin策略确定, 即保证每一个目标 vCPU被选中的概率是相同的, 从 而能最大限度地避免因为 vCPU所亲和的 pCPU不是用于处理该 vCPU所处 理的虚拟中断所对应的物理中断的 pCPU引起额外的 IPI导致的 VM-Exit, 有效地减少上下文切换次数, 并且降低虚拟机对 pCPU的干扰。
进一步, 在确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一 个目标 vCPU的方面, 第四确定单元 904,具体用于根据虚拟中断路由信息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该虚拟中断路由信息包括该 U个目标 pCPU与运行在该 U个目标 pCPU 上的目标 vCPU的对应关系。 这样, Host可以方便快速地确定该第 m vCPU 是否运行在该第 n pCU上。
图 10是根据本发明实施例提供的另一宿主机 Host的结构框图。 图 10 所示的 Host 1000能够执行图 6所示的各个步骤。 Host 1000应用于计算节点 上, 该计算节点包括: 物理硬件层、 运行在该物理硬件层之上的该 Host、 运 行在该 Host之上的 Y个虚拟机 VM、 运行在该 Host之上的 Y个虚拟主机 vhost内核线程、 该至少一个 VM上被虚拟有虚拟硬件, 其中, 该物理硬件 层包括 X个物理中央处理器 pCPU, 该虚拟硬件包括 Z个虚拟中央处理器 vCPU, X、 Y、 Z为大于 1的正整数, 该 Υ个 VM中的每一个 VM包括一个 半虚拟化驱动 virtio设备,该 Y个 VM包括第 k VM,该第 k VM包括第 i virtio 设备,该第 i virtio设备与该 Y个 vhost内核线程中的第 j vhost内核线程对应, 该 Host包括第一确定单元 1001、 第二调用单元 1002、 第三确定单元 1003 和第四确定单元 1005。
第一确定单元 1001, 用于在该第 j vhost内核线程触发第 i vhost线程的 情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为 与该第 i vhost线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个目 标 vCPU为被虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和关 系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU, U为 大于或等于 1且小于或等于 X的正整数, V为大于或等于 1且小于或等于 Z 的正整数;
第二调用单元 1002, 用于使用该第 n pCPU处理该第 i vhost线程; 第三确定单元 1003, 还用于根据该第 i vhost线程, 确定该第 i virtio设 备的虚拟中断;
第四确定单元 1004, 还用于从该 V个目标 vCPU中确定第 m vCPU, 以 便于该第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断, i、 j、 k、 m、 n为正整数。
可见, 本发明实施例的宿主机 Host中, 在该第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个 目标 pCPU为与该第 i vhost线程以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该第 k VM上的与第 i virtio设备的虚 拟中断具有亲和关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V 个目标 vCPU; 使用该第 n pCPU处理该第 i vhost线程; 根据该第 i vhost线 程,确定该第 i virtio设备的虚拟中断;从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断, 从而 图 10所示的 Host能够有效地避免因为 vCPU所亲和的 pCPU不是用于处理 该 vCPU所处理的 virtio设备的虚拟中断所对应的 vhost线程的 pCPU引起额 夕卜的 IPI导致的 VM-Exit, 有效地减少上下文切换次数, 并且降低虚拟机对 pCPU的干扰。
可选的, 作为一个实施例, 第一确定单元 1001, 还用于确定该 V个目 标 vCPU与该第 i virtio设备的虚拟中断的亲和关系,其中该 V个目标 vCPU 为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚拟中断的 vCPU; 确定该 U个目标 pCPU,其中该 V个目标 vCPU能够运行在该 U个目标 pCPU 上, 其中 U等于 1 ; 确定对应于该第 i virtio设备的虚拟中断的第 i vhost线 程;确定该第 i vhost线程与该 U个目标 pCPU的亲和关系,其中该第 i vhost 线程能被该 U个目标 pCPU处理。 该 U个目标 pCPU与该第 i vhost线程的 亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个 目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系可以预先设置好并保 存, 然后在发生 vhost线程的情况下可以根据保存的亲和关系之间找到相应 的 pCPU以及 vCPU处理 vhost线程和 viritio设备的虚拟中断。 或者, 当该 U个目标 pCPU与该第 i vhost线程的亲和关系, 该 U个目标 pCPU与该 V 个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟 中断的亲和关系设置好的情况下, 可以根据这些亲和关系找到相应的 pCPU 以及 vCPU处理对应的 vhost线程和 virtio设备的虚拟中断。在此情况下, 当 第 i vhost线程发生时, 用于处理对应于第 i vhost线程的第 i virito设备的虚 拟中断的第 m vCPU运行在处理该第 i vhost线程的第 n pCPU上。
可选的, 作为另一实施例, 第一确定单元 1001, 还用于确定该 V个目 标 vCPU与该第 i virtio设备的虚拟中断的亲和关系,其中该 V个目标 vCPU 为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚拟中断的 vCPU。; 确定该 U个目标 pCPU,其中该 V个目标 vCPU能够运行在该多个目标 pCPU 上, 其中 U为大于 1且小于或等于 X的正整数; 确定对应于该第 i virtio设 备的虚拟中断的第 i vhost线程; 确定该第 i vhost线程与该 U个目标 pCPU 的亲和关系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。 该 U个目 标 pCPU与该第 i vhost线程的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲 和关系可以预先设置好并保存, 然后在发生 vhost线程的情况下可以根据保 存的亲和关系之间找到相应的 pCPU以及 vCPU处理 vhost线程和 viritio设 备的虚拟中断。 或者, 当该 U个目标 pCPU与该第 i vhost线程的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU 与该第 i virtio设备的虚拟中断的亲和关系设置好的情况下,可以根据这些亲 和关系找到相应的 pCPU以及 vCPU处理对应的 vhost线程和 virtio设备的虚 拟中断。 在此情况下, 当第 i vhost线程发生时, 用于处理对应于第 i vhost 线程的的第 i virito设备的虚拟中断的第 m vCPU运行在有限个确定的 pCPU 上而不是该物理硬件层中的任一个 pCPU上, 并且有可能运行在处理该第 i vhost线程的第 n pCPU上。
进一步,在该 V个目标 vCPU能够运行在该多个目标 pCPU上的情况下 (换言之, 当该第 i vhost线程与该 U个目标 pCPU的亲和关系为一对多的 亲和关系), 第四确定单元 1004, 具体用于确定该第 n pCPU上是否运行有 该 V个目标 vCPU中的至少一个目标 vCPU; 在确定该第 n pCPU上运行有 该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 确定该第 n pCPU上 运行的一个目标 vCPU作为该第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU执行所述第 i virtio设备的虚拟中断; 或者, 在确定该第 n pCPU上 没有运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下,根据优先 级顺序, 从该 V个目标 vCPU中确定一个目标 vCPU作为该第 m vCPU, 以 便于所述第 k VM使用所述第 m vCPU执行所述第 i virtio设备的虚拟中断。 此时, 如果用于处理 virito设备的虚拟中断的 vCPU运行在用于处理 vhost 线程的 pCPU上, 就不会发生由于运行 vCPU的 pCPU与处理 vhost线程的 pCPU不同引起的额外的 IPI导致的 VM-Exit。该优先级顺序可以是预先设定 的 V个目标 vCPU的优先级。 该优先级的选择也可以釆取 round-robin策略 确定, 即保证每一个目标 vCPU被选中的概率是相同的, 从而能最大限度地 避免因为 vCPU所亲和的 pCPU不是用于处理该 vCPU所处理的虚拟中断所 对应的物理中断的 pCPU引起额外的 IPI导致的 VM-Exit, 有效地减少上下 文切换次数, 并且降低虚拟机对 pCPU的干扰。
进一步, 在确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少 一个目标 vCPU的方面, 第四确定单元 1004, 具体用于根据 virtio设备的虚 拟中断路由信息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至 少一个目标 VCPU, 其中该 virtio设备的虚拟中断路由信息包括该 U个目标 pCPU与运行在该 U个目标 pCPU上的目标 vCPU的对应关系。 这样, Host 可以方便快速地确定该第 m vCPU是否运行在该第 n pCU上。 这样, Host 可以方便快速地确定该第 m vCPU是否运行在该第 n pCU上。
图 11是根据本发明实施例提供的计算节点的结构框图。 图 11所示的计 算节点能够执行图 3所示的各个步骤。 该计算节点包括: Y个物理输入输出 设备 1101, 其中该 Y个物理输入输出设备包括第 j物理输入输出设备, X个 物理中央处理器 pCPU 1102,与该 X个物理中央处理器 pCPU和 Y个物理输 入输出设备分别连接的存储器 1103, 其中该 X个物理中央处理器 pCPU中 的一个或多个 pCPU用于调用或执行该存储器 1103中存储的操作指令、 宿 主机 Host, 至少一个虚拟机 VM以及该至少一个虚拟机 VM上被虚拟的虚 拟硬件, 其中该虚拟硬件包括 Z个虚拟中央处理器 vCPU, 该至少一个 VM 包括第 k VM, 该第 j物理输入输出设备直通该第 k VM, 其中, 该 Host用 于:
在该第 j物理输入输出设备发生第 i物理中断的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该 第 k VM上的与第 i虚拟中断具有亲和关系的 vCPU,该第 i虚拟中断对应于 该第 i物理中断, 该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括 该 V个目标 vCPU;
使用该第 n pCPU处理该第 i物理中断;
根据该第 i物理中断, 确定该第 i虚拟中断;
从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i虚拟中断, 其中 X、 Y、 Ζ为大于 1的正整数, U为大于或 等于 1且小于或等于 X的正整数, V为大于或等于 1且小于或等于 Z的正 整数, i、 j、 k、 m、 n为正整数。
可见, 本发明实施例的计算节点中, 在第 j物理输入输出设备发生第 i 物理中断的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 该 U个目 标 pCPU为与该第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该第 k VM上的与第 i虚拟中断具有亲和关系 的 vCPU, 该第 i虚拟中断对应于该第 i物理中断, 该 X个 pCPU包括该 U 个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使用该第 n pCPU处 理该第 i物理中断; 根据该第 i物理中断, 确定该第 i虚拟中断; 从该 V个 目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该 第 i虚拟中断,从而图 11所示的计算节点能够有效地避免因为 vCPU所亲和 的 pCPU 不是用于处理该 vCPU 所处理的虚拟中断所对应的物理中断的 pCPU引起额外的 IPI导致的 VM-Exit,有效地减少上下文切换次数,并且降 低虚拟机对 pCPU的干扰。
可选的, 作为一个实施例, 该 Host还用于通过以下方式确定该 U个目 标 pCPU与该第 i物理中断的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确 定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU 为被虚拟在该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个 目标 pCPU, 其中该 V个目标 vCPU能够运行在该 U个目标 pCPU上, 其中 U等于 1 ; 确定对应于该第 i虚拟中断的第 i物理中断; 确定该第 i物理中断 与该 U个目标 pCPU的亲和关系,其中该第 i物理中断能被该 U个目标 pCPU 处理。 该 U个目标 pCPU与该第 i物理中断的亲和关系、 该 U个目标 pCPU 与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的 亲和关系可以预先设置好并保存, 然后在发生物理中断的情况下可以根据保 存的亲和关系之间找到相应的 pCPU以及 vCPU处理物理中断和虚拟中断。 或者,当该 U个目标 pCPU与该第 i物理中断的亲和关系、该 U个目标 pCPU 与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的 亲和关系设置好的情况下, 可以根据这些亲和关系找到相应的 pCPU 以及 vCPU处理对应的物理中断和虚拟中断。 在此情况下, 当第 i物理中断发生 时, 用于处理对应于第 i物理中断的第 i虚拟中断的第 m vCPU运行在处理 该第 i物理中断的第 n pCPU上。
可选的, 作为另一个实施例, 该 Host还用于通过以下方式确定该 U个 目标 pCPU与该第 i物理中断的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确 定该 V个目标 vCPU与该第 i虚拟中断的亲和关系, 其中该 V个目标 vCPU 为被虚拟在该第 k VM上的能够处理该第 i虚拟中断的 vCPU; 确定该 U个 目标 pCPU, 其中该 V个目标 vCPU能够运行在该多个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数; 确定对应于该第 i虚拟中断的第 i物 理中断; 确定该第 i物理中断与该 U个目标 pCPU的亲和关系, 其中该第 i 物理中断能被该 U个目标 pCPU处理。该 U个目标 pCPU与该第 i物理中断 的亲和关系、 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V 个目标 vCPU与该第 i虚拟中断的亲和关系可以预先设置好并保存, 然后在 发生物理中断的情况下可以根据保存的亲和关系之间找到相应的 pCPU以及 vCPU处理物理中断和虚拟中断。 或者, 当该 U个目标 pCPU与该第 i物理 中断的亲和关系、 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及 该 V个目标 vCPU与该第 i虚拟中断的亲和关系设置好的情况下, 可以根据 这些亲和关系找到相应的 pCPU 以及 vCPU处理对应的物理中断和虚拟中 断。 在此情况下, 当第 i物理中断发生时, 用于处理对应于第 i物理中断的 第 i虚拟中断的第 m vCPU运行在有限个确定的 pCPU上而不是该物理硬件 层中的任一个 pCPU上,并且有可能运行在处理该第 i物理中断的第 n pCPU 上。
进一步,当该 V个目标 vCPU能够运行在该多个目标 pCPU上(换言之, 当该第 i物理中断与该 U个目标 pCPU的亲和关系为一对多的亲和关系)时, 在从该 V个目标 vCPU中确定第 m vCPU的方面, 该 Host具体用于: 确定 该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU; 在 确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目标 vCPU的情 况下, 确定该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU; 在确 定该第 n pCPU上没有运行有该 V个目标 vCPU中的至少一个目标 vCPU的 情况下, 根据优先级顺序, 从该 V个目标 vCPU中确定一个目标 vCPU作为 该第 m vCPU。 此时, 如果用于处理虚拟中断的 vCPU运行在用于处理物理 中断的 pCPU上, 就不会发生由于运行 vCPU的 pCPU与发生物理中断的 pCPU不同引起的额外的 IPI导致的 VM-Exit。该优先级顺序可以是预先设定 的 V个目标 vCPU的优先级。 该优先级的选择也可以釆取 round-robin策略 确定, 即保证每一个目标 vCPU被选中的概率是相同的, 从而能最大限度地 避免因为 vCPU所亲和的 pCPU不是用于处理该 vCPU所处理的虚拟中断所 对应的物理中断的 pCPU弓 I起额外的 IPI导致的 VM-Exit, 有效地减少上下 文切换次数, 并且降低虚拟机对 pCPU的干扰。
进一步, 在确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一 个目标 vCPU的方面, 该 Host具体用于: 根据虚拟中断路由信息, 确定该 第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中 该虚拟中断路由信息包括该 U个目标 pCPU与运行在该 U个目标 pCPU上 的目标 vCPU的对应关系。 这样, Host可以方便快速地确定该第 m vCPU是 否运行在该第 n pCU上。
图 12是根据本发明实施例提供的另一计算节点的结构框图。 图 12所示 的计算节点 1200能够执行图 6所示的各个步骤。 计算节点 1200包括: X个 物理中央处理器 pCPU 1201,与该 X个物理中央处理器 pCPU连接的存储器 1202,其中该 X个物理中央处理器 pCPU中的一个或多个 pCPU用于调用或 执行该存储器 1202中存储的操作指令、 宿主机 Host、 Y个虚拟机 VM、 Y 个虚拟主机 vhost内核线程以及该至少一个虚拟机 VM上被虚拟的虚拟硬件, 其中该虚拟硬件包括 Z个虚拟中央处理器 vCPU, 该 Y个 VM中的每一个 VM包括一个半虚拟化驱动 virtio设备,该 Y个 VM包括第 k VM,该第 k VM 包括第 i virtio设备,该第 i virtio设备与该 Y个 vhost内核线程中的第 j vhost 内核线程对应, 其中, 该 Host用于:
在该第 j vhost内核线程触发第 i vhost线程的情况下,从 U个目标 pCPU 中确定第 n pCPU, 其中, 该 U个目标 pCPU为与该第 i vhost线程以及 V个 目标 vCPU均具有亲和关系的 pCPU, 该 V个目标 vCPU为被虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 该第 i virtio设 备的虚拟中断对应于该第 i vhost线程,该 X个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU;
使用该第 n pCPU处理该第 i vhost线程;
根据该第 i vhost线程, 确定该第 i virtio设备的虚拟中断;
从该 V个目标 vCPU中确定第 m vCPU, 以便于该第 k VM使用该第 m vCPU执行该第 i virtio设备的虚拟中断, 其中 X、 Y、 Ζ为大于 1的正整数, U为大于或等于 1且小于或等于 X的正整数, V为大于或等于 1且小于或等 于 Ζ的正整数, i、 j、 k、 m、 n为正整数。
本发明实施例的计算节点中, 在该第 j vhost内核线程触发第 i vhost线 程的情况下,从 U个目标 pCPU中确定第 n pCPU,其中,该 U个目标 pCPU 为与该第 i vhost线程以及 V个目标 vCPU均具有亲和关系的 pCPU,该 V个 目标 vCPU为被虚拟在该第 k VM上的与第 i virtio设备的虚拟中断具有亲和 关系的 vCPU, 该第 i virtio设备的虚拟中断对应于该第 i vhost线程, 该 X 个 pCPU包括该 U个目标 pCPU, 该 Z个 vCPU包括该 V个目标 vCPU; 使 用该第 n pCPU处理该第 i vhost线程;根据该第 i vhost线程,确定该第 i virtio 设备的虚拟中断;从该 V个目标 vCPU中确定第 m vCPU,以便于该第 k VM 使用该第 m vCPU执行该第 i virtio设备的虚拟中断, 从而图 12所示的计算 节点能够有效地避免因为 vCPU所亲和的 pCPU不是用于处理该 vCPU所处 理的 virtio设备的虚拟中断所对应的 vhost线程的 pCPU引起额外的 IPI导致 的 VM-Exit,有效地减少上下文切换次数,并且降低虚拟机对 pCPU的干扰。
可选的, 作为一个实施例, 该 Host还用于通过以下方式确定该 U个目 标 pCPU与该第 i物理中断的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确 定该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系, 其中该 V 个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚拟中 断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该 U个目标 pCPU上, 其中 U等于 1; 确定对应于该第 i virtio设备的虚拟中断 的第 i vhost线程; 确定该第 i vhost线程与该 U个目标 pCPU的亲和关系, 其中该第 i vhost线程能被该 U个目标 pCPU处理。 该 U个目标 pCPU与该 第 i vhost线程的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和 关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系可以 预先设置好并保存, 然后在发生 vhost线程的情况下可以根据保存的亲和关 系之间找到相应的 pCPU以及 vCPU处理 vhost线程和 viritio设备的虚拟中 断。 或者, 当该 U个目标 pCPU与该第 i vhost线程的亲和关系, 该 U个目 标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系设置好的情况下, 可以根据这些亲和关系 找到相应的 pCPU以及 vCPU处理对应的 vhost线程和 virtio设备的虚拟中断。 在此情况下, 当第 i vhost线程发生时, 用于处理对应于第 i vhost线程的第 i virito设备的虚拟中断的第 m vCPU运行在处理该第 i vhost线程的第 n pCPU 上。
可选的, 作为另一个实施例, 该 Host还用于通过以下方式确定该 U个 目标 pCPU与该第 i物理中断的亲和关系,该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i虚拟中断的亲和关系: 确 定该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系, 其中该 V 个目标 vCPU为被虚拟在该第 k VM上的能够处理该第 i virtio设备的虚拟中 断的 vCPU; 确定该 U个目标 pCPU, 其中该 V个目标 vCPU能够运行在该 多个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数; 确定对应 于该第 i virtio设备的虚拟中断的第 i vhost线程; 确定该第 i vhost线程与该 U个目标 pCPU的亲和关系,其中该第 i vhost线程能被该 U个目标 pCPU处 理。 该 U个目标 pCPU与该第 i vhost线程的亲和关系, 该 U个目标 pCPU 与该 V个目标 vCPU的亲和关系以及该 V个目标 vCPU与该第 i virtio设备 的虚拟中断的亲和关系可以预先设置好并保存, 然后在发生 vhost线程的情 况下可以根据保存的亲和关系之间找到相应的 pCPU以及 vCPU处理 vhost 线程和 viritio设备的虚拟中断。 或者, 当该 U个目标 pCPU与该第 i vhost 线程的亲和关系, 该 U个目标 pCPU与该 V个目标 vCPU的亲和关系以及 该 V个目标 vCPU与该第 i virtio设备的虚拟中断的亲和关系设置好的情况 下, 可以根据这些亲和关系找到相应的 pCPU以及 vCPU处理对应的 vhost 线程和 virtio设备的虚拟中断。 在此情况下, 当第 i vhost线程发生时, 用于 处理对应于第 i vhost线程的的第 i virito设备的虚拟中断的第 m vCPU运行 在有限个确定的 pCPU上而不是该物理硬件层中的任一个 pCPU上, 并且有 可能运行在处理该第 i vhost线程的第 n pCPU上。
进一步,在该 V个目标 vCPU能够运行在该多个目标 pCPU上的情况下 (换言之, 当该第 i vhost线程与该 U个目标 pCPU的亲和关系为一对多的 亲和关系), 在从该 V个目标 vCPU中确定第 m vCPU的方面, 该 Host具体 用于: 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU; 在确定该第 n pCPU上运行有该 V个目标 vCPU中的至少一个目标 vCPU的情况下, 确定该第 n pCPU上运行的一个目标 vCPU作为该第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU执行所述第 i virtio设备的 虚拟中断; 或者, 在确定该第 n pCPU上没有运行有该 V个目标 vCPU中的 至少一个目标 vCPU的情况下, 根据优先级顺序, 从该 V个目标 vCPU中确 定一个目标 vCPU作为该第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU执行所述第 i virtio设备的虚拟中断。 此时, 如果用于处理 virito设备 的虚拟中断的 vCPU运行在用于处理 vhost线程的 pCPU上, 就不会发生由 于运行 vCPU的 pCPU与处理 vhost线程的 pCPU不同引起的额外的 IPI导致 优先级的选择也可以釆取 round-robin策略确定,即保证每一个目标 vCPU被 选中的概率是相同的, 从而能最大限度地避免因为 vCPU所亲和的 pCPU不 是用于处理该 vCPU所处理的虚拟中断所对应的物理中断的 pCPU引起额外 的 IPI导致的 VM-Exit,有效地减少上下文切换次数,并且降低虚拟机对 pCPU 的干扰。
进一步, 在确定该第 n pCPU上是否运行该 V个目标 vCPU中的至少一 个目标 vCPU的方面, 该 Host具体用于: 根据 virtio设备的虚拟中断路由信 息, 确定该第 n pCPU上是否运行有该 V个目标 vCPU中的至少一个目标 vCPU, 其中该 virtio设备的虚拟中断路由信息包括该 U个目标 pCPU与运 行在该 U个目标 pCPU上的目标 vCPU的对应关系。这样, Host可以方便快 速地确定该第 m vCPU是否运行在该第 n pCU上。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流 程, 是可以通过计算机程序来指令相关的硬件(例如处理器)来完成, 所述 的程序可存储于一计算机可读取存储介质中, 该程序在执行时, 可包括如上 述各方法的实施例的流程。 其中, 所述的存储介质可为磁碟、 光盘、 只读存 储记忆体 ( Read-Only Memory, ROM )或随机存储记忆体 ( Random Access Memory, RAM )等。
本领域普通技术人员可以意识到, 结合本文中所公开的实施例描述的各 示例的单元及算法步骤, 能够以电子硬件、 或者计算机软件和电子硬件的结 合来实现。 这些功能究竟以硬件还是软件方式来执行, 取决于技术方案的特 定应用和设计约束条件。 专业技术人员可以对每个特定的应用来使用不同方 法来实现所描述的功能, 但是这种实现不应认为超出本发明的范围。
所属领域的技术人员可以清楚地了解到, 为描述的方便和简洁, 上述描 述的系统、 装置和单元的具体工作过程, 可以参考前述方法实施例中的对应 过程, 在此不再赘述。
在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统、 装置和 方法, 可以通过其它的方式实现。 例如, 以上所描述的装置实施例仅仅是示 意性的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实际实现时可 以有另外的划分方式, 例如多个单元或组件可以结合或者可以集成到另一个 系统, 或一些特征可以忽略, 或不执行。 另一点, 所显示或讨论的相互之间 的耦合或直接辆合或通信连接可以是通过一些接口, 装置或单元的间接耦合 或通信连接, 可以是电性, 机械或其它的形式。 为单元显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或 者全部单元来实现本实施例方案的目的。
另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元 中, 也可以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一 个单元中。
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使 用时, 可以存储在一个计算机可读取存储介质中。 基于这样的理解, 本发明 的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部 分可以以软件产品的形式体现出来, 该计算机软件产品存储在一个存储介质 中, 包括若干指令用以使得一台计算机设备(可以是个人计算机, 服务器, 或者网络设备等)或处理器(processor )执行本发明各个实施例所述方法的 全部或部分步骤。 而前述的存储介质包括: U盘、 移动硬盘、 只读存储器 ( ROM , Read-Only Memory ), 随机存取存储器 (RAM , Random Access Memory ), 磁碟或者光盘等各种可以存储程序代码的介质。
以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围并不局限 于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻易 想到的变化或替换, 都应涵盖在本发明的保护范围之内, 因此本发明的保护 范围应以权利要求的保护范围为准。

Claims

权利要求
1、 一种虚拟化平台处理中断方法, 其特征在于, 应用于计算节点上, 所述计算节点包括:物理硬件层、运行在所述物理硬件层之上的宿主机 Host、 运行在所述 Host之上的至少一个虚拟机 VM、 所述至少一个 VM上被虚拟 有虚拟硬件, 其中, 所述物理硬件层包括 X个物理中央处理器 pCPU和 Y 个物理输入输出设备, 所述虚拟硬件包括 Z个虚拟中央处理器 vCPU, 所述 Y个物理输入输出设备包括第 j物理输入输出设备, 所述至少一个 VM包括 第 k VM, 所述第 j物理输入输出设备直通所述第 k VM, 所述方法由所述 Host执行, 所述方法包括:
在所述第 j物理输入输出设备发生第 i物理中断的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 所述 U个目标 pCPU为与所述第 i物理中断 以及 V个目标 vCPU均具有亲和关系的 pCPU,所述 V个目标 vCPU为被虚 拟在所述第 k VM上的与第 i虚拟中断具有亲和关系的 vCPU,所述第 i虚拟 中断对应于所述第 i物理中断, 所述 X个 pCPU包括所述 U个目标 pCPU, 所述 Z个 vCPU包括所述 V个目标 vCPU;
使用所述第 n pCPU处理所述第 i物理中断;
根据所述第 i物理中断, 确定所述第 i虚拟中断;
从所述 V个目标 vCPU中确定第 m vCPU, 以便于所述第 k VM使用所 述第 m vCPU执行所述第 i虚拟中断;
其中, X、 Y、 Z为大于 1的正整数, U为大于或等于 1且小于或等于 X 的正整数, V为大于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 n为 正整数。
2、 如权利要求 1所述的方法, 其特征在于, 所述 U个目标 pCPU与所 述第 i物理中断的亲和关系,所述 U个目标 pCPU与所述 V个目标 vCPU的 亲和关系以及所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系是通过以 下方式确定的:
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述 U 个目标 pCPU上, 其中 U等于 1 ;
确定对应于所述第 i虚拟中断的第 i物理中断;
确定所述第 i物理中断与所述 U个目标 pCPU的亲和关系, 其中所述第 i物理中断能被所述 U个目标 pCPU处理。
3、 如权利要求 1所述的方法, 其特征在于, 所述 U个目标 pCPU与所 述第 i物理中断的亲和关系,所述 U个目标 pCPU与所述 V个目标 vCPU的 亲和关系以及所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系是通过以 下方式确定的;
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述多 个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数;
确定对应于所述第 i虚拟中断的第 i物理中断;
确定所述第 i物理中断与所述 U个目标 pCPU的亲和关系, 其中所述第 i物理中断能被所述 U个目标 pCPU处理。
4、如权利要求 3所述的方法, 其特征在于, 当所述第 i物理中断与所述 U个目标 pCPU的亲和关系为一对多的亲和关系,所述从所述 V个目标 vCPU 中确定第 m vCPU, 包括:
确定所述第 n pCPU上是否运行有所述 V个目标 vCPU中的至少一个目 标 vCPU;
在确定所述第 n pCPU上运行有所述 V个目标 vCPU中的至少一个目标 vCPU的情况下,确定所述第 n pCPU上运行的一个目标 vCPU作为所述第 m vCPU;
在确定所述第 n pCPU上没有运行有所述 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从所述 V个目标 vCPU中确定一个 目标 vCPU作为所述第 m vCPU。
5、 如权利要求 4所述的方法, 其特征在于, 所述确定所述第 n pCPU上 是否运行有所述 V个目标 vCPU中的至少一个目标 vCPU, 包括:
根据虚拟中断路由信息, 确定所述第 n pCPU上是否运行有所述 V个目 标 vCPU中的至少一个目标 vCPU, 其中所述虚拟中断路由信息包括所述 U
6、 一种虚拟化平台处理中断方法, 其特征在于, 应用于计算节点上, 所述计算节点包括:物理硬件层、运行在所述物理硬件层之上的宿主机 Host、 运行在所述 Host之上的 Y个虚拟机 VM、运行在所述 Host之上的 Y个虚拟 主机 vhost内核线程、 所述至少一个 VM上被虚拟有虚拟硬件, 其中, 所述 物理硬件层包括 X个物理中央处理器 pCPU, 所述虚拟硬件包括 Z个虚拟中 央处理器 vCPU,所述 Y个 VM中的每一个 VM包括一个半虚拟化驱动 virtio 设备, 所述 Y个 VM包括第 k VM, 所述第 k VM包括第 i virtio设备, 所述 第 i virtio设备与所述 Y个 vhost内核线程中的第 j vhost内核线程对应,所述 方法由所述 Host执行, 所述方法包括:
在所述第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 所述 U个目标 pCPU为与所述第 i vhost线 程以及 V个目标 vCPU均具有亲和关系的 pCPU,所述 V个目标 vCPU为被 虚拟在所述第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 所述第 i virtio设备的虚拟中断对应于所述第 i vhost线程, 所述 X个 pCPU 包括所述 U个目标 pCPU, 所述 Z个 vCPU包括所述 V个目标 vCPU;
使用所述第 n pCPU处理所述第 i vhost线程;
根据所述第 i vhost线程, 确定所述第 i virtio设备的虚拟中断; 从所述 V个目标 vCPU中确定第 m vCPU, 以便于所述第 k VM使用所 述第 m vCPU执行所述第 i virtio设备的虚拟中断;
其中, X、 Y、 Z为大于 1的正整数, U为大于或等于 1且小于或等于 X 的正整数, V为大于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 n为 正整数。
7、 如权利要求 6所述的方法, 其特征在于, 所述 U个目标 pCPU与所 述第 i vhost线程的亲和关系, 所述 U个目标 pCPU与所述 V个目标 vCPU 的亲和关系以及所述 V个目标 vCPU与所述第 i virtio设备的虚拟中断的亲 和关系是通过以下方式确定的:
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i virtio设备的虚 拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述 U 个目标 pCPU上, 其中 U等于 1 ;
确定对应于所述第 i virtio设备的虚拟中断的第 i vhost线程;
确定所述第 i vhost线程与所述 U个目标 pCPU的亲和关系, 其中所述 第 i vhost线程能被所述 U个目标 pCPU处理。
8、 如权利要求 6所述的方法, 其特征在于, 所述 U个目标 pCPU与所 述第 i vhost线程的亲和关系, 所述 U个目标 pCPU与所述 V个目标 vCPU 的亲和关系以及所述 V个目标 vCPU与所述第 i virtio设备的虚拟中断的亲 和关系是通过以下方式确定的:
确定所述 V个目标 vCPU与所述第 I virito设备的虚拟中断的亲和关系, 其中所述 V个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i virtio设备的虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述多 个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数;
确定对应于所述第 i virtio设备的虚拟中断的第 i vhost线程;
确定所述第 i vhost线程与所述 U个目标 pCPU的亲和关系, 其中所述 第 i vhost线程能被所述 U个目标 pCPU处理。
9、 如权利要求 8所述的方法, 其特征在于, 当所述第 i vhost线程与所 述 U个目标 pCPU的亲和关系为一对多的亲和关系, 所述从所述 V个目标 vCPU中确定第 m vCPU, 包括:
确定所述第 n pCPU上是否运行有所述 V个目标 vCPU中的至少一个目 标 vCPU;
在确定所述第 n pCPU上运行有所述 V个目标 vCPU中的至少一个目标 vCPU的情况下,确定所述第 n pCPU上运行的一个目标 vCPU作为所述第 m vCPU; 在确定所述第 n pCPU上没有运行有所述 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从所述 V个目标 vCPU中确定一个 目标 vCPU作为所述第 m vCPU。
10、 如权利要求 9所述的方法, 其特征在于, 所述确定所述第 n pCPU 上是否运行有所述 V个目标 vCPU中的至少一个目标 vCPU, 包括:
根据 virtio设备的虚拟中断路由信息, 确定所述第 n pCPU上是否运行 有所述 V个目标 vCPU中的至少一个目标 vCPU, 其中所述 virtio设备的虚 拟中断路由信息包括所述 U个目标 pCPU与运行在所述 U个目标 pCPU上 的目标 vCPU的对应关系。
11、 一种宿主机 Host, 其特征在于, 应用于计算节点上, 所述计算节点 包括: 物理硬件层、 运行在所述物理硬件层之上的所述 Host、 运行在所述 Host之上的至少一个虚拟机 VM、 所述至少一个 VM上被虚拟有虚拟硬件, 其中, 所述物理硬件层包括 X个物理中央处理器 pCPU和 Y个物理输入输 出设备, 所述虚拟硬件包括 Z个虚拟中央处理器 vCPU, 所述 Y个物理输入 输出设备包括第 j物理输入输出设备, 所述至少一个 VM包括第 k VM, 所 述第 j物理输入输出设备直通所述第 k VM, 所述 Host包括:
第一确定单元, 用于在所述第 j物理输入输出设备发生第 i物理中断的 情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 所述 U个目标 pCPU 为与所述第 i物理中断以及 V个目标 vCPU均具有亲和关系的 pCPU, 所述 V个目标 vCPU为被虚拟在所述第 k VM上的与第 i虚拟中断具有亲和关系 的 vCPU, 所述第 i虚拟中断对应于所述第 i物理中断, 所述 X个 pCPU包 括所述 U个目标 pCPU, 所述 Z个 vCPU包括所述 V个目标 vCPU,;
第二调用单元, 用于使用所述第 n pCPU处理所述第 i物理中断; 第三确定单元, 用于根据所述第 i物理中断, 确定所述第 i虚拟中断; 第四确定单元, 用于从所述 V个目标 vCPU中确定第 m vCPU, 以便于 所述第 k VM使用所述第 m vCPU执行所述第 i虚拟中断;
其中, X、 Y、 Z为大于 1的正整数, U为大于或等于 1且小于或等于 X 的正整数, V为大于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 11为 正整数。
12、 如权利要求 11所述的 Host, 其特征在于,
所述第一确定单元, 还用于: 确定所述 V个目标 vCPU与所述第 i虚拟 中断的亲和关系,其中所述 V个目标 vCPU为被虚拟在所述第 k VM上的能 够处理所述第 i虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述 U 个目标 pCPU上, 其中 U等于 1 ;
确定对应于所述第 i虚拟中断的第 i物理中断;
确定所述第 i物理中断与所述 U个目标 pCPU的亲和关系, 其中所述第 i物理中断能被所述 U个目标 pCPU处理。
13、 如权利要求 11所述的 Host, 其特征在于,
所述第一确定单元, 还用于: 确定所述 V个目标 vCPU与所述第 i虚拟 中断的亲和关系,其中所述 V个目标 vCPU为被虚拟在所述第 k VM上的能 够处理所述第 i虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述多 个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数;
确定对应于所述第 i虚拟中断的第 i物理中断;
确定所述第 i物理中断与所述 U个目标 pCPU的亲和关系, 其中所述第 i物理中断能被所述 U个目标 pCPU处理。
14、 如权利要求 13所述的 Host, 其特征在于,
所述第四确定单元, 具体用于: 确定所述第 n pCPU上是否运行有所述 V个目标 vCPU中的至少一个目标 vCPU;
在确定所述第 n pCPU上运行有所述 V个目标 vCPU中的至少一个目标 vCPU的情况下,确定所述第 n pCPU上运行的一个目标 vCPU作为所述第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU执行所述第 i虚拟中断; 或 者,
在确定所述第 n pCPU上没有运行有所述 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从所述 V个目标 vCPU中确定一个 目标 vCPU作为所述第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU 执行所述第 i虚拟中断。
15、 如权利要求 14所述的 Host, 其特征在于,
在所述确定所述第 n pCPU上是否运行所述 V个目标 vCPU中的至少一 个目标 vCPU的方面,所述第四确定单元,具体用于根据虚拟中断路由信息, 确定所述第 n pCPU上是否运行有所述 V个目标 vCPU中的至少一个目标 vCPU, 其中所述虚拟中断路由信息包括所述 U个目标 pCPU与运行在所述 U个目标 pCPU上的目标 vCPU的对应关系。
16、 一种宿主机 Host, 其特征在于, 应用于计算节点上, 所述计算节点 包括: 物理硬件层、 运行在所述物理硬件层之上的所述 Host、 运行在所述 Host之上的 Y个虚拟机 VM、 运行在所述 Host之上的 Y个虚拟主机 vhost 内核线程、 该至少一个 VM上被虚拟有虚拟硬件, 其中, 所述物理硬件层包 括 X 个物理中央处理器 pCPU, 所述虚拟硬件包括 Z个虚拟中央处理器 vCPU, X、 Y、 Z为大于 1的正整数, 所述 Υ个 VM中的每一个 VM包括一 个半虚拟化驱动 virtio设备, 所述 Y个 VM包括第 k VM, 所述第 k VM包 括第 i virtio设备,所述第 i virtio设备与所述 Y个 vhost内核线程中的第 j vhost 内核线程对应, 所述 Host包括:
第一确定单元, 用于在所述第 j vhost内核线程触发第 i vhost线程的情 况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 所述 U个目标 pCPU为 与所述第 i vhost线程以及 V个目标 vCPU均具有亲和关系的 pCPU,所述 V 个目标 vCPU为被虚拟在所述第 k VM上的与第 i virtio设备的虚拟中断具有 亲和关系的 vCPU,所述第 i virtio设备的虚拟中断对应于所述第 i vhost线程, 所述 X个 pCPU包括所述 U个目标 pCPU, 所述 Z个 vCPU包括所述 V个 目标 vCPU;
第二调用单元, 用于使用所述第 n pCPU处理所述第 i vhost线程; 第三确定单元, 用于根据所述第 i vhost线程, 确定所述第 i virtio设备 的虚拟中断;
第四确定单元, 用于从所述 V个目标 vCPU中确定第 m vCPU, 以便于 所述第 k VM使用所述第 m vCPU执行所述第 i virtio设备的虚拟中断;
其中, X、 Y、 Z为大于 1的正整数, U为大于或等于 1且小于或等于 X 的正整数, V为大于或等于 1且小于或等于 Z的正整数, i、 j、 k、 m、 n为 正整数。
17、 如权利要求 16所述的 Host, 其特征在于,
所述第一确定单元, 还用于: 确定所述 V个目标 vCPU与所述第 i虚拟 中断的亲和关系,其中所述 V个目标 vCPU为被虚拟在所述第 k VM上的能 够处理所述第 i virtio设备的虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述 U 个目标 pCPU上, 其中 U等于 1 ;
确定对应于所述第 i virtio设备的虚拟中断的第 i vhost线程;
确定所述第 i vhost线程与所述 U个目标 pCPU的亲和关系, 其中所述 第 i vhost线程能被所述 U个目标 pCPU处理。
18、 如权利要求 16所述的 Host, 其特征在于,
所述第一确定单元, 还用于: 确定所述 V个目标 vCPU与所述第 i虚拟 中断的亲和关系,其中所述 V个目标 vCPU为被虚拟在所述第 k VM上的能 够处理所述第 i virtio设备的虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述多 个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数;
确定对应于所述第 i virtio设备的虚拟中断的第 i vhost线程;
确定所述第 i vhost线程与所述 U个目标 pCPU的亲和关系, 其中所述 第 i vhost线程能被所述 U个目标 pCPU处理。
19、 如权利要求 18所述的 Host, 其特征在于,
所述第四确定单元, 具体用于: 确定所述第 n pCPU上是否运行有所述
V个目标 vCPU中的至少一个目标 vCPU;
在确定所述第 n pCPU上运行有所述 V个目标 vCPU中的至少一个目标 vCPU的情况下,确定所述第 n pCPU上运行的一个目标 vCPU作为所述第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU执行所述第 i virtio设备的 虚拟中断; 或者,
在确定所述第 n pCPU上没有运行有所述 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从所述 V个目标 vCPU中确定一个 目标 vCPU作为所述第 m vCPU, 以便于所述第 k VM使用所述第 m vCPU 执行所述第 i virtio设备的虚拟中断。
20、如权利要求 19所述的 Host,其特征在于,在所述确定所述第 n pCPU 上是否运行所述 V个目标 vCPU中的至少一个目标 vCPU的方面,
所述第四确定单元, 具体用于根据 virtio设备的虚拟中断路由信息, 确 定所述第 n pCPU上是否运行有所述 V 个目标 vCPU 中的至少一个目标 vCPU, 其中所述 virtio设备的虚拟中断路由信息包括所述 U个目标 pCPU 与运行在所述 U个目标 pCPU上的目标 vCPU的对应关系。
21、 一种计算节点, 其特征在于, 所述计算节点包括:
Y个物理输入输出设备, 其中所述 Y个物理输入输出设备包括第 j物理 输入输出设备,
X个物理中央处理器 pCPU,
与所述 X个物理中央处理器 pCPU和 Y个物理输入输出设备分别连接 的存储器,其中所述 X个物理中央处理器 pCPU中的一个或多个 pCPU用于 调用或执行所述存储器中存储的操作指令、 宿主机 Host、 至少一个虚拟机 VM以及所述至少一个虚拟机 VM上被虚拟的虚拟硬件, 其中所述虚拟硬件 包括 Z个虚拟中央处理器 vCPU, 所述至少一个 VM包括第 k VM, 所述第 j 物理输入输出设备直通所述第 k VM,
其中, 所述 Host用于:
在所述第 j物理输入输出设备发生第 i物理中断的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 所述 U个目标 pCPU为与所述第 i物理中断 以及 V个目标 vCPU均具有亲和关系的 pCPU,所述 V个目标 vCPU为被虚 拟在所述第 k VM上的与第 i虚拟中断具有亲和关系的 vCPU,所述第 i虚拟 中断对应于所述第 i物理中断, 所述 X个 pCPU包括所述 U个目标 pCPU, 所述 Z个 vCPU包括所述 V个目标 vCPU;
使用所述第 n pCPU处理所述第 i物理中断;
根据所述第 i物理中断, 确定所述第 i虚拟中断;
从所述 V个目标 vCPU中确定第 m vCPU, 以便于所述第 k VM使用所 述第 m vCPU执行所述第 i虚拟中断;
其中 X、 Υ、 Ζ为大于 1的正整数, U为大于或等于 1且小于或等于 X 的正整数, V为大于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 n为 正整数。
22、 如权利要求 21所述的计算节点, 其特征在于, 所述 Host还用于通 过以下方式确定所述 U个目标 pCPU与所述第 i物理中断的亲和关系, 所述 U个目标 pCPU与所述 V个目标 vCPU的亲和关系以及所述 V个目标 vCPU 与所述第 i虚拟中断的亲和关系:
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述 U 个目标 pCPU上, 其中 U等于 1 ;
确定对应于所述第 i虚拟中断的第 i物理中断;
确定所述第 i物理中断与所述 U个目标 pCPU的亲和关系, 其中所述第 i物理中断能被所述 U个目标 pCPU处理。
23、 如权利要求 21所述的计算节点, 其特征在于, 所述 Host还用于通 过以下方式确定所述 U个目标 pCPU与所述第 i物理中断的亲和关系, 所述
U个目标 pCPU与所述 V个目标 vCPU的亲和关系以及所述 V个目标 vCPU 与所述第 i虚拟中断的亲和关系:
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i虚拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述多 个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数;
确定对应于所述第 i虚拟中断的第 i物理中断;
确定所述第 i物理中断与所述 U个目标 pCPU的亲和关系, 其中所述第 i物理中断能被所述 U个目标 pCPU处理。
24、 如权利要求 23所述的计算节点, 其特征在于, 在所述从所述 V个 目标 vCPU中确定第 m vCPU的方面, 所述 Host具体用于:
确定所述第 n pCPU上是否运行有所述 V个目标 vCPU中的至少一个目 标 vCPU;
在确定所述第 n pCPU上运行有所述 V个目标 vCPU中的至少一个目标 vCPU的情况下,确定所述第 n pCPU上运行的一个目标 vCPU作为所述第 m vCPU;
在确定所述第 n pCPU上没有运行有所述 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从所述 V个目标 vCPU中确定一个 目标 vCPU作为所述第 m vCPU。
25、如权利要求 24所述的计算节点, 其特征在于, 在所述确定所述第 n pCPU上是否运行所述 V个目标 vCPU中的至少一个目标 vCPU的方面, 所 述 Host具体用于: 根据虚拟中断路由信息, 确定所述第 n pCPU上是否运行 有所述 V个目标 vCPU中的至少一个目标 vCPU, 其中所述虚拟中断路由信 对应关系。
26、 一种计算节点, 其特征在于, 所述计算节点包括:
X个物理中央处理器 pCPU,
与所述 X个物理中央处理器 pCPU连接的存储器, 其中所述 X个物理 中央处理器 pCPU中的一个或多个 pCPU用于调用或执行所述存储器中存储 的操作指令、 宿主机 Host、 Y个虚拟机 VM、 Y个虚拟主机 vhost内核线程 以及所述至少一个虚拟机 VM上被虚拟的虚拟硬件,其中所述虚拟硬件包括 Z个虚拟中央处理器 vCPU, 所述 Y个 VM中的每一个 VM包括一个半虚拟 化驱动 virtio设备,所述 Y个 VM包括第 k VM,所述第 k VM包括第 i virtio 设备,所述第 i virtio设备与所述 Y个 vhost内核线程中的第 j vhost内核线程 对应,
其中, 所述 Host用于:
在所述第 j vhost内核线程触发第 i vhost线程的情况下, 从 U个目标 pCPU中确定第 n pCPU, 其中, 所述 U个目标 pCPU为与所述第 i vhost线 程以及 V个目标 vCPU均具有亲和关系的 pCPU,所述 V个目标 vCPU为被 虚拟在所述第 k VM上的与第 i virtio设备的虚拟中断具有亲和关系的 vCPU, 所述第 i virtio设备的虚拟中断对应于所述第 i vhost线程, 所述 X个 pCPU 包括所述 U个目标 pCPU, 所述 Z个 vCPU包括所述 V个目标 vCPU;
使用所述第 n pCPU处理所述第 i vhost线程;
根据所述第 i vhost线程, 确定所述第 i virtio设备的虚拟中断; 从所述 V个目标 vCPU中确定第 m vCPU, 以便于所述第 k VM使用所 述第 m vCPU执行所述第 i virtio设备的虚拟中断;
其中 X、 Υ、 Ζ为大于 1的正整数, U为大于或等于 1且小于或等于 X 的正整数, V为大于或等于 1且小于或等于 Ζ的正整数, i、 j、 k、 m、 n为 正整数。
27、 如权利要求 26所述的计算节点, 其特征在于, 所述 Host还用于通 过以下方式确定所述 U个目标 pCPU与所述第 i物理中断的亲和关系, 所述 U个目标 pCPU与所述 V个目标 vCPU的亲和关系以及所述 V个目标 vCPU 与所述第 i虚拟中断的亲和关系:
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i virtio设备的虚 拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述 U 个目标 pCPU上, 其中 U等于 1 ;
确定对应于所述第 i virtio设备的虚拟中断的第 i vhost线程;
确定所述第 i vhost线程与所述 U个目标 pCPU的亲和关系, 其中所述 第 i vhost线程能被所述 U个目标 pCPU处理。
28、 如权利要求 26所述的计算节点, 其特征在于, 所述 Host还用于通 过以下方式确定所述 U个目标 pCPU与所述第 i物理中断的亲和关系, 所述 U个目标 pCPU与所述 V个目标 vCPU的亲和关系以及所述 V个目标 vCPU 与所述第 i虚拟中断的亲和关系:
确定所述 V个目标 vCPU与所述第 i虚拟中断的亲和关系, 其中所述 V 个目标 vCPU为被虚拟在所述第 k VM上的能够处理所述第 i virtio设备的虚 拟中断的 vCPU;
确定所述 U个目标 pCPU,其中所述 V个目标 vCPU能够运行在所述多 个目标 pCPU上, 其中 U为大于 1且小于或等于 X的正整数;
确定对应于所述第 i virtio设备的虚拟中断的第 i vhost线程;
确定所述第 i vhost线程与所述 U个目标 pCPU的亲和关系, 其中所述 第 i vhost线程能被所述 U个目标 pCPU处理。
29、 如权利要求 28所述的计算节点, 其特征在于, 在所述从所述 V个 目标 vCPU中确定第 m vCPU的方面, 所述 Host具体用于:
确定所述第 n pCPU上是否运行有所述 V个目标 vCPU中的至少一个目 标 vCPU;
在确定所述第 n pCPU上运行有所述 V个目标 vCPU中的至少一个目标 vCPU的情况下,确定所述第 n pCPU上运行的一个目标 vCPU作为所述第 m vCPU;
在确定所述第 n pCPU上没有运行有所述 V个目标 vCPU中的至少一个 目标 vCPU的情况下, 根据优先级顺序, 从所述 V个目标 vCPU中确定一个 目标 vCPU作为所述第 m vCPU。
30、如权利要求 29所述的计算节点, 其特征在于, 在所述确定所述第 n pCPU上是否运行所述 V个目标 vCPU中的至少一个目标 vCPU的方面, 所 述 Host具体用于:
根据 virtio设备的虚拟中断路由信息, 确定所述第 n pCPU上是否运行 有所述 V个目标 vCPU中的至少一个目标 vCPU, 其中所述 virtio设备的虚 拟中断路由信息包括所述 U个目标 pCPU与运行在所述 U个目标 pCPU上 的目标 vCPU的对应关系。
PCT/CN2014/080430 2014-06-20 2014-06-20 虚拟化平台处理中断方法和相关设备 WO2015192381A1 (zh)

Priority Applications (6)

Application Number Priority Date Filing Date Title
EP14894974.6A EP3147784A4 (en) 2014-06-20 2014-06-20 Interruption handling method and relevant device of virtual platform
CN201480079053.5A CN106462451B (zh) 2014-06-20 2014-06-20 虚拟化平台处理中断方法和相关设备
JP2016574176A JP2017518589A (ja) 2014-06-20 2014-06-20 仮想化プラットホームによって割込みを処理する方法および関連デバイス
KR1020177000348A KR101847518B1 (ko) 2014-06-20 2014-06-20 가상화 플랫폼에 의한 중단을 처리하는 및 관련 장치
PCT/CN2014/080430 WO2015192381A1 (zh) 2014-06-20 2014-06-20 虚拟化平台处理中断方法和相关设备
US15/384,961 US10169075B2 (en) 2014-06-20 2016-12-20 Method for processing interrupt by virtualization platform, and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/080430 WO2015192381A1 (zh) 2014-06-20 2014-06-20 虚拟化平台处理中断方法和相关设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/384,961 Continuation US10169075B2 (en) 2014-06-20 2016-12-20 Method for processing interrupt by virtualization platform, and related device

Publications (1)

Publication Number Publication Date
WO2015192381A1 true WO2015192381A1 (zh) 2015-12-23

Family

ID=54934732

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080430 WO2015192381A1 (zh) 2014-06-20 2014-06-20 虚拟化平台处理中断方法和相关设备

Country Status (6)

Country Link
US (1) US10169075B2 (zh)
EP (1) EP3147784A4 (zh)
JP (1) JP2017518589A (zh)
KR (1) KR101847518B1 (zh)
CN (1) CN106462451B (zh)
WO (1) WO2015192381A1 (zh)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144679B (zh) 2017-06-27 2022-03-29 华为技术有限公司 中断请求的处理方法、装置及虚拟化设备
JP7196439B2 (ja) * 2018-07-03 2022-12-27 株式会社デンソー 仮想化環境におけるデバイスへのアクセス方法
US11204796B2 (en) 2019-04-11 2021-12-21 International Business Machines Corporation Dynamic assignment of interrupts based on input/output metrics
US11194611B2 (en) 2019-07-29 2021-12-07 International Business Machines Corporation Dynamic assignment of interrupts based on input/output metrics
US11068411B2 (en) 2019-07-29 2021-07-20 International Business Machines Corporation Reducing impact of context switches through dynamic memory-mapping overallocation
CN113934504A (zh) * 2020-06-29 2022-01-14 华为技术有限公司 一种系统以及中断处理方法
CN114371907A (zh) * 2020-10-15 2022-04-19 华为技术有限公司 一种芯片系统、处理虚拟中断的方法及相应装置
CN112817690B (zh) * 2021-01-22 2022-03-18 华东计算技术研究所(中国电子科技集团公司第三十二研究所) 一种面向arm架构虚拟化领域的中断虚拟化处理方法及系统
CN113961147A (zh) * 2021-10-26 2022-01-21 江苏安超云软件有限公司 在云平台上从已删除的块中回收空间的方法及应用
CN114625480A (zh) * 2022-03-17 2022-06-14 北京有竹居网络技术有限公司 数据处理方法、装置、可读介质以及计算设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090100424A1 (en) * 2007-10-12 2009-04-16 International Business Machines Corporation Interrupt avoidance in virtualized environments
CN102799465A (zh) * 2012-06-30 2012-11-28 华为技术有限公司 分布式虚拟化系统的虚拟中断管理方法及装置
US20130132949A1 (en) * 2011-11-22 2013-05-23 Michael S. Tsirkin Mechanism for virtual device interrupt hinting in a virtualization system
CN103559087A (zh) * 2013-10-31 2014-02-05 华为技术有限公司 一种虚拟处理器之间的中断的实现方法、相关装置和系统
CN103699428A (zh) * 2013-12-20 2014-04-02 华为技术有限公司 一种虚拟网卡中断亲和性绑定的方法和计算机设备

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7853960B1 (en) 2005-02-25 2010-12-14 Vmware, Inc. Efficient virtualization of input/output completions for a virtual device
US8286162B2 (en) 2005-12-30 2012-10-09 Intel Corporation Delivering interrupts directly to a virtual processor
CN100547571C (zh) * 2006-08-29 2009-10-07 联想(北京)有限公司 一种虚拟机系统及其硬件设备中断处理方法
US7840839B2 (en) * 2007-11-06 2010-11-23 Vmware, Inc. Storage handling for fault tolerance in virtual machines
CN100527098C (zh) * 2007-11-27 2009-08-12 北京大学 一种虚拟机管理器的动态内存映射方法
JP5352848B2 (ja) 2008-11-28 2013-11-27 株式会社日立製作所 仮想計算機の制御方法及び計算機装置
US8055827B2 (en) 2009-01-26 2011-11-08 Advanced Micro Devices, Inc. Guest interrupt controllers for each processor to aid interrupt virtualization
US8489789B2 (en) 2010-02-05 2013-07-16 Advanced Micro Devices, Inc. Interrupt virtualization
US9477505B2 (en) * 2012-08-14 2016-10-25 Oracle International Corporation Method for reducing the overhead associated with a virtual machine exit when handling instructions related to descriptor tables

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090100424A1 (en) * 2007-10-12 2009-04-16 International Business Machines Corporation Interrupt avoidance in virtualized environments
US20130132949A1 (en) * 2011-11-22 2013-05-23 Michael S. Tsirkin Mechanism for virtual device interrupt hinting in a virtualization system
CN102799465A (zh) * 2012-06-30 2012-11-28 华为技术有限公司 分布式虚拟化系统的虚拟中断管理方法及装置
CN103559087A (zh) * 2013-10-31 2014-02-05 华为技术有限公司 一种虚拟处理器之间的中断的实现方法、相关装置和系统
CN103699428A (zh) * 2013-12-20 2014-04-02 华为技术有限公司 一种虚拟网卡中断亲和性绑定的方法和计算机设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3147784A4 *

Also Published As

Publication number Publication date
CN106462451B (zh) 2019-11-12
JP2017518589A (ja) 2017-07-06
US10169075B2 (en) 2019-01-01
EP3147784A4 (en) 2017-08-02
KR20170016448A (ko) 2017-02-13
CN106462451A (zh) 2017-02-22
EP3147784A1 (en) 2017-03-29
US20170102963A1 (en) 2017-04-13
KR101847518B1 (ko) 2018-05-28

Similar Documents

Publication Publication Date Title
WO2015192381A1 (zh) 虚拟化平台处理中断方法和相关设备
Desai et al. Hypervisor: A survey on concepts and taxonomy
US10365936B2 (en) Idle processor management by guest in virtualized systems
US20150205542A1 (en) Virtual machine migration in shared storage environment
US9697029B2 (en) Guest idle based VM request completion processing
US8312195B2 (en) Managing interrupts using a preferred binding between a device generating interrupts and a CPU
CN104598294B (zh) 用于移动设备的高效安全的虚拟化方法及其设备
Semnanian et al. Virtualization technology and its impact on computer hardware architecture
EP2881860B1 (en) Method for implementing an interrupt between virtual processors, related device, and system
JP2012079357A5 (zh)
US9697031B2 (en) Method for implementing inter-virtual processor interrupt by writing register data in a single write operation to a virtual register
KR20160033517A (ko) 인터럽트 컨트롤러를 위한 하이브리드 가상화 방법
US20060294518A1 (en) Method, apparatus and system for a lightweight virtual machine monitor
WO2012069276A1 (en) Device emulation in a virtualized computing environment
JP6315725B2 (ja) 一般的なデバイスリダイレクションを介したリモートセッションキーボードおよびマウス入力
WO2018040845A1 (zh) 一种计算资源调度方法及装置
US20160253196A1 (en) Optimized extended context management for virtual machines
US20170024231A1 (en) Configuration of a computer system for real-time response from a virtual machine
US10387178B2 (en) Idle based latency reduction for coalesced interrupts
US9766917B2 (en) Limited virtual device polling based on virtual CPU pre-emption
Syed et al. A pattern for a virtual machine environment
Kawahara et al. The Continuity of Out-of-band Remote Management across Virtual Machine Migration in Clouds
KR100928866B1 (ko) 가상 환경에서의 어플리케이션 실행 장치 및 방법
Manco et al. Towards the super fluid cloud
US10754676B2 (en) Sharing ownership of an input/output device using a device driver partition

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14894974

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2016574176

Country of ref document: JP

Kind code of ref document: A

REEP Request for entry into the european phase

Ref document number: 2014894974

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2014894974

Country of ref document: EP

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 20177000348

Country of ref document: KR

Kind code of ref document: A