How does CPU frequency work in conky?

6,726

Solution 1

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:

% 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:

# 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:

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

References

Solution 2

That shows the current CPU frequency, you've probably got CPU frequency scaling activated, so your CPU "slows down" when there's not much to do, and if you do something CPU intensive it should speed up to 2.8 and/or something in between, it's normal.

Solution 3

In case you want to print the CPU frequency your CPU is capable of, instead of or in addition to the currently used CPU speed try:

${pre_exec cat /proc/cpuinfo | grep 'model name' | uniq | awk '{print $10}' }

This will only execute once at the launch of conky, and output the CPU frequency listed in /proc/cpuinfo.

I am not sure if the output of model name is unified, so if you don't get the right output you have to edit the $10 in awk to a lower or higher number.

Share:
6,726

Related videos on Youtube

Mitro
Author by

Mitro

I used computer for the first time when I was 10 and now it's my primary occupation. I like looking at the things I use daily and ask myself questions such as “How it is made?”, “How does it work?”, or "Could I do it better?". Something that "just works" isn't good enough for me. I always want to do the best with everything I use or develop. I like learning and love coding.

Updated on September 18, 2022

Comments

  • Mitro
    Mitro over 1 year

    I'm setting up conky and I would like to add the CPU frequency, but if I put

    ${freq_g cpu0} Ghz
    

    I get 1.2Ghz. Why is that? My CPU is 2.8Ghz.