Communication method and device of virtual processor, storage medium and electronic equipment
By monitoring the communication frequency and status of the virtual processor and dynamically adjusting its priority and communication methods, the problem of low communication efficiency of virtual processors in the virtual machine is solved and more efficient communication processing is achieved.
Patent Information
- Application Number
- CN202411045470.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-08
AI Technical Summary
In KVM virtualization environments, communication between virtual processors is inefficient, and the prior art has failed to effectively solve this problem.
By monitoring the communication methods between virtual processors, the virtual processor that frequently initiates communication is determined as the target virtual processor and identifies it. A faster communication method is adopted when calling using the scheduling module to improve communication efficiency. The specific steps include obtaining the current status of the virtual processor, controlling it to enter or exit the virtual machine execution environment, sending an interrupt signal, and dynamically adjusting its priority.
The communication efficiency between virtual processors is improved, the problem of low communication efficiency in virtual machines is solved, and faster communication processing is achieved through monitoring and scheduling optimization.
Smart Images

Figure CN118916118A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of virtual machine technology, and in particular to a communication method, device, storage medium and electronic device of a virtual processor. Background Art
[0002] Currently in the KVM (Kernel-based Virtual Machine, an open source virtualization technology based on the Linux kernel) virtualization environment, the VCPU (Virtual CPU) of a virtual machine exists as a thread in the host environment. In a multi-core virtual machine system, there are dependencies between multiple VCPUs of a virtual machine and they need to communicate with each other. When a VCPU of a virtual machine initiates communication with another VCPU that is not running, it will affect the communication efficiency of the VCPU.
[0003] Therefore, in the related art, there is a problem of low communication efficiency between virtual processors in a virtual machine.
[0004] In the related art, no effective solution has been proposed for the problem of low communication efficiency between virtual processors in a virtual machine. Summary of the invention
[0005] Embodiments of the present application provide a communication method, device, storage medium, and electronic device for a virtual processor, so as to at least solve the problem of low communication efficiency between virtual processors in a virtual machine in the related art.
[0006] According to one embodiment of the present application, a communication method for a virtual processor is applied to a virtual machine, the virtual machine running in an operating system of a host machine, the virtual machine including multiple virtual processors, a monitoring module, and a scheduling module, the scheduling module being used to call the virtual processor, the monitoring module being used to monitor the manner in which the multiple virtual processors initiate communication to obtain monitoring data, and a communication channel existing between the multiple virtual processors, including: determining from the monitoring data the number of times the virtual processor initiates communication in a first communication manner; determining from the multiple virtual processors a target virtual processor, wherein the target virtual processor is a virtual processor that initiates communication in the first communication manner a number of times greater than a first preset number; identifying an identification bit of the target virtual processor, and calling the target virtual processor through the scheduling module so that the target virtual processor initiates communication in a second communication manner, wherein the communication time of the second communication manner is less than the communication time of the first communication manner.
[0007] In an exemplary embodiment, the multiple virtual processors include a first virtual processor and a second virtual processor. When it is determined that the first virtual processor is a communication initiator and the second virtual processor is a communication receiver, before determining from the monitoring data the number of times the virtual processor initiates communication in the first communication mode, the method further includes: obtaining a current state of the second virtual processor through the scheduling module, wherein the current state includes: an execution state and a non-execution state, wherein the execution state indicates that the thread corresponding to the second virtual processor is in the execution thread queue of the scheduling module, and the non-execution state indicates that the thread corresponding to the second virtual processor is not in the execution thread queue of the scheduling module; when determining that the second virtual processor When the virtual machine is in the non-running state, the first virtual processor is controlled by the scheduling module to exit the virtual machine execution environment, so that the first virtual processor enters the operating system of the host machine; the first virtual processor is controlled to send an interrupt signal to the second virtual processor through the programmable interrupt controller in the operating system of the host machine, so as to determine that the virtual processor initiates communication in the first communication mode, wherein the interrupt signal corresponds to an interrupt task, and the interrupt signal is used to interrupt the current execution task of the second virtual processor; the thread corresponding to the second virtual processor is added to the execution thread queue of the scheduling module; and the second virtual processor is called by the scheduling module, so that the second virtual processor processes the interrupt task.
[0008] In an exemplary embodiment, after calling the second virtual processor through the scheduling module so that the second virtual processor processes the interrupt task, the method also includes: after determining that the second virtual processor has processed the interrupt task, responding the processing result of the interrupt task to the first virtual processor through the scheduling module; after determining that the first virtual processor has received the processing result of the interrupt task, controlling the first virtual processor to enter the virtual machine execution environment from the operating system of the host machine through the scheduling module.
[0009] In an exemplary embodiment, the method also includes: determining a communication recipient with which the target virtual processor initiates communication, sending an inter-core communication signal to a virtual processor corresponding to the communication recipient through the target virtual processor, wherein the inter-core communication signal corresponds to a target execution task; calling the virtual processor corresponding to the communication recipient through the scheduling module to process the target execution task; after determining that the virtual processor corresponding to the communication recipient has processed the target execution task, responding the processing result of the target execution task to the target virtual processor through the scheduling module.
[0010] In an exemplary embodiment, before determining the communication recipient of the target virtual processor to initiate communication, and sending an inter-core communication signal to the virtual processor corresponding to the communication recipient through the target virtual processor, the method also includes: determining whether the identification bit of the target virtual processor has been identified through the monitoring module; when it is determined that the target virtual processor has been identified, traversing the first threads corresponding to the virtual processors in the virtual machine except the target virtual processor; for the first thread, adjusting the first thread from the first priority when called by the scheduling module to the second priority to obtain the adjusted first thread; and adding the adjusted first thread to the execution thread queue of the scheduling module, wherein the second priority is greater than the first priority.
[0011] In an exemplary embodiment, the method further includes: determining from the monitoring data the number of times the target virtual processor initiates communication in the second communication mode; and when it is determined that the number of times the target virtual processor initiates communication in the second communication mode is less than a second preset number, canceling the identification of the identification bit of the target virtual processor.
[0012] In an exemplary embodiment, the method also includes: determining, through the monitoring module, whether the identification bit of the target virtual processor has been unmarked; when it is determined through the monitoring module that the identification bit of the target virtual processor has been unmarked, traversing the second threads corresponding to the virtual processors in the virtual machine other than the target virtual processor; for the second thread, adjusting the second thread from the second priority when called by the scheduling module to the first priority, wherein the second priority is greater than the first priority.
[0013] According to another embodiment of the present application, a communication device for a virtual processor is provided, comprising: a first determination module, used to determine the number of times the virtual processor initiates communication in a first communication mode from the monitoring data; a second determination module, used to determine a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number; an identification module, used to identify an identification bit of the target virtual processor, and call the target virtual processor through the scheduling module so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
[0014] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0015] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0016] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiment are implemented.
[0017] Through the present application, the number of times a virtual processor initiates communication in a first communication mode can be determined from monitoring data obtained by monitoring the communication mode of the virtual processor, and the virtual processor that initiates communication in the first communication mode more than the first preset number of times can be determined as the target virtual processor, and then the identification bit of the target virtual processor can be identified, so that the scheduling module can initiate communication in a second communication mode when calling the target virtual processor. Therefore, the problem of low communication efficiency between virtual processors in a virtual machine in the related art can be solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a hardware structure block diagram of a server device of a virtual processor communication method according to an embodiment of the present application;
[0019] Figure 2 is a flow chart of a communication method of a virtual processor according to an embodiment of the present application;
[0020] Figure 3 is a schematic diagram of a communication method of a virtual processor according to an embodiment of the present application (I);
[0021] Figure 4 is a schematic diagram of a communication method of a virtual processor according to an embodiment of the present application (II);
[0022] Figure 5 It is a structural block diagram of a communication device of a virtual processor according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0025] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a server device of a virtual processor communication method according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) processor 102 (processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0026] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the communication method of the virtual processor in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the method of communication of the above-mentioned virtual processor is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0027] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0028] In this embodiment, a communication method of a virtual processor is provided. Figure 2 The present invention is a flowchart of a communication method for a virtual processor according to an embodiment of the present application. The method is applied to a virtual machine, the virtual machine runs in an operating system of a host machine, the virtual machine includes multiple virtual processors, a monitoring module, and a scheduling module. The scheduling module is used to call the virtual processor. The monitoring module is used to monitor the communication mode initiated by the multiple virtual processors to obtain monitoring data. There are communication channels between the multiple virtual processors, such as Figure 2 As shown, the process of the method includes the following steps:
[0029] Step S202: determining, from the monitoring data, the number of times the virtual processor initiates communication in the first communication mode.
[0030] Step S204, determining a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number;
[0031] Optionally, in the above step S204, the target virtual processor may include multiple virtual processors.
[0032] Step S206, marking the identification bit of the target virtual processor, and calling the target virtual processor through the scheduling module process, so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
[0033] Through the above steps, the number of times a virtual processor initiates communication in the first communication mode can be determined from the monitoring data obtained by monitoring the communication mode of the virtual processor, and the virtual processor that initiates communication in the first communication mode more than the first preset number of times is determined as the target virtual processor, and then the identification bit of the target virtual processor is identified, so that the scheduling module can initiate communication in the second communication mode when calling the target virtual processor. Therefore, the problem of low communication efficiency between virtual processors in the virtual machine in the related technology can be solved.
[0034] In an exemplary embodiment, the multiple virtual processors include a first virtual processor and a second virtual processor. When it is determined that the first virtual processor is a communication initiator and the second virtual processor is a communication receiver, before executing the above step S202 to determine the number of times the virtual processor initiates communication in the first communication mode from the monitoring data, the method further includes: obtaining the current state of the second virtual processor through the scheduling module, wherein the current state includes: an execution state and a non-execution state, wherein the execution state indicates that the thread corresponding to the second virtual processor is in the execution thread queue of the scheduling module, and the non-execution state indicates that the thread corresponding to the second virtual processor is not in the execution thread queue of the scheduling module; when determining the first virtual processor When the second virtual processor is in the non-running state, the first virtual processor is controlled to exit the virtual machine execution environment through the scheduling module, so that the first virtual processor enters the operating system of the host machine; the first virtual processor is controlled to send an interrupt signal to the second virtual processor through the programmable interrupt controller in the operating system of the host machine, so as to determine that the virtual processor initiates communication in the first communication mode, wherein the interrupt signal corresponds to an interrupt task, and the interrupt signal is used to interrupt the current execution task of the second virtual processor; the thread corresponding to the second virtual processor is added to the execution thread queue of the scheduling module; and the second virtual processor is called through the scheduling module, so that the second virtual processor processes the interrupt task.
[0035] Optionally, in the above embodiment, when the scheduling module schedules the first virtual processor to initiate communication with the second virtual processor in the first communication mode, the scheduling module needs to first obtain the status of the second virtual processor. When the second virtual processor is in a non-execution state, it cannot receive the communication signal of the first virtual processor. It should be noted that the above non-execution state is relative to the scheduling module, that is, the thread corresponding to the second virtual processor is not in the execution thread queue of the scheduling module, but at this time the thread corresponding to the second virtual processor may be scheduled by other applications. At this time, the first virtual processor needs to exit the virtual machine execution environment first, enter the host machine's operating system to obtain root permissions, and then send an interrupt signal to the second virtual processor through APIC (Advanced Programmable Interrupt Controller). After receiving the interrupt signal, the second virtual processor suspends the current execution task and enters the execution thread queue of the scheduling module to execute the interrupt task.
[0036] Optionally, in the above embodiment, if the scheduling module obtains that the state of the second virtual processor is in the execution state, the scheduling module directly sends a communication signal to the second virtual processor for scheduling.
[0037] In an exemplary embodiment, after executing the above process and calling the second virtual processor through the scheduling module so that the second virtual processor processes the interrupt task, the method also includes: after determining that the second virtual processor has processed the interrupt task, responding the processing result of the interrupt task to the first virtual processor through the scheduling module; after determining that the first virtual processor has received the processing result of the interrupt task, controlling the first virtual processor to enter the virtual machine execution environment from the operating system of the host machine through the scheduling module.
[0038] It should be noted that, in the above embodiment, the first virtual processor can enter the virtual machine execution environment from the host machine's operating system and resume operation only after the second virtual processor has processed the interrupt task.
[0039] In an exemplary embodiment, the method also includes: determining a communication recipient with which the target virtual processor initiates communication, sending an inter-core communication signal to a virtual processor corresponding to the communication recipient through the target virtual processor, wherein the inter-core communication signal corresponds to a target execution task; calling the virtual processor corresponding to the communication recipient through the scheduling module to process the target execution task; after determining that the virtual processor corresponding to the communication recipient has processed the target execution task, responding the processing result of the target execution task to the target virtual processor through the scheduling module.
[0040] It should be noted that the communication process in the above embodiment is a process of initiating communication with the target virtual processor in the second communication mode. During the above communication process, the virtual processor corresponding to the communication recipient will be in an execution state, that is, the scheduling module can directly call the virtual processor corresponding to the communication recipient to process the target task.
[0041] In an exemplary embodiment, before determining the communication recipient of the target virtual processor to initiate communication, and sending an inter-core communication signal to the virtual processor corresponding to the communication recipient through the target virtual processor, the method also includes: determining whether the identification bit of the target virtual processor has been identified through the monitoring module; when it is determined that the target virtual processor has been identified, traversing the first threads corresponding to the virtual processors in the virtual machine except the target virtual processor; for the first thread, adjusting the first thread from the first priority when called by the scheduling module to the second priority to obtain the adjusted first thread; and adding the adjusted first thread to the execution thread queue of the scheduling module, wherein the second priority is greater than the first priority.
[0042] Optionally, in the above embodiment, when the target virtual processor initiates communication, the scheduling module will first check the identification bit of the target virtual processor, and if it is determined that the identification bit of the target virtual processor has been identified, it will adjust the scheduling priority of other virtual processors, so that the scheduling module can add the threads corresponding to other virtual processors to the execution thread queue, and then directly schedule other virtual processors when the target virtual processor initiates communication to other virtual processors.
[0043] Through the above embodiment, the flag bit of the target virtual processor is set so that the scheduling module can schedule other virtual processors as quickly as possible to quickly process the communication request of the target virtual processor, thereby improving the communication efficiency of the virtual processors in the multi-core virtual machine.
[0044] In an exemplary embodiment, the method further includes: determining from the monitoring data the number of times the target virtual processor initiates communication in the second communication mode; and when it is determined that the number of times the target virtual processor initiates communication in the second communication mode is less than a second preset number, canceling the identification of the identification bit of the target virtual processor.
[0045] In an exemplary embodiment, the method also includes: determining, through the monitoring module, whether the identification bit of the target virtual processor has been unmarked; when it is determined through the monitoring module that the identification bit of the target virtual processor has been unmarked, traversing the second threads corresponding to the virtual processors in the virtual machine other than the target virtual processor; for the second thread, adjusting the second thread from the second priority when called by the scheduling module to the first priority, wherein the second priority is greater than the first priority.
[0046] Optionally, in the above embodiment, the identification bit of the virtual processor can be dynamically adjusted. When the virtual processor frequently initiates communication, the virtual processor is marked to adjust the communication mode of the virtual device to the second communication mode, thereby improving communication efficiency. When the communication frequency of the virtual processor becomes low, the mark is canceled and the first communication mode is restored.
[0047] Through the above embodiments, the communication frequency of the virtual processor can be monitored to dynamically adjust the communication mode of the virtual processor, thereby improving the processor communication efficiency of the multi-core virtual machine.
[0048] Obviously, the embodiments described above are only some embodiments of the present application, not all embodiments. In order to better understand the verification method of the above test case, the above process is described below in conjunction with the embodiments, but it is not intended to limit the technical solutions of the embodiments of the present application, specifically:
[0049] In an optional embodiment, if Figure 3 As shown, VCPU0 is equivalent to the first virtual processor, VCPU1 is equivalent to the second virtual processor, when VCPU0 initiates ipi (Inter-Processor Interrupt, inter-core interrupt) communication to VCPU1 in the first communication mode, if VCPU1 is not in the running state (equivalent to the non-execution state), VCPU0 needs to exit the virtual environment first and enter the root state, that is, enter the host operating system, set the VCPU1 thread to the running state (equivalent to the execution state), so that the CFS scheduler (equivalent to the scheduling module) can schedule the thread corresponding to VCPU1, and then record the number of ipi communications d in the above communication mode. When the preset number is exceeded within the preset period, for example, after exceeding 10 times in 5 minutes, the busy_ipi flag is set to the flag bit of VCPU0.
[0050] In the above embodiment, after setting the busy_ipi flag for the flag bit of VCPU0, the priority of other VCPUs needs to be adjusted. Under normal circumstances, the scheduling module normally schedules the VCPU threads according to the CFS scheduling process, that is, it schedules fairly according to the vruntime (virtual runtime) of the virtual processor. The smaller the vruntime, the higher the scheduling priority. However, if the thread is marked with the busy_ipi flag, when the VCPU thread is scheduled again, the other VCPU threads of the virtual machine will be traversed, and the virtual runtime vruntime of the scheduling entity of other VCPU threads will be temporarily subtracted by a preset time, so as to achieve the purpose of giving priority to other VCPU threads.
[0051] like Figure 4 As shown in the figure, under the scheduling policy of the CFS scheduler, the vruntime of all threads will increase at the same speed with time t. If it is detected that the busy_ipi flag is set for the VCPU0 thread when scheduling VCPU0, the CFS scheduler will traverse other VCPU threads of the virtual machine, such as VCPU1, and then temporarily subtract a preset value from the vruntime value of the VCPU1 thread. In this way, the CFS scheduler can prioritize the VCPU1 thread over other applications, so that the VCPU 1 thread and the VCPU0 thread can be scheduled and run by the CFS scheduler at the same time, thereby quickly completing the communication process between VCPU 1 and VCPU0.
[0052] Furthermore, when the monitoring module records that the number of communications of VCPU0 within a preset period is less than the preset number, for example, the number of communications within 5 minutes is less than 1 time, the busy_ipi flag of VCPU0 is cleared. At this time, the VCPU scheduling module schedules other VCPU threads normally according to the CFS scheduling process, and adds the vruntime of other VCPU threads to the preset value subtracted above, so that the priority of each thread of the virtual machine remains consistent.
[0053] Through the above embodiments, the frequency of VCPU communication in the virtual machine can be monitored, and the priority of the VCPU can be dynamically adjusted so that the VCPUs communicating in the virtual machine can be scheduled simultaneously as soon as possible, thereby improving the communication efficiency between VCPUs in the virtual machine.
[0054] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0055] In the present embodiment, a communication device of a virtual processor is also provided, and the system is used to implement the above-mentioned embodiment and preferred implementation mode, and the descriptions that have been made are not repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0056] Figure 5 is a structural block diagram of a communication device of a virtual processor according to an embodiment of the present application, such as Figure 5 As shown, the device comprises:
[0057] A first determining module 52, configured to determine, from the monitoring data, the number of times the virtual processor initiates communication in a first communication manner;
[0058] A second determining module 54 is used to determine a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number;
[0059] The identification module 56 is used to identify the identification bit of the target virtual processor, and call the target virtual processor through the scheduling module so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
[0060] Through the above device, the number of times a virtual processor initiates communication in the first communication mode can be determined from the monitoring data obtained by monitoring the communication mode of the virtual processor, and the virtual processor that initiates communication in the first communication mode more than the first preset number of times can be determined as the target virtual processor, and then the identification bit of the target virtual processor is identified, so that the scheduling module can initiate communication in the second communication mode when calling the target virtual processor. Therefore, the problem of low communication efficiency between virtual processors in the virtual machine in the related technology can be solved.
[0061] In an exemplary embodiment, the first determination module 52 is further used to: obtain the current state of the second virtual processor through the scheduling module, wherein the current state includes: an execution state and a non-execution state, wherein the execution state indicates that the thread corresponding to the second virtual processor is in the execution thread queue of the scheduling module, and the non-execution state indicates that the thread corresponding to the second virtual processor is not in the execution thread queue of the scheduling module; when it is determined that the second virtual processor is in the non-running state, control the first virtual processor to exit the virtual machine execution environment through the scheduling module so that the first virtual processor enters the operating system of the host machine; control the first virtual processor to send an interrupt signal to the second virtual processor through the programmable interrupt controller in the operating system of the host machine so as to determine that the virtual processor initiates communication in the first communication mode, wherein the interrupt signal corresponds to an interrupt task, and the interrupt signal is used to interrupt the current execution task of the second virtual processor; add the thread corresponding to the second virtual processor to the execution thread queue of the scheduling module; call the second virtual processor through the scheduling module so that the second virtual processor processes the interrupt task.
[0062] In an exemplary embodiment, the first determination module 52 is also used to: after determining that the second virtual processor has processed the interrupt task, respond the processing result of the interrupt task to the first virtual processor through the scheduling module; after determining that the first virtual processor has received the processing result of the interrupt task, control the first virtual processor to enter the virtual machine execution environment from the operating system of the host machine through the scheduling module.
[0063] In an exemplary embodiment, the device is also used to: determine the communication recipient of the target virtual processor to initiate communication, send an inter-core communication signal to the virtual processor corresponding to the communication recipient through the target virtual processor, and the inter-core communication signal corresponds to a target execution task; call the virtual processor corresponding to the communication recipient through the scheduling module to process the target execution task; after determining that the virtual processor corresponding to the communication recipient has processed the target execution task, respond the processing result of the target execution task to the target virtual processor through the scheduling module.
[0064] In an exemplary embodiment, the device is also used to: determine whether the identification bit of the target virtual processor has been identified through the monitoring module; when it is determined that the target virtual processor has been identified, traverse the first threads corresponding to the virtual processors in the virtual machine other than the target virtual processor; for the first thread, adjust the first thread from the first priority when called by the scheduling module to the second priority to obtain the adjusted first thread; add the adjusted first thread to the execution thread queue of the scheduling module, wherein the second priority is greater than the first priority.
[0065] In an exemplary embodiment, the device is also used to: determine from the monitoring data the number of times the target virtual processor initiates communication in the second communication mode; and when it is determined that the number of times the target virtual processor initiates communication in the second communication mode is less than a second preset number, cancel the identification of the identification bit of the target virtual processor.
[0066] In an exemplary embodiment, the device is also used to: determine whether the identification bit of the target virtual processor has been unmarked through the monitoring module; when it is determined through the monitoring module that the identification bit of the target virtual processor has been unmarked, traverse the second threads corresponding to the virtual processors in the virtual machine other than the target virtual processor; for the second thread, adjust the second thread from the second priority when it is called by the scheduling module to the first priority, wherein the second priority is greater than the first priority.
[0067] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0068] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0069] Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:
[0070] S1, determining from the monitoring data the number of times the virtual processor initiates communication in a first communication mode;
[0071] S2, determining a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number;
[0072] S3, marking the identification bit of the target virtual processor, and calling the target virtual processor through the scheduling module program, so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
[0073] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0074] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0075] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0076] S1, determining from the monitoring data the number of times the virtual processor initiates communication in a first communication mode;
[0077] S2, determining a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number;
[0078] S3, marking the identification bit of the target virtual processor, and calling the target virtual processor through the scheduling module program, so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
[0079] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0080] Optionally, in this embodiment, the computer program may be configured to perform the following steps by means of the computer program:
[0081] S1, determining from the monitoring data the number of times the virtual processor initiates communication in a first communication mode;
[0082] S2, determining a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number;
[0083] S3, marking the identification bit of the target virtual processor, and calling the target virtual processor through the scheduling module program, so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
[0084] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0085] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0086] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A communication method for a virtual processor, characterized in that: Applied to a virtual machine, the virtual machine runs in an operating system of a host machine, the virtual machine includes multiple virtual processors, a monitoring module, and a scheduling module, the scheduling module is used to call the virtual processor, the monitoring module is used to monitor the communication mode initiated by the multiple virtual processors to obtain monitoring data, and there is a communication channel between the multiple virtual processors, including: Determine from the monitoring data the number of times the virtual processor initiates communication in a first communication manner; Determine a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number; The identification bit of the target virtual processor is identified, and the target virtual processor is called through the scheduling module so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
2. The method according to claim 1, characterized in that The multiple virtual processors include a first virtual processor and a second virtual processor. When it is determined that the first virtual processor is a communication initiator and the second virtual processor is a communication receiver, before determining from the monitoring data the number of times the virtual processor initiates communication in the first communication mode, the method further includes: Acquire the current state of the second virtual processor through the scheduling module, wherein the current state includes: an execution state and a non-execution state, wherein the execution state indicates that the thread corresponding to the second virtual processor is in the execution thread queue of the scheduling module, and the non-execution state indicates that the thread corresponding to the second virtual processor is not in the execution thread queue of the scheduling module; When it is determined that the second virtual processor is in the non-operating state, controlling the first virtual processor to exit the virtual machine execution environment through the scheduling module, so that the first virtual processor enters the operating system of the host machine; Controlling the first virtual processor to send an interrupt signal to the second virtual processor through a programmable interrupt controller in the operating system of the host machine, so as to determine that the virtual processor initiates communication in a first communication mode, wherein the interrupt signal corresponds to an interrupt task, and the interrupt signal is used to interrupt the currently executed task of the second virtual processor; Adding the thread corresponding to the second virtual processor to the execution thread queue of the scheduling module; The second virtual processor is called through the scheduling module so that the second virtual processor processes the interrupt task.
3. The method according to claim 2, characterized in that After calling the second virtual processor through the scheduling module so that the second virtual processor processes the interrupt task, the method further includes: After determining that the second virtual processor has processed the interrupt task, responding the processing result of the interrupt task to the first virtual processor through the scheduling module; After determining that the first virtual processor receives the interrupt task processing result, the scheduling module controls the first virtual processor to enter the virtual machine execution environment from the operating system of the host machine.
4. The method according to claim 1, characterized in that: The method further comprises: Determine a communication receiver of the target virtual processor to initiate communication, and send an inter-core communication signal to a virtual processor corresponding to the communication receiver through the target virtual processor, wherein the inter-core communication signal corresponds to a target execution task; Calling the virtual processor corresponding to the communication recipient through the scheduling module to process the target execution task; After determining that the virtual processor corresponding to the communication recipient has processed the target execution task, the processing result of the target execution task is responded to the target virtual processor through the scheduling module.
5. The method according to claim 4, characterized in that Before determining a communication recipient to which the target virtual processor initiates communication, and sending an inter-core communication signal to a virtual processor corresponding to the communication recipient through the target virtual processor, the method further includes: Determine, by the monitoring module, whether the identification bit of the target virtual processor has been identified; When it is determined that the target virtual processor has been identified, traverse first threads corresponding to virtual processors other than the target virtual processor in the virtual machine; For the first thread, adjusting the first thread from a first priority when the first thread is called by the scheduling module to a second priority, to obtain an adjusted first thread; The adjusted first thread is added to an execution thread queue of the scheduling module, wherein the second priority is greater than the first priority.
6. The method according to claim 1, characterized in that The method further comprises: Determine from the monitoring data the number of times the target virtual processor initiates communication in the second communication mode; When it is determined that the number of times the target virtual processor initiates communication in the second communication mode is less than a second preset number, the identification of the identification bit of the target virtual processor is canceled.
7. The method according to claim 6, characterized in that The method further comprises: Determine, by the monitoring module, whether the identification bit of the target virtual processor has been de-identified; When it is determined by the monitoring module that the identification bit of the target virtual processor has been unmarked, traverse the second threads corresponding to the virtual processors other than the target virtual processor in the virtual machine; For the second thread, the second thread is adjusted from a second priority level when the second thread is called by the scheduling module to a first priority level, wherein the second priority level is greater than the first priority level.
8. A communication device for a virtual processor, characterized in that: include: A first determining module, configured to determine, from the monitoring data, the number of times the virtual processor initiates communication in a first communication mode; A second determination module is used to determine a target virtual processor from the multiple virtual processors, wherein the target virtual processor is a virtual processor that initiates communication in the first communication mode a number of times greater than a first preset number; An identification module is used to identify the identification bit of the target virtual processor, and call the target virtual processor through the scheduling module so that the target virtual processor initiates communication in a second communication mode, wherein the communication time of the second communication mode is less than the communication time of the first communication mode.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.
