Method, apparatus, device, and storage medium for processing interruption information
By modifying the indication information of the timer interrupt identifier in the virtual machine to preset indication information, the consumption problem caused by frequent switching mode of the virtual machine is solved, and the effect of improving the processing efficiency of the virtual machine is achieved.
Patent Information
- Application Number
- CN202410008667.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-03
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2044-01-03
AI Technical Summary
In the prior art, the virtual machine needs to frequently switch modes through the VMM virtual timer, resulting in large consumption of virtual machines and reducing processing efficiency.
When receiving the timer setting instruction, the indication information of the timer interrupt identification modified by the virtual machine is a preset indication information, indicating that the VCPU process can receive the timer interrupt information in the virtualized mode, thereby avoiding mode switching.
It reduces the consumption of VCPU processes, improves the processing efficiency of the virtual machine, and avoids the performance losses caused by frequent switching modes of the virtual machine.
Smart Images

Figure CN117891573B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the technical field of virtual machines, and in particular, to a method, apparatus, device, and storage medium for processing interrupt information. Background Art
[0002] In order to improve the resource utilization rate of the CPU (Central Processing Unit), multiple virtual machines are provided in the CPU, and each virtual machine can independently process processes. Among them, Timer (timer) is widely used in various operation scenarios of virtual machines, and the scheduler of the CPU operating system uses the timer to enable each process to alternately occupy the resources of the virtual machine according to a certain time period.
[0003] Currently, the timer of the virtual machine is processed by the VMM (Virtual Machine Manager). When a virtual machine needs to set a timer, the virtual machine exits from the virtualization mode to the host mode, and the VMM virtualizes a timer. Then the virtual machine enters the virtualization mode from the host mode to continue processing the task process. When the set timer expires, the virtual machine exits from the virtualization mode to the host mode again, and the VMM injects a timer interrupt into the virtual machine, so that the virtual machine can pause the current task process and process the task process corresponding to the timer.
[0004] However, the inventors found that the prior art has at least the following technical problems: virtualizing the timer through the VMM requires the virtual machine to switch between the host mode and the virtualization mode multiple times, resulting in a large consumption of the virtual machine, and thus reducing the processing efficiency of the virtual machine. Summary of the Invention
[0005] Embodiments of the present disclosure provide a method, apparatus, device, and storage medium for processing interrupt information, which can reduce the consumption of the VCPU process and improve the processing efficiency of the virtual machine.
[0006] In a first aspect, an embodiment of the present disclosure provides a method for processing interrupt information, which is applied to a Central Processing Unit (CPU), where the CPU includes an interrupt injection module and at least one Physical Central Processing Unit (PCPU), and the Physical Central Processing Unit (PCPU) is used to run a Virtual Central Processing Unit (VCPU) process on a virtual machine; the method includes:
[0007] In response to receiving a timer setting instruction, determining a target VCPU process corresponding to the timer setting instruction, and obtaining a timer interrupt identifier corresponding to the target VCPU process through a virtual machine corresponding to the target VCPU process;
[0008] Modify the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in the virtualization mode;
[0009] In response to reaching the set time corresponding to the timer setting instruction, inject timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module.
[0010] In a second aspect, an embodiment of the present disclosure provides a processing device for interrupt information, which is applied to a central processing unit (CPU), where the CPU includes an interrupt injection module and at least one physical processor (PCPU), and the physical processor (PCPU) is used to run a virtual processor (VCPU) process on a virtual machine; the device includes:
[0011] An acquisition module, configured to determine a target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction, and obtain a timer interrupt identifier corresponding to the target VCPU process through a virtual machine corresponding to the target VCPU process;
[0012] A modification module, configured to modify the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in the virtualization mode;
[0013] A processing module, configured to inject timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module in response to reaching the set time corresponding to the timer setting instruction.
[0014] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0015] A processor, and a memory communicatively connected to the processor;
[0016] The memory stores computer-executable instructions;
[0017] The processor executes the computer-executable instructions stored in the memory to implement the method for processing interrupt information as described in the first aspect above.
[0018] Fourthly, embodiments of the present disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method for processing interruption information as described in the first aspect above.
[0019] Fifthly, embodiments of the present disclosure provide a computer program product including a computer program, which, when executed by a processor, implements the method for processing interruption information as described in the first aspect above.
[0020] The method, apparatus, device, and storage medium for processing interruption information provided in this embodiment include: in response to receiving a timer setting instruction, determining a target VCPU process corresponding to the timer setting instruction, and obtaining a timer interruption identifier corresponding to the target VCPU process through a virtual machine corresponding to the target VCPU process; modifying the indication information corresponding to the timer interruption identifier to preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interruption information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interruption information in the virtualization mode; in response to reaching the set time corresponding to the timer setting instruction, injecting timer interruption information into the target VCPU process in the virtualization mode through an interruption injection module. In the embodiments of the present application, since the indication information corresponding to the timer interruption identifier is modified to the preset indication information before reaching the set time corresponding to the timer setting instruction, when reaching the set time corresponding to the timer setting instruction, the interruption injection module can directly inject a timer interruption into the target VCPU process in the client mode. Therefore, the virtual machine does not need to switch from the client mode to the host mode, thereby reducing the consumption of the VCPU process and improving the processing efficiency of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following briefly introduces the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0022] Figure 1 It is a schematic diagram of an application scenario of a method for processing interruption information provided in an embodiment of the present disclosure;
[0023] Figure 2 It is a flowchart of a method for processing interruption information provided in an embodiment of the present disclosure;
[0024] Figure 3Schematic diagram of a method for processing interruption information provided by an embodiment of the present disclosure;
[0025] Figure 4 Flowchart of another method for processing interruption information provided by an embodiment of the present disclosure;
[0026] Figure 5 Block diagram of a structure of an apparatus for processing interruption information provided by an embodiment of the present disclosure;
[0027] Figure 6 Schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0028] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.
[0029] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data that have been authorized by the user or fully authorized by all parties. And the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards, and corresponding operation entrances are provided for the user to choose to authorize or refuse.
[0030] To improve the resource utilization rate of the CPU (Central Processing Unit), multiple virtual machines are provided in the CPU, and each virtual machine can independently process processes. Among them, the Timer (timer) is widely used in various operation scenarios of virtual machines. For example, in scenarios where timed tasks or periodic tasks are implemented. The scheduler of the CPU operating system uses the timer to enable each process to alternately occupy the resources of the virtual machine according to a certain time period.
[0031] Currently, the timer of the virtual machine is processed by the VMM (Virtual Machine Manager). When the virtual machine needs to set a timer, it exits from the virtualization mode (i.e., the Guest mode) to the host mode (i.e., the Host mode), and the VMM virtualizes a timer. Then the virtual machine enters the virtualization mode from the host mode to continue processing the task process. When the set timer expires, the virtual machine exits from the virtualization mode to the host mode again, and the VMM injects a timer interrupt into the virtual machine, so that the virtual machine can pause the current task process and process the task process corresponding to the timer. It should be noted that the system privilege corresponding to the host mode is higher, and the system privilege corresponding to the virtualization mode is lower. Therefore, for system security, the task process is run in the virtualization mode. When the task process needs to obtain information with a higher privilege, the virtual machine where the task process is located needs to exit from the virtualization mode to the host mode.
[0032] However, currently, the overhead of Timer simulation in virtualization is relatively large. When setting a Timer in the virtual machine and when the Timer expires, the virtual machine needs to exit from the virtualization mode to the host mode. That is to say, the virtual machine needs to exit twice (the first exit is to set the Timer, and the second exit is to inject an interrupt after the Timer expires).
[0033] It can be seen that virtualizing the timer through the VMM requires the virtual machine to switch between the host mode and the virtualization mode multiple times, resulting in a large consumption of the VCPU (Virtual Central Processing Unit) process, thus reducing the processing efficiency of the virtual machine.
[0034] Therefore, how to reduce the consumption of the VCPU process and improve the processing efficiency of the virtual machine is an urgent problem to be solved at present.
[0035] In the related art, a module can be installed inside a virtual machine. This module writes the timer (Timer) to be set into the shared memory in a certain format, and then creates a polling process on the CPU to continuously poll the shared memory of the virtual machine. When a new timer (Timer) is set inside the virtual machine, the polling process reads the timer information of the virtual machine and starts a timer (Timer). When the timer (Timer) expires, the polling process injects a timer interrupt into the virtual machine. Since the CPU can obtain the timer information of the virtual machine from the shared memory through the created polling process, there is no need for the virtual machine to switch between the host mode and the virtualization mode multiple times.
[0036] However, the disadvantage of the above technology is that CPU resources need to be reserved on the host to poll the timer information of the virtual machine, which will cause a certain amount of CPU resource consumption.
[0037] Furthermore, to solve the above problems, without increasing CPU resource consumption, a virtual machine running in the virtualization mode can directly receive timer interrupt information without the need for the virtual machine to switch between the host mode and the virtualization mode.
[0038] This embodiment provides the following technical concept: When a virtual machine is running in virtualization mode and a specific interrupt message needs to be injected into the VCPU process in the virtual machine, only the indication information corresponding to the timer interrupt of the VCPU process needs to be modified to a preset indication information (for example, set to 1). At this time, the interrupt information can be injected into the VCPU process in virtualization mode without causing the virtual machine to exit from virtualization mode. Correspondingly, the specific steps may include: First, in response to receiving a timer setting instruction, determine the target VCPU process corresponding to the timer setting instruction, and obtain the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process; Second, modify the indication information corresponding to the timer interrupt identifier to the preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in virtualization mode; Finally, in response to reaching the setting time corresponding to the timer setting instruction, inject the timer interrupt information into the target VCPU process in virtualization mode through the interrupt injection module. In this case, since the indication information corresponding to the timer interrupt identifier is modified to the preset indication information before reaching the setting time corresponding to the timer setting instruction, in this way, when reaching the setting time corresponding to the timer setting instruction, the timer interrupt can be directly injected into the target VCPU process in the client mode through the interrupt injection module. Therefore, the virtual machine does not need to switch from the client mode to the host mode, thereby reducing the consumption of the VCPU process and improving the processing efficiency of the virtual machine.
[0039] It should be noted that in the DPU (Data Processing Unit) scenario, many processes on the CPU are offloaded to the DPU for processing, so that the CPU does not need to reserve specific PCPUs to process the processes on the CPU, thereby improving the processing efficiency of the CPU. In the embodiments of the present disclosure, since the virtual machine does not need to switch from the client mode to the host mode, the consumption of the VCPU process is reduced, the processing efficiency of the virtual machine is improved, and at the same time, the processing efficiency of the CPU is further improved.
[0040] The application scenarios of the embodiments of the present disclosure are explained below:
[0041] The method for processing interrupt information provided by the embodiments of the present disclosure can be applied to various operation scenarios of virtual machines. For example, in scenarios where timing tasks or periodic tasks are implemented. Figure 1 It is a schematic diagram of the application scenario of a method for processing interrupt information provided by the embodiments of the present disclosure. As Figure 1As shown in the figure, there are three task processes running in the CPU, namely: Process A, Process B, and the VCPU process on the virtual machine. Exemplarily, a timer can be set for the VCPU process (scheduled task) through the method in this application. Before the timer of the VCPU process expires, the CPU processes the task as: Process A. When the timer of the VCPU process expires, the CPU pauses processing the task of Process A and processes the VCPU process. After processing the VCPU process, it continues to process Process A.
[0042] The following uses a detailed embodiment to elaborate on the method for processing interrupt information provided by the embodiments of the present disclosure.
[0043] Figure 2 It is a flowchart of a method for processing interrupt information provided by the embodiments of the present disclosure. The execution subject of this interrupt information processing method can be the central processing unit CPU, where the CPU includes an interrupt injection module and at least one physical processor PCPU, and the physical processor PCPU is used to run the VCPU process on the virtual machine. As Figure 2 shown, the method includes:
[0044] S201. In response to receiving a timer setting instruction, determine the target VCPU process corresponding to the timer setting instruction, and obtain the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process.
[0045] In the embodiments of the present application, a task list is established in the virtual machine, and the task list includes multiple processes. The multiple processes include the VCPU process and other processes (such as disk processes, memory processes, etc.).
[0046] Optionally, obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine may include the following steps (a) to (c):
[0047] (a) Obtain the attribute information respectively corresponding to at least one VCPU process in the virtual machine through the virtual machine corresponding to the target VCPU process, where the attribute information includes the interrupt identifiers respectively corresponding to multiple interrupt types.
[0048] In some embodiments, each VCPU process corresponds to an attribute information, and the attribute information of each VCPU process can be uploaded to the virtual machine. In this way, the virtual machine can modify the attribute information of the VCPU process in the virtualization mode. Exemplarily, the attribute information corresponding to the VCPU process can be represented by pi_desc. Among them, the multiple interrupt types include timer interrupt, disk interrupt, etc.
[0049] (b)The virtual machine selects the target attribute information corresponding to the target VCPU process from the attribute information respectively corresponding to at least one VCPU process according to the process identifier corresponding to the target VCPU process.
[0050] Optionally, one process corresponds to one process identifier, which may be a process name, a process code, etc. For example, the process identifier may be: VCPU1, VCPU2, VCPU3, etc.
[0051] In some embodiments, if the process identifier corresponding to the target VCPU process is: VCPU1, then the target attribute information corresponding to VCPU1 is selected from the attribute information respectively corresponding to at least one VCPU process.
[0052] (c)The virtual machine selects the timer interrupt identifier corresponding to the target VCPU process from the interrupt identifiers respectively corresponding to multiple interrupt types included in the target attribute information.
[0053] In some embodiments, the interrupt identifier is an interrupt number. The target attribute information may include 256 interrupt types, and each interrupt type corresponds to an interrupt number. Among them, the interrupt number can be represented by a pir value. Exemplarily, the timer interrupt number is: pir = 236.
[0054] S202: The virtual machine modifies the indication information corresponding to the timer interrupt identifier to preset indication information, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in the virtualization mode.
[0055] In some embodiments, the indication information corresponding to the timer interrupt identifier may be the encoding information corresponding to the timer interrupt identifier. Optionally, the encoding information corresponding to the timer interrupt identifier is "pir = 236". Among them, the preset indication information may be "1", indicating that the target VCPU process can receive timer interrupt information in the virtualization mode. It should be noted that when the indication information corresponding to the timer interrupt identifier is "0", it means that the target VCPU process cannot receive timer interrupt information in the virtualization mode.
[0056] Optionally, the indication information corresponding to the timer interrupt identifier can be modified to the preset indication information through a hook operation. Correspondingly, before the virtual machine modifies the indication information corresponding to the timer interrupt identifier to the preset indication information, it may further include: performing a hook operation on a preset program in the virtual machine, where the hook operation is used to modify the indication information corresponding to the timer interrupt identifier to the preset indication information when a timer setting instruction is received.
[0057] Optionally, the preset program is the set next event function.
[0058] Exemplarily, as Figure 3 shown, the interrupt number can be represented by the pir value. In this case, an operation of hooking the set_next_event function in the virtual machine can be performed. Each time a new timer is set, the indication information corresponding to the timer interrupt identifier (pir = 236 in the pi desc) can be modified to 1, and the timer setting operation can be completed.
[0059] S203. In response to reaching the setting time corresponding to the timer setting instruction, inject timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module.
[0060] In the embodiments of the present disclosure, the value of the setting time is not specifically limited. Optionally, the setting time can be 10 milliseconds, 100 milliseconds, etc.
[0061] Optionally, this step is: in response to reaching the setting time corresponding to the timer setting instruction, the timer can send timer interrupt information to the CPU where the virtual machine is located, and the CPU injects the timer interrupt information into the target VCPU process of the virtual machine through the interrupt injection module.
[0062] Among them, the virtual machine runs in the virtualization mode and does not need the virtual machine to switch from the client mode to the host mode.
[0063] The embodiments of the present disclosure provide a method for processing interrupt information, including: in response to receiving a timer setting instruction, determining the target VCPU process corresponding to the timer setting instruction, and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process; modifying the indication information corresponding to the timer interrupt identifier to a preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in the virtualization mode; in response to reaching the setting time corresponding to the timer setting instruction, injecting timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module. In the embodiments of the present application, since the indication information corresponding to the timer interrupt identifier is modified to the preset indication information before reaching the setting time corresponding to the timer setting instruction, in this way, when reaching the setting time corresponding to the timer setting instruction, the timer interrupt can be directly injected into the target VCPU process in the client mode through the interrupt injection module. Therefore, the virtual machine does not need to switch from the client mode to the host mode, thereby reducing the consumption of the VCPU process and improving the processing efficiency of the virtual machine.
[0064] In the embodiments of the present application, as Figure 3 shown, the CPU further includes a virtual machine control module. When the virtual machine switches modes, parameters within the virtual machine control module can be modified so that the CPU can inject timer interrupt information into the target VCPU process of the virtual machine through the interrupt injection module. That is, adjustments need to be made on both the host side and the virtual machine (Guest) side.
[0065] Figure 4 FIG. is a flowchart of a method for processing interrupt information provided by an embodiment of the present disclosure. As Figure 4 shown, the steps for making adjustments on the host side include:
[0066] S401. In response to the virtual machine switching from the host mode to the virtualization mode, modify the virtual machine control module from the local timer mode to the virtual machine interrupt mode; wherein, the virtual machine interrupt mode is used for the virtual machine control module to send timer interrupt information to the virtual machine running in the virtualization mode.
[0067] Optionally, as Figure 3 shown, the virtual machine control module can be represented by APIC_LVTT. The local timer mode can be represented by LOCAL_TIMER_VECTOR, and the virtual machine interrupt mode can be represented by POSTED_INTR_VECTOR.
[0068] In response to the virtual machine switching from the host mode to the virtualization mode, modify APIC_LVTT to: "POSTED_INTR_VECTOR". In this way, the CPU can trigger the timer expiration in the virtualization mode, and through the virtual machine control module, a POSTED_INTR_VECTOR interrupt information can be generated, and this POSTED_INTR_VECTOR interrupt information can be directly sent to the virtual machine running in the virtualization mode without causing the virtual machine to exit the virtualization mode.
[0069] S402. In response to the virtual machine switching from the virtualization mode to the host mode, modify the virtual machine control module from the virtual machine interrupt mode to the local timer mode.
[0070] It should be noted that after the virtual machine completes the timer task, the virtual machine can switch from the virtualization mode to the host mode. At this time, the parameters of the virtual machine control module also need to be reset.
[0071] Exemplarily, when the virtual machine switches from the virtualization mode to the host mode, modify APIC_LVTT to: "LOCAL_TIMER_VECTOR", which can ensure the normal triggering of the timer task on the host.
[0072] It should be noted that other interrupt information except the timer interrupt information will also trigger the interrupt injection module to inject timer interrupt information into the virtual machine, resulting in the virtual machine receiving invalid timer interrupt information and affecting the performance of the virtual machine.
[0073] In some embodiments, to avoid the impact of invalid timer interrupt information on the virtual machine, before step 201, it further includes:
[0074] Obtain the first quantity of timer interrupt information received by the virtual machine within a preset duration and the second quantity of other interrupt information except the timer interrupt information;
[0075] If the first quantity is greater than the second quantity, execute step 201; if the first quantity is not greater than the second quantity, do not execute step 201.
[0076] Figure 5 It is a structural block diagram of a processing device for interrupt information provided by an embodiment of the present disclosure. This processing device is applied to a central processing unit (CPU), where the CPU includes an interrupt injection module and at least one physical processor (PCPU), and the physical processor (PCPU) is used to run the VCPU process on the virtual machine; see Figure 5 This device includes: an acquisition module 501, a modification module 502, and a processing module 503;
[0077] Among them, the acquisition module 501 is configured to, in response to receiving a timer setting instruction, determine the target VCPU process corresponding to the timer setting instruction, and obtain the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process;
[0078] The modification module 502 is configured to modify the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in the virtualization mode;
[0079] The processing module 503 is configured to, in response to reaching the setting time corresponding to the timer setting instruction, inject timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module.
[0080] According to one or more embodiments of the present disclosure, the obtaining module 501 obtains the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process, which specifically includes: obtaining the respective corresponding attribute information of at least one VCPU process in the virtual machine through the virtual machine corresponding to the target VCPU process, where the attribute information includes interrupt identifiers corresponding to multiple interrupt types respectively; the virtual machine selects the target attribute information corresponding to the target VCPU process from the respective corresponding attribute information of the at least one VCPU process according to the process identifier corresponding to the target VCPU process; the virtual machine selects the timer interrupt identifier corresponding to the target VCPU process from the interrupt identifiers corresponding to multiple interrupt types included in the target attribute information.
[0081] According to one or more embodiments of the present disclosure, the apparatus further includes: a setting module, which is used to perform a hook operation on a preset program in the virtual machine, where the hook operation is used to modify the indication information corresponding to the timer interrupt identifier to preset indication information when a timer setting instruction is received.
[0082] According to one or more embodiments of the present disclosure, the preset program is a set next event function.
[0083] According to one or more embodiments of the present disclosure, the CPU further includes a virtual machine control module; correspondingly, the apparatus further includes: an adjustment module, which, in response to the virtual machine switching from the host mode to the virtualization mode, modifies the virtual machine control module from the local timer mode to the virtual machine interrupt mode; wherein, the virtual machine interrupt mode is used for the virtual machine control module to send timer interrupt information to the virtual machine running in the virtualization mode.
[0084] According to one or more embodiments of the present disclosure, the adjustment module is further used to, in response to the virtual machine switching from the virtualization mode to the host mode, modify the virtual machine control module from the virtual machine interrupt mode to the local timer mode.
[0085] According to one or more embodiments of the present disclosure, the apparatus further includes: a condition judgment module, which is used to obtain the first quantity of timer interrupt information received by the virtual machine within a preset duration and the second quantity of other interrupt information except the timer interrupt information; if the first quantity is greater than the second quantity, then perform the steps of determining the target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction, and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process.
[0086] Among them, the acquisition module 501, the modification module 502, and the processing module 503 are connected in sequence. The interrupt information processing device provided in this embodiment can execute the technical solutions of the above method embodiments, and its implementation principle and technical effects are similar, which will not be elaborated here.
[0087] Figure 6 This is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present disclosure. Refer to Figure 6 , the electronic device 600 can be a terminal device or a server. Among them, the terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (Personal Digital Assistant, abbreviated as PDA), tablet computers (Portable Android Device, abbreviated as PAD), portable multimedia players (Portable Media Player, abbreviated as PMP), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present disclosure.
[0088] As Figure 6 shown, the electronic device 600 may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (Read Only Memory, abbreviated as ROM) 602 or the program loaded from the storage device 608 into the random access memory (Random Access Memory, abbreviated as RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The input / output (I / O) interface 605 is also connected to the bus 604.
[0089] Generally, the following devices can be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (Liquid Crystal Display, abbreviated as LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 can allow the electronic device 600 to communicate with other devices wirelessly or wiredly to exchange data. Although Figure 6An electronic device 600 with various devices is shown, but it should be understood that it is not required to implement or have all the shown devices. Instead, more or fewer devices may be implemented or had.
[0090] In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes program code for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
[0091] It should be noted that the above-mentioned computer-readable medium in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable signal medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0092] The above-mentioned computer-readable medium can be included in the above-mentioned electronic device; or it can exist separately without being assembled into the electronic device.
[0093] The above computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0094] Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0095] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur in a different order than noted in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0096] The units described in the embodiments of the present disclosure may be implemented in software or in hardware. Wherein, the name of the unit does not constitute a limitation on the unit itself in some cases. For example, the first acquisition unit may also be described as "the unit for acquiring at least two Internet protocol addresses".
[0097] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), Systems on Chip (SOCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0098] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a Random Access Memory (RAM), a Read Only Memory (ROM), an Erasable Programmable Read Only Memory (EPROM or Flash Memory), an optical fiber, a portable Compact Disc Read Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0099] In a first aspect, according to one or more embodiments of the present disclosure, a method for processing interrupt information is provided, which is applied to a Central Processing Unit (CPU), where the CPU includes an interrupt injection module and at least one Physical Central Processing Unit (PCPU), and the PCPU is used to run a VCPU process on a virtual machine; the method includes:
[0100] In response to receiving a timer setting instruction, determine the target VCPU process corresponding to the timer setting instruction, and obtain the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process;
[0101] Modify the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in virtualization mode;
[0102] In response to reaching the set time corresponding to the timer setting instruction, inject timer interrupt information into the target VCPU process in virtualization mode through the interrupt injection module.
[0103] According to one or more embodiments of the present disclosure, obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process includes: obtaining the attribute information respectively corresponding to at least one VCPU process in the virtual machine through the virtual machine corresponding to the target VCPU process, where the attribute information includes interrupt identifiers respectively corresponding to multiple interrupt types; selecting, by the virtual machine according to the process identifier corresponding to the target VCPU process, the target attribute information corresponding to the target VCPU process from the attribute information respectively corresponding to the at least one VCPU process; and selecting, by the virtual machine, the timer interrupt identifier corresponding to the target VCPU process from the interrupt identifiers respectively corresponding to the multiple interrupt types included in the target attribute information.
[0104] According to one or more embodiments of the present disclosure, before modifying the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, it further includes: performing a hook operation on a preset program in the virtual machine, where the hook operation is used to modify the indication information corresponding to the timer interrupt identifier to preset indication information when receiving a timer setting instruction.
[0105] According to one or more embodiments of the present disclosure, the preset program is a set next event function.
[0106] According to one or more embodiments of the present disclosure, a virtual machine control module is further provided in the CPU; correspondingly, before responding to receiving a timer setting instruction, determining the target VCPU process corresponding to the timer setting instruction, and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process, it further includes: in response to the virtual machine switching from the host mode to the virtualization mode, modifying the virtual machine control module from the local timer mode to the virtual machine interrupt mode; where the virtual machine interrupt mode is used for the virtual machine control module to send timer interrupt information to the virtual machine running in the virtualization mode.
[0107] According to one or more embodiments of the present disclosure, it further includes: in response to the virtual machine switching from the virtualization mode to the host mode, modifying the virtual machine control module from the virtual machine interrupt mode to the local timer mode.
[0108] Before determining the target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process, it further includes: obtaining a first quantity of timer interrupt information received by the virtual machine within a preset duration and a second quantity of other interrupt information except the timer interrupt information; if the first quantity is greater than the second quantity, then execute the steps of determining the target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process.
[0109] In a second aspect, according to one or more embodiments of the present disclosure, there is provided a processing apparatus for interrupt information, which is applied to a central processing unit CPU, where the CPU includes an interrupt injection module and at least one physical processor PCPU, and the physical processor PCPU is used to run VCPU processes on virtual machines; the apparatus includes:
[0110] An obtaining module, configured to determine a target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction, and obtain a timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process;
[0111] A modification module, configured to modify the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, where the indication information is used to indicate whether the target VCPU process can receive timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive timer interrupt information in the virtualization mode;
[0112] A processing module, configured to inject timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module in response to reaching the set time corresponding to the timer setting instruction.
[0113] According to one or more embodiments of the present disclosure, the obtaining module obtains the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process, which specifically includes: obtaining the attribute information respectively corresponding to at least one VCPU process in the virtual machine through the virtual machine corresponding to the target VCPU process, where the attribute information includes interrupt identifiers respectively corresponding to multiple interrupt types; the virtual machine selects the target attribute information corresponding to the target VCPU process from the attribute information respectively corresponding to the at least one VCPU process according to the process identifier corresponding to the target VCPU process; the virtual machine selects the timer interrupt identifier corresponding to the target VCPU process from the interrupt identifiers respectively corresponding to the multiple interrupt types included in the target attribute information.
[0114] According to one or more embodiments of the present disclosure, the device further includes: a setting module, which is used to perform a hook operation on a preset program in the virtual machine, where the hook operation is used to modify the indication information corresponding to the timer interrupt identifier to preset indication information when a timer setting instruction is received.
[0115] According to one or more embodiments of the present disclosure, the preset program is a set next event function.
[0116] According to one or more embodiments of the present disclosure, a virtual machine control module is further provided in the CPU; correspondingly, the device further includes: an adjustment module, which, in response to the virtual machine switching from the host mode to the virtualization mode, modifies the virtual machine control module from the local timer mode to the virtual machine interrupt mode; wherein, the virtual machine interrupt mode is used for the virtual machine control module to send timer interrupt information to the virtual machine running in the virtualization mode.
[0117] According to one or more embodiments of the present disclosure, the adjustment module is further used to, in response to the virtual machine switching from the virtualization mode to the host mode, modify the virtual machine control module from the virtual machine interrupt mode to the local timer mode.
[0118] According to one or more embodiments of the present disclosure, the device further includes: a condition judgment module, which is used to obtain the first quantity of timer interrupt information received by the virtual machine within a preset duration and the second quantity of other interrupt information except the timer interrupt information; if the first quantity is greater than the second quantity, then perform the steps of determining the target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction, and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process.
[0119] In a third aspect, according to one or more embodiments of the present disclosure, an electronic device is provided, including: a processor, and a memory communicatively connected to the processor;
[0120] The memory stores computer-executable instructions;
[0121] The processor executes the computer-executable instructions stored in the memory to implement the method for processing interruption information as described in the first aspect above and various possible designs of the first aspect.
[0122] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, in which computer-executable instructions are stored. When the processor executes the computer-executable instructions, the method for processing interruption information as described in the first aspect above and various possible designs of the first aspect is implemented.
[0123] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which when executed by a processor, implements the method for processing interruption information as described in the first aspect above and various possible designs of the first aspect.
[0124] The above description is only a preferred embodiment of the present disclosure and an explanation of the applied technical principle. Those skilled in the art should understand that the scope of the disclosure involved in the present disclosure is not limited to the technical solution formed by the specific combination of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosure concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) having similar functions disclosed in the present disclosure.
[0125] In addition, although the operations are depicted in a specific order, this should not be construed as requiring that the operations be performed in the specific order shown or in sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments may also be implemented combinatorially in a single embodiment. Conversely, the various features described in the context of a single embodiment may also be implemented separately or in any suitable sub-combination in multiple embodiments.
[0126] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. On the contrary, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A method for processing interrupt information, characterized in that: Applied to a central processing unit (CPU), wherein the CPU includes a virtual machine control module, an interrupt injection module and at least one physical processor (PCPU), and the physical processor (PCPU) is used to run a virtual processor (VCPU) process on a virtual machine; the method includes: In response to the virtual machine switching from the host mode to the virtualization mode, the virtual machine control module is modified from the local timer mode to the virtual machine interrupt mode; wherein the virtual machine interrupt mode is used for the virtual machine control module to send timer interrupt information to the virtual machine running in the virtualization mode; In response to receiving a timer setting instruction, determining a target VCPU process corresponding to the timer setting instruction, and obtaining a timer interrupt identifier corresponding to the target VCPU process through a virtual machine corresponding to the target VCPU process; Modifying the indication information corresponding to the timer interrupt identifier into preset indication information by the virtual machine, wherein the indication information is used to indicate whether the target VCPU process can receive the timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive the timer interrupt information in the virtualization mode; In response to reaching the set time corresponding to the timer setting instruction, timer interrupt information is generated by the virtual machine control module, the timer interrupt information is sent to the virtual machine running in the virtualization mode, and the timer interrupt information is injected into the target VCPU process in the virtualization mode by the interrupt injection module.
2. The method according to claim 1, characterized in that The step of obtaining a timer interrupt flag corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process includes: Acquire, through the virtual machine corresponding to the target VCPU process, attribute information respectively corresponding to at least one VCPU process in the virtual machine, wherein the attribute information includes interrupt identifiers respectively corresponding to a plurality of interrupt types; Selecting, by the virtual machine, target attribute information corresponding to the target VCPU process from the attribute information respectively corresponding to the at least one VCPU process according to the process identifier corresponding to the target VCPU process; The virtual machine selects a timer interrupt identifier corresponding to the target VCPU process from the interrupt identifiers respectively corresponding to the multiple interrupt types included in the target attribute information.
3. The method according to claim 1, characterized in that Before the virtual machine modifies the indication information corresponding to the timer interrupt flag into preset indication information, the method further includes: A hook operation is performed on a preset program in the virtual machine, wherein the hook operation is used to modify the indication information corresponding to the timer interrupt identifier to preset indication information when a timer setting instruction is received.
4. The method according to claim 3, characterized in that The preset program is to set the next event setnextevent function.
5. The method according to claim 1, characterized in that Also includes: In response to the virtual machine switching from the virtualization mode to the host mode, the virtual machine control module is modified from the virtual machine interrupt mode to the local timer mode.
6. The method according to any one of claims 1 to 5, characterized in that: In response to receiving the timer setting instruction, determining the target VCPU process corresponding to the timer setting instruction, and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process, further comprising: Obtain a first number of timer interrupt messages received by the virtual machine within a preset time period and a second number of other interrupt messages except the timer interrupt messages; If the first number is greater than the second number, the steps of determining the target VCPU process corresponding to the timer setting instruction in response to receiving the timer setting instruction, and obtaining the timer interrupt identifier corresponding to the target VCPU process through the virtual machine corresponding to the target VCPU process are executed.
7. A device for processing interrupt information, characterized in that: Applied to a central processing unit (CPU), wherein the CPU includes a virtual machine control module, an interrupt injection module and at least one physical processor (PCPU), and the physical processor (PCPU) is used to run a virtual processor (VCPU) process on a virtual machine; the device includes: A mode modification module, configured to modify the virtual machine control module from a local timer mode to a virtual machine interrupt mode in response to the virtual machine switching from a host mode to a virtualization mode; wherein the virtual machine interrupt mode is used for the virtual machine control module to send timer interrupt information to the virtual machine running in the virtualization mode; an acquisition module, configured to, in response to receiving a timer setting instruction, determine a target VCPU process corresponding to the timer setting instruction, and acquire a timer interrupt identifier corresponding to the target VCPU process through a virtual machine corresponding to the target VCPU process; A modification module, configured to modify the indication information corresponding to the timer interrupt identifier to preset indication information through the virtual machine, wherein the indication information is used to indicate whether the target VCPU process can receive the timer interrupt information in the virtualization mode, and the preset indication information is used to indicate that the target VCPU process can receive the timer interrupt information in the virtualization mode; A processing module is used to generate timer interrupt information through the virtual machine control module in response to reaching the set time corresponding to the timer setting instruction, send the timer interrupt information to the virtual machine running in the virtualization mode, and inject the timer interrupt information into the target VCPU process in the virtualization mode through the interrupt injection module.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method for processing interrupt information according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the processor executes the computer-executable instructions, the method for processing interrupt information according to any one of claims 1 to 6 is implemented.
10. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the method for processing interrupt information according to any one of claims 1 to 6.
Citation Information
Patent Citations
Interrupt request processing method, device, and virtualization device
CN109144679A