Method and related apparatus for cpu frequency monitoring in cloud computing scenario

By using a lightweight module to obtain the CPU frequency from the host kernel in a cloud computing scenario, the virtual machine CPU is monitored in real time and a frequency reduction alarm is generated. This solves the problems of performance interference and insufficient accuracy of traditional monitoring methods, and achieves efficient and stable CPU frequency management, ensuring virtual machine performance and user feedback.

CN120371460BActive Publication Date: 2026-03-27BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In cloud computing scenarios with full resource utilization, traditional CPU frequency monitoring methods suffer from performance interference, insufficient monitoring accuracy, inability to accurately distinguish between virtual machine CPUs running on the host machine and other non-virtual machine CPU resources, and lack of proactive alarm mechanisms, which affects the performance stability and reliability of virtual machines.

Method used

A lightweight module is used to obtain the CPU's calibrated frequency from the host kernel. Through kernel space and hardware interaction, the actual frequency of the virtual machine's CPU is monitored in real time. When the difference exceeds the threshold, a frequency reduction alarm message is generated and sent to the smart card for user feedback.

Benefits of technology

It enables precise monitoring of virtual machine CPU frequency, reduces system resource consumption, improves monitoring efficiency and accuracy, ensures virtual machine stability, provides a proactive alarm mechanism, reduces the risk of business interruption, and ensures high availability of cloud computing services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371460B_ABST
    Figure CN120371460B_ABST
Patent Text Reader

Abstract

The application discloses a CPU frequency monitoring method and related device in a cloud computing scenario, and is applied to a virtual machine. The method comprises the following steps: acquiring a lightweight module for CPU frequency monitoring from a host kernel; acquiring a calibration frequency of a virtual machine CPU based on the lightweight module; comparing an actual frequency of the virtual machine CPU with the calibration frequency based on the lightweight module, and acquiring down frequency alarm information of the virtual machine CPU; and sending the down frequency alarm information to a smart card based on the lightweight module, and sending the down frequency alarm information to a user by the smart card. The method reduces the performance influence caused by the switching between a user space and a kernel space, and realizes efficient monitoring of the CPU frequency on the host side while ensuring the stability of the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of cloud computing, in particular to a CPU frequency monitoring method and related device in a cloud computing scenario, applied to a virtual machine. BACKGROUND

[0002] In a traditional cloud computing scenario, a cloud service provider divides a single physical server into multiple virtual machines using virtualization technology and sells them to users. However, in this virtualization scenario, all physical CPU cores on the server cannot be completely allocated to the virtual machines of the users. Because the cloud service provider needs to reserve a portion of the CPU resources to run some network virtualization processes, storage virtualization processes, system monitoring processes, etc. These processes running on the reserved CPU resources ensure the stability, security and efficiency of the cloud service, but at the same time, they also bring the overhead of virtualization resources. Now, one of the more common ideas in the industry to reduce this virtualization resource overhead is to unload these processes and some other unnecessary processes from the physical CPU to the smart card, and let the smart card take on the tasks of network virtualization, storage virtualization, monitoring, etc. Only the necessary processes for maintaining the operation of the virtual machine are allowed to run on the host machine. This scenario, in which the host machine tries to use all of its CPU resources for virtual machine sales, is called a full resource utilization scenario.

[0003] In the cloud computing full resource utilization scenario, only the necessary processes that can maintain the operation of the host machine and the virtual machine should run on the physical CPU of the host machine, and other processes should be cut off or unloaded to the smart card as much as possible to reduce the jitter caused to the virtual machine. Therefore, some monitoring processes in the traditional virtualization scenario are not suitable for the host machine in this scenario, because these processes cause too much jitter to the virtualization, affecting the stability of the virtual machine operation and causing a poor user experience.

[0004] In the cloud computing full resource utilization scenario, accurate monitoring of the CPU frequency has strict requirements, as it is directly related to the stability and reliability of the virtual machine performance. However, in the existing traditional virtualization scenario, the CPU frequency monitoring method has the shortcomings of performance interference, insufficient monitoring accuracy, etc. First, the existing CPU frequency monitoring method is mainly called in the user space. This approach causes frequent switching between the user space and the kernel space, which seriously affects the system performance and in turn significantly interferes with the performance of the virtual machine in this scenario. Second, the traditional method cannot accurately distinguish between the CPU running the virtual machine on the host machine and other non-virtual machine CPU resources, and when monitoring the frequency, it treats all CPU resources as a whole, resulting in a large number of invalid monitoring operations. Third, most of the current monitoring processes only periodically record the running frequency of the CPU and cannot actively alarm when the CPU frequency is abnormal. SUMMARY

[0005] Therefore, the embodiments of the present application provide a CPU frequency monitoring method and device in a cloud computing scenario, electronic equipment, computer storage medium and computer program product, aiming at solving the performance interference, insufficient monitoring accuracy and other related problems of the traditional CPU frequency monitoring method.

[0006] In a first aspect, the embodiments of the present application provide a CPU frequency monitoring method in a cloud computing scenario, applied to a virtual machine, the method comprising:

