[one-liner]: Why is Conky reporting a lower CPU frequency, when my CPU frequency is actually much higher?

Background

If you’ve every dealt with Conky you may have gotten a little confused when you’re trying to get it to display your CPU frequency like so:

1
${freq_g cpu0} Ghz

… and Conky is reporting your CPU frequency as 1.12GHz when in fact it’s actually much higher than that, say 2.67GHz. Most likely this is being caused by the CPU governing features that are present in most modern hardware. Here’s a behind the scenes 5 second tour of seeing what’s going on within your Linux Kernel.

Solution

First, from the conky man page.

cpu (cpuN)

CPU usage in percents. For SMP machines, the CPU number can
be provided as an argument. ${cpu cpu0} is the total usage, and ${cpu
cpuX} (X >= 1) are individual CPUs.

freq_g (n)

Returns CPU #n’s frequency in GHz. CPUs are counted from 1.
If omitted, the parameter defaults to 1.

You most likely have something like SpeedStep enabled which is acting like a governor on a car, regulating the speed of the cores inside your CPU. You can confirm that this is going on by looking at the output of this command:

1
2
3
4
5
6
7
8
9
% less /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 37
model name      : Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz
stepping        : 5
cpu MHz         : 1199.000
...

The 2 numbers that matter are the 2.67GHz, that the GHz that my CPU is rated to operate at followed by the number 1199.00, this is what my CPU is allowed to run at by the governor setup on my Linux laptop.

You can see what governor is currently configured like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# available governors
% sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors 
powersave ondemand userspace performance 
# which one am I using?
% sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 
powersave
 
# what's my current frequency scaling?
% sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 
1199000
 
# what maximum is available?
% sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 
2667000
 
# what's the minimum?
% sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 
1199000
 
# what scaling frequencies can my CPU support?
% sudo cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 
2667000 2666000 2533000 2399000 2266000 2133000 1999000 1866000 1733000 1599000 1466000 1333000 1199000

You can override your governor by doing the following, using one of the governor’s listed above:

1
% sudo sh -c "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

References

links

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

This entry was posted in conky, linux, monitoring, one-liner, performance, Syndicated, sysadmin, tips & tricks. Bookmark the permalink.

Comments are closed.