in Linux Redhat

How To Change The CPU governor

Performance tunning is one of the most exciting and complicated subject at the same time, it’s complicated because if you change one setting it might affect the others so you must have a deep understanding of the what, how, why and the why not of other aspect of the operating system that you would like to change.
So here, I’ll demonstrate how to change the cpu governor of a Red Hat 6.6 which come with the governor userspace enabled by default to use the performance governor .

Here is some notes from the Red Hat documentation to have some refreshed information:

The governor defines the power characteristics of the system CPU, which in turn affects CPU performance. Each governor has its own unique behavior, purpose, and suitability in terms of workload.

More information about this modules can be found here =>

Different kernel module exist which implement the required cpu governors driver, you can find them here:

[root@server ~]# ll  /lib/modules//kernel/drivers/cpufreq/
total 88
-rwxr--r--. 1 root root 20600 Sep 16  2014 cpufreq_conservative.ko
-rwxr--r--. 1 root root 27088 Sep 16  2014 cpufreq_ondemand.ko
-rwxr--r--. 1 root root  5360 Sep 16  2014 cpufreq_powersave.ko
-rwxr--r--. 1 root root 14144 Sep 16  2014 cpufreq_stats.ko
-rwxr--r--. 1 root root 10944 Sep 16  2014 freq_table.ko

And you can check for the loaded module using lsmod

[root@server ~]# lsmod | grep cpu
cpufreq_ondemand       10544  0
freq_table              4936  1 cpufreq_ondemand
pcc_cpufreq             5090  0

If the kernel module isn’t loaded, you can load it using modprobe

# modprobe <module_name>

So to change this settings you have two options:

1- Work with the files in the /sys/devices/system/cpu/<cpu_number>/cpufreq/scaling_governor directory
2- Or use the cpupower CLI

I prefer the option number two.

First you must install the cpupowerutils package if it’s not installed

yum install cpupowerutils –y

Then you can check for the all the available governors to you

[root@server ~]# cpupower frequency-info --governors
analyzing CPU 0:
ondemand userspace performance

To change the current governor from userspace to performance, use the following command:

[root@server ~]# cpupower frequency-set -g performance
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
Setting cpu: 8
Setting cpu: 9
Setting cpu: 10
Setting cpu: 11
Setting cpu: 12
Setting cpu: 13
Setting cpu: 14
Setting cpu: 15

You can confirm the change using

[root@server ~]# cat /sys/devices/system/cpu/cpu[0-9]/cpufreq/scaling_governor


[root@server ~]# cpupower frequency-info --policy
analyzing CPU 0:
1200000 2600000 performance

This setting are for the run time environment and will be lost after a system restart. To make this change persistent across reboot, edit the /etc/sysconfig/cpuspeed.

sed -i 's/^GOVERNOR=/GOVERNOR=performance/g' /etc/sysconfig/cpuspeed

Share your thoughts