[0007] obtaining a lightweight module for CPU frequency monitoring from a host kernel; obtaining a calibration frequency of the CPU based on the lightweight module; comparing the actual frequency of the CPU with the calibration frequency based on the lightweight module to obtain a frequency reduction alarm information of the CPU; and sending the frequency reduction alarm information to a smart card based on the lightweight module, and the smart card sends the frequency reduction alarm information to a user.

[0008] In some embodiments, the obtaining of the lightweight module for CPU frequency monitoring from the host kernel comprises: searching and loading the lightweight module from a module storage path designated by the host kernel through a kernel module loading mechanism.

[0009] In some embodiments, the obtaining of the calibration frequency of the CPU based on the lightweight module comprises: the lightweight module obtains the calibration frequency of the CPU by reading a hardware register of the virtual machine CPU.

[0010] In some embodiments, before the comparing of the actual frequency of the CPU with the calibration frequency based on the lightweight module, the method further comprises: the lightweight module collects the actual frequency of the virtual machine CPU at a preset time interval.

[0011] In some embodiments, the comparing of the actual frequency of the CPU with the calibration frequency based on the lightweight module comprises: calculating a difference value between the calibration frequency and the actual frequency based on the lightweight module, and comparing whether the difference value exceeds a preset threshold value.

[0012] In some embodiments, the obtaining of the frequency reduction alarm information of the CPU comprises: if the difference value is greater than the preset threshold value, generating a frequency reduction alarm information; and the frequency reduction alarm information comprises a frequency-reduced CPU number, a frequency reduction amplitude and a frequency reduction occurrence time.

[0013] In some embodiments, before the obtaining of the calibration frequency of the CPU based on the lightweight module, the method further comprises: obtaining a mask vector of the CPU; and the lightweight module obtains the CPU to be monitored in frequency based on the mask vector.

[0014] In some embodiments, the obtaining the mask vector of the CPU comprises: obtaining the number of virtual machines on each CPU; and setting the mask of the CPU with the number of virtual machines greater than zero to 1.

[0015] In some embodiments, the lightweight module is periodically woken up to perform the following operations: first, obtaining the actual performance counter value and the maximum performance counter value of the current CPU; then, sleeping for 1 second; again, obtaining the actual performance counter value and the maximum performance counter value of the current CPU; and finally, calculating the actual frequency of the CPU based on the actual performance counter values and the maximum performance counter values sampled twice.

[0016] In the second aspect, the embodiments of the present application provide a CPU frequency monitoring device in a cloud computing scenario, applied to a virtual machine, and the device comprises:

[0017] An initialization module obtains a lightweight module for CPU frequency monitoring from a host kernel.

[0018] A calibration frequency obtaining module obtains the calibration frequency of the CPU based on the lightweight module.

[0019] A frequency comparison module compares the actual frequency of the CPU with the calibration frequency based on the lightweight module, and obtains the frequency reduction alarm information of the CPU.

[0020] A frequency reduction alarm module sends the frequency reduction alarm information to a smart card based on the lightweight module, and the smart card sends the frequency reduction alarm information to a user.

[0021] In the third aspect, the embodiments of the present application provide an electronic device, comprising a processor and a memory for storing a computer program capable of running on the processor, wherein the processor is configured to run the computer program to perform the method of the first aspect.

[0022] In the fourth aspect, the embodiments of the present application provide a computer storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.

[0023] In the fifth aspect, the embodiments of the present application provide a computer program product, comprising a computer program, and the computer program is executed by an electronic device to implement the steps of the method of the first aspect.

[0024] The embodiments of the present application provide a CPU frequency monitoring method and device in a cloud computing scenario, an electronic device, a computer storage medium and a computer program product, and solve the following technical problems.

[0025] In the full resource utilization scenario of cloud computing, the CPU frequency of a virtual machine is effectively monitored, and CPU frequency reduction alarm information is obtained in a timely manner and fed back to a user. The lightweight module loading method adopted by the application greatly reduces the occupation of system resources. Running in the kernel space enables the monitoring process to interact more closely with the hardware, capturing subtle changes in CPU frequency in real time, without any interference with the normal operation of the virtual machine. This almost "unaware" monitoring mode provides unprecedented stability protection for cloud computing service providers, ensuring that each virtual machine can obtain stable computing resources in a multi-tenant environment, avoiding performance fluctuations caused by monitoring behavior.

[0026] The application improves the precise monitoring capability. Through precise identification of the running state of the virtual machine, the application can quickly locate the CPU core of the running virtual machine and carry out frequency monitoring accordingly. This precise focus monitoring strategy not only improves the monitoring efficiency and reduces system overhead, but also enables cloud computing operation and maintenance personnel to clearly understand the CPU performance status of each virtual machine, providing accurate data support for resource allocation and scheduling.

[0027] The active alarm mechanism improves the safety of the system. Once the CPU frequency is abnormal, the system will immediately push the alarm information to the user. At the same time, the alarm information also carries detailed CPU state data, including the normal frequency before frequency reduction, the frequency reduction amplitude, the occurrence time, etc., helping the user to quickly judge the severity of the problem, take targeted solutions, effectively reduce the risk of business interruption caused by CPU failure, and ensure the high availability of cloud computing services.

[0028] With the continuous development of cloud computing technology, the application is expected to play a role in a wider field, such as edge computing, big data processing clusters, etc., and continuously provide reliable technical support for CPU frequency monitoring in complex computing environments. BRIEF DESCRIPTION OF DRAWINGS

