Control method and device of central processing unit, equipment and medium
By dynamically adjusting the core operating status of multi-core CPUs and adjusting the core activation and interruption according to the current usage rate, the task termination and performance degradation caused by excessive mechanical methods of reducing CPU power consumption in the existing technology is solved, and the performance and performance are ensured. Under the premise of life, the effect of dynamically reducing CPU power consumption.
Patent Information
- Application Number
- CN202411519652.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-29
AI Technical Summary
The existing methods of reducing CPU power consumption are too mechanical, which can easily lead to task termination and CPU performance degradation.
By dynamically adjusting CPU performance, the core with the lowest usage rate is determined based on the current usage rate of each core of the multi-core CPU and interrupting its operation until its usage exceeds the preset range, and then enable the core.
While ensuring CPU performance and service life, dynamically reduce CPU power consumption to avoid task termination and performance degradation.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] The present disclosure generally relates to the field of computer technology, and more particularly to a method, device, equipment and medium for controlling a central processing unit. Background Art
[0002] For Linux systems, they are often equipped with multi-core central processing units (CPUs). For multi-core CPUs, each core runs a process at the same time, and different processes are run serially between multiple cores.
[0003] In order to reduce the power consumption of a multi-core CPU during use, in related technologies, the CPU energy consumption is controlled by adjusting and controlling the CPU clock frequency. Specifically, the CPU power management settings can be found and modified through software tools to reduce or increase the CPU clock frequency, thereby controlling the CPU operating energy consumption; or the CPU operating parameters can be directly modified manually through software tools to control the CPU operating energy consumption.
[0004] However, in the process of modifying and controlling the CPU's operating energy consumption through software tools, since the CPU's originally selected operating parameters are directly modified, the CPU terminal load may be too high, leading to task termination and CPU performance degradation. Summary of the invention
[0005] In view of the above-mentioned defects or deficiencies in the related art, it is desired to provide a central processing unit control method, device, equipment and medium, which can solve the problem that the existing method of reducing CPU power consumption is too mechanical and easily leads to task termination and CPU performance degradation, dynamically adjust the CPU performance according to the actual situation of CPU execution, and timely reduce the CPU power consumption while ensuring the CPU performance and service life.
[0006] In a first aspect, a method for controlling a central processing unit is provided, the method comprising: Acquire usage parameters of a central processing unit, wherein the usage parameters include usage parameters of a central processing unit, and the central processing unit is a multi-core central processing unit; According to the usage parameter, obtaining the usage rate of each core currently enabled by the central processing unit; In the case where the usage rate of each of the currently enabled cores is within a preset usage rate range, determining a first core with the lowest usage rate among each of the currently enabled cores, determining a target process corresponding to the first core, releasing the correspondence between the target process and the first core and interrupting the operation of the first core until the usage rate of any core among the currently enabled cores of the central processor exceeds the preset usage rate range, and the first core is the process executed by the only core that executes the target process; Enable the first core.
[0007] In the present application, the usage parameters of the central processing unit are first obtained (the usage parameters include the usage parameters of the central processing unit, and the central processing unit is a multi-core central processing unit), and then, according to the usage parameters, the usage rate of each core currently enabled in the central processing unit is obtained; then, when the usage rate of each of the above cores is within the preset usage rate range, the first core with the lowest usage rate among the above cores currently enabled is determined, and the target process corresponding to the first core is determined, the corresponding relationship between the target process and the first core is released and the operation of the first core is interrupted, until the usage rate of any core of the core currently enabled by the central processing unit exceeds the preset usage rate range (the first core is the only core that executes the above target process); finally, the above first core is enabled. In this way, by continuously and dynamically determining the relationship between the currently enabled core in the central processing unit and the preset usage rate range, the first core with the lowest usage rate is dynamically closed or enabled according to the relationship, and the power consumption of the CPU is timely reduced under the premise of ensuring the CPU performance and service life, as well as the user experience.
[0008] In a second aspect, a credential requesting device is provided, the device comprising: A communication unit, configured to receive a request message sent by the second node; the request message is used to request a credential for accessing a third node; A processing unit, configured to determine one or more authorized resource addresses of the third node, and compress the one or more authorized resource addresses to obtain compressed resource information; the authorized resource address is a resource address of the resource address of the third node that the second node is allowed to access; The communication unit is also used to send a certificate to the second node according to the compressed resource information; the certificate includes the compressed resource information In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in the first aspect is implemented.
[0009] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the program is executed by a processor, the method described in the first aspect is implemented.
[0010] In a fifth aspect, a computer program product is provided. The computer program product includes instructions, and the instructions are executed by a processor to implement the method described in the first aspect.
[0011] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings: Figure 1 One of the flowcharts of the control method of the central processing unit provided in the embodiment of the present application; Figure 2 A second flowchart of a control method for a central processing unit provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of a control device of a central processing unit provided in an embodiment of the present application; Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0013] The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0014] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The application scenarios in the present application are described below.
[0015] For Linux systems, they are often equipped with multi-core central processing units (CPUs). For multi-core CPUs, each core runs a process at the same time, and different processes are run serially between multiple cores.
[0016] In order to reduce the power consumption of a multi-core CPU during use, a popular strategy in the relevant technology is to control the energy consumption of the CPU by adjusting and controlling the CPU clock frequency.
[0017] It is understandable that since the CPU executes instructions step by step under the control of the clock signal, and each clock signal cycle completes one step of operation, the clock frequency largely reflects the speed of the CPU. Generally, the CPU clock frequency, computing performance, and power consumption are directly proportional. When the CPU clock frequency drops to the lowest (offline state), its computing performance also reaches the lowest value, and the power consumption also reaches the lowest value, that is, the maximum energy saving effect is achieved.
[0018] For example, you can use software tools to find and modify the CPU's power management settings to reduce or increase the CPU's clock frequency, thereby controlling the CPU's operating energy consumption; or you can use software tools to directly modify the CPU's operating parameters to control the CPU's operating energy consumption.
[0019] Specifically, the above-mentioned software tool can be a cpupower tool, which is used to view and modify the power management settings of the CPU, such as frequency scaling and adjusting the operating mode; it can also directly access and modify / sys / devices / system / cpu / cpuid / ... as root, that is, modify the operating parameters of the CPU in the pseudo file system, reduce the clock frequency, and then reduce the operating frequency of the CPU.
[0020] However, for the energy-saving needs of a multi-core CPU, the above two existing solutions only mechanically reduce the clock frequency of one or some cores without considering the current load of each core in the multi-core. For example, they do not specifically consider the actual current utilization rate of each core in the CPU, nor do they consider whether interrupting the load or reducing the operating frequency will lead to task termination and shorten the CPU life.
[0021] Based on this, implementing such a solution can indeed directly and significantly reduce CPU power consumption, but it will bring more adverse negative effects such as task termination and device performance degradation. Overall, the benefits do not outweigh the costs.
[0022] Based on this, the present application proposes a control method, device, equipment and medium for a central processing unit, which can solve the problem that the existing method of reducing CPU power consumption is too mechanical, easily leading to task termination and CPU performance degradation. It can dynamically adjust the CPU performance according to the actual situation of CPU execution, and timely reduce the CPU power consumption while ensuring the CPU performance and service life.
[0023] Figure 3 FIG. 1 is a flow chart of a control method of a central processing unit provided in an embodiment of the present application. Figure 3 As shown, the method includes the following steps 301 to 304: Step 301: Obtain the usage parameters of the central processing unit.
[0024] In the embodiment of the present application, the usage parameters include usage parameters of a central processing unit, and the central processing unit is a multi-core central processing unit.
[0025] In one example, the central processing unit may be a processor of a Linux system.
[0026] In the embodiment of the present application, the usage parameter of the above-mentioned central processing unit may include the usage status of each core in the above-mentioned central processing unit.
[0027] Exemplarily, the above-mentioned usage parameters may include system performance parameters and resource usage parameters of the central processing unit.
[0028] In one example, the system performance parameters may include a current CPU operating speed parameter, a CPU enabled core number parameter, and a CPU energy saving mode parameter. Further, the CPU operating speed parameter may include an operating speed parameter of each core in the CPU.
[0029] In an example, the resource usage parameters may include the resource occupancy rate and resource usage duration of the central processor. Further, the resource usage parameters of the central processor may include the resource occupancy rate and resource usage duration of each core in the central processor.
[0030] It is understandable that, in the case where the above-mentioned central processor is a Linux system central processor, during the normal operation of the Linux system, a preset command can be used to obtain the usage parameters of the Linux system central processor.
[0031] In one embodiment, the preset command may be a cat / proc / stat command. The cat / proc / stat command may be used to obtain system performance parameters and resource usage parameters of a central processing unit of a Linux system.
[0032] Step 302: According to the usage parameters, the usage rate of each core currently enabled by the central processing unit is obtained.
[0033] In the embodiment of the present application, the above-mentioned usage parameters include operating rate parameters, resource occupancy rate and resource usage duration. Therefore, the usage parameters can be used to obtain the usage rate of each core currently enabled in the central processing unit.
[0034] It is understandable that the reason why the utilization rate of each core currently enabled in the CPU is obtained is that, in the embodiment of the present application, the core of the CPU is always in a dynamic adjustment state. In order to achieve the function of reducing energy consumption, some cores in the CPU may be set to an interrupt state (for example, when the CPU executes fewer processes), and other cores may be set to an enabled state, or all cores of the CPU may be set to an enabled state. Therefore, the currently enabled cores may include all cores of the CPU, or may include some cores of the CPU.
[0035] Optionally, in an embodiment of the present application, the utilization rate of each core in the above-mentioned central processing unit is obtained according to the above-mentioned usage parameters, including: determining the idle time of the above-mentioned core during the running time according to the above-mentioned usage parameters; determining the utilization rate of each core according to the running time of each core and the idle time of each core.
[0036] In the embodiment of the present application, after obtaining the above-mentioned usage parameters, it is necessary to calculate and analyze the above-mentioned usage parameters.
[0037] Exemplarily, the key parameters in the usage parameters are: the time each CPU in a multi-core CPU spends on each process and the idle time of each CPU (i.e., idle time), and the total time spent by all processes in the CPU, i.e., the total time of each item.
[0038] According to the key parameters in the above usage parameters, there are the following ways to calculate the usage rate.
[0039] Example 1: According to the formula: , using the / proc / stat statistics obtained once, the total usage of each core from the time the system was started to the current time can be calculated.
[0040] Example 2: Get / proc / stat statistics twice at a certain interval T, calculate the difference of each item in the statistics to form a / proc / stat difference statistics, and then use the formula: , the difference statistical information can be used to calculate the average usage rate of each core in the central processing unit within the interval time T, where the time T can be specified or customized by the user, and the embodiment of the present application does not limit this.
[0041] It is understandable that after calculating the usage rate of each core, the usage rate of the entire CPU can also be obtained accordingly. For example, the usage rate of the entire CPU can be obtained by averaging the usage rate of each core.
[0042] Furthermore, the above-mentioned method of averaging the utilization rate of each core to obtain the utilization rate of the entire central processing unit may include a direct addition and averaging method, and may also include a weighted addition and averaging method, which is not limited in the embodiments of the present application.
[0043] Step 303: When the usage rate of each of the currently enabled cores is within a preset usage rate range, determine the first core with the lowest usage rate among each of the currently enabled cores, and determine the target process corresponding to the first core, release the correspondence between the target process and the first core, and interrupt the operation of the first core until the usage rate of any of the currently enabled cores of the central processing unit exceeds the preset usage rate range.
[0044] In the embodiment of the present application, the first core is the only core that executes the target process.
[0045] In the embodiment of the present application, the above-mentioned preset usage rate range can be customized by the user or customized by the central processing unit, and the embodiment of the present application does not limit this.
[0046] In the embodiment of the present application, the above-mentioned preset usage rate range may be related to the number of cores enabled in the central processing unit. It is understandable that when all the cores are enabled, it means that the current central processing unit is in a non-energy-saving mode, and when some of the cores are in an interrupted operation state, it means that the central processing unit is already in an energy-saving mode.
[0047] Therefore, different numbers of enabled cores of different CPUs correspond to different preset usage rate ranges.
[0048] Furthermore, the preset usage rate range may be limited by a threshold value corresponding to the preset usage rate range. For details about the threshold value corresponding to the preset usage rate range, please refer to the subsequent description, which will not be elaborated here.
[0049] In the embodiment of the present application, in order to save the energy consumption of the central processing unit to the greatest extent flexibly and timely in combination with the actual usage of the central processing unit while ensuring the service life and performance of the central processing unit, it is necessary to flexibly and dynamically control the activation and interrupt operation of each core in the central processing unit, that is, to continuously adjust the activation and interrupt operation of multiple cores in the central processing unit.
[0050] It is understandable that for a central processing unit, it often runs multiple processes, and the number of processes may be the same as or different from the number of cores. In the process of running multiple processes, assuming that the utilization rate of each core is within the preset utilization rate range, the central processing unit has the conditions to shut down some cores to save energy. On this basis, in order to avoid problems such as sudden termination of processes when shutting down some cores, by obtaining the utilization rate of each core and filtering out the core with the lowest utilization rate, find the target process corresponding to the core, that is, in the current time period, only the process that can be run through the core with the lowest utilization rate, unbind this type of target process from the core with the lowest utilization rate, and then the terminal can run the first core.
[0051] Furthermore, the process of determining whether the usage rate of each core is within a preset usage rate range is a continuously cyclic process. If a core with the lowest usage rate is successfully interrupted, the process will continue to check whether the usage rate of the remaining cores that are still enabled is within the preset usage rate range. Assuming that it is still within the preset usage rate range, the first core with the lowest usage rate among each of the currently enabled cores can be determined, and the target process corresponding to the first core can be determined. The correspondence between the target process and the first core is released and the operation of the first core is interrupted until the usage rate of any core among the currently enabled cores of the above-mentioned central processor exceeds the preset usage rate range, and then the step of shutting down the first core with the lowest usage rate will be stopped.
[0052] In one example, in a Linux system, each core runs only one process in the same time period. When the number of processes is greater than the number of enabled cores, different processes are executed serially in multiple cores.
[0053] Step 304: Enable the first core.
[0054] Exemplarily, if the usage rate of any core among the cores currently enabled in the central processing unit exceeds a preset usage rate range, the first core that was previously interrupted will be enabled.
[0055] It can be understood that from the foregoing content, the first core of the interrupt may be one core or multiple cores. The reason is that for the currently enabled core, a core with the lowest utilization rate will be selected as the first core interrupt each time. This process may be repeated multiple times, so the operation of multiple cores may be interrupted.
[0056] In an example, when the first core is one core, the one core may be directly enabled.
[0057] In one example, when the first core mentioned above is a plurality of cores, all the previously interrupted cores can be directly enabled, or the plurality of previously closed cores can be opened in sequence, that is, one previously interrupted core is enabled at a time, and then another previously interrupted core is enabled based on repeating the above steps 301 to 303.
[0058] In the method provided in the embodiment of the present application, the usage parameters of the central processing unit are first obtained (the usage parameters include the usage parameters of the central processing unit, and the central processing unit is a multi-core central processing unit), and then, according to the usage parameters, the usage rate of each core currently enabled in the central processing unit is obtained; then, when the usage rate of each of the above cores is within the preset usage rate range, the first core with the lowest usage rate among the above cores currently enabled is determined, and the target process corresponding to the first core is determined, the corresponding relationship between the target process and the first core is released and the operation of the first core is interrupted, until the usage rate of any core of the core currently enabled by the central processing unit exceeds the preset usage rate range (the first core is the only core that executes the above target process); finally, the above first core is enabled. In this way, by continuously and dynamically determining the relationship between the currently enabled core in the central processing unit and the preset usage rate range, the first core with the lowest usage rate is dynamically closed or enabled according to the relationship, and the power consumption of the CPU is timely reduced under the premise of ensuring the CPU performance and service life, as well as the user experience.
[0059] In another embodiment of the present application, a method for determining a preset usage range based on the number of enabled cores of the central processing unit is also provided. Exemplarily, when the usage rate of each of the above cores is within the preset usage range, the first core with the lowest usage rate among the above multiple cores is determined, and the target process corresponding to the above first core is determined, and the correspondence between the above target process and the above first core is released. In the control method of the central processing unit provided in the embodiment of the present application, it includes: determining the number of enabled cores in the above central processing unit; determining the threshold value of the preset usage range corresponding to the above preset usage range according to the number of enabled cores in the above central processing unit; when the usage rate of each of the above cores is less than the threshold value of the above preset usage range, determining the first core with the lowest usage rate among the above multiple cores, and determining the target process corresponding to the above first core, and releasing the correspondence between the above target process and the above first core.
[0060] It can be understood from the foregoing that in the embodiment of the present application, in the process of determining whether the usage rate of the core of the central processing unit is within the preset usage rate range, when the number of enabled central processing units is different, the preset usage rate range is also different.
[0061] Furthermore, when all cores in the central processing unit are enabled, the preset usage threshold corresponding to the preset usage range is lower. The reason is that the central processing unit has used all core resources to execute process tasks. Only when all cores are within the preset usage range corresponding to the lower preset usage threshold, the conditions for further shutting down the first core in the central processing unit are met.
[0062] Correspondingly, when all core parts in the central processing unit are enabled, it means that some cores have been interrupted. At this time, the preset usage threshold corresponding to the preset usage range is higher. The reason is that the central processing unit only uses part of the core resources to execute process tasks, that is, the central processing unit can execute all tasks using part of the resources at this time. Then, the part of the cores that are currently enabled are within the preset usage range corresponding to the higher preset usage threshold, and the conditions for further shutting down the first core in the central processing unit are also met.
[0063] Optionally, the above-mentioned determination of the threshold of the preset usage range corresponding to the preset usage range based on the number of enabled cores in the central processing unit, in the central processing unit control method provided in the embodiment of the present application, includes: when the number of enabled cores in the above-mentioned central processing unit is the same as the total number of cores of the central processing unit, determining that the threshold of the preset usage range corresponding to the above-mentioned preset usage range is a first preset usage rate; when the number of enabled running cores in the above-mentioned central processing unit is less than the total number of cores of the central processing unit, determining that the threshold of the preset usage range corresponding to the above-mentioned preset usage range is a second preset usage rate.
[0064] Exemplarily, the first preset usage rate is less than the second preset usage rate.
[0065] Exemplarily, the first preset usage rate may be 50%, and the second preset usage rate may be 70%.
[0066] Exemplarily, the first preset usage rate and the second preset usage rate may be user-defined or preset, which is not limited in the embodiments of the present application.
[0067] Optionally, in the above-mentioned enabling of the above-mentioned first core, in the control method of the central processing unit provided in the embodiment of the present application, the control method of the central processing unit provided in the embodiment of the present application includes: obtaining the usage rate of each core of the currently enabled cores of the central processing unit, and enabling the above-mentioned first core when the usage rate of any core of the above-mentioned currently enabled cores is greater than the second preset usage rate.
[0068] It is understandable that before the above-mentioned first core is enabled, some of the cores in the central processor have been interrupted. Therefore, the currently enabled cores are not all the cores in the central processor, but only some of the cores in the central processor. It can be seen from the above description that for the central processor in which only some of the cores are enabled, the preset usage rate threshold for determining its preset usage rate range is a higher second preset usage rate. That is, when the usage rate of any core in the above-mentioned currently enabled cores is greater than the second preset usage rate, the above-mentioned first core is enabled.
[0069] Optionally, in an embodiment of the present application, when the usage rate of each of the cores is within a preset usage rate range, determining the first core with the lowest usage rate among each of the currently enabled cores, the control method of the central processing unit provided in the embodiment of the present application includes: when the usage rate of each of the cores is within a preset usage rate range, determining that the current mode of the central processing unit is an energy-saving mode, determining the first core with the lowest usage rate among each of the currently enabled cores, and updating the threshold of the preset usage rate range corresponding to the preset usage rate range from the first preset usage rate to the second preset usage rate or maintaining the second preset usage rate.
[0070] Exemplarily, in order to facilitate the central processing unit to determine the preset usage rate threshold corresponding to the preset usage rate range, the preset usage rate threshold corresponding to the preset usage rate range that the current central processing unit needs to use can be distinguished as the first preset usage rate or the second preset usage rate by assigning the central processing unit an energy-saving mode and a non-energy-saving mode.
[0071] Exemplarily, the energy-saving mode described above may be represented by using values assigned in parameters.
[0072] In an example, if the POWERSAVE_MODE in the usage parameter is 0, it indicates that the system is in a non-energy-saving mode; if the POWERSAVE_MODE in the usage parameter is 1, it indicates that the system is in an energy-saving mode.
[0073] Exemplarily, when in energy-saving mode, the preset usage rate threshold corresponding to the preset usage rate range required by the above-mentioned central processing unit is the second preset usage rate; when in non-energy-saving mode, the preset usage rate threshold corresponding to the preset usage rate range required by the above-mentioned central processing unit is the first preset usage rate.
[0074] Optionally, in an embodiment of the present application, the target process corresponding to the above-mentioned first core in the other cores is determined, and the correspondence between the above-mentioned target process and the above-mentioned first core is released. The control method of the central processing unit in the embodiment of the present application includes: traversing the list of executable cores corresponding to each process in all processes of the above-mentioned central processing unit; according to the list of executable cores corresponding to each of the above-mentioned processes, determining that the core in the executable list is the process corresponding to the above-mentioned first core as the target process; and modifying the core in the executable list of the above-mentioned target process to other cores, and the above-mentioned other cores are cores other than the first core in the above-mentioned central processing unit.
[0075] For example, for each process in the CPU, it does not necessarily tend to run in any core. For example, the CPU includes 4 cores and 10 processes, namely core 1, core 2, core 3, and core 4, and processes 1 to 10. Then, process 5 among processes 1 to 10 may only run in core 4 when all cores are enabled, but not in other cores.
[0076] Furthermore, the fact that process No. 5 runs only in core No. 4 and not in other cores does not mean that process No. 5 cannot run in other cores, but that it has the strongest affinity with core No. 4.
[0077] In one example, for a central processing unit, the core that each process tends to run can be known through an affinity list, that is, a list of executable cores. That is, the core that each process tends to run can be known through the Cpus_allowed_list of each core. For example, the affinity list of process No. 5 may only include core No. 1, core No. 2, and core No. 3.
[0078] Exemplarily, based on the above introduction, it is necessary to traverse and obtain the list of executable cores for each process. In the above process of shutting down the first core with the lowest utilization rate, for processes that can run on both the first core and other cores, even if the first core is shut down, it will not affect the subsequent operation of these processes. As for the target process that has a corresponding relationship with the first core, that is, the target process that previously only has the first core in the list of executable cores, it is necessary to unbind the target process from the first core before shutting down the first core, and modify the core in the executable list of the target process to other cores, that is, bind the target process to other cores, so as to ensure the subsequent operation of the target process.
[0079] Optionally, in the embodiment of the present application, the above-mentioned obtaining of the usage parameters of the central processing unit, in the control method of the central processing unit in the embodiment of the present application, includes: obtaining the usage parameters of the above-mentioned central processing unit according to the resource acquisition cycle of the above-mentioned central processing unit.
[0080] Exemplarily, the resource acquisition cycle of the central processor is a cycle for acquiring systemic parameters corresponding to the central processor, and the usage parameters of the central processor include the usage time of each core in the central processor and the energy-saving state parameters corresponding to the central processor.
[0081] It is understandable that the central processing unit needs to obtain various performance parameters in the central processing unit according to a certain period, and this period is the resource acquisition period.
[0082] In the embodiment of the present application, the usage parameters of the central processing unit may be synchronously acquired according to the resource acquisition cycle of the central processing unit.
[0083] In this way, in the process of obtaining the usage parameters of the central processing unit, there is no need to set a clock signal separately, thus saving setting costs and setting procedures, and improving the efficiency of obtaining the usage parameters of the central processing unit.
[0084] The following will be combined Figure 2 The operation process of the present application is described by Example 3. In Example 3, the CPU is a multi-core CPU of the Linux system, and the description starts with the CPU not interrupting any core: Step (1): Enter the cat / proc / stat command according to the cycle length T. During the normal operation of the Linux system, use the cat / proc / stat command according to the cycle length T to obtain the statistical information of the system performance and resource usage of the central processing unit (that is, the usage parameters of the above-mentioned central processing unit). And according to the system performance and resource usage, define the value of the energy-saving mode mark POWERSAVE_MODE as 0, where the value 0 represents that the energy-saving mode is not turned on (default value), and the value 1 represents that the energy-saving mode is turned on.
[0085] Step (2): Obtain the time spent by each core on different processes. The statistical information obtained in step (1) (i.e., the usage parameters of the above-mentioned CPU) is calculated and analyzed. The key data in the statistical information is the time spent by each core of the multi-core CPU on different processes, and the total time used by each core and the relevant data of the entire CPU are used.
[0086] Step (3): Calculate the CPU usage of each core. Based on the above statistical information, calculate the CPU usage of each core.
[0087] Step (4): Based on the data obtained in step (3), the following judgments are made in step A1 and step A2: Step A1: When all cores are enabled and the utilization of all cores is less than 50% (i.e., the first preset utilization), it indicates that the current CPU is in a low-load state. If so, the flag POWERSAVE_MODE is written from 0 to 1, indicating that the CPU is in energy-saving mode, and then proceeds to step A2. Otherwise, jump to step (1) and repeat; Step A2: Filter out the lowest-utilized core Lowest_cpu_id in the CPU (that is, the first core mentioned above), and then use the cat / proc / [PID] / status command to traverse all processes in the current Linux system and obtain the affinity list of each process, that is, Cpus_allowed_list. Further filter out the processes in the affinity list that only have the lowest-utilized core. Record the pids of these processes bound to the Lowest_cpu_id core (that is, the unique identifier id of the process in the Linux system), use the taskset command to migrate all these processes to other cores other than the first core, and then execute step A3; Step A3: Shut down the Lowest_cpu_id core to reduce the power consumption of the CPU. Specifically, write the file: / sys / devices / system / cpu / <cpu_id> / online value is 0 to shut down the core, then return to step (1) and repeat.
[0088] Step (5): When some cores are enabled, that is, POWERSAVE_MODE is set to 1, the following steps B1 and B2 are executed according to whether the usage rate of the enabled cores is less than 70% (that is, the second preset usage rate). Step B1: When the usage of all currently enabled cores is less than 70%, go to step A2 again: Step B2: If the usage rate of any CPU among all currently enabled cores is greater than 70%, enable the previously disabled cores in turn. Specifically, determine a core ID, that is, determine a cpu_id, by writing the file: / sys / devices / system / cpu / <cpu_id> / online is set to 1 to turn on the first core, then return to step (1) and repeat the process. At the same time, the flag POWERSAVE_MODE is written to 0, that is, the power saving mode is turned off, and then the entire process is exited; The present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the training rule determination method described in the present application is implemented. For example, the following can be executed: Figure 1 The individual steps of the method are shown.
[0089] The present invention provides a computer program product, which includes instructions that are executed by a processor when the processor executes the instructions. Figure 1 The individual steps of the method are shown.
[0090] It should be noted that although the operations of the method of the present invention are described in a particular order in the drawings, this does not require or imply that the operations must be performed in this particular order or that all illustrated operations must be performed to achieve desired results.
[0091] Figure 3 FIG. 1 is a block diagram of a credential requesting device according to an embodiment of the present application. The device may be deployed in an authorization node (eg, the first node described above). Figure 3 The device includes an acquisition unit 601 and an execution unit 602.
[0092] An acquisition unit 601 acquires usage parameters of a central processing unit, wherein the usage parameters include usage parameters of a central processing unit, and the central processing unit is a multi-core central processing unit; The acquisition unit 601 is further configured to acquire the usage rate of each core currently enabled by the central processing unit according to the usage parameter; The execution unit 602 is used to determine, when the usage rate of each of the currently enabled cores is within a preset usage rate range, a first core with the lowest usage rate among each of the currently enabled cores, and determine a target process corresponding to the first core, and cancel the correspondence between the target process and the first core and interrupt the operation of the first core until the usage rate of any core among the currently enabled cores of the central processor exceeds the preset usage rate range, and the first core is the only core that executes the target process; The execution unit 602 is further configured to enable the first core.
[0093] In one embodiment, the execution unit 602 is specifically used to determine the number of enabled cores in the central processing unit; determine the threshold of the preset usage range corresponding to the preset usage range based on the number of enabled cores in the central processing unit; when the usage of each core is less than the threshold of the preset usage range, determine the first core with the lowest usage among the multiple cores, determine the target process corresponding to the first core, and release the correspondence between the target process and the first core.
[0094] In one embodiment, the execution unit 602 is specifically used to, when the number of enabled cores in the central processing unit is the same as the total number of cores in the central processing unit, determine that the threshold of the preset usage range corresponding to the preset usage range is a first preset usage rate; when the number of enabled running cores in the central processing unit is less than the total number of cores in the central processing unit, determine that the threshold of the preset usage range corresponding to the preset usage range is a second preset usage rate; and the first preset usage rate is less than the second preset usage rate.
[0095] In one embodiment, the execution unit 602 is specifically used to obtain the usage rate of each core in the currently enabled cores of the central processing unit, and enable the first core when the usage rate of any core in the currently enabled cores is greater than a second preset usage rate.
[0096] In one embodiment, the execution unit 602 is specifically used to determine that the current mode of the central processing unit is the energy-saving mode, and determine the first core with the lowest usage among each of the currently enabled cores, when the usage rate of each core is within a preset usage rate range, and update the threshold of the preset usage rate range corresponding to the preset usage rate range from the first preset usage rate to the second preset usage rate or maintain the second preset usage rate.
[0097] In one embodiment, the acquisition unit 601 is specifically used to determine the idle time of each core during the running time according to the usage parameters; and determine the utilization rate of each core according to the running time of each core and the idle time of each core.
[0098] In one embodiment, the execution unit 602 is specifically used to traverse the list of executable cores corresponding to each process in all the processes of the central processing unit; determine that the core in the executable list is the process corresponding to the first core as the target process according to the list of executable cores corresponding to each process; and modify the core in the executable list of the target process to other cores, wherein the other cores are cores other than the first core in the central processing unit.
[0099] In one embodiment, the acquisition unit 602 is specifically used to acquire the usage parameters of the central processing unit according to the resource acquisition cycle of the central processing unit. The resource acquisition cycle of the central processing unit is a cycle for acquiring the corresponding systematic parameters of the central processing unit. The usage parameters of the central processing unit include the usage time of each core in the central processing unit and the energy-saving state parameters corresponding to the central processing unit.
[0100] It should be understood that the units recorded in the control device of the central processing unit correspond to the various steps in the method described in the accompanying drawings. Therefore, the operations and features described above for the method are also applicable to the control device of the central processing unit and the units contained therein, and will not be repeated here. The control device of the central processing unit can be pre-implemented in the browser or other security applications of the computer device, or can be loaded into the browser or its security application of the computer device by downloading or other means. The corresponding units in the control device of the central processing unit can cooperate with the units in the computer device to implement the solution of the embodiment of the present application.
[0101] For the several modules or units mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0102] It should be noted that for details not disclosed in the control device of the central processing unit in the embodiment of the present application, please refer to the details disclosed in the above embodiments of the present application, which will not be repeated here.
[0103] Reference below Figure 4 , Figure 4 A schematic diagram of the structure of a computer device suitable for implementing the embodiments of the present application is shown. Figure 4 As shown, the computer system 1700 includes a central processing unit (CPU) 1701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1702 or the program loaded from the storage part 1708 to the random access memory (RAM) 1703. In the RAM 1703, various programs and data required for the operation instructions of the system are also stored. The CPU 1701, the ROM 1702, and the RAM 1703 are connected to each other through a bus 1704. An input / output (I / O) interface 1705 is also connected to the bus 1704.
[0104] The following components are connected to the I / O interface 1705: an input section 1706 including a keyboard, a mouse, etc.; an output section 1707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1708 including a hard disk, etc.; and a communication section 1709 including a network interface card such as a LAN card, a modem, etc. The communication section 1709 performs communication processing via a network such as the Internet. A drive 1710 is also connected to the I / O interface 1705 as needed. A removable medium 1711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1710 as needed, so that a computer program read therefrom is installed into the storage section 1708 as needed.
[0105] In particular, according to an embodiment of the present application, the above reference flow chart Figure 1 The described process can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 1709, and / or installed from a removable medium 1711. When the computer program is executed by the central processing unit (CPU) 1701, the above-mentioned functions defined in the system of the present application are executed.
[0106] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium such as a computer-readable storage medium that can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0107] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operating instructions of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the aforementioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, the boxes represented by two connections can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operating instruction, or can be implemented with a combination of dedicated hardware and computer instructions.
[0108] The units or modules involved in the embodiments described in the present application may be implemented by software or hardware. The units or modules described may also be set in a processor. For example, it may be described as: a processor includes a first receiving module, a second receiving module, and a sending module. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves.
[0109] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device. The above computer-readable storage medium stores one or more programs, and when the above programs are used by one or more processors to execute the control method of the central processing unit described in the present application.
[0110] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present application (but not limited to) by each other to form a technical solution.
Claims
1. A method for controlling a central processing unit, characterized in that: include: Acquire usage parameters of a central processing unit, wherein the usage parameters include usage parameters of a central processing unit, and the central processing unit is a multi-core central processing unit; According to the usage parameter, obtaining the usage rate of each core currently enabled by the central processing unit; In the case where the usage rate of each of the currently enabled cores is within a preset usage rate range, determining a first core with the lowest usage rate among each of the currently enabled cores, determining a target process corresponding to the first core, canceling the correspondence between the target process and the first core, and interrupting the operation of the first core until the usage rate of any core among the currently enabled cores of the central processor exceeds the preset usage rate range, and the first core is the only core that executes the target process; Enable the first core.
2. The method according to claim 1, characterized in that When the usage rate of each core is within a preset usage rate range, determining a first core with the lowest usage rate among the multiple cores, determining a target process corresponding to the first core, and removing the correspondence between the target process and the first core, includes: Determining the number of enabled cores in the central processing unit; Determining a threshold value of a preset usage rate range corresponding to the preset usage rate range according to the number of enabled cores in the central processing unit; When the usage rate of each core is less than the threshold of the preset usage rate range, a first core with the lowest usage rate among the multiple cores is determined, and a target process corresponding to the first core is determined, and the correspondence between the target process and the first core is released.
3. The method according to claim 2, characterized in that The step of determining a threshold value of a preset usage rate range corresponding to the preset usage rate range according to the number of enabled cores in the central processing unit includes: In a case where the number of enabled cores in the central processing unit is the same as the total number of cores in the central processing unit, determining that the threshold of the preset usage rate range corresponding to the preset usage rate range is a first preset usage rate; In a case where the number of running cores enabled in the central processing unit is less than the total number of cores of the central processing unit, determining that the threshold of the preset usage rate range corresponding to the preset usage rate range is a second preset usage rate; The first preset usage rate is less than the second preset usage rate.
4. The method according to claim 1, characterized in that The enabling of the first core includes: The usage rate of each core in the currently enabled cores of the central processing unit is obtained, and when the usage rate of any core in the currently enabled cores is greater than a second preset usage rate, the first core is enabled.
5. The method according to claim 1, characterized in that The step of determining, when the usage rate of each core is within a preset usage rate range, a first core with the lowest usage rate among each of the currently enabled cores, comprises: When the usage rate of each core is within a preset usage rate range, the current mode of the central processing unit is determined to be the energy-saving mode, and the first core with the lowest usage rate among each of the currently enabled cores is determined, and the threshold of the preset usage rate range corresponding to the preset usage rate range is updated from the first preset usage rate to the second preset usage rate or the second preset usage rate is maintained.
6. The method according to claim 1, characterized in that The obtaining, according to the usage parameter, a usage rate of each core in the central processing unit includes: Determining the idle time of each core during the running time according to the usage parameter; The utilization rate of each core is determined according to the operating time of each core and the idle time of each core.
7. The method according to claim 1, characterized in that The determining a target process corresponding to the first core in other cores and removing the correspondence between the target process and the first core includes: Traversing a list of executable cores corresponding to each process in all processes of the central processor; According to the executable core list corresponding to each process, determining that the process corresponding to the core in the executable core list is the target process; The core in the executable list of the target process is modified to another core, where the other core is a core other than the first core in the central processing unit.
8. The method according to claim 1, characterized in that: The obtaining of the usage parameters of the central processing unit includes: According to the resource acquisition cycle of the central processing unit, the usage parameters of the central processing unit are obtained. The resource acquisition cycle of the central processing unit is a cycle for obtaining systematic parameters corresponding to the central processing unit. The usage parameters of the central processing unit include the usage time of each core in the central processing unit and the energy-saving state parameters corresponding to the central processing unit.
9. A control device for a central processing unit, characterized in that: The device comprises: An acquisition unit, which acquires usage parameters of a central processing unit, wherein the usage parameters include usage parameters of the central processing unit, and the central processing unit is a multi-core central processing unit; The acquisition unit is further configured to acquire the usage rate of each core currently enabled by the central processing unit according to the usage parameter; an execution unit, configured to determine, when the usage rate of each of the currently enabled cores is within a preset usage rate range, a first core with the lowest usage rate among each of the currently enabled cores, and determine a target process corresponding to the first core, and to release the corresponding relationship between the target process and the first core and interrupt the operation of the first core until the usage rate of any core among the currently enabled cores of the central processor exceeds the preset usage rate range, and the first core is the only core that executes the target process; The execution unit is further used to enable the first core.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, comprising instructions, characterized in that: When the instructions are executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Power supply management method based on automatic adjustment of processor nuclear number
CN102520782A
Method and system for regulating and controlling multi-core central processing unit (CPU)
CN102866921A
Regulation control method and apparatus for multi-core processor and mobile terminal using method
CN105893141A
Performing power management in a multicore processor
CN107209545A
Domestic server power consumption real-time dynamic adjustment method
CN112394803A