Showing posts with label cpu frequency. Show all posts
Showing posts with label cpu frequency. Show all posts

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







Friday, January 27, 2017

how to find cpu frequency in linux ?

Frequency


CPU frequency scaling enables the operating system to scale the CPU frequency up or down in order to save power. CPU frequencies can be scaled automatically depending on the system load, in response to ACPI events, or manually by userspace programs.
CPU frequency scaling is implemented in the Linux kernel, the infrastructure is called cpufreq

The frequency/speed of the processor is reported by both lscpu and /proc/cpuinfo.
Method 1:
lscpu | grep -i mhz

Example :
ravi@linuxforfreshers.com:~$ lscpu | grep -i mhz
CPU MHz:               1596.000

Method 2:

cat /proc/cpuinfo | grep -i mhz | uniq
Example:
ravi@linuxforfreshers.com:~$ cat /proc/cpuinfo | grep -i mhz | uniq
cpu MHz                      : 1596.000

Method 3:
The change of frequency can be seen by monitoring the output of /proc/cpuinfo using watch.
$ watch -n 0.1 "cat /proc/cpuinfo | grep -i mhz"

Method 4:
Using lshw command
Example:
ravi@linuxforfreshers.com:~$ sudo lshw -c cpu | grep capacity
       capacity: 1596MHz

Method 5:
Using dmidecode
Example:
ravi@linuxforfreshers.com:~$ sudo dmidecode -t processor | grep "Speed"
            Max Speed: 6000 MHz
            Current Speed: 2133 MHz



You can also get the current cpu frequency with this command:
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
Note : root access required using this command.
Example :
ravi@linuxforfreshers.com:~$ sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq
2133000