[0029] Figure 1 The flowchart of the CPU frequency monitoring method in the cloud computing scenario provided by the embodiment of the application;

[0030] Figure 2 The overall flowchart of the CPU frequency monitoring method in the cloud computing scenario provided by the embodiment of the application;

[0031] Figure 3 The host side flowchart of the CPU frequency monitoring method in the cloud computing scenario provided by the embodiment of the application;

[0032] Figure 4 The lightweight module flowchart of the CPU frequency monitoring method in the cloud computing scenario provided by the embodiment of the application;

[0033] Figure 5 A structural schematic diagram of a CPU frequency monitoring device in a cloud computing scenario is provided for an embodiment of the present application.

[0034] Figure 6 A structural schematic diagram of an electronic device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0035] The present application will be further described in detail below with reference to the accompanying drawings and embodiments.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the description herein is for describing particular embodiments only and is not intended to be limiting of the present application.

[0037] As shown in Figure 1 An embodiment of the present application provides a CPU frequency monitoring method in a cloud computing scenario, applied to a virtual machine, comprising the following steps:

[0038] Step S110, obtaining a lightweight module for CPU frequency monitoring from a host kernel.

[0039] This step is the starting point of the entire monitoring method, and the lightweight module is the basis for implementing subsequent functions of CPU frequency monitoring. By obtaining the module, necessary tools are provided for subsequent operations such as obtaining the rated frequency, actual frequency of the CPU, and frequency comparison and alarm.

[0040] Step S120, obtaining the rated frequency of the CPU based on the lightweight module.

[0041] The rated frequency is an important reference value for subsequent frequency comparison, which provides a benchmark for determining whether the CPU is downclocked.

[0042] Step S130, comparing the actual frequency of the CPU with the rated frequency based on the lightweight module, and obtaining the downclocking alarm information of the CPU.

[0043] Through such a comparison operation, it can be found in time whether the CPU is downclocked, and the downclocking alarm information can accurately inform the user of specific information related to downclocking.

[0044] Step S140, sending the downclocking alarm information to a smart card based on the lightweight module, and the smart card sends the downclocking alarm information to the user.

[0045] This enables the user to obtain the downclocking condition of the CPU in time so as to take corresponding measures.

[0046] In some embodiments, the method comprises obtaining a lightweight module for CPU frequency monitoring from a host kernel.

[0047] The lightweight module is a cpufreq-monitor module. The cpufreq-monitor module is a kernel module specially designed for monitoring the CPU frequency of a host in a cloud computing full resource selling scenario. Its function is to realize the frequency monitoring function of the specified CPU. After loading the module, a delayed_work is created for each CPU, and these delayed_works are periodically awakened to perform subsequent frequency monitoring operations.

[0048] In a virtual machine environment, CPU mask is a mechanism for specifying which physical CPU cores virtual machines can use. Usually, a flag bit corresponds to a CPU core, and by setting the corresponding bit, it indicates whether the core is used by the virtual machine.

[0049] For example, for a system with 8 CPU cores, the CPU mask can be an 8-bit data structure. If the mask is 10101010, it means that the 2nd, 4th, 6th, and 8th CPU cores have virtual machines, while the 1st, 3rd, 5th, and 7th cores do not. In this way, access to physical CPU resources can be precisely controlled, resources can be reasonably allocated and isolated, and system performance and stability can be improved.

[0050] For example, libvirt is an open source tool for managing virtualization platforms. When libvirt starts a virtual machine, libvirt side senses that there is a new virtual CPU (vCPU) running on the physical CPU, then calculates the cpumask (CPU mask) and writes it to the interface exposed by the cpufreq-monitor module. After the cpufreq-monitor module receives the cpumask, it starts to monitor the frequency of the specified CPU.

[0051] By obtaining the lightweight module, the monitoring efficiency can be guaranteed while minimizing the interference with the performance of the virtual machine, and the lightweight monitoring of the CPU frequency of the host can be realized.

[0052] The method can effectively monitor the running frequency of the CPU on the host side in a cloud computing full resource utilization scenario. By working with libvirt, it can accurately monitor the frequency of the CPU running the virtual machine. Once the CPU frequency drop is detected, the method can actively alert the user to ensure that the user can promptly detect and handle related issues.

[0053] In some embodiments, the method comprises obtaining the rated frequency of the CPU based on the lightweight module.

[0054] The lightweight module cpufreq-monitor obtains the rated frequency of the CPU through a specific mechanism, which serves as a reference for subsequent comparison of the actual running frequency of the CPU.

[0055] For example, after the cpufreq-monitor module is loaded and receives the cpumask input by libvirt and starts monitoring the specified CPU, the module obtains the rated frequency of the CPU according to the internal setting process.

[0056] The rated frequency of the CPU is obtained, which provides an accurate reference standard for subsequent judgment of whether the CPU is underclocked, making the underclocking judgment more accurate and reliable.

[0057] In some embodiments, the method comprises obtaining underclocking alarm information of the CPU based on the comparison of the actual frequency of the CPU and the rated frequency by the lightweight module.

