Thursday, January 17, 2019

How to find cpu minimum, current & maximum frequency in linux ?

cpu manufacturers pro-grammatically reduce the frequency of the processor. You can find out the current and possible frequency with the command:

How to find available frequencies ?

cat  /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies

Sample output:

cat  /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies
2933000 2128000 1596000
2933000 2128000 1596000


Finding each core   minimum, current & maximum frequency


grep '' /sys/devices/system/cpu/cpu0/cpufreq/scaling_{min,cur,max}_freq

Sample output:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq:1596000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:1596000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq:2933000

Here we can see that the current processor frequency-1596 Mhz and the maximum-2933 Mhz.

Above example for core 0 if you have N number of cores use *:


grep '' /sys/devices/system/cpu/cpu*/cpufreq/scaling_{min,cur,max}_freq

Sample output :

/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq:1596000
/sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq:1596000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:1596000
/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq:2128000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq:2933000
/sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq:2933000

How to find cpu count ?

grep -c 'model name' /proc/cpuinfo


Sample output :

2



Use various performance governors.

ondemand: The CPU freq governor "on-demand" sets the CPU depending on the current usage.
To do this the CPU must have the capability to switch the frequency very quickly.

conservative: The CPU freq governor "conservative", much like the "on-demand" governor, sets
the CPU depending on the current usage. It differs in behavior in that it gracefully increases
and decreases the CPU speed rather than jumping to max speed the moment there is any
load on the CPU. This behavior is more suitable in a battery powered environment.

userspce: The CPU freq governor "user-space" allows the user, or any user-space program
running with UID "root", to set the CPU to a specific frequency by making a sysfs
file "scaling_setspeed" available in the CPU-device directory.

powersave: The CPU freq governor "powersave" sets the CPU statically to the lowest
frequency within the borders of scaling_min_freq and scaling_max_freq.

performance: The CPU freq governor "performance" sets the CPU statically to the highest
frequency within the borders of scaling_min_freq and scaling_max_freq.



How to find available_governors?

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

Sample output:

conservative ondemand userspace powersave performance


Set permanently one eg.:


sudo echo "performance" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

performance







No comments:

Post a Comment