Using cpufreq-set (with examples)
- Linux
- November 5, 2023
Setting the CPU frequency policy of CPU 1 to “userspace”:
sudo cpufreq-set -c 1 -g userspace
Motivation: This use case is helpful when you want to manually control the CPU frequency of a specific CPU core. By setting the CPU frequency policy to “userspace”, you can manually determine the frequency at which the CPU operates.
Explanation:
-c 1
: Specifies the CPU core number as 1. This parameter is used to identify the CPU core to which the frequency policy is applied.-g userspace
: Sets the CPU frequency policy to “userspace”. This means that the CPU frequency will be determined by user-defined values.
Example Output:
Setting CPU 1 frequency policy to userspace.
Setting the current minimum CPU frequency of CPU 1:
sudo cpufreq-set -c 1 --min min_frequency
Motivation: This use case allows you to set the minimum frequency at which the CPU core operates. Setting the minimum frequency can be useful in scenarios where you want to conserve power or reduce heat generation.
Explanation:
-c 1
: Specifies the CPU core number as 1.--min min_frequency
: Sets the current minimum CPU frequency tomin_frequency
. The value should be within the range returned by thecpufreq-info -l
command.
Example Output:
Setting CPU 1 minimum frequency to 800 MHz.
Setting the current maximum CPU frequency of CPU 1:
sudo cpufreq-set -c 1 --max max_frequency
Motivation: This use case allows you to set the maximum frequency at which the CPU core operates. By setting the maximum frequency, you can optimize performance for certain tasks or applications that require higher processing power.
Explanation:
-c 1
: Specifies the CPU core number as 1.--max max_frequency
: Sets the current maximum CPU frequency tomax_frequency
. The value should be within the range returned by thecpufreq-info -l
command.
Example Output:
Setting CPU 1 maximum frequency to 2.40 GHz.
Setting the current work frequency of CPU 1:
sudo cpufreq-set -c 1 -f work_frequency
Motivation: This use case allows you to set the current frequency at which the CPU core operates. By directly specifying the work frequency, you have fine-grained control over the CPU’s performance.
Explanation:
-c 1
: Specifies the CPU core number as 1.-f work_frequency
: Sets the current CPU frequency towork_frequency
. The value should be within the range returned by thecpufreq-info -l
command.
Example Output:
Setting CPU 1 frequency to 1.80 GHz.
By utilizing the cpufreq-set
command with different options, you can have more control over the CPU frequency and optimize system performance according to your specific needs.