[0058] APERF (Actual Performance Frequency) and MPERF (Maximum Performance Frequency) are hardware performance counters provided by Intel and AMD CPUs, which are used to measure the actual running frequency and running cycle number of the CPU at the maximum frequency. The APERF counter records the cycle number of the CPU in the actual running state. It reflects the actual running frequency of the CPU under the current load and frequency adjustment strategy. The MPERF counter records the cycle number of the CPU at the maximum frequency (i.e. the nominal main frequency). It represents the running cycle number of the CPU in the ideal state. Therefore, the current running frequency of the CPU can be obtained by calculating the two counters.

[0059] The cpufreq-monitor module obtains the aperf and mperf values of the current CPU, and calculates the current running frequency of the CPU according to the aperf and mperf values of the two samplings (firstly obtaining the aperf and mperf values of the current CPU, then sleeping for 1 second, and then obtaining the aperf and mperf values of the current CPU again). The actual running frequency is compared with the rated frequency. When it is detected that the actual running frequency of a certain CPU is lower than the preset threshold (i.e. the threshold related to the rated frequency), an alarm is triggered, and underclocking alarm information is obtained.

[0060] For example, during the execution of the delayed_work in the periodic wakeup, the frequency is calculated in the above-mentioned manner, compared with the rated frequency, and if the frequency is lower than the preset threshold, it is considered that underclocking occurs, and the module will print alarm logs.

[0061] By comparing the actual CPU frequency with the calibrated frequency in this way, it is possible to detect CPU frequency reduction in a timely manner, obtain frequency reduction alarm information, and notify users to take appropriate measures in a timely manner.

[0062] In some embodiments, the method includes sending the frequency reduction alarm information to a smart card based on the lightweight module, and the smart card sending the frequency reduction alarm information to a user.

[0063] When the cpufreq-monitor module receives a frequency reduction alarm (printing an alarm log), it forwards the alarm to the smart card. Upon receiving the alarm, the smart card sends an alarm message to the user according to its configured communication method.

[0064] For example, after the cpufreq-monitor module detects CPU frequency reduction and prints an alarm log, it sends the alarm log to the smart card through a specific communication interface. The smart card then sends the frequency reduction alarm information to the user via SMS, push notifications, or other means.

[0065] This information transmission method allows for timely feedback to users regarding CPU frequency reduction, enabling them to understand the system status and make appropriate decisions.

[0066] like Figure 2 The diagram shows the overall flowchart of a CPU frequency monitoring method in a cloud computing scenario. The host machine, smart card, and user are closely linked through a series of collaborative processes. The host machine, as the hardware foundation, runs the cpufreq-monitor module in kernel space and components such as qemu and libvirt in user space. QEMU (Quick Emulator) is an open-source, general-purpose hardware emulation and virtualization management component. The cpufreq-monitor module is responsible for monitoring the frequency of the physical CPUs (cpu0, cpu1, etc.) at the host machine's hardware layer and transmitting the collected CPU frequency-related downclocking alarm information to the smart card. The smart card uses its log filtering function to filter out downclocking alarm information from a large amount of log data. These alarms often reflect abnormal issues such as CPU downclocking. Finally, the user, as the receiving end of the entire system, receives the filtered abnormal information from the smart card, triggering an alarm mechanism to promptly report these anomalies to the user so that they can quickly take measures to ensure the stable operation of virtual machines in the cloud computing environment.

[0067] In a virtual machine CPU frequency monitoring system in a cloud computing environment, the host machine encompasses three important layers: user space, kernel, and hardware. Each of these layers plays a key role in the entire monitoring system and collaborates with each other to ensure system operation.

[0068] In user space, the qemu module is used for machine emulation and virtualization. It simulates the CPU runtime environment of virtual machines through multiple virtual CPUs (vCPUs), providing basic support for the operation of virtual machines. Meanwhile, libvirt is used to manage the open-source APIs, daemons, and tools of the virtualization platform. By interacting with the kernel space using the CPU mask cpumask, it can accurately identify the CPU running the virtual machine, laying the foundation for subsequent precise monitoring.

[0069] The cpufreq-monitor module at the kernel level is the core of CPU frequency monitoring. It runs in kernel space, obtains the CPU information to be monitored through cpumask, and then monitors the frequency of the physical CPUs (such as cpu0, cpu1, cpu2...cpuN) at the host hardware level, collects CPU frequency-related log information, and passes this information to the smart card for further processing.

[0070] At the hardware level, the actual physical CPU of the host machine is the target of the entire monitoring system. The operating frequency of the physical CPU directly affects the performance of the virtual machine. By monitoring its frequency, the system can promptly detect and handle any anomalies such as CPU throttling, ensuring the stable operation of the cloud computing environment.

[0071] like Figure 3 The diagram shown illustrates the host-side process of a CPU frequency monitoring method in a cloud computing scenario. Figure 2 The overall flowchart is a detailed diagram of the host machine side, which describes the collaborative relationship between modules such as libvirt, qemu, and cpufreq-monitor at the user space, kernel, and hardware levels.

