CN117909086A - Intelligent control method and system for performing frequency modulation on CPU - Google Patents

Intelligent control method and system for performing frequency modulation on CPU Download PDF

Info

Publication number
CN117909086A
CN117909086A CN202410309503.0A CN202410309503A CN117909086A CN 117909086 A CN117909086 A CN 117909086A CN 202410309503 A CN202410309503 A CN 202410309503A CN 117909086 A CN117909086 A CN 117909086A
Authority
CN
China
Prior art keywords
cpu
frequency modulation
frequency
performance event
occurrence
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202410309503.0A
Other languages
Chinese (zh)
Other versions
CN117909086B (en
Inventor
朱振华
姚若河
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
South China University of Technology SCUT
Allwinner Technology Co Ltd
Original Assignee
South China University of Technology SCUT
Allwinner Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by South China University of Technology SCUT, Allwinner Technology Co Ltd filed Critical South China University of Technology SCUT
Priority to CN202410309503.0A priority Critical patent/CN117909086B/en
Priority claimed from CN202410309503.0A external-priority patent/CN117909086B/en
Publication of CN117909086A publication Critical patent/CN117909086A/en
Application granted granted Critical
Publication of CN117909086B publication Critical patent/CN117909086B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Power Sources (AREA)

Abstract

The invention discloses an intelligent control method and system for frequency modulation of a CPU, wherein when the CPU is required to be frequency modulated, a performance monitoring unit of the CPU is controlled to acquire the corresponding occurrence times of performance events, a calculation ratio example factor of the CPU is calculated based on the occurrence times of the performance events, and then the calculation ratio example factor is combined with the next frequency modulation frequency of the CPU to jointly control the CPU to perform frequency modulation, so that the CPU frequency is accurately regulated under the condition that the actual performance of the CPU is not influenced, the conditions of low-efficiency scenes that the CPU operates at high frequency but instructions are not much are reduced, such as when the CPU accesses external data, the frequency of the CPU is reduced, thereby saving the power consumption of the CPU, reducing the condition that the CPU cannot work out and improving the operation efficiency of the CPU.

Description

Intelligent control method and system for performing frequency modulation on CPU
Technical Field
The invention relates to the technical field of computers, in particular to an intelligent control method and system for frequency modulation of a CPU.
Background
The CPU dynamic frequency modulation technology can optimize the energy efficiency, temperature control, heat dissipation management and performance of the CPU under different load conditions, so that the CPU can realize optimal energy utilization and performance under different scenes.
At present, the main current technology of dynamic frequency modulation of the CPU is to do dynamic frequency modulation according to the load of the CPU or the load of the process, which often encounters that the CPU runs in a high frequency band for a long time, but the actual executed instruction of the CPU is less, that is, the value of each instruction cycle (CYCLES PER instructions, CPI) is larger, in other words, the CPU is in a state of shutdown of the CPU, the CPU cannot work out, the load of the CPU is high, but the actual executed operation is very few. When the CPU is executing the task, the efficiency of the CPU can be improved by reducing the frequency of the CPU under the premise of ensuring that the execution efficiency of the task is not reduced.
Currently, the frequency of the CPU is mainly adjusted in the industry by the following two strategies: userspace strategy, dynamically adjusting CPU frequency through a user space program; schedutil strategy: the method is a default frequency modulation strategy of linux, and is based on a frequency modulation strategy triggered by a scheduling event of a scheduler, and dynamic frequency modulation is carried out according to the current CPU utilization rate.
However, practice finds that the user space in userspace strategies dynamically adjusts the CPU frequency according to the calculation power requirement of the operation scene, the CPU frequency cannot be selected according to the utilization rate of the CPU, and the CPU frequency selection is not accurate enough and is not applicable to all scenes; the schedutil strategy can solve the problem of the userspace strategy, but the schedutil strategy has the inefficient scene that the CPU operates at high frequency but the instruction is not executed, namely, the CPU does not work out and does not work, and the running efficiency of the CPU is poor in the case. Therefore, it is important to provide a technical solution for reducing the situations of high-frequency operation of the CPU but not more inefficient situations of instruction execution, so as to improve the operation performance of the CPU.
Disclosure of Invention
The technical problem to be solved by the invention is to provide an intelligent control method and system for frequency modulation of a CPU, which can reduce the conditions of low-efficiency scenes of high-frequency operation of the CPU but few instruction execution, thereby improving the operation efficiency of the CPU.
In order to solve the technical problems, a first aspect of the embodiment of the present invention discloses an intelligent control method for performing frequency modulation on a CPU, where the method includes:
When the CPU is required to be subjected to frequency modulation, acquiring the current frequency modulation frequency of the CPU, and determining the next frequency modulation frequency of the CPU;
according to the current frequency modulation frequency of the CPU and the next frequency modulation frequency of the CPU, controlling a performance monitoring unit of the CPU to execute data acquisition operation on performance event data when the CPU works at the current frequency modulation frequency of the CPU to obtain performance event data corresponding to the CPU, wherein the performance event data corresponding to the CPU comprises the occurrence times of the performance event corresponding to the CPU;
and determining a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, and controlling the CPU to execute frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU.
In a first aspect of the present invention, the performance monitoring unit for controlling the CPU performs a data collection operation on performance event data when the CPU operates at a current fm frequency of the CPU, to obtain performance event data corresponding to the CPU, including:
starting to control a performance monitoring unit of the CPU to execute data acquisition operation on performance event data in a certain time period when the CPU works at the current frequency modulation frequency of the CPU by taking the time when the CPU needs to be subjected to frequency modulation as the starting time of data acquisition;
in the process of executing the acquisition operation, judging whether the current frequency modulation frequency of the CPU is equal to the next frequency modulation frequency of the CPU;
and when judging that the current frequency modulation frequency of the CPU is not equal to the next frequency modulation frequency of the CPU, controlling the performance monitoring unit to stop executing the data acquisition operation to obtain the performance event data corresponding to the CPU.
As an optional implementation manner, in the first aspect of the present invention, the determining a frequency modulation frequency of the CPU next time includes:
Judging whether the CPU generates a scheduling event, and controlling the CPU to execute to a scheduling entry and acquiring scheduling information of the scheduling event when the judging result is yes, wherein the scheduling information comprises the utilization rate of the CPU and the highest frequency supported by the CPU;
Calculating the next frequency modulation frequency of the CPU according to the scheduling information;
wherein, the calculation formula of the next frequency modulation frequency of the CPU is as follows:
next_freq=C*max_freq*cpu_util;
In the formula, next_freq is the next frequency modulation frequency of the CPU, max_freq is the highest frequency supported by the CPU, cpu_utel is the utilization rate of the CPU, cpu_utel is the sum of the utilization rates of a plurality of scheduling classes and the utilization rate of interrupt on the CPU, and C is a constant.
As an optional implementation manner, in the first aspect of the present invention, the number of performance event occurrences corresponding to the CPU includes the number of shutdown cycles of the CPU, the number of instruction execution occurrences of the CPU, and the number of total execution cycles of the CPU;
wherein, the determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU includes:
calculating the calculation redundancy period number of the CPU according to the instruction execution occurrence times of the CPU and the shutdown period occurrence times of the CPU;
and calculating a calculation ratio factor of the CPU according to the calculation redundancy period number of the CPU and the total execution period occurrence number of the CPU.
As an optional implementation manner, in the first aspect of the present invention, a calculation formula of the calculation ratio example factor of the CPU is as follows:
K=1 - X/cpu_cycles;
X = stall_cycles - m * instructions;
Wherein K is a calculation ratio factor of the CPU, X is a calculation redundancy period number of the CPU, cpu_cycles is a total execution period occurrence number of the CPU, stall_cycles is a shutdown period occurrence number of the CPU, m is a constant, and instructions is an instruction execution occurrence number of the CPU.
In an optional implementation manner, in the first aspect of the present invention, the controlling the CPU to perform the frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU includes:
Calculating the target frequency modulation frequency of the CPU according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU, wherein when the calculation ratio factor of the CPU is more than or equal to 1, the calculation ratio factor of the CPU takes 1, and when the calculation ratio factor of the CPU is less than 1, the calculation ratio factor of the CPU takes an actual value;
Controlling the CPU to execute frequency modulation operation according to the target frequency modulation frequency of the CPU and the current frequency modulation frequency of the CPU;
the calculation formula of the target frequency modulation frequency of the CPU is as follows:
target_freq = next_freq * K;
in the formula, target_freq is the target frequency modulation frequency of the CPU, and K is the calculation ratio factor of the CPU.
In an optional implementation manner, in the first aspect of the present invention, the controlling the CPU to perform the frequency modulation operation according to the target frequency modulation of the CPU and the current frequency modulation of the CPU includes:
Judging whether the current frequency modulation frequency of the CPU is equal to the target frequency modulation frequency of the CPU;
When the current frequency modulation frequency of the CPU is judged to be unequal to the target frequency modulation frequency of the CPU, the CPU is controlled to set the current frequency modulation frequency of the CPU as the target frequency modulation frequency of the CPU.
As an optional implementation manner, in the first aspect of the present invention, the performance event data corresponding to the CPU further includes a performance event occurrence type corresponding to the CPU, the number of performance event occurrences corresponding to the CPU includes a number of performance event occurrences corresponding to each of the performance event occurrence types, and all the performance event occurrence types include a shutdown cycle occurrence type of the CPU, an instruction execution occurrence type of the CPU, and a total execution cycle occurrence type of the CPU;
Before determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, the method further comprises:
Calculating the occurrence times of the performance events corresponding to each performance event occurrence type, and judging whether the occurrence times of the performance events corresponding to the shutdown period occurrence types of the CPU are larger than or equal to preset shutdown times or not;
and when the result is judged to be yes, judging whether the occurrence times of the performance events corresponding to the instruction execution occurrence types of the CPU are smaller than or equal to the preset execution times, and when the occurrence times of the performance events corresponding to the instruction execution types of the CPU are smaller than or equal to the preset execution times, triggering the execution of the performance event data corresponding to the CPU, and determining the calculation ratio factor of the CPU.
The second aspect of the embodiment of the invention discloses an intelligent control system for performing frequency modulation on a CPU, which comprises:
the acquisition module is used for acquiring the current frequency modulation frequency of the CPU when the CPU is required to be subjected to frequency modulation;
the determining module is used for determining the next frequency modulation frequency of the CPU;
The control module is used for controlling the performance monitoring unit of the CPU to execute data acquisition operation on the performance event data when the CPU works at the current frequency modulation frequency of the CPU according to the current frequency modulation frequency of the CPU and the frequency modulation frequency of the next time of the CPU to obtain the performance event data corresponding to the CPU, wherein the performance event data corresponding to the CPU comprises the occurrence times of the performance event corresponding to the CPU;
the determining module is further used for determining a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU;
the control module is also used for controlling the CPU to execute frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU.
In a second aspect of the present invention, as an optional implementation manner, the specific manner in which the control module controls the performance monitoring unit of the CPU to perform the data collection operation on the performance event data when the CPU operates at the current fm frequency of the CPU, to obtain the performance event data corresponding to the CPU includes:
starting to control a performance monitoring unit of the CPU to execute data acquisition operation on performance event data in a certain time period when the CPU works at the current frequency modulation frequency of the CPU by taking the time when the CPU needs to be subjected to frequency modulation as the starting time of data acquisition;
in the process of executing the acquisition operation, judging whether the current frequency modulation frequency of the CPU is equal to the next frequency modulation frequency of the CPU;
and when judging that the current frequency modulation frequency of the CPU is not equal to the next frequency modulation frequency of the CPU, controlling the performance monitoring unit to stop executing the data acquisition operation to obtain the performance event data corresponding to the CPU.
In a second aspect of the present invention, a specific manner of determining the next frequency modulation frequency of the CPU by the determining module includes:
Judging whether the CPU generates a scheduling event, and controlling the CPU to execute to a scheduling entry and acquiring scheduling information of the scheduling event when the judging result is yes, wherein the scheduling information comprises the utilization rate of the CPU and the highest frequency supported by the CPU;
Calculating the next frequency modulation frequency of the CPU according to the scheduling information;
wherein, the calculation formula of the next frequency modulation frequency of the CPU is as follows:
next_freq=C*max_freq*cpu_util;
In the formula, next_freq is the next frequency modulation frequency of the CPU, max_freq is the highest frequency supported by the CPU, cpu_utel is the utilization rate of the CPU, cpu_utel is the sum of the utilization rates of a plurality of scheduling classes and the utilization rate of interrupt on the CPU, and C is a constant.
As an optional implementation manner, in the second aspect of the present invention, the number of performance event occurrences corresponding to the CPU includes the number of shutdown cycles of the CPU, the number of instruction execution occurrences of the CPU, and the number of total execution cycles of the CPU;
The specific mode of determining the calculation ratio example factor of the CPU according to the performance event data corresponding to the CPU by the determining module comprises the following steps:
calculating the calculation redundancy period number of the CPU according to the instruction execution occurrence times of the CPU and the shutdown period occurrence times of the CPU;
and calculating a calculation ratio factor of the CPU according to the calculation redundancy period number of the CPU and the total execution period occurrence number of the CPU.
As an alternative implementation manner, in the second aspect of the present invention, the calculation formula of the calculation ratio example factor of the CPU is as follows:
K=1 - X/cpu_cycles;
X = stall_cycles - m * instructions;
Wherein K is a calculation ratio factor of the CPU, X is a calculation redundancy period number of the CPU, cpu_cycles is a total execution period occurrence number of the CPU, stall_cycles is a shutdown period occurrence number of the CPU, m is a constant, and instructions is an instruction execution occurrence number of the CPU.
In a second aspect of the present invention, as an optional implementation manner, the specific manner of controlling, by the control module, the CPU to perform the frequency modulation operation according to the calculation ratio example factor of the CPU and the frequency modulation frequency of the next time of the CPU includes:
Calculating the target frequency modulation frequency of the CPU according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU, wherein when the calculation ratio factor of the CPU is more than or equal to 1, the calculation ratio factor of the CPU takes 1, and when the calculation ratio factor of the CPU is less than 1, the calculation ratio factor of the CPU takes an actual value;
Controlling the CPU to execute frequency modulation operation according to the target frequency modulation frequency of the CPU and the current frequency modulation frequency of the CPU;
the calculation formula of the target frequency modulation frequency of the CPU is as follows:
target_freq = next_freq * K;
in the formula, target_freq is the target frequency modulation frequency of the CPU, and K is the calculation ratio factor of the CPU.
In a second aspect of the present invention, as an optional implementation manner, the specific manner of controlling, by the control module, the CPU to perform the frequency modulation operation according to the target frequency modulation frequency of the CPU and the current frequency modulation frequency of the CPU includes:
Judging whether the current frequency modulation frequency of the CPU is equal to the target frequency modulation frequency of the CPU;
When the current frequency modulation frequency of the CPU is judged to be unequal to the target frequency modulation frequency of the CPU, the CPU is controlled to set the current frequency modulation frequency of the CPU as the target frequency modulation frequency of the CPU.
As an optional implementation manner, in the second aspect of the present invention, the performance event data corresponding to the CPU further includes a performance event occurrence type corresponding to the CPU, the number of performance event occurrences corresponding to the CPU includes a number of performance event occurrences corresponding to each of the performance event occurrence types, and all the performance event occurrence types include a shutdown cycle occurrence type of the CPU, an instruction execution occurrence type of the CPU, and a total execution cycle occurrence type of the CPU;
Wherein, intelligent control system still includes:
The calculation module is used for calculating the occurrence times of the performance event corresponding to each performance event occurrence type before the determination module determines the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU;
The judging module is used for judging whether the occurrence times of the performance events corresponding to the occurrence types of the shutdown periods of the CPU are larger than or equal to the preset shutdown times;
And the judging module is further used for judging whether the occurrence times of the performance events corresponding to the instruction execution occurrence types of the CPU are smaller than or equal to the preset execution times or not when the judging result is yes, and triggering the determining module to execute the performance event data corresponding to the CPU and determine the calculation ratio factor of the CPU when the occurrence times of the performance events corresponding to the instruction execution types of the CPU are smaller than or equal to the preset execution times.
The third aspect of the present invention discloses another intelligent control system for performing frequency modulation on a CPU, the intelligent control system comprising:
A memory storing executable program code;
A processor coupled to the memory;
The processor calls the executable program codes stored in the memory to execute part or all of the steps in any intelligent control method for performing frequency modulation on the CPU disclosed in the first aspect of the invention.
The fourth aspect of the present invention discloses a computer storage medium, where the computer storage medium stores computer instructions, where the computer instructions are used to execute part or all of the steps in any one of the intelligent control methods for frequency modulation of a CPU disclosed in the first aspect of the present invention when the computer instructions are called.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
The embodiment of the invention discloses an intelligent control method and system for performing frequency modulation on a CPU, wherein the method comprises the following steps: when the CPU is required to be subjected to frequency modulation, acquiring the current frequency modulation frequency of the CPU, and determining the next frequency modulation frequency of the CPU; according to the current frequency modulation frequency of the CPU and the next frequency modulation frequency of the CPU, controlling a performance monitoring unit of the CPU to execute data acquisition operation on performance event data when the CPU works at the current frequency modulation frequency of the CPU to obtain performance event data corresponding to the CPU, wherein the performance event data corresponding to the CPU comprises the occurrence times of the performance event of the CPU; and determining a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, and controlling the CPU to execute frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU. Therefore, when the CPU needs to be subjected to frequency modulation, the performance monitoring unit of the CPU is controlled to acquire the corresponding performance event occurrence times, the calculation proportion factor of the CPU is calculated based on the performance event occurrence times, and then the calculation proportion factor is combined with the next frequency modulation frequency of the CPU to jointly control the CPU to execute frequency modulation, so that the CPU frequency is accurately regulated under the condition that the actual performance of the CPU is not affected, the conditions of low-efficiency scenes that the CPU operates at high frequency but instructions are not executed are reduced, such as when the CPU accesses external data, the frequency of the CPU is reduced, the CPU power consumption is saved, the condition that the CPU cannot work out is reduced, and the CPU operation efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of an intelligent control method for performing frequency modulation on a CPU according to an embodiment of the invention;
FIG. 2 is a schematic diagram of an intelligent control system for frequency modulation of a CPU according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of another intelligent control system for frequency modulation of a CPU according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of another intelligent control system for performing frequency modulation on a CPU according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terms first, second and the like in the description and in the claims and in the above-described figures are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, apparatus, article, or device that comprises a list of steps or elements is not limited to the list of steps or elements but may, in the alternative, include other steps or elements not expressly listed or inherent to such process, method, article, or device.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the invention. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The invention discloses an intelligent control method and system for frequency modulation of a CPU, which can collect the corresponding occurrence times of performance events by controlling a performance monitoring unit of the CPU when the CPU is required to be frequency modulated, calculate the calculation ratio example factor of the CPU based on the occurrence times of the performance events, and then combine the calculation ratio example factor with the next frequency modulation frequency of the CPU to jointly control the CPU to execute the frequency modulation, so that the CPU frequency is accurately regulated under the condition that the actual performance of the CPU is not affected, the conditions of low-efficiency scenes of high-frequency operation of the CPU but instruction execution are reduced, such as when the CPU accesses external data, the frequency of the CPU is reduced, thereby saving the power consumption of the CPU, reducing the condition that the CPU cannot work out and further improving the operation efficiency of the CPU. The following will describe in detail.
Example 1
Referring to fig. 1, fig. 1 is a flow chart of an intelligent control method for performing frequency modulation on a CPU according to an embodiment of the present invention. The method can be applied to scenes which need CPU frequency modulation and are provided with Linux platforms, such as memory copying, video playing (such as video playing with sound-shaking tape barrage and fast-handed video playing), and the like, and particularly, the scenes with high CPU utilization rate and few CPU instructions are executed. As shown in fig. 1, the intelligent control method for performing frequency modulation on the CPU may include the following operations:
101. when the CPU is required to be subjected to frequency modulation, the current frequency modulation frequency of the CPU is obtained, and the next frequency modulation frequency of the CPU is determined.
In the embodiment of the invention, when the frequency modulation request for the CPU is received or the frequency modulation drive of the CPU is detected to be loaded, the CPU is required to be subjected to frequency modulation, the performance monitoring unit of the CPU is started, and the performance monitoring unit is controlled to execute the acquisition operation of the performance event data.
102. According to the current frequency modulation frequency of the CPU and the next frequency modulation frequency of the CPU, the performance monitoring unit of the CPU is controlled to execute data acquisition operation on the performance event data when the CPU works at the current frequency modulation frequency of the CPU, so that the performance event data corresponding to the CPU is obtained, wherein the performance event data corresponding to the CPU comprises the occurrence times of the performance event of the performance monitoring unit.
It should be noted that, the step of "starting to control the performance monitoring unit of the CPU to perform the data acquisition operation on the performance event data when the CPU operates at the current frequency modulation frequency of the CPU" may occur simultaneously with or before the step of "determining the next frequency modulation frequency of the CPU". The situation before the method is that in the process of executing data acquisition operation, when judging that the CPU has scheduling event, the next frequency modulation frequency of the CPU is determined. However, the step of "starting to control the performance monitoring unit of the CPU to perform the data acquisition operation on the performance event data when the CPU is operating at the current fm frequency of the CPU" necessarily occurs after the step of "obtaining the current fm frequency of the CPU".
103. And determining a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, and controlling the CPU to execute frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU.
Therefore, the intelligent control method for performing frequency modulation on the CPU described in FIG. 1 is implemented by controlling the performance monitoring unit of the CPU to collect the corresponding occurrence times of performance events when the CPU needs to be subjected to frequency modulation, calculating the calculation ratio example factor of the CPU based on the occurrence times of the performance events, combining the calculation ratio example factor with the next frequency modulation frequency of the CPU, and jointly controlling the CPU to perform frequency modulation, so that the CPU frequency is accurately adjusted under the condition that the actual performance of the CPU is not affected, the conditions of low-efficiency scenes that the CPU operates at high frequency but instructions are not much are reduced, such as when the CPU accesses external data, the frequency of the CPU is reduced, such as the frequency of 200-800M is reduced, the performance is not affected, the CPU power consumption is saved, the condition that the CPU cannot work out is reduced, and the CPU operation efficiency is further improved.
In the embodiment of the present invention, optionally, a performance monitoring unit for controlling a CPU performs a data acquisition operation on performance event data when the CPU works at a current frequency modulation frequency of the CPU, to obtain performance event data corresponding to the CPU, including:
Starting to control a performance monitoring unit of the CPU to execute data acquisition operation on performance event data when the CPU works at the current frequency modulation frequency of the CPU by taking the time when the CPU is determined to be required to be subjected to frequency modulation as the starting time of data acquisition;
in the process of executing the acquisition operation, judging whether the current frequency modulation frequency of the CPU is equal to the next frequency modulation frequency of the CPU;
When the current frequency modulation frequency of the CPU is not equal to the next frequency modulation frequency of the CPU, the performance monitoring unit is controlled to stop executing data acquisition operation, and performance event data corresponding to the CPU are obtained.
In the embodiment of the invention, optionally, when the current frequency modulation frequency of the CPU is equal to the next frequency modulation frequency of the CPU, the CPU is determined to schedule the end of frequency modulation, i.e. the frequency modulation is not needed.
For example, when it is determined that the time when the CPU needs to perform frequency modulation is 10:00, the performance event data is immediately collected at 10:00, if the performance event data is collected at 10:10, if it is determined that the current frequency modulation frequency of the CPU is not equal to the next frequency modulation frequency of the CPU, the collection of the performance event data is immediately stopped at 10:10, and the performance event data collected at 10:00-10:10 is used as the performance event data corresponding to the CPU to perform the related operation of the subsequent CPU frequency modulation.
Therefore, according to the embodiment of the invention, when the CPU is judged to be required to be subjected to frequency modulation, the performance event data are acquired immediately, and when the frequency modulation frequency of the next time of the CPU is judged to be unequal to the current frequency modulation frequency of the CPU, the data acquisition is stopped, so that the accurate CPU performance event data with enough data volume can be acquired, the calculation accuracy of the calculation ratio factor of the CPU is improved, and the accuracy of the frequency modulation control of the CPU is improved.
In an alternative embodiment, determining the next frequency modulation frequency of the CPU includes:
Judging whether a scheduling event occurs to the CPU, and controlling the CPU to execute to a scheduling entry and acquiring scheduling information of the scheduling event when the judging result is yes, wherein the scheduling information comprises the utilization rate of the CPU and the highest frequency supported by the CPU;
Calculating the next frequency modulation frequency of the CPU according to the scheduling information;
the next frequency modulation frequency calculation formula of the CPU is as follows:
next_freq=C*max_freq*cpu_util;
In the formula, next_freq is the next frequency modulation frequency of the CPU, max_freq is the highest frequency supported by the CPU, cpu_utel is the utilization rate of the CPU, cpu_utel is the sum of the utilization rates of a plurality of scheduling classes on the CPU and the utilization rate of the interrupt, and C is a constant. Wherein the plurality of scheduling classes of the CPU include two or three of a fairness scheduler, a real-time scheduler, and a deadline scheduler.
In this alternative embodiment, optionally, when it is detected that the operating system of the CPU needs to perform scheduling or when a process scheduling request is detected, it is determined that a scheduling event has occurred in the CPU. And ending the flow when judging that the CPU does not have the scheduling event, or continuously executing the step of judging whether the CPU has the scheduling event.
It can be seen that this alternative embodiment can improve the accuracy of calculating the frequency modulation frequency by performing the next calculation of the frequency modulation frequency of the CPU based on the obtained scheduling information when it is determined that the CPU has a scheduling event.
In another optional embodiment, the number of performance event occurrences corresponding to the CPU includes a number of shutdown cycles of the CPU, a number of instruction execution occurrences of the CPU, and a total number of execution cycles of the CPU; and the statistical units of all performance event data are M/s;
Wherein, according to the performance event data corresponding to the CPU, determining the calculation ratio factor of the CPU comprises:
Calculating the calculation redundancy period number of the CPU according to the instruction execution occurrence times of the CPU and the shutdown period occurrence times of the CPU;
and calculating the calculation ratio factor of the CPU according to the calculation redundancy period number of the CPU and the total execution period occurrence number of the CPU.
In this alternative embodiment, the calculation formula of the calculation ratio factor of the CPU is as follows:
K=1 - X/cpu_cycles;
X = stall_cycles - m * instructions;
In the formula, K is a calculation ratio factor of the CPU, X is a calculation redundancy period number of the CPU, cpu_cycles is total execution period occurrence times of the CPU, stall_cycles is shutdown period occurrence times of the CPU, m is a constant, for example, in an Android system of a Cortex-A55 core, m is usually 1.5, and instructions are instruction execution occurrence times of the CPU. Wherein, m is instructions also called the reasonable shutdown period occurrence number of the last operation stage of the CPU.
Therefore, according to the alternative embodiment, the number of times of execution of the instructions of the CPU and the number of times of occurrence of the shutdown period of the CPU are used for calculating the computational power redundancy period number of the CPU, and then the number of times of occurrence of the total execution period of the CPU is calculated, so that the computational power comparison factor of the CPU is obtained, the accurate calculation of the computational power comparison factor of the CPU can be realized, the frequency modulation control operation of the subsequent CPU is improved, and the occurrence of the condition that the output of the CPU is not output is reduced.
In yet another alternative embodiment, controlling the CPU to perform the frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU includes:
Calculating the target frequency modulation frequency of the CPU according to the calculation ratio factor of the CPU and the frequency modulation frequency of the CPU next time, wherein when the calculation ratio factor of the CPU is more than or equal to 1, the calculation ratio factor of the CPU takes 1, when the calculation ratio factor of the CPU is less than 1, the calculation ratio factor of the CPU takes an actual value, if the calculated calculation ratio factor is 1.5, the calculation ratio factor takes 1 when the target frequency modulation frequency of the CPU is actually calculated, if the calculated calculation ratio factor is 0.8, and if the calculated calculation ratio factor is actually calculated, the calculation ratio factor takes an actual value of 0.8;
controlling the CPU to execute frequency modulation operation according to the target frequency modulation frequency of the CPU and the current frequency modulation frequency of the CPU;
The calculation formula of the target frequency modulation frequency of the CPU is as follows:
target_freq = next_freq * K;
In the formula, target_freq is the target frequency modulation frequency of the CPU, and K is the calculation ratio factor of the CPU.
In this optional embodiment, optionally, controlling the CPU to perform the frequency modulation operation according to the target frequency modulation of the CPU and the current frequency modulation of the CPU includes:
Judging whether the current frequency modulation frequency of the CPU is equal to the target frequency modulation frequency of the CPU;
When the current frequency modulation frequency of the CPU is not equal to the target frequency modulation frequency of the CPU, the CPU is controlled to set the current frequency modulation frequency of the CPU as the target frequency modulation frequency of the CPU. Further, optionally, after the current fm frequency of the CPU is modulated to the target fm frequency, the steps 101-102 are re-executed, and the fm of the CPU is terminated.
In this alternative embodiment, optionally, when it is determined that the current frequency of the CPU is equal to the target frequency of the CPU, the steps 101 to 102 are re-executed, and the frequency modulation of the CPU is terminated.
Therefore, according to the alternative embodiment, the accurate target frequency modulation frequency can be calculated based on the calculated calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU, and compared with the current frequency modulation frequency, so that the accurate frequency modulation of the CPU can be realized while the performance of the CPU is ensured, the condition that the CPU cannot work out is further reduced, and the running efficiency of the CPU is further improved.
In yet another optional embodiment, the performance event data corresponding to the CPU further includes a performance event occurrence type corresponding to the CPU, the number of performance event occurrences corresponding to the CPU includes a number of performance event occurrences corresponding to each performance event occurrence type, and all performance event occurrence types include a shutdown cycle occurrence type of the CPU, an instruction execution occurrence type of the CPU, and a total execution cycle occurrence type of the CPU;
Before determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, the intelligent control for performing frequency modulation on the CPU can further comprise the following steps:
Calculating the occurrence times of the performance events corresponding to each performance event occurrence type, and judging whether the occurrence times of the performance events corresponding to the shutdown period occurrence type of the CPU are larger than or equal to the preset shutdown times or not;
When the result is judged to be yes, judging whether the occurrence times of the performance events corresponding to the instruction execution occurrence types of the CPU are smaller than or equal to the preset execution times, and when the occurrence times of the performance events corresponding to the instruction execution types of the CPU are smaller than or equal to the preset execution times, triggering and executing the operation of determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU.
In this alternative embodiment, when it is determined that the number of performance events corresponding to the occurrence type of the shutdown cycle of the CPU is smaller than the preset shutdown number, or when it is determined that the number of performance events corresponding to the instruction execution occurrence type of the CPU is greater than the preset execution number, the frequency modulation control operation of the CPU is terminated.
Therefore, before calculating the calculation ratio factor of the CPU, the optional embodiment performs the subsequent operation of controlling the frequency modulation of the CPU if it is determined that the number of times of shutdown of the CPU occurs in the acquired period of time is greater and the number of times of instruction execution of the CPU is less than the specified number of times in the acquired period of time, and accurately controls the CPU to perform the frequency modulation operation, so that the power consumption of the intelligent control system can be reduced while not reducing the task execution efficiency of the CPU and reducing the low-efficiency scenario of high-frequency operation of the CPU but not more instructions execution.
Example two
Referring to fig. 2, fig. 2 is a schematic structural diagram of an intelligent control system for performing frequency modulation on a CPU according to an embodiment of the present invention. The device can be applied to scenes which need CPU frequency modulation and are provided with Linux platforms, such as memory copy, video playing (such as video playing with sound-shaking tape barrage and fast-handed video playing), and the like, and particularly, the device has high CPU utilization rate but few CPU instructions. As shown in fig. 2, the intelligent control system for frequency modulation of the CPU may include:
an obtaining module 201, configured to obtain a current frequency modulation frequency of the CPU when the CPU needs to be frequency-modulated;
a determining module 202, configured to determine a next frequency modulation frequency of the CPU;
the control module 203 is configured to control, according to the current frequency modulation frequency of the CPU and the frequency modulation frequency of the CPU next time, the performance monitoring unit of the CPU to perform a data acquisition operation on performance event data when the CPU works at the current frequency modulation frequency of the CPU, so as to obtain performance event data corresponding to the CPU, where the performance event data corresponding to the CPU includes the number of performance event occurrences of the performance monitoring unit;
The determining module 202 is further configured to determine a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU;
the control module 203 is further configured to control the CPU to perform a frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time the CPU.
Therefore, the intelligent control system for performing frequency modulation on the CPU described in FIG. 2 can control the CPU to perform frequency modulation by controlling the performance monitoring unit of the CPU to acquire the corresponding occurrence times of the performance events when the CPU is required to perform frequency modulation, calculating the calculation ratio factor of the CPU based on the occurrence times of the performance events, combining the calculation ratio factor with the next frequency modulation frequency of the CPU, and controlling the CPU to perform frequency modulation together, so that the CPU frequency is accurately adjusted under the condition that the actual performance of the CPU is not affected, the conditions of low-efficiency scenes that the CPU operates at high frequency but the instruction is not much are reduced, such as when the CPU accesses external data, the frequency of the CPU is reduced, thereby saving the power consumption of the CPU, reducing the condition that the CPU cannot work out and further improving the CPU operation efficiency.
In an alternative embodiment, the specific manner of controlling the performance monitoring unit of the CPU to perform the data collection operation on the performance event data when the CPU works at the current frequency modulation frequency of the CPU to obtain the performance event data corresponding to the CPU includes:
Starting to control a performance monitoring unit of the CPU to execute data acquisition operation on performance event data when the CPU works at the current frequency modulation frequency of the CPU by taking the time when the CPU is determined to be required to be subjected to frequency modulation as the starting time of data acquisition;
in the process of executing the acquisition operation, judging whether the current frequency modulation frequency of the CPU is equal to the next frequency modulation frequency of the CPU;
When the current frequency modulation frequency of the CPU is not equal to the next frequency modulation frequency of the CPU, the performance monitoring unit is controlled to stop executing data acquisition operation, and performance event data corresponding to the CPU are obtained.
Therefore, the intelligent control system for performing frequency modulation on the CPU described in fig. 2 can also acquire performance event data immediately when judging that the frequency modulation on the CPU is needed, and stop data acquisition when judging that the frequency modulation frequency of the next time of the CPU is not equal to the current frequency modulation frequency of the CPU, so that accurate CPU performance event data with enough data volume can be acquired, thereby being beneficial to improving the calculation accuracy of the calculation ratio factor of the CPU and further being beneficial to improving the frequency modulation control accuracy of the CPU.
In another alternative embodiment, the specific manner in which the determining module 202 determines the next frequency modulation frequency of the CPU includes:
Judging whether a scheduling event occurs to the CPU, and controlling the CPU to execute to a scheduling entry and acquiring scheduling information of the scheduling event when the judging result is yes, wherein the scheduling information comprises the utilization rate of the CPU and the highest frequency supported by the CPU;
Calculating the next frequency modulation frequency of the CPU according to the scheduling information;
the next frequency modulation frequency calculation formula of the CPU is as follows:
next_freq=C*max_freq*cpu_util;
In the formula, next_freq is the next frequency modulation frequency of the CPU, max_freq is the highest frequency supported by the CPU, cpu_utel is the utilization rate of the CPU, cpu_utel is the sum of the utilization rates of a plurality of scheduling classes on the CPU and the utilization rate of the interrupt, and C is a constant. Wherein the plurality of scheduling classes of the CPU include two or three of a fairness scheduler, a real-time scheduler, and a deadline scheduler.
Therefore, the intelligent control system for performing frequency modulation on the CPU as described in fig. 2 can also improve the accuracy of the calculation of the frequency modulation frequency by performing the next calculation of the frequency modulation frequency of the CPU based on the obtained scheduling information when it is determined that the CPU has a scheduling event.
In yet another optional embodiment, the number of performance event occurrences corresponding to the CPU includes a number of shutdown cycles of the CPU, a number of instruction execution occurrences of the CPU, and a number of total execution cycles of the CPU; and the statistical units of all performance event data are M/s;
the specific manner of determining the calculation ratio example factor of the CPU by the determining module 202 according to the performance event data corresponding to the CPU includes:
Calculating the calculation redundancy period number of the CPU according to the instruction execution occurrence times of the CPU and the shutdown period occurrence times of the CPU;
and calculating the calculation ratio factor of the CPU according to the calculation redundancy period number of the CPU and the total execution period occurrence number of the CPU.
In this alternative embodiment, the calculation formula of the calculation ratio factor of the CPU is as follows:
K=1 - X/cpu_cycles;
X = stall_cycles - m * instructions;
In the formula, K is a calculation ratio factor of the CPU, X is a calculation redundancy period number of the CPU, cpu_cycles is total execution period occurrence times of the CPU, stall_cycles is shutdown period occurrence times of the CPU, m is a constant, for example, in an Android system of a Cortex-A55 core, m is usually 1.5, and instructions are instruction execution occurrence times of the CPU. Wherein, m is instructions also called the reasonable shutdown period occurrence number of the last operation stage of the CPU.
Therefore, the intelligent control system for performing frequency modulation on the CPU described in FIG. 2 can also calculate the calculation redundancy cycle number of the CPU through the instruction execution occurrence number of the CPU and the shutdown cycle occurrence number of the CPU, further calculate the calculation redundancy cycle number of the CPU and the total execution cycle occurrence number of the CPU to obtain the calculation comparison example factor of the CPU, and can realize the accurate calculation of the calculation comparison example factor of the CPU, thereby being beneficial to improving the frequency modulation control operation of the subsequent CPU and further being beneficial to reducing the occurrence condition that the output of the CPU is not operated.
In yet another alternative embodiment, the specific manner of controlling the CPU to perform the frequency modulation operation by the control module 203 according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU includes:
Calculating the target frequency modulation frequency of the CPU according to the calculation ratio factor of the CPU and the frequency modulation frequency of the CPU next time, wherein when the calculation ratio factor of the CPU is more than or equal to 1, the calculation ratio factor of the CPU takes 1, when the calculation ratio factor of the CPU is less than 1, the calculation ratio factor of the CPU takes an actual value, if the calculated calculation ratio factor is 1.5, the calculation ratio factor takes 1 when the target frequency modulation frequency of the CPU is actually calculated, if the calculated calculation ratio factor is 0.8, and if the calculated calculation ratio factor is actually calculated, the calculation ratio factor takes an actual value of 0.8;
controlling the CPU to execute frequency modulation operation according to the target frequency modulation frequency of the CPU and the current frequency modulation frequency of the CPU;
The calculation formula of the target frequency modulation frequency of the CPU is as follows:
target_freq = next_freq * K;
In the formula, target_freq is the target frequency modulation frequency of the CPU, and K is the calculation ratio factor of the CPU.
In this alternative embodiment, the specific manner of controlling the CPU to perform the frequency modulation operation by the control module 203 according to the target frequency modulation frequency of the CPU and the current frequency modulation frequency of the CPU includes:
Judging whether the current frequency modulation frequency of the CPU is equal to the target frequency modulation frequency of the CPU;
When the current frequency modulation frequency of the CPU is not equal to the target frequency modulation frequency of the CPU, the CPU is controlled to set the current frequency modulation frequency of the CPU as the target frequency modulation frequency of the CPU.
Further, optionally, after the current fm frequency of the CPU is controlled to be modulated to the target fm frequency, the control module 203 triggers the acquisition module 201 to re-execute the operation of acquiring the current fm frequency of the CPU, thereby triggering the determination module 202 to re-execute the operation of determining the next fm frequency of the CPU, and further triggering the control module 203 to re-execute the operation of performing the data acquisition operation on the performance event data when the CPU works at the current fm frequency of the CPU according to the current fm frequency of the CPU and the next fm frequency of the CPU, so as to obtain the operation of the performance event data corresponding to the CPU.
Therefore, the intelligent control system for performing frequency modulation on the CPU described in FIG. 2 can also calculate the accurate target frequency modulation frequency based on the calculated calculation ratio factor of the CPU and the next frequency modulation frequency of the CPU, and compare the target frequency modulation frequency with the current frequency modulation frequency, so that the accurate frequency modulation of the CPU can be realized while the performance of the CPU is ensured, the condition that the CPU cannot work out is further reduced, and the running efficiency of the CPU is further improved.
In yet another optional embodiment, the performance event data corresponding to the CPU further includes a performance event occurrence type corresponding to the CPU, the number of performance event occurrences corresponding to the CPU includes a number of performance event occurrences corresponding to each performance event occurrence type, and all performance event occurrence types include a shutdown cycle occurrence type of the CPU, an instruction execution occurrence type of the CPU, and a total execution cycle occurrence type of the CPU;
Fig. 3 is a schematic structural diagram of another intelligent control system for performing frequency modulation on a CPU according to the embodiment of the present invention, as shown in fig. 3, where, as shown in fig. 3, the intelligent control system further includes:
the calculating module 204 is configured to calculate a number of performance event occurrences corresponding to each performance event occurrence type before the determining module 202 determines a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU;
the judging module 205 is configured to judge whether the number of performance events corresponding to the occurrence type of the shutdown period of the CPU is greater than or equal to a preset shutdown number;
The judging module 205 is further configured to, when the result of the judgment is yes, judge whether the number of performance events corresponding to the instruction execution occurrence type of the CPU is less than or equal to the preset number of execution times, and when the number of performance events corresponding to the instruction execution occurrence type of the CPU is less than or equal to the preset number of execution times, trigger the determining module 202 to execute the above operation of determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU.
Therefore, before the calculation ratio factor of the CPU is calculated, the intelligent control system for performing frequency modulation on the CPU described in fig. 3 performs the subsequent operation of controlling the frequency modulation on the CPU if it is determined that the number of times of shutdown of the CPU occurs in a period of time and the number of times of instruction execution of the CPU is less than the specified number of times in the period of time, so as to accurately control the CPU to perform the frequency modulation operation, thereby ensuring that the power consumption of the intelligent control system can be reduced while not reducing the task execution efficiency of the CPU and reducing the low-efficiency scenario of the CPU in which the high-frequency operation is performed but the instruction execution is not too much.
Example III
Referring to fig. 4, fig. 4 is a schematic structural diagram of an intelligent control system for performing frequency modulation on a CPU according to an embodiment of the present invention. The intelligent control system can be applied to scenes which need CPU frequency modulation and are provided with Linux platforms, such as memory copying, video playing (such as video playing with sound-shaking tape barrage and fast-handing video playing), and the like, and particularly, the intelligent control system is used for scenes with high CPU utilization rate and few CPU instructions. As shown in fig. 4, the intelligent control system may include:
A memory 301 storing executable program code;
A processor 302 coupled with the memory 301;
further, an input interface 303 and an output interface 304 coupled to the processor 302 may also be included;
the processor 302 invokes executable program codes stored in the memory 301 for executing the steps in the intelligent control method for frequency modulation of a CPU described in the first embodiment.
Example IV
The embodiment of the invention discloses a computer-readable storage medium storing a computer program for electronic data exchange, wherein the computer program causes a computer to execute the steps in the intelligent control method for frequency modulation of a CPU described in the embodiment.
Example five
The embodiment of the invention discloses a computer program product, which comprises a non-transitory computer readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute the steps in the intelligent control method for frequency modulation of a CPU described in the embodiment.
The apparatus embodiments described above are merely illustrative, wherein the modules illustrated as separate components may or may not be physically separate, and the components shown as modules may or may not be physical, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above detailed description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course by means of hardware. Based on such understanding, the foregoing technical solutions may be embodied essentially or in part in the form of a software product that may be stored in a computer-readable storage medium including read-only memory (ROM), random access memory (Random Access Memory, RAM), programmable read-only memory (Programmable Read-only memory, PROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, EPROM), one-time programmable read-only memory (OTPROM), electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (Compact Disc Read-only memory, CD-ROM) or other optical disc memory, magnetic disc memory, tape memory, or any other medium that can be used for computer-readable carrying or storing data.
Finally, it should be noted that: the embodiment of the invention discloses an intelligent control method and system for performing frequency modulation on a CPU, which are disclosed by the embodiment of the invention only as a preferred embodiment of the invention, and are only used for illustrating the technical scheme of the invention, but not limiting the technical scheme; although the invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art will understand that; the technical scheme recorded in the various embodiments can be modified or part of technical features in the technical scheme can be replaced equivalently; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions.

Claims (7)

1. An intelligent control method for performing frequency modulation on a CPU (Central processing Unit), which is characterized by comprising the following steps:
When the CPU is required to be subjected to frequency modulation, acquiring the current frequency modulation frequency of the CPU, and determining the next frequency modulation frequency of the CPU;
according to the current frequency modulation frequency of the CPU and the next frequency modulation frequency of the CPU, controlling a performance monitoring unit of the CPU to execute data acquisition operation on performance event data when the CPU works at the current frequency modulation frequency of the CPU to obtain performance event data corresponding to the CPU, wherein the performance event data corresponding to the CPU comprises the occurrence times of the performance event corresponding to the CPU;
Determining a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, and controlling the CPU to execute frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU;
The corresponding performance event occurrence times of the CPU comprise the shutdown period occurrence times of the CPU, the instruction execution occurrence times of the CPU and the total execution period occurrence times of the CPU;
wherein, the determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU includes:
calculating the calculation redundancy period number of the CPU according to the instruction execution occurrence times of the CPU and the shutdown period occurrence times of the CPU;
calculating a calculation ratio factor of the CPU according to the calculation redundancy period number of the CPU and the total execution period occurrence number of the CPU;
The calculation formula of the calculation ratio factor of the CPU is as follows:
K=1 - X/cpu_cycles;
X = stall_cycles - m * instructions;
Wherein K is a calculation ratio factor of the CPU, X is a calculation redundancy period number of the CPU, cpu_cycles is a total execution period occurrence number of the CPU, stall_cycles is a shutdown period occurrence number of the CPU, m is a constant, and instructions is an instruction execution occurrence number of the CPU;
the determining the next frequency modulation frequency of the CPU comprises the following steps:
Judging whether the CPU generates a scheduling event, and controlling the CPU to execute to a scheduling entry and acquiring scheduling information of the scheduling event when the judging result is yes, wherein the scheduling information comprises the utilization rate of the CPU and the highest frequency supported by the CPU;
Calculating the next frequency modulation frequency of the CPU according to the scheduling information;
wherein, the calculation formula of the next frequency modulation frequency of the CPU is as follows:
next_freq=C*max_freq*cpu_util;
In the formula, next_freq is the next frequency modulation frequency of the CPU, max_freq is the highest frequency supported by the CPU, cpu_utel is the utilization rate of the CPU, cpu_utel is the sum of the utilization rates of a plurality of scheduling classes and the utilization rate of interrupt on the CPU, and C is a constant.
2. The intelligent control method for performing frequency modulation on a CPU according to claim 1, wherein the performance monitoring unit for controlling the CPU performs a data acquisition operation on performance event data when the CPU operates at a current frequency modulation frequency of the CPU, to obtain the performance event data corresponding to the CPU, and includes:
starting to control a performance monitoring unit of the CPU to execute data acquisition operation on performance event data in a certain time period when the CPU works at the current frequency modulation frequency of the CPU by taking the time when the CPU needs to be subjected to frequency modulation as the starting time of data acquisition;
in the process of executing the acquisition operation, judging whether the current frequency modulation frequency of the CPU is equal to the next frequency modulation frequency of the CPU;
and when judging that the current frequency modulation frequency of the CPU is not equal to the next frequency modulation frequency of the CPU, controlling the performance monitoring unit to stop executing the data acquisition operation to obtain the performance event data corresponding to the CPU.
3. The intelligent control method for performing frequency modulation on a CPU according to claim 1 or 2, wherein the controlling the CPU to perform the frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the CPU next time includes:
Calculating the target frequency modulation frequency of the CPU according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU, wherein when the calculation ratio factor of the CPU is more than or equal to 1, the calculation ratio factor of the CPU takes 1, and when the calculation ratio factor of the CPU is less than 1, the calculation ratio factor of the CPU takes an actual value;
Judging whether the current frequency modulation frequency of the CPU is equal to the target frequency modulation frequency of the CPU;
When judging that the current frequency modulation frequency of the CPU is not equal to the target frequency modulation frequency of the CPU, controlling the CPU to set the current frequency modulation frequency of the CPU as the target frequency modulation frequency of the CPU;
the calculation formula of the target frequency modulation frequency of the CPU is as follows:
target_freq = next_freq * K;
in the formula, target_freq is the target frequency modulation frequency of the CPU, and K is the calculation ratio factor of the CPU.
4. The intelligent control method for performing frequency modulation on a CPU according to claim 1 or 2, wherein the performance event data corresponding to the CPU further includes a performance event occurrence type corresponding to the CPU, the number of performance event occurrences corresponding to the CPU includes a number of performance event occurrences corresponding to each of the performance event occurrence types, and all the performance event occurrence types include an off-stream period occurrence type of the CPU, an instruction execution occurrence type of the CPU, and a total execution period occurrence type of the CPU;
Before determining the calculation ratio factor of the CPU according to the performance event data corresponding to the CPU, the method further comprises:
Calculating the occurrence times of the performance events corresponding to each performance event occurrence type, and judging whether the occurrence times of the performance events corresponding to the shutdown period occurrence types of the CPU are larger than or equal to preset shutdown times or not;
when the result is yes, judging whether the occurrence times of the performance events corresponding to the instruction execution occurrence types of the CPU are smaller than or equal to the preset execution times;
when judging that the occurrence times of the performance event corresponding to the instruction execution occurrence type of the CPU is smaller than or equal to the preset execution times, triggering and executing the performance event data corresponding to the CPU, and determining a calculation ratio factor of the CPU.
5. An intelligent control system for frequency modulation of a CPU, the system comprising:
the acquisition module is used for acquiring the current frequency modulation frequency of the CPU when the CPU is required to be subjected to frequency modulation;
the determining module is used for determining the next frequency modulation frequency of the CPU;
The control module is used for controlling the performance monitoring unit of the CPU to execute data acquisition operation on the performance event data when the CPU works at the current frequency modulation frequency of the CPU according to the current frequency modulation frequency of the CPU and the frequency modulation frequency of the next time of the CPU to obtain the performance event data corresponding to the CPU, wherein the performance event data corresponding to the CPU comprises the occurrence times of the performance event of the performance monitoring unit;
the determining module is further used for determining a calculation ratio factor of the CPU according to the performance event data corresponding to the CPU;
the control module is also used for controlling the CPU to execute frequency modulation operation according to the calculation ratio factor of the CPU and the frequency modulation frequency of the next time of the CPU;
The corresponding performance event occurrence times of the CPU comprise the shutdown period occurrence times of the CPU, the instruction execution occurrence times of the CPU and the total execution period occurrence times of the CPU;
The specific mode of determining the calculation ratio example factor of the CPU according to the performance event data corresponding to the CPU by the determining module comprises the following steps:
calculating the calculation redundancy period number of the CPU according to the instruction execution occurrence times of the CPU and the shutdown period occurrence times of the CPU;
calculating a calculation ratio factor of the CPU according to the calculation redundancy period number of the CPU and the total execution period occurrence number of the CPU;
The calculation formula of the calculation ratio factor of the CPU is as follows:
K=1 - X/cpu_cycles;
X = stall_cycles - m * instructions;
Wherein K is a calculation ratio factor of the CPU, X is a calculation redundancy period number of the CPU, cpu_cycles is a total execution period occurrence number of the CPU, stall_cycles is a shutdown period occurrence number of the CPU, m is a constant, and instructions is an instruction execution occurrence number of the CPU;
the specific mode of determining the next frequency modulation frequency of the CPU by the determining module comprises the following steps:
Judging whether the CPU generates a scheduling event, and controlling the CPU to execute to a scheduling entry and acquiring scheduling information of the scheduling event when the judging result is yes, wherein the scheduling information comprises the utilization rate of the CPU and the highest frequency supported by the CPU;
Calculating the next frequency modulation frequency of the CPU according to the scheduling information;
wherein, the calculation formula of the next frequency modulation frequency of the CPU is as follows:
next_freq=C*max_freq*cpu_util;
In the formula, next_freq is the next frequency modulation frequency of the CPU, max_freq is the highest frequency supported by the CPU, cpu_utel is the utilization rate of the CPU, cpu_utel is the sum of the utilization rates of a plurality of scheduling classes and the utilization rate of interrupt on the CPU, and C is a constant.
6. An intelligent control system for frequency modulation of a CPU, the intelligent control system comprising:
A memory storing executable program code;
A processor coupled to the memory;
the processor invokes the executable program code stored in the memory to perform the intelligent control method of frequency modulation of a CPU as claimed in any one of claims 1 to 4.
7. A computer storage medium storing computer instructions which, when invoked, are operable to perform the intelligent control method of frequency modulation of a CPU as claimed in any one of claims 1 to 4.
CN202410309503.0A 2024-03-19 Intelligent control method and system for performing frequency modulation on CPU Active CN117909086B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410309503.0A CN117909086B (en) 2024-03-19 Intelligent control method and system for performing frequency modulation on CPU

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410309503.0A CN117909086B (en) 2024-03-19 Intelligent control method and system for performing frequency modulation on CPU

Publications (2)

Publication Number Publication Date
CN117909086A true CN117909086A (en) 2024-04-19
CN117909086B CN117909086B (en) 2024-07-05

Family

ID=

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102929383A (en) * 2012-11-06 2013-02-13 山东大学 Method for reducing embedded system power consumption through central processing unit (CPU) dynamic frequency modulation technology
CN107515663A (en) * 2016-06-15 2017-12-26 北京京东尚科信息技术有限公司 The method and apparatus for adjusting central processor core running frequency
CN115511585A (en) * 2022-09-22 2022-12-23 天津大学 Space-time request resource transaction method and system for edge cloud market
CN116450346A (en) * 2023-03-27 2023-07-18 珠海全志科技股份有限公司 CPU energy efficiency optimization method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102929383A (en) * 2012-11-06 2013-02-13 山东大学 Method for reducing embedded system power consumption through central processing unit (CPU) dynamic frequency modulation technology
CN107515663A (en) * 2016-06-15 2017-12-26 北京京东尚科信息技术有限公司 The method and apparatus for adjusting central processor core running frequency
CN115511585A (en) * 2022-09-22 2022-12-23 天津大学 Space-time request resource transaction method and system for edge cloud market
CN116450346A (en) * 2023-03-27 2023-07-18 珠海全志科技股份有限公司 CPU energy efficiency optimization method and device

Similar Documents

Publication Publication Date Title
US7194385B2 (en) Performance level setting of a data processing system
US7131015B2 (en) Performance level selection in a data processing system using a plurality of performance request calculating algorithms
US7321942B2 (en) Performance counter for adding variable work increment value that is dependent upon clock frequency
US8117415B2 (en) Storage device estimating a completion time for a storage operation
US20080162965A1 (en) Managing performance of a processor in a data processing image
US7346791B2 (en) Method for controlling a clock frequency of an information processor in accordance with the detection of a start and a end of a specific processing section
JP2013232207A (en) Method, system, and apparatus for scheduling computer micro-jobs for execution without disruption
US11494193B2 (en) Serialization floors and deadline driven control for performance optimization of asymmetric multiprocessor systems
US20070266385A1 (en) Performance level setting in a data processing system
US20040039935A1 (en) Method and device for measuring the execution time of a real task in a real time system
CN117909086B (en) Intelligent control method and system for performing frequency modulation on CPU
JP2001160041A (en) System for reducing cpu load of on-line system
CN117909086A (en) Intelligent control method and system for performing frequency modulation on CPU
WO1998003917A1 (en) Method of regulating the performance of an application program in a digital computer
JP2004005305A (en) Monitoring method of memory use capacity, and computer system
CN113961428B (en) Software monitoring system capable of automatically relieving preset background occupation duration
CN110647401B (en) Frequency modulation method, frequency modulation device, storage medium and electronic equipment
CA2469451A1 (en) Method and apparatus to use task priority to scale processor performance
CN113032207A (en) Application process monitoring method and device, electronic equipment and storage medium
CN117608388B (en) Power consumption control method and device applied to SoC system and SoC system
CN114153689B (en) BMC and device monitoring method and device thereof and readable storage medium
WO2024139996A1 (en) Air conditioner operation method and apparatus, electronic device, and computer readable storage medium
US20230126081A1 (en) Electronic device and method thereof for controlling power consumption
US20230385100A1 (en) Computer system using energy barrier instructions
US11194381B2 (en) Techniques for controlling processor performance states

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant