How to Use the Command 'cpufreq-info' (with Examples)
- Linux
- December 17, 2024
The cpufreq-info
command is a useful utility for accessing various information about your CPU’s frequency settings. This command gives insights into the current frequency, the policies assigned to the CPUs, and what the minimum and maximum allowable frequencies are, among other features. Primarily used in Linux systems, it can provide detailed information specific to each CPU core and is invaluable for performance tuning, troubleshooting, and ensuring your system is configured for optimal power efficiency.
Use Case 1: Show CPU Frequency Information for All CPUs
Code:
cpufreq-info
Motivation:
Running the cpufreq-info
command without any options provides a comprehensive overview of the frequency settings of all CPUs on your system. This is particularly useful for quickly assessing the CPU frequency states and policies across multiple cores, allowing for a high-level understanding of the current performance settings and any power consumption implications.
Explanation:
The command cpufreq-info
without additional arguments queries the system for information about the current state, potential states, and policies for all CPU cores. It accesses CPU frequency details managed by the system’s CPU frequency scaling governors and delivers this in an organized format.
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: 0.97 ms.
hardware limits: 800 MHz - 3.30 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 800 MHz and 3.30 GHz.
The governor "powersave" may decide which speed to use
within this range.
current CPU frequency is 800 MHz.
Use Case 2: Show CPU Frequency Information for the Specified CPU
Code:
cpufreq-info -c 2
Motivation:
When troubleshooting or optimizing specific cores within a multi-core system, you might only need information pertinent to a single CPU. This command allows you to target specific CPUs, offering detailed frequency settings and policy information. This is vital for pinpointing performance issues related to particular cores in systems running parallelized tasks.
Explanation:
The -c
option specifies the CPU number for the query, allowing you to focus on a single core rather than the entire system. This can help isolate issues or optimizations on particular hardware threads associated with a CPU core.
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: 0.97 ms.
hardware limits: 800 MHz - 3.30 GHz
available cpufreq governors: performance, powersave
current policy: frequency should be within 800 MHz and 3.30 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency is 3.30 GHz.
Use Case 3: Show the Allowed Minimum and Maximum CPU Frequency
Code:
cpufreq-info -l
Motivation:
Understanding the allowed frequency range is critical for users who are configuring their systems for specific performance characteristics or for saving energy. By showing the permissible minimum and maximum CPU frequencies, users can quickly determine the range of performance they can expect under the system’s current configuration.
Explanation:
The -l
option enables the display of the lower and upper bounds of the frequency that the CPUs can operate. It provides the hard limits that the hardware and system configuration currently impose, which can be used as a basis for further customization and tuning of CPU performance.
Example Output:
800000 3300000
Use Case 4: Show the Current Minimum and Maximum CPU Frequency and Policy in Table Format
Code:
cpufreq-info -o
Motivation:
For administrators managing complex environments, comparing the minimum and maximum frequencies across CPUs in a unified table format is extremely helpful. The consolidated view aids quick diagnosis and policy evaluation across multiple CPUs, facilitating easier configuration and performance assessment.
Explanation:
The -o
argument requests an organized table format that succinctly displays the current policy, including minimum and maximum frequencies across different CPUs. This is especially useful in scenarios requiring rapid audits of CPU settings.
Example Output:
CPU minimum maximum policy
--------------------------------------
0 800 MHz 3.30 GHz powersave
1 800 MHz 3.30 GHz performance
2 800 MHz 3.30 GHz performance
3 800 MHz 3.30 GHz powersave
Use Case 5: Show Available CPU Frequency Policies
Code:
cpufreq-info -g
Motivation:
From a performance and energy management standpoint, knowing all the available policies your system supports allows a user to configure their system effectively. This command outputs the governors, or policies, available for CPU frequency scaling on the system, offering insights into potential configuration changes that can be made to balance performance and energy savings.
Explanation:
The -g
option lists all possible frequency policies (governors) that are supported by the cpufreq module on the system. These policies determine how CPU frequency scaling is managed, ranging from energy-saving-focused settings to performance-centered configurations.
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:
When CPU frequency information needs to be interpreted quickly, using a human-readable format is beneficial. This command gives immediate insights into the current operating frequency of the CPUs using the cpufreq kernel module’s interventions, suited for real-time assessments without delving into raw data.
Explanation:
The -f
option requests the current frequency, and the -m
flag converts it into a more human-readable format. This combination allows users to gain insight into the CPUs’ performance without sifting through extensive details or executing additional calculations.
Example Output:
2.30 GHz
Use Case 7: Show Current CPU Work Frequency in a Human-Readable Format, by Reading It from Hardware
Code:
sudo cpufreq-info -w -m
Motivation:
Reading the present CPU frequency directly from hardware ensures that the data reflects the most accurate status unaffected by potential software discrepancies. This is crucial for applications where hardware-level measurement precision is necessary, such as detailed performance tuning or diagnostic tasks requiring admin-level authority.
Explanation:
The -w
option tells cpufreq-info to read the frequency directly from the hardware. Combined with the -m
option for human-readable format and prefixed with sudo
for root access, it provides a precise measure of the CPU frequency according to the hardware, ensuring accuracy even in bypassing system caching or latency.
Example Output:
2.10 GHz
Conclusion:
The cpufreq-info
command serves as an essential tool for Linux users looking to monitor and adjust their CPU’s operating frequencies. By understanding and utilizing its diverse options, system administrators and power users can fine-tune system performance and manage power consumption effectively. Whether gathering data for the entire CPU set, adjusting specific core frequencies, or exploring CPU frequency policies and limitations, cpufreq-info
offers flexibility and detailed insights into CPU performance metrics.