[0072] Libvirt is the core management module. Two key variables cpumask and ref are defined first, where cpumask represents the CPU that needs to be monitored finally notified to the cpufreq-monitor module, and ref represents the number of vCPUs running on each CPU. The operations of libvirt to the virtual machine QEMU process include starting (virsh start), destroying (virsh destroy), shutting down (virsh shutdown), hot migration, etc., and in addition, the abnormal exit of QEMU needs to be handled. In the functions of these operations, the processing logic of cpumask and ref is added. For example, when a new vCPU is started on CPU X, check whether the X bit in cpumask is 1, if it is 0, set it to 1, if it is 1, increase the ref count; if cpumask changes, write the new cpumask to the cpufreq-monitor module. When a vCPU is destroyed on CPU X, decrease the ref count, if the ref count is 0, set the X bit in cpumask to 0, and write the new cpumask to the cpufreq-monitor module. In addition, the situation of libvirt process restart needs to be considered, after libvirt restart, each domain is reconnected and the corresponding cpumask is obtained, the cpumask and ref are recalculated, and then the new cpumask is written to the cpufreq-monitor module.

[0073] Where cpumask ref is used to manage the CPU mask reference, and interacts with the kernel through cpumask. In the qemu related operation module, the qemuProcessLaunch module (QEMU process start module) is responsible for starting the qemu instance, and is realized by the virsh start command or by the live migration operation to migrate the qemu instance. The qemuProcessStop module (QEMU process stop module) is used to stop the qemu instance, and is achieved by means of the virsh destroy command. The processMonitorEOFEvent is used to monitor the qemu process end event, which is triggered when the qemu instance is closed through the virsh shutdown command, and is also associated with this component if an exception occurs. The qemuProcessReconnect module (QEMU process reconnect module) is used to handle the qemu process reconnection related matters.

[0074] The libvirt module connects user space and the kernel via sysfs. sysfs is a virtual file system used to transfer information between kernel space and user space; here, it is responsible for transferring cpumask information and connecting libvirt with the cpufreq-monitor module in the kernel.

[0075] cpufreq-monitor is a CPU frequency monitoring module in the kernel. It receives cpumask information from libvirt via sysfs to determine the CPU to be monitored, and then monitors the frequency of physical CPUs such as cpu0, cpu1, and cpuX at the hardware level.

[0076] like Figure 4 The diagram shown is a schematic of a lightweight module for a CPU frequency monitoring method in a cloud computing scenario provided in an embodiment of this application.

[0077] The lightweight module cpufreq-monitor uses a delayed-work mechanism for CPU frequency monitoring.

[0078] Figure 4 The text shows that different physical CPUs (cpu0, cpu1, ..., cpuN) correspond to their respective aperf and mperf metrics (aperf0, mperf0; aperf1, mperf1; ...; aperfN, mperfN), indicating that each CPU has independent performance metric sampling points for targeted monitoring and calculation of its own frequency.

[0079] There are multiple identical delayed-work processes on different physical CPUs (cpu0, cpu1, ..., cpuN). Each process has the same steps, representing a periodic task of monitoring CPU frequency.

[0080] The process for periodic tasks is as follows.

[0081] 1. Wake-up: Start the delayed work task and move it from the waiting state to the execution state.

[0082] 2. Obtain Aperf and Mperf Samples: Aperf (Architectural Performance) and Mperf (Micro-architectural Performance) are metrics related to CPU performance. This step obtains sample data for these metrics, which will be used for subsequent frequency calculations.

[0083] 3. Sleep: As needed for sampling, put the task into a sleep state and continue sampling after a period of time.

[0084] 4. Re-acquire aperf mperf samples: Re-collect aperf and mperf data, through at least two samples, to obtain the CPU running frequency between the two samples.

[0085] 5. Calculate CPU frequency: Use the acquired aperf and mperf sample data to calculate the current CPU running frequency according to a specific algorithm.

[0086] 6. Schedule to wait for re-awakening: After completing a frequency calculation, set the task to a waiting state, and the scheduler will re-awaken the task at the appropriate time to start the next round of frequency monitoring process.

[0087] Create a delayed_work for each CPU, which is periodically awakened to perform the following operations: first, acquire the aperf and mperf values of the current CPU, then sleep for 1 second, re-acquire the aperf and mperf values of the current CPU, and calculate the current running frequency of the CPU according to the aperf and mperf values of the two samples. If the frequency is lower than the preset threshold, an alarm is triggered; if it meets the expectation, it is scheduled to the next cycle for continuous monitoring.

[0088] Figure 4 The lightweight module shown brings many benefits. First, accurate monitoring. Through libvirt, the running virtual machine CPU is identified using cpumask, making the monitoring target more targeted and avoiding invalid monitoring of non-virtual machine related CPU resources, greatly improving the accuracy of monitoring and helping cloud computing service providers accurately grasp the CPU performance status of virtual machines. Second, efficient and stable. The cpufreq-monitor module runs in the kernel space, which can effectively reduce the impact on the stability of virtual machines and reduce performance jitter compared to traditional user space monitoring, ensuring stable operation of virtual machines in a multi-tenant environment, while also improving monitoring efficiency and enabling real-time capture of CPU frequency changes. Through this lightweight kernel module design, the invention can maximize the reduction of interference with virtual machine performance while ensuring monitoring efficiency, making it suitable for host CPU frequency monitoring needs in cloud computing scenarios.

