cpuspeed Command in Linux



cpuspeed is a Linux program that manages your computer CPU (central processing unit) speed to balance performance and power efficiency.

When your system is in idle state (not doing much), the cpuspeed command reduces the CPU speed and voltage to save the power consumption of your system. When you need more performance, for example if you want to run demanding tasks, this command will help you increase the CPU speed.

Table of Contents

Here is a comprehensive guide to the options available with the cpuspeed command −

Key Features of cpuspeed Command in Linux

The following are the key features of cpuspeed command in linux −

1. Idle Management

The cpuspeed command can also adjust your CPU speed based on the temperature and whether your laptop is plugged in or running on battery. When your computer is idle, cpuspeed lowers the CPU speed of your system to save energy. In case the system gets too hot, it can reduce CPU speed to prevent overheating.

2. AC Adapter Behavior

When you unplug your laptop, the cpuspeed command will minimize the CPU speed to save battery. When you plug it back in, it will maximize the CPU speed for better performance.

3. Group Management

By default, the cpuspeed command manages all CPU cores, however, you can specify specific core groups if needed.

Syntax for cpuspeed Command in Linux

The basic syntax to use the cpuspeed command in Linux is as follows −

cpuspeed [options]

Where [options] are different flags that can be utilized with the cpuspeed command for customizing its behavior.

Different Options Available for cpuspeed Command

With cpuspeed command, you can use multiple options, these are discussed in the table given below:

Option Description
-d Daemonize the process (run in the background).
-i <interval> Set the interval for idle percentage tests (default is 20 tenths of a second).
-p <fast up> <threshold> Define idle percentage thresholds −
<fast up> − Idle percentage below which a core runs at maximum speed.
<threshold> − Idle percentage above which a cores speed decreases (and below which it increases).
-m <minimum speed> Set the minimum CPU speed (in KHz).
-M >maximum speed> Set the maximum CPU speed (in KHz).
-n Exclude niced programs from idle time calculations.
-w Exclude time waiting for I/O from idle time calculations.
-t <temp file> <maxtemp> Control CPU speed based on temperature.
-T <interval> Poll temperature at specified intervals (default is 10 tenths of a second).
-a <AC file> Manage CPU speed when the AC adapter is disconnected (default behavior).
-A <interval> Poll AC adapter state (default is 50 tenths of a second).
-C Operate at peak speed when the AC adapter is connected.
-D Avoid enforcing minimum speed settings when the AC adapter is unplugged.
-r Restore previous speed on program exit.
-S <CPU core 1> [[<CPU core 2>] ...] Manage specific core groups (enclosed in quotes).

Notes

To keep your CPU core at maximum speed for better performance, such as for gaming, video editing, you can send the process a special signal (SIGUSR1). If you want to keep a CPU core at minimum speed to save battery life, you can use another signal (SIGUSR2).

Many modern Linux operating systems, the kernel provides support for adjusting CPU frequencies dynamically called CPU frequency scaling scaling. However, the cpuspeed daemon specifically works with the userspace frequency scaling governor. Other governors (like ondemand and conservative) rely solely on the Linux kernel for dynamic frequency adjustments.

Fedora and Red Hat distributions provide a unified configuration file for both scenarios.

Additionally, they offer a cpuspeed init script that configures either in-kernel CPU frequency scaling or cpu speed, depending on the systems needs.

Relevant Files

If you are interested in configuration details, check these files:

  • /etc/sysconfig/cpuspeed − Configuration file
  • /usr/sbin/cpuspeed − The cpuspeed program itself
  • /etc/init.d/cpuspeed − Initialization script

Conclusion

The cpuspeed is a powerful program that is designed to balance power efficiency and performance by dynamically adjusting your computers CPU speed. It ensures your CPU adapts to your usage, whether you are browsing or running resource-intensive tasks on your computer. You can explore its several options discussed in this tutorial and fine-tune your system for optimal performance.

Advertisements