Virtual machine health detection method and system based on inter-kernel mutual detection
Through the virtual machine health detection method based on inter-core mutual inspection, the problem of incomplete detection of virtual machine health status and mis-checking risks in the existing technology is solved, and the accurate monitoring and detection of the core status of the virtual machine is realized, ensuring automotive electronics The system functions safely and stably operates.
Patent Information
- Application Number
- CN202411109357.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-12-13
AI Technical Summary
The existing virtual machine health status detection scheme has the risk of false detection and additional consumption, and cannot accurately monitor the processor core status, affecting the functional safety of the automotive electronic system.
Using the virtual machine health detection method based on inter-core mutual inspection, the performance detection unit counter overflows generates an unblocked interrupt, detects whether the number of overflows exceeds the threshold, and triggers the number of overflows between cores to clear the number of overflows when necessary, to realize the inter-core interrupt. Check each other to ensure the health of the virtual machine.
Improve the accuracy and reliability of virtual machine health detection, prevent the impact of single or multiple core exceptions on the system, ensure the normal operation of the system, and the virtual machine monitor is completely decoupled from the virtual machine system, without the need to perceive the existence of virtualization, and realize Invisible detection.
Smart Images

Figure CN119127543A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtual machine monitoring, and in particular to a virtual machine health detection method and system based on inter-core mutual detection. Background Art
[0002] With the development of the modern automobile industry, we have entered a new era of "software-defined cars". The automotive electronic and electrical architecture is undergoing a transformation from a traditional distributed architecture to a central computing architecture. In this context, the application of virtualization technology has become particularly important. Virtualization technology supports multi-core and multi-operating system environments in hybrid critical systems, which not only improves resource utilization, but also reduces hardware costs, and is perfectly compatible with the central computer architecture of the car.
[0003] In the hybrid critical system of automobiles, in order to ensure the stable operation and functional safety of the system, it is particularly important to monitor the status of each virtual machine (VM) and the status of the processor core (Core). It is necessary to detect anomalies in a timely and accurate manner and take corresponding measures to ensure that the automotive electronic system is in a specific functional safety state.
[0004] The current monitoring solutions are mainly aimed at monitoring virtual machines. The mainstream solution is to determine whether the virtual machine is abnormal through the heartbeat mechanism or I / O detection mechanism. However, this detection solution has the potential risk of false detection. For example, even if the virtual machine is running normally, only the heartbeat task crashes, which may cause false detection. At the same time, the heartbeat monitoring solution requires the virtual machine to be deeply integrated with the heartbeat mechanism, which brings additional consumption to the virtual machine. The virtual machine operating system needs to be aware of the existence of virtualization. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a virtual machine health detection method and system based on inter-core mutual detection to solve the imperfection of existing virtual machine health status detection and make up for the vacancy of virtualization processor core detection.
[0006] The technical problem solved by the present invention can be achieved by adopting the following technical solutions:
[0007] A virtual machine health detection method based on inter-core mutual detection includes:
[0008] Step S1, when it is detected that the counter of the performance detection unit of any core used by the virtual machine overflows, a non-maskable interrupt is generated;
[0009] Step S2, detecting whether the overflow times of all cores used by the virtual machine exceed a preset threshold:
[0010] If yes, then report the alarm information, perform exception processing, and go to step S3;
[0011] If not, proceed to step S3;
[0012] Step S3, the core that triggers the non-maskable interrupt sends an inter-core interrupt to all other cores used by the virtual machine;
[0013] Step S4: the core responds to the inter-core interrupt to perform an overflow count clearing operation.
[0014] Preferably, in step S1, the core performs an overflow count plus one operation in response to the non-maskable interrupt.
[0015] Preferably, each of the cores corresponds to one of the preset thresholds;
[0016] The preset thresholds corresponding to different cores are the same or different.
[0017] Preferably, the reporting of alarm information and performing exception handling at the same time include:
[0018] Step S21, detecting whether all the cores used by the virtual machine are abnormal:
[0019] If yes, the virtual machine is determined to be abnormal, a first alarm message is reported, an abnormal process is performed on the abnormal virtual machine, and the overflow times of all cores used by the abnormal virtual machine are cleared to zero;
[0020] If not, it is determined that one or more of the cores are abnormal, and the second alarm information is reported. Meanwhile, abnormal processing is performed on the abnormal cores, and the overflow times of the abnormal cores are cleared.
[0021] Preferably, the inter-core interrupt is sent in a broadcast manner.
[0022] Preferably, in step S4, the abnormal core cannot respond to the inter-core interrupt and does not perform the overflow count clearing operation.
[0023] Preferably, after step S4, the method further includes: returning to step S1 to perform next cycle detection.
[0024] The present invention also provides a virtual machine health detection system based on inter-core mutual detection, which is used to implement the virtual machine health detection method based on inter-core mutual detection as described above, and the system includes:
[0025] A plurality of cores, each of which is used to generate a non-maskable interrupt when detecting an overflow of a performance detection unit counter; and to detect whether the number of overflows of all cores used by the virtual machine exceeds a preset threshold, and to report an alarm message when the number of overflows exceeds the preset threshold, and to perform exception processing at the same time;
[0026] The core that triggers the non-maskable interrupt is also used to send an inter-core interrupt to all other cores used by the virtual machine;
[0027] The core performs an overflow count clearing operation in response to the inter-core interrupt.
[0028] Preferably, the core executes an overflow count increment operation in response to the non-maskable interrupt.
[0029] Preferably, the abnormal core cannot respond to the inter-core interrupt and does not perform the overflow count clearing operation.
[0030] The advantages or beneficial effects of the technical solution of the present invention are:
[0031] The present invention detects the processor cores used by the virtual machine to prevent the impact of abnormalities of a single or multiple cores on the system; and through mutual inspection between cores, the detection is made more accurate and reliable, thereby ensuring the normal operation of the entire system; in addition, the virtual machine monitor completely decouples the detection of the virtual machine, is transparent to the virtual machine system, and does not need to perceive the existence of virtualization, thereby achieving non-perceptible health detection of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A general virtualization framework diagram in a preferred embodiment of the present invention;
[0033] Figure 2 A flowchart of a virtual machine health detection method based on inter-core mutual detection in a preferred embodiment of the present invention;
[0034] Figure 3 A flowchart of a virtual machine health detection method based on inter-core mutual detection in a preferred embodiment of the present invention;
[0035] Figure 4 A schematic diagram of a PMU counter overflow triggering an NMI interrupt in a preferred embodiment of the present invention;
[0036] Figure 5 This is a schematic diagram of other cores processing IPI interrupts in a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0039] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments, but they are not intended to limit the present invention.
[0040] like Figure 1 A general virtualization framework diagram is shown. Figure 1 The figure shows the central processing unit (CPU), the multiple processor cores (Core0, Core1, ..., Coren) it contains, the performance monitoring unit (PMU) of each core, the virtual machine monitor (Hypervisor), multiple virtual machines (VM1, ..., VMN) and their respective virtual central processors (vcpu0, vcpu1, ..., vcpun). The virtual central processor is the virtualization product of the physical CPU and can be used independently by the virtual machine logically. Each VCPU has the ability to execute instructions and process data, allowing the virtual machine to run multi-threaded applications without a direct correspondence to the physical CPU core.
[0041] The processor core mentioned in this embodiment may be referred to as a core for short.
[0042] The inter-core mutual health monitoring process of the Hypervisor layer corresponds to the health detection scheme shown in the embodiment of the present invention.
[0043] See also Figure 2 In a preferred embodiment of the present invention, based on the above problems existing in the prior art, a virtual machine health detection method based on inter-core mutual detection is provided, comprising:
[0044] Step S1, when a counter overflow of a performance monitor unit (PMU) of any core used by the virtual machine is detected, a non-maskable interrupt (NMI) is generated;
[0045] The core responds to the non-maskable interrupt and performs an overflow count plus one operation.
[0046] Step S2: Detect whether the overflow times of all cores used by the virtual machine exceed a preset threshold:
[0047] If yes, then report the alarm information, perform exception processing, and go to step S3;
[0048] If not, proceed to step S3;
[0049] Step S3, the core that triggers the non-maskable interrupt sends an inter-processor interrupt (IPI) to all other cores used by the virtual machine;
[0050] In step S4, the core responds to the inter-core interrupt to perform an overflow count clearing operation.
[0051] Specifically, the existing monitoring solutions are mainly for monitoring virtual machines, and the virtual machines make abnormal judgments based on the heartbeat mechanism or I / O detection mechanism, which has the risk of false detection. At the same time, the virtual machine needs to sense the existence of virtualization, which will bring additional consumption to the virtual machine. In the embodiment of the present invention, when the PMU counter overflow of a core is detected, the hardware PMU generates an NMI interrupt, indicating that the core is abnormal.
[0052] When a core receives an NMI interrupt, it increments the overflow count by 1 and checks whether the overflow counts of all cores, including itself, exceed the preset threshold:
[0053] If the overflow times of all cores do not exceed the preset threshold, it means that all cores are running normally and the IPI interrupt is sent directly;
[0054] If the number of overflows of any core exceeds the preset threshold, it indicates that a core is operating abnormally. Then, all cores used by any virtual machine are detected to see if they are abnormal:
[0055] If not all cores are abnormal, it means that all virtual machines are running normally, but one or more cores are abnormal. At this time, the error information is recorded and reported, and the corresponding exception processing is performed. The overflow count of the abnormal core is set to 0, and then the IPI interrupt is sent.
[0056] If all cores used by any virtual machine are abnormal, it means that there is an abnormal virtual machine. At this time, the error information is recorded and reported, and the exception is handled at the same time, such as restarting the virtual machine and setting the overflow count of all cores used by the abnormal virtual machine to 0, and then sending the IPI interrupt.
[0057] After receiving the IPI interrupt, other cores will set their corresponding overflow times to 0.
[0058] Through the above scheme, the embodiment of the present invention provides a more low-level and fine-grained detection scheme, that is, monitoring the core used by the virtual machine system to achieve health detection of the virtual machine; and based on the core mutual inspection mechanism, the detection is made more accurate and reliable, thereby ensuring the normal operation of the entire system.
[0059] Since it is a core monitoring, the virtual machine monitor is completely decoupled from the detection of the virtual machine, which is transparent to the virtual machine system and does not need to be aware of the existence of virtualization, thus achieving unconscious health detection of the virtual machine.
[0060] In this embodiment, a PMU counter is configured for each core. The increment time of the PMU counter is related to the system clock frequency of the CPU. For example, if the system clock frequency is 1000HZ, it means that the PMU counter will increment once every millisecond. The time when the PMU counter overflows can be calculated through this relationship, for example, it is set to trigger an overflow event once every 5 seconds or 10 seconds.
[0061] The overflow number is set independently for the PMU counter of each core. The overflow number of the PMU counter corresponding to each core can be set according to actual needs. For example, it is executed after the virtual machine system is powered on normally and initialized, and the preset count value is stored as the reference value in the corresponding configuration. When the current value of the PMU counter exceeds the pre-designed value, it is determined that the PMU counter overflows and immediately triggers a specific type of overflow interrupt. The interrupt is explicitly registered as a non-maskable interrupt (NMI) to ensure that it can be responded to by the system unconditionally and is not affected by any interrupt masking settings.
[0062] In this embodiment, each core is not only configured with a PMU counter to monitor its performance, but also an independent overflow counter is established for each core. This counter is used to record the number of times the PMU counter of each core overflows. A threshold is set in advance for the overflow counter of each core as the alarm threshold corresponding to each core. The threshold can be set according to actual needs. When the overflow counter reaches the alarm threshold, the system will trigger a series of predefined response measures, including but not limited to: reporting the alarm information to relevant personnel or monitoring system based on the reporting mechanism, and executing the exception handling process (such as restarting the virtual machine).
[0063] As a preferred implementation, in step S1, the core executes an overflow count plus one operation in response to a non-maskable interrupt.
[0064] Specifically, after receiving the NMI interrupt, any core adds 1 to the overflow count of the core itself. Similarly, when the current value of the PMU counter of a core exceeds the pre-designed value, the overflow count counter of the core adds 1.
[0065] As a preferred implementation, each core corresponds to a preset threshold; the preset threshold is the preset alarm threshold mentioned above;
[0066] The preset thresholds corresponding to different cores may be the same or different.
[0067] As a preferred embodiment, wherein Figure 3 As shown, the alarm information is reported and the exception processing includes:
[0068] Step S21, detecting whether all cores used by the virtual machine are abnormal:
[0069] If yes, the virtual machine is determined to be abnormal, the first alarm information is reported, and the abnormal virtual machine is processed abnormally, and the overflow times of all cores used by the abnormal virtual machine are cleared to zero;
[0070] If not, it is determined that one or more cores are abnormal, and the second alarm information is reported. At the same time, the abnormal core is processed abnormally, and the overflow times of the abnormal core are cleared.
[0071] In the above step S2, the alarm information for a certain virtual machine includes the above first alarm information or the second alarm information.
[0072] In this embodiment, the virtual machine system includes multiple virtual machines. Figure 1 The general virtualization framework diagram shown includes virtual machines VM1, ..., and VMN. Each virtual machine corresponds to one or more virtual central processors, and the virtual central processors use the cores of the corresponding physical CPU to implement corresponding functions. The number of virtual central processors corresponding to different virtual machines can be set according to actual needs.
[0073] When any core abnormality of any virtual machine is detected, an alarm message is reported and the abnormality is handled at the same time.
[0074] If not all cores of a virtual machine are abnormal, the virtual machine runs normally, but one or more cores run abnormally, and the first alarm information is reported, which includes the error information of the recorded abnormal core; at the same time, the abnormal core is handled abnormally, such as restarting the core; and the overflow counter of the abnormal core is set to 0.
[0075] For example, it is assumed that the virtual machine VM1 corresponds to the virtual CPUs vcpu0, vcpu1, vcpu2, and vcpu3; and the virtual machine VMN corresponds to the virtual CPUs vcpun-1 and vcpun.
[0076] If the PMU counter of core Core0 overflows, core Core0 is abnormal; but cores Core1, Core2, and Core3 corresponding to virtual machine VM1 are all running normally, which means that virtual machine VM1 is running normally, and the error information of abnormal core Core0 is reported. At the same time, abnormal core Core0 is handled abnormally, and the overflow counter of abnormal core Core0 is set to 0. At this time, the corresponding overflow counters of other cores corresponding to the virtual machine VM1, such as core Core1, core2, and core3, will not be set to 0.
[0077] If all cores of a virtual machine are abnormal, the virtual machine runs abnormally and reports a second alarm message, which includes the error information of the abnormal core of the abnormal virtual machine. At the same time, the abnormal virtual machine is handled abnormally, such as restarting the virtual machine; and the overflow counters of all cores of the abnormal virtual machine are set to 0.
[0078] For example, if the PMU counter of core Core0 overflows, core Core0 is abnormal, and cores Core1, Core2, and Core3 corresponding to virtual machine VM1 are all running abnormally, which means that virtual machine VM1 is running abnormally, and the error information of the abnormal virtual machine VM1 is reported. At the same time, the abnormal virtual machine VM1 is handled abnormally, and the overflow counters of all cores of virtual machine VM1 are set to 0.
[0079] As a preferred implementation, the inter-core interrupt is sent in a broadcast manner.
[0080] In this embodiment, an IPI interrupt is pre-registered for each core.
[0081] Specifically, the abnormal core will broadcast IPI interrupts to other cores, that is, send IPI interrupts to all cores of the virtual machine corresponding to the abnormal core. For example, if core Core0 is abnormal, the abnormal core Core0 will broadcast IPI interrupts to other cores corresponding to virtual machine VM1, such as core Core1, core Core2, and core Core3.
[0082] The IPI interrupt is broadcast by the core that generates the NMI interrupt.
[0083] In this embodiment, the IPI interrupt is a type of soft interrupt.
[0084] As a preferred implementation, in step S4, the abnormal core cannot respond to the inter-core interrupt and does not perform the overflow count clearing operation.
[0085] Specifically, the abnormal core cannot receive the IPI interrupt.
[0086] like Figure 4 A schematic diagram showing a PMU counter overflow triggering an NMI interrupt. Figure 4 The following describes the process of performing core mutual checking in the interrupt handling function and sending IPI interrupts to other cores after any core receives an NMI interrupt.
[0087] Figure 5 A schematic diagram showing other cores processing IPI interrupts. Figure 5 The process of other normal cores or abnormal cores handling IPI interrupts is described in.
[0088] Specifically, the processor core is checked periodically by combining hardware timer-triggered interrupts (PMU), non-maskable interrupts (NMI), and inter-core interrupts (IPI). When a core is abnormal, the IPI interrupt cannot respond, and the counter value (number of overflows) of the abnormal core will exceed the preset alarm threshold and be detected.
[0089] As a preferred implementation, after step S4, the method further includes: returning to step S1 to perform next cycle detection.
[0090] Specifically, the embodiment of the present invention achieves the purpose of detecting multiple cores with one core by periodically running the steps of the above method, and determines the operation status of the virtual machine through the usage of multiple cores and virtual machines, making the detection more accurate, and all detection actions are independent of the virtual machine itself.
[0091] The present invention also provides a virtual machine health detection system based on inter-core mutual detection, which is used to implement the virtual machine health detection method based on inter-core mutual detection as described above, and the system includes:
[0092] A plurality of cores, each core is used to generate a non-maskable interrupt when detecting an overflow of a performance detection unit counter; and detect whether the number of overflows of all cores used by the virtual machine exceeds a preset threshold, and report an alarm message when the number of overflows exceeds the preset threshold, and perform exception processing at the same time;
[0093] The core that triggers the non-maskable interrupt is also used to send inter-core interrupts to all other cores used by the virtual machine;
[0094] The core responds to the inter-core interrupt to perform an overflow count clearing operation.
[0095] As a preferred implementation, the core executes an operation of increasing the overflow count by one in response to a non-maskable interrupt.
[0096] As a preferred implementation, the abnormal core cannot respond to the inter-core interrupt and does not perform the overflow count clearing operation.
[0097] The advantages or beneficial effects of adopting the above technical solution are: completely decoupling the hypervisor's detection of virtual machines, making it transparent to the virtual machine system and making the virtual machine system completely unaware, dividing the detection scheme into finer granularity, being able to detect the status of each core, preventing the impact of single or multiple core anomalies on the system, and making the detection more accurate and reliable through core mutual inspection, thereby ensuring the normal operation of the entire system.
[0098] The above are only preferred embodiments of the present invention, and are not intended to limit the implementation methods and protection scope of the present invention. Those skilled in the art should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the contents of this specification and illustrations should be included in the protection scope of the present invention.
Claims
1. A virtual machine health detection method based on inter-core mutual detection, characterized in that: include: Step S1, when it is detected that the counter of the performance detection unit of any core used by the virtual machine overflows, a non-maskable interrupt is generated; Step S2, detecting whether the overflow times of all cores used by the virtual machine exceed a preset threshold: If yes, then report the alarm information, perform exception processing, and go to step S3; If not, proceed to step S3; Step S3, the core that triggers the non-maskable interrupt sends an inter-core interrupt to all other cores used by the virtual machine; Step S4: the core responds to the inter-core interrupt to perform an overflow count clearing operation.
2. The virtual machine health detection method based on inter-core mutual detection according to claim 1 is characterized in that: In the step S1, the core performs an overflow count increment operation in response to the non-maskable interrupt.
3. The virtual machine health detection method based on inter-core mutual detection according to claim 1 is characterized in that: Each of the cores corresponds to one of the preset thresholds; The preset thresholds corresponding to different cores are the same or different.
4. The virtual machine health detection method based on inter-core mutual detection according to claim 1 is characterized in that: The reporting of alarm information and the handling of exceptions include: Step S21, detecting whether all the cores used by the virtual machine are abnormal: If yes, the virtual machine is determined to be abnormal, a first alarm message is reported, an abnormal process is performed on the abnormal virtual machine, and the overflow times of all cores used by the abnormal virtual machine are cleared to zero; If not, it is determined that one or more of the cores are abnormal, and the second alarm information is reported. At the same time, abnormal processing is performed on the abnormal core, and the overflow times of the abnormal core are cleared.
5. The virtual machine health detection method based on inter-core mutual detection according to claim 1 is characterized in that: The inter-core interrupt is sent in a broadcast manner.
6. The virtual machine health detection method based on inter-core mutual detection according to claim 1 is characterized in that: In the step S4, the abnormal core cannot respond to the inter-core interrupt, and does not perform the overflow count clearing operation.
7. The virtual machine health detection method based on inter-core mutual detection according to claim 1 is characterized in that: After step S4, the method further includes: returning to step S1 to perform next cycle detection.
8. A virtual machine health detection system based on inter-core mutual detection, characterized in that: A system for implementing the virtual machine health detection method based on inter-core mutual detection as described in any one of claims 1 to 7 includes: A plurality of cores, each of which is used to generate a non-maskable interrupt when detecting an overflow of a performance detection unit counter; and to detect whether the number of overflows of all cores used by the virtual machine exceeds a preset threshold, and to report an alarm message when the number of overflows exceeds the preset threshold, and to perform exception processing at the same time; The core that triggers the non-maskable interrupt is also used to send an inter-core interrupt to all other cores used by the virtual machine; The core performs an overflow count clearing operation in response to the inter-core interrupt.
9. The virtual machine health detection system based on inter-core mutual detection according to claim 8 is characterized in that: The core performs an overflow count increment operation in response to the non-maskable interrupt.
10. The virtual machine health detection system based on inter-core mutual detection according to claim 8 is characterized in that: The abnormal core cannot respond to the inter-core interrupt and does not perform the overflow count clearing operation.