[0089] In some embodiments, the CPU frequency monitoring method in a cloud computing scenario further includes: acquiring a lightweight module for CPU frequency monitoring from the host kernel, including searching for and loading the lightweight module from the specified module storage path of the host kernel through the kernel module loading mechanism.

[0090] The lightweight module is obtained in this specific way to ensure correct loading and use of the module, ensuring the stability and reliability of the system. This additional feature closely cooperates with the previous step of obtaining the lightweight module, further specifying the specific way of obtaining the module, which helps to improve the efficiency and accuracy of obtaining the module. By obtaining the module in this way, system resources can be used more efficiently, reducing unnecessary errors and conflicts.

[0091] In some embodiments, the method further comprises: the lightweight module obtains the rated frequency of the CPU based on the lightweight module, including the lightweight module obtaining the rated frequency of the CPU by reading the hardware register of the virtual machine CPU.

[0092] This way of obtaining the rated frequency is direct and accurate, and the information stored in the hardware register can truly reflect the rated frequency of the CPU. This additional feature is closely related to the step of obtaining the rated frequency, and specifies the specific way of obtaining, which improves the accuracy of obtaining the rated frequency. By reading the hardware register to obtain the rated frequency, the most accurate rated frequency value can be obtained, providing a reliable data basis for subsequent frequency comparison.

[0093] In some embodiments, the method further comprises: before the lightweight module compares the actual frequency of the CPU with the rated frequency, the method further comprises the lightweight module collecting the actual frequency of the virtual machine CPU at a preset time interval.

[0094] This can obtain the actual frequency change of the CPU in time, providing the latest data for accurate frequency comparison. This additional feature cooperates with the frequency comparison step to provide real-time and accurate data support for frequency comparison, which helps to discover CPU frequency reduction more timely. By collecting the actual frequency at a preset time interval, the running state of the CPU can be dynamically tracked, and abnormal frequency reduction can be discovered in time.

[0095] In some embodiments, the method further comprises: the lightweight module compares the actual frequency of the CPU with the rated frequency based on the lightweight module, including the lightweight module calculating the difference between the rated frequency and the actual frequency, and comparing whether the difference exceeds a preset threshold.

[0096] Through this quantitative comparison method, it can be more clearly judged whether the CPU is frequency-reduced. This additional feature specifies the specific calculation and judgment method of frequency comparison, making the frequency comparison more scientific and accurate, which helps to improve the reliability of frequency reduction judgment.

[0097] In some embodiments, the method further comprises: the obtaining of the frequency reduction alarm information of the CPU comprises generating frequency reduction alarm information if the difference is greater than a preset threshold; and the frequency reduction alarm information comprises the number of the CPU that is reduced in frequency, the frequency reduction amplitude, and the time when the frequency reduction occurs.

[0098] The detailed frequency reduction alarm information enables the user to comprehensively understand the frequency reduction situation, so as to make more appropriate decisions. The additional feature is closely related to the step of obtaining the frequency reduction alarm information, refines the content of the frequency reduction alarm information, improves the practicability of the alarm information, and helps the user to better cope with the CPU frequency reduction problem.

[0099] In some embodiments, the method further comprises: before the obtaining of the rated frequency of the CPU based on the lightweight module, the method further comprises obtaining a mask vector of the CPU; and the lightweight module obtains the CPU to be monitored in frequency based on the mask vector.

[0100] In this way, the CPU to be monitored can be operated in a targeted manner, improving the monitoring efficiency. The additional feature cooperates with the step of obtaining the rated frequency to determine the range of the CPU to be monitored, which helps to concentrate resources for effective monitoring and improves the targeting and efficiency of the monitoring.

[0101] In some embodiments, the obtaining of the mask vector of the CPU specifically comprises the following steps: first, obtaining the number of virtual machines on each CPU. This step is realized through a specific system interface or monitoring tool, and each CPU in the system is traversed to query and record the number of virtual machines running thereon. Then, the mask of the CPU with a number of virtual machines greater than zero is set to 1. This operation is to clearly distinguish which CPU has a running virtual machine in the subsequent process. The CPU with a mask of 1 is the CPU with a running virtual machine, and through this way, the CPU with a virtual machine load can be conveniently monitored and managed in a targeted manner in the subsequent process.

[0102] The two steps are essential technical features for obtaining the mask vector of the CPU, and cooperate with each other to accurately identify the CPU with a running virtual machine, providing basic data support for subsequent operations related to the CPU, so that the system can more accurately allocate resources, monitor performance, etc. to the CPU with a running virtual machine, improving the management efficiency and accuracy of the system.

[0103] In some embodiments, the method further comprises periodic operation of the lightweight module. The lightweight module is periodically woken up to perform the following operations: first, obtain the actual performance counter value and the maximum performance counter value of the current CPU. This is achieved by interacting with the CPU hardware and using the system-provided performance counter reading interface to obtain the corresponding values, which reflect the current actual running status of the CPU and its theoretical maximum running capability. Then sleep for 1 second, which is a short sleep time to allow the CPU to run for a relatively stable period of time to obtain more accurate performance data. Again, obtain the actual performance counter value and the maximum performance counter value of the current CPU, and finally calculate the actual frequency of the CPU based on the actual performance counter values and the maximum performance counter values of the two samplings. Through such an operation process, the actual running frequency of the CPU can be dynamically and accurately obtained, so as to timely grasp the running state of the CPU.

