Wednesday, February 15, 2017

Read, Modify CPU frequency & Governors in Linux from command Line

Hi Folks welcome to my blog..

I have a short post in changing CPU frequency & governors from command line on a Linux machine. I am using BeagleBoneBlack booted to shell with minimal file-system generated from build-root with Kernel version 3.8.13.

I am at shell prompt as a sudo user.

Reading CPU information: We get the CPU information reading the cpuinfo file in proc file-system.

# cat /proc/cpuinfo

Reading CPU frequency & governors:

Change directory to  /sys/bus/cpu/devices/cpu0/cpufreq

# cd /sys/bus/cpu/devices/cpu0/cpufreq
# ls

To get the available CPU frequencies for  scaling read the below file.
# cat scaling_available_frequencies

To get the current CPU frequency, read the below file.
# cat cpuinfo_cur_freq

CPU is currently running at 1GHz

To read the current CPU governor, read the below file
# cat scaling_available_governors

similarly to read the current CPU governor read the below file
# cat scaling_governor

Changing CPU frequency

In order to change the CPU frequency, we have to change the CPU governor to userspace. This allows to run the CPU at user specified frequencies.

In case of ondemand governor we can set the scaling_max_freq & scaling_min_freq, but we cannot set a specific frequency from the available list of CPU frequencies.

For more details read the following link:

# echo userspace > scaling_governor
# echo  600000 > scaling_setspeed

#cat cpuinfo_cur_freq

Changing CPU frequency to 600MHz, we can set only values available under scaling_available_frequencies

Now you change the CPU governor to ondemand and try to modify the scaling_max_freq & scaling_min_freq  frequencies and observe the effect when you try to change the CPU current frequency.

Thanks for your time. Please feel free to post your comments.

1 comment:

  1. Thanks for sharing this awasome news for us. Get your outdoor storage needs organized with a backyard Garden shed in wide variety of metal, plastic and wood material with any home style and garden view..if you live abroad and want to get garden shed in Newzealnd you will be also see here Garden shed Nz. For more visit my page