A CPU frequency adjustment method, system, and storage medium
By adjusting the CPU frequency according to the CPU type and utilization rate through the BIOS, the problem of poor CPU frequency adjustment in the general frequency adjustment method is solved, and the efficiency of energy efficiency and operation and maintenance is improved.
Patent Information
- Application Number
- CN202211305538.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-24
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-10-24
AI Technical Summary
In existing technologies, the general CPU frequency adjustment method based on the operating system cannot take into account the differences in heat dissipation capabilities of different CPU models, resulting in the CPU frequency not being adjusted to the optimal parameters, reducing operation and maintenance efficiency, and requiring users to manually configure parameters.
The BIOS determines the maximum supported CPU frequency based on the CPU type and utilization rate, and adjusts the CPU frequency using frequency adjustment coefficients and timing durations to meet the preset energy efficiency requirements, automatically adjusting the CPU frequency.
It improves the CPU's energy efficiency, enhances operational efficiency, eliminates the need for manual parameter configuration, and adapts to the differences between different CPU models.
Smart Images

Figure CN115686178B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of central processing unit frequency adjustment technology, and in particular to a CPU frequency adjustment method, system and storage medium. Background Technology
[0002] With the widespread application of technologies such as cloud computing, 5G, and cryptocurrencies across various fields, data center energy consumption has increased, and electricity costs have become a major component of total data center expenditures. Statistics show that total energy consumption of data centers nationwide exceeded 200 billion kilowatt-hours in 2021, and has grown rapidly in subsequent years, surpassing 250 billion kilowatt-hours in 2023, equivalent to 1.5 times the electricity consumption of Shanghai. Therefore, reducing electricity costs is one of the key issues that green data center managers need to address.
[0003] The central processing unit (CPU) is the most energy-consuming component in a server. Reducing CPU energy consumption per unit generally relies on improvements in chip manufacturing processes. Taking the x86 operating system as an example, the energy efficiency ratio (EER, which is the ratio of energy conversion efficiency; a higher EER means more energy savings) of each CPU generation increases by an average of 20%. This improvement in EER requires the cooperation of both the chip and the operating system's (OS) frequency tuning software. Currently, most server manufacturers use a generic frequency tuning method based on the OS. However, due to differences in the heat dissipation capabilities of different CPU models, this generic method cannot adjust the CPU frequency to optimal parameters. In practice, users often need to manually configure parameters, reducing operational efficiency. Summary of the Invention
[0004] This application provides a CPU frequency adjustment method, system, and storage medium for adjusting the CPU frequency to improve the CPU's energy efficiency ratio.
[0005] In a first aspect, this application provides a CPU frequency adjustment method, comprising: determining the maximum supported frequency of the CPU based at least on the type of the CPU and the CPU utilization rate within a first time interval; the maximum supported frequency of the CPU refers to the upper limit of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio; and determining the CPU frequency within a second time interval based on the maximum supported frequency of the CPU, such that the CPU frequency within the second time interval is less than or equal to the maximum supported frequency of the CPU.
[0006] Understandably, based on the method provided in this application, the BIOS determines the CPU utilization rate within a first time interval based on parameters such as CPU type and CPU frequency; then, based on the CPU utilization rate, it determines the maximum supported CPU frequency (the maximum supported CPU frequency refers to the upper limit of the CPU frequency when the CPU is greater than or equal to a preset energy efficiency ratio); and adjusts the CPU frequency within a second time interval based on the CPU utilization rate, so that the adjusted CPU frequency is less than or equal to the CPU's maximum supported frequency. Thus, compared to related technologies that adjust the CPU frequency solely based on CPU utilization rate, this application embodiment can also determine the CPU utilization rate based on the CPU type, fully considering the differences between different CPU models, and thereby improving the CPU's energy efficiency ratio by adjusting the CPU frequency. Furthermore, the entire process does not require manual parameter configuration by the user, effectively improving operational efficiency.
[0007] In one possible implementation, determining the maximum supported frequency of the CPU based at least on the CPU type and the CPU utilization rate within a first time interval includes: determining the CPU frequency adjustment coefficient based on the CPU type and the CPU utilization rate; the frequency adjustment coefficient refers to the maximum adjustment range of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio; and determining the maximum supported frequency of the CPU based on the CPU frequency adjustment coefficient.
[0008] It is understood that, based on the method provided in the embodiments of this application, the maximum supported frequency of the CPU is determined according to the frequency modulation coefficient. This frequency modulation coefficient is determined by parameters such as the CPU type and CPU utilization rate, reflecting the maximum frequency adjustment range of the CPU while meeting a preset energy efficiency ratio. Thus, the maximum supported frequency of the CPU determined based on the CPU's frequency modulation coefficient reflects the upper limit of the CPU's frequency while meeting the preset energy efficiency ratio. Therefore, the CPU frequency determined based on the CPU's maximum supported frequency is the optimal CPU frequency to meet the preset energy efficiency ratio.
[0009] In another possible implementation, determining the CPU frequency scaling factor based on the CPU type and CPU utilization includes: determining the CPU frequency scaling factor from a first preset mapping relationship based on the CPU type and CPU utilization; wherein the first preset mapping relationship includes the mapping relationship between the CPU type and CPU utilization and the CPU frequency scaling factor.
[0010] It is understood that, based on the method provided in the embodiments of this application, the adjustment range of the CPU frequency (i.e., the CPU frequency adjustment coefficient) can be determined according to parameters such as the CPU type and CPU utilization rate. In this way, compared with the method in the prior art that only determines the CPU frequency based on the CPU utilization rate, the factors affecting the CPU frequency can be considered from multiple aspects, such as the CPU performance and the CPU energy efficiency ratio, so as to accurately determine the CPU frequency while improving the CPU energy efficiency ratio.
[0011] In another possible implementation, determining the maximum supported frequency of the CPU based at least on the CPU type and the CPU utilization rate during the first time interval includes: determining the maximum supported frequency of the CPU based on the CPU type, the CPU utilization rate, and the type of operating system (OS) running on the CPU.
[0012] It is understandable that different types of operating systems have different performance levels, and therefore the corresponding CPU frequency scaling factors will also be different. For example, if an operating system runs faster and has fewer signaling interactions, the CPU working with that operating system will have higher energy efficiency, and the maximum supported frequency of the CPU can be lower. Conversely, if an operating system runs slower and has more signaling interactions, the CPU working with that operating system will have lower energy efficiency, and the maximum supported frequency of the CPU can be higher.
[0013] In another possible implementation, the CPU utilization rate mentioned above includes the average CPU utilization rate; the average CPU utilization rate refers to the average utilization rate of the multiple CPU cores included in the CPU.
[0014] It is understood that the method provided in this application determines the utilization rate of each CPU core by reading the frequency of each CPU core among multiple CPU cores, and then determines the average CPU utilization rate based on the utilization rates of multiple CPU cores. Thus, compared to related technologies that determine CPU utilization rate based only on the frequency of a single CPU core, the method provided in this application can take into account the frequency of each CPU core, reducing the error in the calculated CPU utilization rate.
[0015] In another possible implementation, the method further includes determining the duration of the second time interval based on the CPU type, CPU utilization, and the type of OS running on the CPU.
[0016] In another possible implementation, determining the duration of the second time interval based on the CPU type, CPU utilization, and OS type includes: determining a target timing duration from a second preset mapping relationship based on the CPU type, CPU utilization, and OS type; wherein the second preset mapping relationship includes the mapping relationship between the CPU type, CPU utilization, and OS type and the target timing duration; the target timing duration refers to the target timing duration for obtaining the CPU frequency that matches the CPU type, OS type, and CPU utilization; and determining the duration of the second time interval based on the target timing duration.
[0017] It is understood that in this embodiment, the duration of the second time interval is related to the target timing duration. The target timing duration is related to CPU utilization. For example, when CPU utilization is high, to ensure task processing speed, the CPU frequency needs to be adjusted quickly. Therefore, the target timing duration needs to be shortened, and the scanning frequency increased to quickly adjust the CPU frequency. When CPU utilization is low, the CPU frequency requirement is lower. If the target timing duration is short and the scanning frequency is fast, the repetition rate of the acquired data is high, so the target timing duration can be increased. The target timing duration is related to the OS type. Different OS types correspond to different target timing durations and different scanning frequencies. For example, Linux runs faster than Windows, so Linux corresponds to a shorter target timing duration and a faster scanning frequency, while Windows corresponds to a longer target timing duration and a slower scanning frequency. The target timing duration is also related to the CPU type. Different CPU types correspond to different target timing durations. For example, a faster CPU corresponds to a shorter target timing duration, while a slower CPU corresponds to a longer target timing duration.
[0018] Secondly, this application provides a CPU frequency adjustment system, comprising: a determining module, configured to determine the maximum supported frequency of the CPU based at least on the type of the CPU and the CPU utilization rate within a first time interval; the maximum supported frequency of the CPU refers to the upper limit of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio; an adjusting module, configured to determine the CPU frequency within a second time interval based on the CPU's maximum supported frequency, such that the CPU frequency within the second time interval is less than or equal to the CPU's maximum supported frequency; the second time interval is after the first time interval.
[0019] In one possible implementation, a determining module is specifically used to determine the CPU's frequency scaling factor based on the CPU type and CPU utilization rate; the frequency scaling factor refers to the maximum adjustment range of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio; and the maximum supported frequency of the CPU is determined based on the CPU's frequency scaling factor.
[0020] In another possible implementation, the determining module is specifically used to determine the CPU frequency modulation coefficient from a first preset mapping relationship based on the CPU type and CPU utilization rate; wherein the first preset mapping relationship includes the mapping relationship between the CPU type and CPU utilization rate and the CPU frequency modulation coefficient.
[0021] In another possible implementation, a determining module is used to determine the maximum supported frequency of the CPU based on the CPU type, CPU utilization, and the type of operating system (OS) running on the CPU.
[0022] In another possible implementation, CPU utilization includes average CPU utilization; average CPU utilization refers to the average utilization of the multiple CPU cores included in the CPU.
[0023] In another possible implementation, the determining module is also used to determine the duration of the second time interval based on the type of CPU, the CPU utilization rate, and the type of OS running on the CPU.
[0024] In another possible implementation, a determining module is specifically used to determine the target timing duration from a second preset mapping relationship based on the CPU type, CPU utilization, and OS type; wherein the second preset mapping relationship includes the mapping relationship between the CPU type, CPU utilization, and OS type and the target timing duration; the target timing duration refers to the target timing duration for obtaining the CPU frequency that matches the CPU type, OS type, and CPU utilization; and the duration of the second time interval is determined based on the target timing duration.
[0025] Thirdly, this application provides a CPU, including: an interface and logic circuitry, wherein the logic circuitry is used to execute any of the CPU frequency adjustment methods provided in the first aspect above.
[0026] Fourthly, this application provides a CPU frequency adjustment system, including: an OS, and a basic input / output system BIOS that communicates with the OS; the BIOS is used to execute any of the CPU frequency adjustment methods provided in the first aspect above.
[0027] Fifthly, this application provides a computer device, which includes a processor and a memory; the processor is coupled to the memory; the memory is used to store computer instructions, which are loaded and executed by the processor to enable the computer device to implement any of the CPU frequency adjustment methods provided in the first aspect above.
[0028] Sixthly, this application provides a computer-readable storage medium storing computer-executable instructions that, when executed on a computer, cause the computer to perform any of the CPU frequency adjustment methods provided in the first aspect.
[0029] In a seventh aspect, this application provides a computer program product including computer instructions that, when executed on a computer, cause the computer to perform any of the CPU frequency adjustment methods provided in the first aspect.
[0030] For a detailed description of aspects two through seven and their various implementations in this application, please refer to the detailed description in aspect one and its various implementations; and for a detailed description of the beneficial effects of aspects two through seven and their various implementations, please refer to the beneficial effect analysis in aspect one and its various implementations, which will not be repeated here.
[0031] These or other aspects of this application will become more readily apparent in the following description. Attached Figure Description
[0032] Figure 1 A schematic diagram of the hardware environment involved in a CPU frequency adjustment method provided in an embodiment of this application;
[0033] Figure 2 A flowchart of a CPU frequency adjustment method provided in this application embodiment Figure 1 ;
[0034] Figure 3 A flowchart of a CPU frequency adjustment method provided in this application embodiment Figure 2 ;
[0035] Figure 4 A statistical chart of CPU energy efficiency ratio provided for embodiments of this application;
[0036] Figure 5 This is a schematic diagram of a CPU frequency adjustment system provided in an embodiment of this application. Detailed Implementation
[0037] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0038] The terms "first" and "second," etc., used in the specification and drawings of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.
[0039] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.
[0040] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0041] In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0042] The CPU is the most energy-consuming component in a server. Reducing CPU energy consumption per unit generally relies on improvements in chip manufacturing processes. Taking the x86 operating system as an example, the CPU's energy efficiency ratio (EER, which is the ratio of energy conversion efficiency; a higher EER means more energy savings) increases by an average of 20% with each generation. This improvement in EER requires cooperation between the chip and the OS's frequency tuning software. Currently, most server manufacturers use a generic frequency tuning method based on the OS. However, due to differences in the heat dissipation capabilities of different CPU models, this generic method cannot adjust the CPU frequency to optimal parameters. In practice, users often need to manually configure parameters, reducing operational efficiency.
[0043] Therefore, CPU energy-saving technologies in related fields have poor applicability and poor energy-saving effects.
[0044] To address the aforementioned technical problems, this application provides a method for adjusting the CPU frequency. The method involves: the BIOS determining the CPU utilization rate within a first time interval based on parameters such as CPU type and CPU frequency; then determining the maximum supported CPU frequency (the maximum supported CPU frequency refers to the upper limit of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio) based on the CPU utilization rate; and finally determining the CPU frequency within a second time interval based on the CPU utilization rate, ensuring that the CPU frequency within the second time interval is less than or equal to the CPU's maximum supported frequency. Thus, compared to related technologies that adjust the CPU frequency solely based on CPU utilization rate, this application's embodiment can also determine the CPU utilization rate based on the CPU type, fully considering the differences between different CPU models. By adjusting the CPU frequency, the CPU's energy efficiency ratio can be improved, and the entire process requires no manual parameter configuration by the user, effectively improving operational efficiency.
[0045] The embodiments provided in this application will now be described in detail with reference to the accompanying drawings.
[0046] The technical solutions provided in this application can be applied to computer devices. The hardware of the computer device includes a processor, an out-of-band controller, and memory, while the software mainly includes an out-of-band management module, processor firmware, and an operating system (OS) management unit.
[0047] The processor may include a CPU, which contains one or more CPU cores. All data processing operations of the CPU are performed by the CPU cores. The more CPU cores a CPU contains, the faster it can process data.
[0048] The out-of-band management module is located within the out-of-band controller, the OS management unit is located within the processor, and the processor firmware can be located within the processor (e.g., ...). Figure 1 (as shown), or the processor firmware can also be located on a firmware chip outside the processor (as shown). Figure 1 (Not shown in the text)
[0049] The out-of-band management module can be a management unit for non-business modules. For example, the out-of-band management module can remotely maintain and manage computer equipment through a dedicated data channel. This out-of-band management module is completely independent of the computer equipment's operating system and can communicate with the basic input / output system (BIOS) and the operating system (or OS management unit) through the computer equipment's out-of-band management interface.
[0050] The BIOS is a set of programs embedded in a ROM chip on the computer's motherboard. The BIOS stores the computer's most important basic input / output programs, power-on self-test (POST) programs, and system boot programs. The main function of the BIOS is to provide the lowest-level, most direct hardware settings and control for the computer.
[0051] For example, an out-of-band management module may include a management unit for the operating status of a computer device, a management system in a management chip outside the processor, a baseboard management controller (BMC), a system management mode (SMM), etc. It should be noted that the specific form of the out-of-band management module is not limited in the embodiments of this application; the above is merely illustrative. In the following embodiments, only a BMC is used as an example of an out-of-band management module for explanation.
[0052] For example, processor firmware (also known as processor firmware program) can be firmware, basic input output system (BIOS), management engine (ME), microcode, or intelligent management unit (IMU), etc. It should be noted that the specific form of the processor firmware in this application embodiment is not limited; the above is merely illustrative. In the following embodiments, only the BIOS processor firmware is used as an example for explanation.
[0053] Memory, also known as internal memory or main memory, is installed in memory slots on the motherboard of a computer device.
[0054] It should be noted that the system architecture and application scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0055] It should be noted that the executing entity of the central processing unit frequency adjustment method provided in this application embodiment is not limited. For example, the method can be executed by the computer device itself or by the BIOS in the computer device. For ease of subsequent explanation, the following embodiments will use the execution of the method by the BIOS as an example.
[0056] The following is a detailed description of a central processing unit frequency adjustment method provided in an embodiment of this application.
[0057] The central processing unit frequency adjustment method provided in this application embodiment can be derived from, for example: Figure 1 The BIOS in the server shown is used to execute this. Optionally, the method provided in this application embodiment may include a preparation phase and a frequency tuning phase.
[0058] The preparation phase precedes the frequency modulation phase. For details regarding the preparation and frequency modulation phases, please refer to the following examples.
[0059] I. Preparation Stage
[0060] like Figure 2 As shown, the preparation phase may include the following steps:
[0061] S101: After startup, the BIOS obtains information about the CPU and the OS.
[0062] Here, the CPU is the CPU in the server where the BIOS is located, and the OS is the operating system running on the CPU of that server.
[0063] The CPU information includes: CPU type, CPU frequency parameters, and CPU basic configuration.
[0064] For example, CPU types include: Intel Core 2 DUO P8400 CPU 2.26GHz, Core i5-12400F, Ryzen R3-3300K or AMD 3950X 16-core, etc.
[0065] As one possible implementation, the BIOS obtains the CPU type through the CPUID. The CPUID is a supplementary instruction for x86 architecture processors, used to discover detailed CPU information.
[0066] For example, CPU frequency parameters include: CPU clock speed, CPU external clock speed, and / or CPU multiplier, etc.
[0067] As one possible implementation, the BIOS obtains the CPU's frequency parameters through a model-specific register (MSR). The MSR is a register in the x86 architecture used to control CPU operation and monitor CPU performance.
[0068] For example, the basic configuration of a CPU includes configuration information such as setting up CPU overclocking. CPU overclocking refers to artificially increasing the CPU's base clock speed or multiplier to significantly increase its operating frequency.
[0069] One possible implementation is to enter the Setup interface in the BIOS to configure the CPU's basic settings. This Setup interface contains multiple settings for configuring the CPU's operating mode. For example, the BIOS can enter the Setup interface and enable the Turbo function (i.e., CPU overclocking) to turn it on and off.
[0070] Understandably, CPU information reflects CPU performance. For example, assuming a CPU type is an Intel Core 2 Duo P8400 CPU 2.26GHz, this CPU has a clock speed of 2.26GHz, supports 64-bit computing, and includes two CPU cores. As another example, assuming a CPU type is a Core i5-12400F, this CPU has a clock speed of 3.7-4.4GHz, supports 64-bit computing, and includes six CPU cores. It's clear that a higher CPU clock speed means a larger number of bits supported, resulting in faster processing speed and better performance. Similarly, a CPU with more CPU cores also tends to have faster processing speeds and better performance.
[0071] The OS information mentioned above includes details such as the OS type. For example, the OS type includes Windows, Linux, or Mac.
[0072] As one possible implementation, the BIOS obtains the OS type through the Advanced Configuration and Power Management Interface (ACPI). The ACPI defines the working interface between the BIOS and the OS, serving as a bridge between them.
[0073] Understandably, the type of operating system (OS) can reflect its performance. For example, suppose OS types include Windows and Linux; Linux runs faster than Windows. For the same task, Linux involves more signaling interactions than Windows; therefore, Linux has a higher energy efficiency ratio than Windows.
[0074] S102. Determine the maximum frequency and minimum frequency of the CPU.
[0075] The CPU's maximum frequency (max_freq) specifies the maximum frequency at which the CPU can operate, while the CPU's minimum frequency (min_freq) specifies the minimum frequency at which the CPU can operate.
[0076] `max_freq` and `min_freq` are fixed values determined by the CPU's hardware characteristics. For example, `min_freq` is typically 800M; `max_freq` can be 2.0GHz or 3.0GHz, etc.
[0077] In some embodiments, max_freq can be determined based on the CPU's frequency parameters and its basic configuration. For example, when the CPU overclocking function is not enabled, max_freq can be the CPU's base frequency; when the CPU overclocking function is enabled, max_freq can be the overclocked frequency.
[0078] It is understandable that since min_freq and max_freq limit the minimum and maximum frequencies that the CPU can run, the CPU frequency determined subsequently must be within the range defined by [min_freq, max_freq].
[0079] S103. Import the CPU frequency modulation feature library into the BIOS.
[0080] In some embodiments, the frequency modulation feature library includes a variety of parameters and the mapping relationship between the various parameters.
[0081] Optionally, the CPU frequency modulation feature library includes at least one or more of the following parameters: CPU type, OS type, CPU utilization, CPU frequency modulation coefficient, CPU maximum frequency, CPU minimum frequency, and target timing duration.
[0082] The aforementioned CPU frequency adjustment coefficient reflects the maximum frequency adjustment range of the CPU when the CPU's energy efficiency ratio (the ratio of CPU performance to power consumption) is greater than or equal to the preset energy efficiency ratio. The preset energy efficiency ratio refers to the CPU's energy efficiency ratio in the OS's default frequency adjustment mode; for example, the OS's default frequency adjustment mode can be on-demand or conservation mode, etc. The preset energy efficiency ratio of the same type of CPU may be different under different types of OS, and the preset energy efficiency ratio corresponding to different types of CPUs may also be different. This application embodiment does not limit this.
[0083] It's understandable that the CPU's frequency scaling factor is preset. Specifically, first, the CPU's initial frequency is calculated based on parameters such as CPU type and CPU utilization. Then, the CPU's energy efficiency ratio (EER) is determined based on the initial frequency, and it's checked whether the EER meets the preset EER. If not, the CPU's initial frequency is adjusted to obtain the CPU's final frequency that meets the preset EER. The adjustment amount by which the CPU's initial frequency is adjusted to its final frequency is the CPU's frequency scaling factor.
[0084] The target timing duration mentioned above refers to the timing duration for acquiring the CPU frequency, which is matched with the CPU type, OS type, and CPU utilization.
[0085] It is understandable that when acquiring CPU frequency, a timer is typically used to measure the CPU frequency within a pre-set timeout period. Since different types of CPUs, different types of operating systems, and different CPU utilization rates all correspond to different timeout periods, this embodiment of the application can pre-calculate an optimal target timeout period based on different combinations of CPU type, CPU utilization rate, and OS type. Thus, during CPU frequency adjustment, the actual timeout period can be calibrated according to the pre-set target timeout period.
[0086] For example, when the CPU frequency modulation feature library includes at least one CPU type, at least one CPU utilization rate, and at least one CPU frequency modulation coefficient, the CPU frequency modulation feature library includes a first preset mapping relationship; wherein, the first preset mapping relationship includes a mapping relationship between at least one CPU type, at least one CPU utilization rate, and at least one CPU frequency modulation coefficient. As another example, when the CPU frequency modulation feature library also includes at least one OS type, the aforementioned first preset mapping relationship further includes a mapping relationship between at least one CPU type, at least one OS type, at least one CPU utilization rate, and at least one CPU frequency modulation coefficient.
[0087] For example, the first preset mapping relationship can be in the form shown in Table 1:
[0088] Table 1
[0089] CPU type OS type CPU utilization CPU frequency modulation coefficient CPU type 1 Windows 30%-50% 0.5 CPU type 1 Windows 60%-70% 0.6 CPU type 1 Windows 80%-100% 1 CPU type 1 Linux 30%-50% 0.4 CPU type 1 Linux 60%-70% 0.5 CPU type 1 Linux 80%-100% 0.9 CPU Type 2 Windows 30%-50% 0.55 CPU Type 2 Windows 60%-70% 0.65 CPU Type 2 Windows 80%-100% 1
[0090] In another example, when the CPU frequency modulation feature library includes at least one CPU type, at least one OS type, at least one CPU utilization rate, and at least one target timing duration, the CPU frequency modulation feature library includes a second mapping relationship; wherein the second mapping relationship includes a mapping relationship between at least one CPU type, at least one OS type, and at least one CPU utilization rate, and at least one target timing duration.
[0091] For example, the CPU frequency modulation feature library can be in the form shown in Table 2:
[0092] Table 2
[0093] CPU type OS type CPU utilization Target timing duration CPU type 1 Windows 30%-50% 30ms CPU type 1 Windows 60%-70% 20ms CPU type 1 Windows 80%-100% 10ms CPU type 1 Linux 30%-50% 20ms CPU type 1 Linux 60%-70% 15ms CPU type 1 Linux 80%-100% 10ms CPU Type 2 Windows 30%-50% 25ms CPU Type 2 Windows 60%-70% 18ms CPU Type 2 Windows 80%-100% 12ms
[0094] S104. Register the timer callback function in the BIOS.
[0095] The timer callback function is used to adjust the timer to start counting when the timer times out, so that the timer can execute the next counting cycle.
[0096] S105. Initialize the timer.
[0097] It is understandable that initializing the timer allows you to define parameters such as the timer's operating mode, timing period, and timing duration, and then start the timer so that the BIOS can call the timer during the frequency adjustment phase.
[0098] In summary, before entering the frequency adjustment phase, the CPU and OS information should be obtained first, and the CPU frequency adjustment feature library and timer callback functions should be imported into the BIOS to prepare for the process. In this way, after entering the frequency adjustment phase, the BIOS can directly use the CPU and OS information, and directly call the frequency adjustment feature library and timer callback functions, thereby improving the efficiency of operation and maintenance.
[0099] II. Frequency Modulation Phase
[0100] In some embodiments, the execution entity for the frequency modulation phase can be the BIOS, such as... Figure 3 As shown, the frequency modulation stage may include the following steps:
[0101] S201. Obtain the CPU frequency within the first time interval and calculate the CPU utilization rate.
[0102] The CPU utilization rate mentioned above reflects the CPU resources used by programs running on the server during the first time interval.
[0103] In some embodiments, the CPU includes multiple CPU cores, then obtaining the CPU frequency within the first time interval includes obtaining the frequencies of the multiple CPU cores included in the CPU within the first time interval. The CPU utilization rate can be the average CPU utilization rate, that is, the average utilization rate of the multiple CPU cores included in the CPU.
[0104] For example, the CPU frequency within a first time interval can be obtained by calling a timer, and the average CPU utilization can be calculated based on the CPU frequency within the first time interval. Specifically, this can be achieved through the following steps:
[0105] Step a1: Call the timer.
[0106] The timer's duration is the length of the first time interval.
[0107] Step a2: Upon receiving the first interrupt signal, obtain the first CPU frequency of each CPU core among the multiple CPU cores.
[0108] The first interrupt signal is a system management interrupt (SMI) triggered when the timer reaches the first time point. For example, the first time point can be the time when the timer starts counting.
[0109] The SMI mentioned above is an interrupt signal mechanism, triggered by hardware and processed by the BIOS. SMI is the highest priority interrupt.
[0110] Step a3: Upon receiving the second interrupt signal, obtain the second CPU frequency of each CPU core among the multiple CPU cores.
[0111] The second interrupt signal is an SMI triggered when the timer reaches the second time point. For example, the second time point can be the time when the timer ends. The second time point is after the first time point, and the time interval between the first and second time points is the first time interval.
[0112] Step a4: Calculate the utilization rate of each CPU core based on the first CPU frequency, second CPU frequency, first time point, and second time point of each CPU core.
[0113] For example, assuming that multiple CPU cores include a first CPU core (the first CPU core can be any one of the multiple CPU cores), the first CPU core has a first CPU frequency of C1, a second CPU frequency of C2, a first time point of T1, and a second time point of T2, then the utilization rate of the first CPU core satisfies the following formula (1):
[0114] CPU utilization rate = (C2-C1) / [(T2-T1)*f] Formula (1)
[0115] Where f is the CPU base frequency.
[0116] Step a5: Determine the average CPU utilization rate based on the utilization rate of each CPU core among multiple CPU cores.
[0117] In some embodiments, the average CPU utilization rate is the average utilization rate of multiple CPU cores.
[0118] For example, suppose the CPU cores include: a first CPU core, a second CPU core, and a third CPU core; wherein the utilization rate of the first CPU core is 30%, the utilization rate of the second CPU core is 60%, and the utilization rate of the third CPU core is 90%, then the average CPU utilization rate is: (30% + 60% + 90%) / 3 = 60%.
[0119] It is understood that the method provided in this application determines the utilization rate of each CPU core by reading the frequency of each CPU core among multiple CPU cores, and then determines the average CPU utilization rate based on the utilization rates of multiple CPU cores. Thus, compared to related technologies that determine CPU utilization rate based only on the frequency of a single CPU core, the method provided in this application can take into account the frequency of each CPU core, reducing the error in the calculated CPU utilization rate.
[0120] S202. Determine the CPU frequency adjustment coefficient based at least on the CPU type and the CPU utilization rate during the first time interval.
[0121] Understandably, different types of CPUs have different performance characteristics, therefore their corresponding frequency adjustment factors also differ. For example, a high-performance CPU operates faster, so its frequency adjustment range can be smaller; conversely, a low-performance CPU operates slower, requiring a higher frequency to ensure task processing speed, thus necessitating a larger frequency adjustment range. CPU utilization also affects its frequency. For instance, a high CPU utilization requires a higher frequency to maintain task processing speed, allowing for a larger frequency adjustment range; conversely, a low CPU utilization requires a lower frequency, allowing for a smaller frequency adjustment range.
[0122] As one possible implementation, step S202 above can be implemented as follows: determining the CPU frequency modulation coefficient from the first preset mapping relationship based on the CPU type and CPU utilization rate.
[0123] The first preset mapping relationship includes the mapping relationship between the CPU type and CPU utilization rate and the CPU frequency adjustment coefficient.
[0124] For example, if the CPU type is CPU1, the CPU utilization rate is 45%, and the first preset mapping relationship is shown in Table 1, then the CPU frequency adjustment coefficient is 0.5.
[0125] In some embodiments, determining the CPU frequency scaling factor based at least on the CPU type and the CPU utilization rate during the first time interval further includes determining the CPU frequency scaling factor based on the OS type, the CPU type, and the CPU utilization rate.
[0126] It is understandable that different types of operating systems have different performance, and therefore the CPU frequency adjustment coefficients corresponding to different types of operating systems are also different. For example, if the operating system runs faster and has fewer signaling interactions, the CPU working with that operating system will have higher energy efficiency, and the CPU frequency adjustment range can be smaller. If the operating system runs slower and has more signaling interactions, the CPU working with that operating system will have lower energy efficiency, and the CPU frequency adjustment range can be larger.
[0127] As one possible implementation, the aforementioned first preset mapping relationship also includes: a mapping relationship between the OS type, CPU type, CPU utilization, and CPU frequency scaling factor. Thus, the above method can be implemented as follows: determining the CPU frequency scaling factor from the first preset mapping relationship based on the OS type, CPU type, and CPU utilization.
[0128] For example, the OS type can be Windows, the CPU type is CPU type 1, the CPU utilization rate is 80%, the first preset mapping relationship is shown in Table 1, then the CPU frequency adjustment coefficient is 1.
[0129] It is understood that, based on the method provided in the embodiments of this application, the adjustment range of the CPU frequency (i.e., the CPU frequency adjustment coefficient) can be determined according to parameters such as the CPU type, OS type, and CPU utilization. In this way, compared with the prior art method of determining the CPU frequency only based on the CPU utilization, the influence factors of the CPU frequency can be considered from multiple aspects, such as the CPU performance, OS performance, and CPU energy efficiency ratio, so as to accurately determine the CPU frequency while improving the CPU energy efficiency ratio.
[0130] S203. Determine the maximum supported frequency of the CPU based on the CPU's frequency modulation coefficient.
[0131] The maximum supported frequency of a CPU refers to the upper limit of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to the preset energy efficiency ratio.
[0132] In some embodiments, step S203 above can be implemented as follows: determining the maximum supported frequency of the CPU based on the CPU's maximum frequency max_freq, the CPU's minimum frequency min_freq, the CPU's utilization rate, and the frequency modulation coefficient. For example, the maximum supported frequency of the CPU satisfies the following formula (2):
[0133] f = min_freq + CPU frequency adjustment coefficient × CPU utilization rate × (max_freq - min_freq) × 100% Formula (2)
[0134] Where f is the maximum supported frequency of the CPU.
[0135] It is understood that, based on the method provided in the embodiments of this application, the maximum supported frequency of the CPU is determined according to the frequency modulation coefficient. This frequency modulation coefficient is determined by parameters such as the CPU type and CPU utilization rate, reflecting the maximum frequency adjustment range of the CPU while meeting a preset energy efficiency ratio. Thus, the maximum supported frequency of the CPU determined based on the CPU's frequency modulation coefficient reflects the upper limit of the CPU's frequency while meeting the preset energy efficiency ratio. Therefore, the CPU frequency determined based on the CPU's maximum supported frequency is the optimal CPU frequency to meet the preset energy efficiency ratio.
[0136] S204. Adjust the CPU frequency within the second time interval according to the CPU's maximum supported frequency, so that the adjusted CPU frequency is less than or equal to the CPU's maximum supported frequency.
[0137] The second time interval occurs after the first time interval. Optionally, the duration of the second time interval may be the same as or different from the duration of the first time interval. In some embodiments, the method further includes determining the duration of the second time interval; the specific determination method is described in the following embodiments and will not be repeated here.
[0138] In some embodiments, step S204 can be implemented as follows: sending the maximum supported frequency of the CPU to the OS, and the OS adjusting the frequency of the CPU within the second time interval according to the maximum supported frequency of the CPU.
[0139] For example, assuming the OS is Linux and the OS uses the ondemand frequency adjustment mode, the OS can adjust the CPU frequency within the second time interval according to the CPU's maximum supported frequency, which can be achieved through the following steps:
[0140] Step b1: Calculate the CPU utilization rate during the first time interval.
[0141] Optionally, the CPU utilization rate can be the average CPU utilization rate, which is the average utilization rate of the multiple CPU cores included in the CPU.
[0142] Step b2: When the CPU utilization rate is greater than or equal to 80%, adjust the CPU frequency to the maximum supported frequency of the CPU.
[0143] In this embodiment, the maximum supported CPU frequency is less than or equal to max_freq. It is understood that the maximum supported CPU frequency is determined in real-time by the BIOS according to steps S201-S203, therefore, the maximum supported CPU frequency is variable. max_freq, determined by the CPU's hardware characteristics, is a fixed value. Therefore, in this embodiment, when the CPU utilization rate is greater than or equal to 80%, the CPU frequency is adjusted to the CPU's maximum supported frequency, which matches the current CPU type and CPU utilization rate. Compared to related technologies, adjusting the CPU frequency to max_freq effectively improves energy utilization efficiency.
[0144] Step b3: When the CPU utilization rate is less than 80%, determine the CPU frequency based on the maximum CPU frequency, the minimum CPU frequency, and the CPU utilization rate.
[0145] The maximum supported CPU frequency is less than or equal to the maximum CPU frequency (max_freq). It's understandable that the maximum supported CPU frequency is determined in real-time by the BIOS according to steps S201-S203 above; therefore, the maximum supported CPU frequency is variable. The maximum CPU frequency, however, is a fixed value determined by the CPU type.
[0146] For example, the CPU frequency can be determined according to the following formula (3):
[0147] CPU frequency = min_freq + CPU utilization rate × (max_freq - min_freq) × 100% Formula (3)
[0148] It is understood that, based on the method provided in this application embodiment, the BIOS determines the CPU utilization rate within a first time interval based on parameters such as CPU type and CPU frequency; then, based on the CPU utilization rate, it determines the maximum supported frequency of the CPU (the maximum supported frequency of the CPU refers to the upper limit of the CPU frequency when the CPU is greater than or equal to a preset energy efficiency ratio); and adjusts the CPU frequency within a second time interval based on the CPU utilization rate, so that the adjusted CPU frequency is less than or equal to the maximum supported frequency of the CPU. Thus, compared to the method in related technologies that only adjusts the CPU frequency based on the CPU utilization rate, this application embodiment can also determine the CPU utilization rate based on the CPU type, fully considering the differences between different CPU models, and thereby improving the CPU's energy efficiency ratio by adjusting the CPU frequency. Furthermore, the entire process does not require manual parameter configuration by the user, effectively improving operational efficiency.
[0149] In some embodiments, determining the duration of the second time interval can be achieved by determining the duration of the second time interval based on the type of OS, the type of CPU, and the CPU utilization rate.
[0150] As one possible implementation, the target timing duration is determined from a second preset mapping relationship based on the CPU type, CPU utilization, and OS type; then, the duration of the second time interval is determined based on the target timing duration.
[0151] The second preset mapping relationship includes the mapping relationship between CPU type, CPU utilization, OS type, and target timing duration. For example, the second preset mapping relationship can be in the form shown in Table 2.
[0152] For example, assuming the CPU type is CPU1, the OS type is Windows, the CPU utilization rate is 45%, and the second preset mapping relationship is in the form shown in Table 2, then the target timing duration is 30ms, and the duration of the second time interval is 30ms.
[0153] It is understandable that the target timing duration is related to the CPU utilization rate. For example, when the CPU utilization rate is high, in order to ensure the task processing speed, the CPU frequency needs to be adjusted quickly. Therefore, the target timing duration needs to be shortened and the scanning frequency increased, thereby quickly adjusting the CPU frequency. When the CPU utilization rate is low, the CPU frequency requirement is lower. If the target timing duration is short and the scanning frequency is fast, the repetition rate of the acquired data will be high. Therefore, the target timing duration can be increased.
[0154] The target timing duration is related to the type of operating system (OS). Different OS types have different target timing durations and scan frequencies. For example, Linux runs faster than Windows, so Linux has a shorter target timing duration and a faster scan frequency, while Windows has a longer target timing duration and a slower scan frequency.
[0155] The target timing duration is related to the type of CPU. Different types of CPUs have different target timing durations. For example, CPUs with faster processing speeds have shorter target timing durations, while CPUs with slower processing speeds have longer target timing durations.
[0156] Below, using servers built with Intel's V6 series 36-core CPU and Windows 2016, Windows 2019, and SUSE 15.2 operating systems as examples, the CPU frequency adjustment method provided in this application is used for adjustment. Simultaneously, server testing software (SPECpower) is used to test the energy efficiency ratio of the three combinations. The test results are as follows: Figure 4 As shown, by adjusting the CPU frequency using the method provided in this application embodiment, the CPU's energy efficiency ratio can be improved by 1%-13% (assuming an average power consumption of 600W per hour for each V6 system server, the annual power consumption of 10,000 servers is 600W×24h×365×10000=52.56 million kWh, thus saving approximately 530,000-6.83 million kWh of electricity per year), effectively improving energy utilization efficiency.
[0157] like Figure 5 As shown, this application embodiment provides a CPU frequency adjustment system for performing, such as Figure 3 The CPU frequency adjustment method shown is described. The CPU frequency adjustment system 300 includes: a determining module 301 and an adjusting module 302.
[0158] The determining module 301 is used to determine the maximum supported frequency of the CPU based at least on the type of CPU and the CPU utilization rate within a first time interval; the maximum supported frequency of the CPU refers to the upper limit of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio.
[0159] The adjustment module 302 is used to determine the CPU frequency within a second time interval based on the CPU's maximum supported frequency, so that the CPU frequency within the second time interval is less than or equal to the CPU's maximum supported frequency; the second time interval is after the first time interval.
[0160] In one possible implementation, the determining module 301 is specifically used to determine the CPU frequency adjustment coefficient based on the CPU type and CPU utilization rate; the frequency adjustment coefficient refers to the maximum adjustment range of the CPU frequency when the CPU's energy efficiency ratio is greater than or equal to a preset energy efficiency ratio; and the maximum supported frequency of the CPU is determined based on the CPU frequency adjustment coefficient.
[0161] In another possible implementation, the determining module 301 is specifically used to determine the CPU frequency modulation coefficient from a first preset mapping relationship based on the CPU type and CPU utilization rate; wherein, the first preset mapping relationship includes the mapping relationship between the CPU type and CPU utilization rate and the CPU frequency modulation coefficient.
[0162] In another possible implementation, the determining module 301 is specifically used to determine the maximum supported frequency of the CPU based on the CPU type, CPU utilization, and the type of operating system (OS) running on the CPU.
[0163] In another possible implementation, CPU utilization includes average CPU utilization; average CPU utilization refers to the average utilization of the multiple CPU cores included in the CPU.
[0164] In another possible implementation, the determining module 301 is also used to determine the duration of the second time interval based on the type of CPU, the CPU utilization rate, and the type of OS running on the CPU.
[0165] In another possible implementation, the determining module 301 is specifically used to determine the target timing duration from a second preset mapping relationship based on the CPU type, CPU utilization, and OS type; wherein, the second preset mapping relationship includes the mapping relationship between the CPU type, CPU utilization, OS type, and the target timing duration; the target timing duration refers to the target timing duration for obtaining the CPU frequency that matches the CPU type, OS type, and CPU utilization; and the duration of the second time interval is determined based on the target timing duration.
[0166] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the CPU frequency adjustment system can be divided into different functional modules to complete all or part of the functions described above.
[0167] This application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be executed by computer instructions instructing related hardware. The program can be stored in the computer-readable storage medium, and when executed, it can include the processes of the above method embodiments. The computer-readable storage medium can be any of the foregoing embodiments or memory. The computer-readable storage medium can also be an external storage device for the CPU frequency adjustment system, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the CPU frequency adjustment system. Further, the computer-readable storage medium can include both internal storage units of the CPU frequency adjustment system and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the CPU frequency adjustment system. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0168] This application also provides a computer program product, which includes a computer program that, when run on a computer, causes the computer to execute any of the CPU frequency adjustment methods provided in the above embodiments.
[0169] Although this application has been described herein in conjunction with various embodiments, those skilled in the art, by reviewing the accompanying drawings, disclosure, and appended claims, will understand and implement other variations of the disclosed embodiments in carrying out the claimed application. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude multiple components. A single processor or other unit can implement several functions listed in the claims. While different dependent claims may recite certain measures, this does not mean that these measures cannot be combined to produce good results.
[0170] Although this application has been described in conjunction with specific features and embodiments, it is obvious that various modifications and combinations can be made thereto without departing from the spirit and scope of this application. Accordingly, this specification and drawings are merely exemplary illustrations of this application as defined by the appended claims, and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of this application. Clearly, those skilled in the art can make various alterations and modifications to this application without departing from the spirit and scope of this application. Thus, if such modifications and modifications of this application fall within the scope of the claims of this application and their equivalents, this application is also intended to include such modifications and modifications.
[0171] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for adjusting the frequency of a central processing unit (CPU), characterized in that, The method includes: The maximum supported frequency of the CPU is determined based at least on the type of the CPU and the CPU utilization rate within the first time interval; the maximum supported frequency of the CPU refers to the upper limit of the CPU frequency when the energy efficiency ratio of the CPU is greater than or equal to a preset energy efficiency ratio. The frequency of the CPU within a second time interval is determined based on the maximum supported frequency of the CPU, such that the frequency of the CPU within the second time interval is less than or equal to the maximum supported frequency of the CPU.
2. The method according to claim 1, characterized in that, Determining the maximum supported frequency of the CPU based at least on the type of the CPU and the CPU utilization rate during the first time interval includes: The frequency adjustment factor of the CPU is determined based on the type of CPU and the utilization rate of the CPU; the frequency adjustment factor refers to the maximum adjustment range of the CPU frequency when the energy efficiency ratio of the CPU is greater than or equal to the preset energy efficiency ratio. The maximum supported frequency of the CPU is determined based on the CPU's frequency modulation coefficient.
3. The method according to claim 2, characterized in that, Determining the CPU frequency modulation coefficient based on the CPU type and CPU utilization includes: Based on the CPU type and the CPU utilization rate, the CPU frequency adjustment coefficient is determined from a first preset mapping relationship; wherein, the first preset mapping relationship includes the mapping relationship between the CPU type and the CPU utilization rate and the CPU frequency adjustment coefficient.
4. The method according to any one of claims 1 to 3, characterized in that, Determining the maximum supported frequency of the CPU based at least on the type of the CPU and the CPU utilization rate during a first time interval includes: The maximum supported frequency of the CPU is determined based on the type of CPU, the CPU utilization rate, and the type of operating system (OS) running on the CPU.
5. The method according to any one of claims 1 to 3, characterized in that, The CPU utilization rate includes the average CPU utilization rate; the average CPU utilization rate refers to the average utilization rate of the multiple CPU cores included in the CPU.
6. The method according to any one of claims 1 to 3, characterized in that, The method further includes: The duration of the second time interval is determined based on the type of CPU, the CPU utilization rate, and the type of OS running on the CPU.
7. The method according to claim 6, characterized in that, Determining the duration of the second time interval based on the CPU type, CPU utilization, and OS type includes: Based on the CPU type, CPU utilization, and OS type, a target timing duration is determined from a second preset mapping relationship; wherein, the second preset mapping relationship includes the mapping relationship between the CPU type, CPU utilization, and OS type and the target timing duration; the target timing duration refers to the target timing duration for obtaining the CPU frequency that matches the CPU type, OS type, and CPU utilization. The duration of the second time interval is determined based on the target timing duration.
8. A CPU, characterized in that, include: An interface and logic circuitry, the logic circuitry being used to perform the CPU frequency adjustment method as described in any one of claims 1 to 7.
9. A CPU frequency adjustment system, characterized in that, include: OS, and the BIOS, the underlying input / output system that communicates with the OS; The BIOS is used to execute the CPU frequency adjustment method as described in any one of claims 1 to 7.
10. A computer device, characterized in that, The computer device includes a processor and a memory; the processor is coupled to the memory; the memory is used to store computer instructions, which are loaded and executed by the processor to enable the computer device to implement the CPU frequency adjustment method as described in any one of claims 1 to 7.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when executed on a computer, cause the computer to perform the CPU frequency adjustment method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Computing capability description method, interaction method and node device for fog computing
US20190190789A1
Energy efficiency adjustments for a CPU governor
US20210224119A1