[0104] This operation cooperates with the previous operation of obtaining the CPU mask vector to jointly perfect the monitoring system of the CPU running state. Obtaining the CPU mask vector determines the CPUs that need to be monitored, and the lightweight module periodically obtains the actual frequency of the CPUs to further understand the running performance of the CPUs, which helps to timely discover CPU performance abnormal conditions and improve the stability and reliability of the system.

[0105] As shown in Figure 5 The embodiment of the present application also provides a CPU frequency monitoring device in a cloud computing scenario, which is applied to a virtual machine and has the characteristics that the device comprises:

[0106] An initialization module 210 obtains a lightweight module for CPU frequency monitoring from a host kernel;

[0107] A rated frequency obtaining module 220 obtains the rated frequency of the CPU based on the lightweight module;

[0108] A frequency comparison module 230 compares the actual frequency of the CPU with the rated frequency based on the lightweight module, and obtains the frequency reduction alarm information of the CPU;

[0109] A frequency reduction alarm module 240 sends the frequency reduction alarm information to a smart card based on the lightweight module, and the smart card sends the frequency reduction alarm information to a user.

[0110] The device has the following beneficial effects.

[0111] The initialization module 210 obtains a lightweight module for CPU frequency monitoring from a host kernel. The initialization module 210 accesses the host kernel through a specific system call interface, obtains a lightweight module for CPU frequency monitoring which has been pre-configured, and provides a basic tool for subsequent monitoring operations. The module is a starting point for normal operation of the entire device and is an essential technical feature.

[0112] The rated frequency obtaining module 220 obtains the rated frequency of the CPU based on the lightweight module. The rated frequency obtaining module 220 communicates with the CPU hardware through the lightweight module to obtain the rated frequency set by the CPU factory or the system, which is a reference value for judging whether the actual operation of the CPU is normal. It cooperates with the initialization module, and the rated frequency obtaining module can obtain the rated frequency based on the lightweight module obtained by the initialization module, provides basic data for subsequent frequency comparison, and enables the device to effectively evaluate the running status of the CPU.

[0113] The frequency comparison module 230 compares the actual frequency of the CPU with the rated frequency based on the lightweight module, and obtains the frequency reduction alarm information of the CPU. After obtaining the actual frequency and the rated frequency of the CPU, the frequency comparison module 230 compares and analyzes through a specific algorithm and logic, judges whether the actual frequency is lower than the rated frequency, and generates the frequency reduction alarm information if it is lower. The module is a key link for the device to realize the alarm function, cooperates with the previous modules, uses the lightweight module obtained by the initialization module and the rated frequency obtained by the rated frequency obtaining module, and combines the comparison and analysis of the actual frequency itself to timely find the frequency reduction of the CPU.

[0114] The frequency reduction alarm module 240 sends the frequency reduction alarm information to the smart card based on the lightweight module, and the smart card sends the frequency reduction alarm information to the user. After obtaining the frequency reduction alarm information, the frequency reduction alarm module 240 accurately sends the information to the smart card through the communication interface of the smart card with the help of the lightweight module, and the smart card transmits the alarm information to the user, ensuring that the user can timely know the frequency reduction of the CPU. The module completes the interaction link between the entire monitoring device and the user, and together with the previous modules constitutes a complete monitoring and alarm system, so that the user can timely know the running status of the CPU where the virtual machine is located, so as to take corresponding measures.

[0115] As shown in Figure 6 , the embodiment of the application further provides an electronic device 600. Figure 4 Only an exemplary structure of the electronic device 600 is shown, not all structures, and part or all of the structures can be implemented as needed. As shown in Figure 4 , the embodiment of the application further provides an electronic device 600. Figure 4As shown, the electronic device 600 provided by the embodiments of the present application includes at least one processor 601, a memory 602, a user interface 603 and at least one network interface 604. The various components in the electronic device 600 are coupled together by a bus system 605. It can be understood that the bus system 605 is used to realize the connection communication between the components. The bus system 605 includes, in addition to a data bus, a power supply bus, a control bus and a status signal bus. However, for the purpose of clear illustration, all the buses are marked as the bus system 605 in the Figure 4

[0116] The user interface 603 can include a display, a keyboard, a mouse, a trackball, a click wheel, a key, a button, a touchpad or a touch screen, etc.

[0117] The memory 602 in the embodiments of the present application is used to store various types of data to support the operation of the electronic device. Examples of the data include any computer programs used for operating on the electronic device.

[0118] The intelligent guiding method of the electronic device disclosed by the embodiments of the present application can be applied in the processor 601 or implemented by the processor 601. The processor 601 can be an integrated circuit chip with the processing capability of signals. In the implementation process, the steps of the intelligent guiding method of the electronic device can be completed by the integrated logic circuit of hardware in the processor 601 or the instructions in the form of software. The processor 601 mentioned above can be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 601 can realize or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiments of the present application, the hardware decoding processor can be directly embodied to execute the steps, or the hardware and software modules in the decoding processor can be combined to execute the steps. The software module can be located in the storage medium, which is located in the memory 602. The processor 601 reads the information in the memory 602 and combines the hardware to complete the steps of the intelligent guiding method of the electronic device provided by the embodiments of the present application.

