How to use the command cpufreq-info (with examples)
- Linux
- December 25, 2023
The cpufreq-info
command is a tool that allows users to retrieve and display CPU frequency information on a Linux system. This information is useful for monitoring and managing the performance of CPUs.
Use case 1: Show CPU frequency information for all CPUs
Code:
cpufreq-info
Motivation: This use case can be helpful in understanding the current CPU frequency status for all available CPUs. It enables users to get an overview of the frequency at which their CPUs are operating.
Explanation: By running the cpufreq-info
command without any arguments, the tool will display the CPU frequency information for all CPUs in the system. This includes details such as the current frequency, minimum and maximum frequency, and the available frequency policies.
Example output:
analyzing CPU 0:
driver: intel_pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: Cannot determine or is not supported.
hardware limits: 800 MHz - 4.00 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 800 MHz and 4.00 GHz.
The governor "powersave" may decide which speed to use
within this range.
current CPU frequency: 851 MHz (asserted by call to hardware)
boost state support:
Supported: yes
Active: yes
3200 MHz max turbo 4 active cores
3200 MHz max turbo 3 active cores
3200 MHz max turbo 2 active cores
3200 MHz max turbo 1 active cores
Use case 2: Show CPU frequency information for the specified CPU
Code:
cpufreq-info -c cpu_number
Motivation: This use case is useful when you want to retrieve CPU frequency information for a specific CPU in the system. It allows you to target a particular CPU and obtain its frequency details.
Explanation: To show CPU frequency information for a specified CPU, the -c
argument is used, followed by the number of the CPU. For example, cpufreq-info -c 2
will display the frequency information for the second CPU in the system.
Example output:
analyzing CPU 2:
driver: intel_pstate
CPUs which run at the same hardware frequency: 2
CPUs which need to have their frequency coordinated by software: 2
maximum transition latency: Cannot determine or is not supported.
hardware limits: 800 MHz - 4.00 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 800 MHz and 4.00 GHz.
The governor "powersave" may decide which speed to use
within this range.
current CPU frequency: 857 MHz (asserted by call to hardware)
boost state support:
Supported: yes
Active: yes
3200 MHz max turbo 4 active cores
3200 MHz max turbo 3 active cores
3200 MHz max turbo 2 active cores
3200 MHz max turbo 1 active cores
Use case 3: Show the allowed minimum and maximum CPU frequency
Code:
cpufreq-info -l
Motivation: This use case is helpful to determine the lowest and highest frequencies allowed for the CPUs in the system. It provides information about the operating range of the CPU frequencies.
Explanation: The -l
argument is used to display the lowest and highest allowed CPU frequencies in the system. This can aid in understanding the limits imposed by hardware or software configurations.
Example output:
800 MHz - 4.00 GHz
Use case 4: Show the current minimum and maximum CPU frequency and policy in table format
Code:
cpufreq-info -o
Motivation: This use case presents the current minimum and maximum CPU frequency along with the corresponding frequency policy in a more organized and table-like format. It provides an overview of the CPU frequencies and policies at a glance.
Explanation: By using the -o
argument, the cpufreq-info
tool displays a table containing the current minimum and maximum CPU frequencies and the associated frequency policy. This table format makes it easier to read and compare the information for different CPUs.
Example output:
CPU | Minimum | Maximum | Governor
-------+----------------+----------------+---------------
CPU0 | 800 MHz | 4.00 GHz | powersave
CPU1 | 800 MHz | 4.00 GHz | powersave
CPU2 | 800 MHz | 4.00 GHz | powersave
CPU3 | 800 MHz | 4.00 GHz | powersave
Use case 5: Show available CPU frequency policies
Code:
cpufreq-info -g
Motivation: This use case allows users to view the available CPU frequency policies in the system. It helps users understand the different policies they can choose from to manage the CPU frequencies.
Explanation: Using the -g
argument, the cpufreq-info
command displays the available CPU frequency governors or policies. These governors govern the behavior of the CPU frequency and determine the frequency at which the CPU operates at a given time.
Example output:
performance powersave
Use case 6: Show current CPU work frequency in a human-readable format, according to the cpufreq kernel module
Code:
cpufreq-info -f -m
Motivation: This use case provides the current CPU frequency in a human-readable format according to the cpufreq kernel module. It allows users to easily understand the current frequency at which their CPUs are operating.
Explanation: By using the -f
argument, the cpufreq-info
command displays the current CPU work frequency in a human-readable format. The -m
argument enhances the output by adding a unit (MHz) to represent the frequency measurement.
Example output:
800 MHz
Use case 7: Show current CPU work frequency in a human-readable format, by reading it from hardware (only available to root)
Code:
sudo cpufreq-info -w -m
Motivation: This use case is useful when you want to obtain the current CPU work frequency by directly reading it from the hardware. It provides accurate information about the actual CPU frequency and is particularly helpful for system administrators.
Explanation: The sudo
command is used to execute the cpufreq-info
command with root privileges, allowing it to read the CPU frequency information directly from the hardware. The -w
argument is used to display the current CPU work frequency, and the -m
argument provides a human-readable format with the unit (MHz).
Example output:
2800 MHz
Conclusion:
The cpufreq-info
command is a versatile tool for retrieving and displaying CPU frequency information on a Linux system. It provides various use cases to assist users in monitoring performance and managing CPU frequencies. Whether you need an overview of all CPUs, specific CPU details, or frequency policies, the cpufreq-info
command offers a range of capabilities to meet your needs.