[0119] ​In an exemplary embodiment, the electronic device 600 can be implemented by one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic elements for executing the aforementioned methods.

[0120] It can be appreciated that the memory 602 can be volatile memory or nonvolatile memory, and can also include both volatile and nonvolatile memory. Where the memory is nonvolatile memory, it can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a magnetic disc memory or. Where the memory is volatile memory, it can be a random access memory (RAM) used as an external cache memory. By way of example, and not limitation, many forms of RAM can be used, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM). The memory described herein is intended to include, without being limited to, these and any other suitable types of memory.

[0121] In an example embodiment, the embodiments of the present application further provide a computer storage medium, specifically a computer readable storage medium, which stores a computer program executable by a processor to complete the steps of the method of the embodiments of the present application. The computer readable storage medium can be a ROM, a PROM, an EPROM, an EEPROM, a flash memory, a magnetic surface memory, an optical disc, or a CD-ROM memory, etc.

[0122] In an example embodiment, the embodiments of the present application further provide a computer program product comprising a computer program executable by the processor 601 of an electronic device to complete the steps of the method of the embodiments of the present application.

[0123] It should be noted that "first", "second", etc. are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.

[0124] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.

[0125] In the technical solutions of the present disclosure, the acquisition, storage and application of user personal information involved comply with relevant laws and regulations and do not violate public order and good customs.

[0126] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A CPU frequency monitoring method in a cloud computing scenario, applied to a virtual machine, and having the steps of: The method comprises: obtaining a lightweight module for CPU frequency monitoring from a host kernel; obtaining a rated frequency of the CPU based on the lightweight module; comparing an actual frequency of the CPU with the rated frequency based on the lightweight module to obtain a frequency reduction alarm information of the CPU; sending the frequency reduction alarm information to a smart card based on the lightweight module, and the smart card sends the frequency reduction alarm information to a user; Before the obtaining of the rated frequency of the CPU based on the lightweight module, the method further comprises: obtaining a mask vector of the CPU, and the obtaining of the mask vector of the CPU specifically comprises: obtaining a number of virtual machines on each CPU; and setting a mask of a CPU with a number of virtual machines greater than zero to 1; the lightweight module obtains the CPU to be monitored in frequency based on the mask vector.

2. The method of claim 1, wherein, The obtaining of the lightweight module for CPU frequency monitoring from the host kernel comprises: finding and loading the lightweight module from a module storage path designated by the host kernel through a kernel module loading mechanism.

3. The method of claim 1, wherein, The obtaining of the rated frequency of the CPU based on the lightweight module comprises: the lightweight module obtains the rated frequency of the CPU by reading a hardware register of the virtual machine CPU.

4. The method of claim 1, wherein, Before the comparing of the actual frequency of the CPU with the rated frequency based on the lightweight module, the method further comprises: the lightweight module collects the actual frequency of the virtual machine CPU at a preset time interval.

5. The method of claim 1, wherein, The comparing of the actual frequency of the CPU with the rated frequency based on the lightweight module comprises: the lightweight module calculates a difference value of the rated frequency and the actual frequency, and compares whether the difference value is greater than a preset threshold value.

6. The method of claim 5, wherein, The obtaining of the frequency reduction alarm information of the CPU comprises: if the difference value is greater than the preset threshold value, generating the frequency reduction alarm information; the frequency reduction alarm information comprises a CPU number for frequency reduction, a frequency reduction amplitude, and a time of frequency reduction.

7. The method of claim 1 wherein, The lightweight module is periodically woken up to perform the following operations: firstly, obtaining an actual performance counter value and a maximum performance counter value of a current CPU, then sleeping for 1 second, again obtaining the actual performance counter value and the maximum performance counter value of the current CPU, and calculating an actual frequency of the CPU according to the actual performance counter values and the maximum performance counter values sampled twice. 8.A CPU frequency monitoring device in a cloud computing scenario, applied to a virtual machine, and having the characteristics that, The device comprises: an initialization module for obtaining a lightweight module for CPU frequency monitoring from a host kernel; a rated frequency obtaining module for obtaining a rated frequency of the CPU based on the lightweight module, wherein, before the obtaining of the rated frequency of the CPU based on the lightweight module, the rated frequency obtaining module is further configured to obtain a mask vector of the CPU; the lightweight module obtains the CPU to be monitored in frequency based on the mask vector; and the obtaining of the mask vector of the CPU specifically comprises: obtaining a number of virtual machines on each CPU; and setting a mask of a CPU with a number of virtual machines greater than zero to 1. A frequency comparison module compares the actual frequency of the CPU with the rated frequency based on the lightweight module, and obtains a frequency reduction alarm information of the CPU; A frequency reduction alarm module sends the frequency reduction alarm information to a smart card based on the lightweight module, and the smart card sends the frequency reduction alarm information to a user.

9. An electronic device, comprising: Comprise: A processor and a memory for storing a computer program capable of running on the processor, wherein the processor is configured to execute the steps of the method of any one of claims 1 to 7 when running the computer program.

10. A computer storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 7.

11. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Hardware counter virtualization-based performance analysis method for multiple virtual machines

    CN102073535A

  • Method and interrupt controller for treating i / o operation interrupt requests in a virtual machine system

    EP0419723A1