8

I mean to determine the clock speed. I am posting below the output of the various commands listed here.

For the max freq, I see 4 different sources, with 2 different values:

  1. CPU max MHz: 3300,0000 from lscpu.
  2. capacity: 3300MHz from lshw.
  3. capacity: 3800MHz from sudo lshw.
  4. Max Speed: 3800 MHz from dmidecode.

For the current freq, I see 4 different sources, with roughly 3 different values:

  1. CPU MHz: 2100.000 from lscpu.
  2. cpu MHz : 1691 (averaged by me) from cat /proc/cpuinfo.
  3. Current Speed: 2600 MHz from dmidecode.
  4. Detected 2594.332 MHz processor from cat /var/log/dmesg.

My observations:

  1. There was a wide variation in the output obtained, for both the max freq and current freq. How to make sense of this? For instance, lshw gives different results with or without sudo. Is this expected? Which should be considered more reliable, and why?
  2. The clock speed was even different among the 4 processors. Is such a wide variation expected?

Note: As appropriately asked by @hobbs, this OP was motivated by the need for understanding the relation between "Clock speed" (whichever variant corresponds), CPU freq spec, and memory speed spec (here there is also possibly more than one value, see e.g. dmidecode showing Memory Module Voltage: 3.3 V for DDR3 RAM).


Output:

$ lscpu | grep "MHz"
CPU MHz:                         2100.000
CPU max MHz:                     3300,0000
CPU min MHz:                     1200,0000

$ cat /proc/cpuinfo | grep "MHz" cpu MHz : 1753.417 cpu MHz : 1200.000 cpu MHz : 2212.235 cpu MHz : 1600.000

$ lshw -c cpu | grep capacity WARNING: you should run this program as super-user. capacity: 3300MHz $ sudo lshw -c cpu | grep capacity capacity: 3800MHz

$ sudo dmidecode -t processor | grep "Speed" Max Speed: 3800 MHz Current Speed: 2600 MHz

$ cat /var/log/dmesg | grep "MHz processor" [ 0.000000] kernel: tsc: Detected 2594.332 MHz processor

$ cat /var/log/kern.log | grep "MHz processor"

  • All of them are true in some way, and it depends on what you really want to know. "The clock speed" isn't really one thing. There's A) the available speed steppings, B) the active speed stepping for each core at a certain instant, C) the highest speed stepping available to a single core with the other cores idle and average-power constraints satisfied, D) the highest speed stepping available to all cores sustained, E) the actual number of clocks run by a core over some recent period of time, F) doubtless some other things... So what do you want to decide based on "the clock speed"? – hobbs Mar 30 '22 at 22:26
  • @hobbs - I meant to understand the relation between "Clock speed" (whichever variant corresponds), CPU spec, and memory speed spec (here there is also possibly more than one value, see e.g. https://askubuntu.com/questions/1400050/dmidecode-showing-memory-module-voltage-3-3-v-for-ddr3-ram). – sancho.s ReinstateMonicaCellio Mar 31 '22 at 05:56

2 Answers2

7

The following deductions are done entirely based on my own experiments and extrapolations. Also, part of the deduction is comparing the numbers with the official clock speeds reported by the CPU manufacturer.

This command shows the current clock for each processor core: (all subsequent commands run on Intel Atom C3558 CPU)

$ cat /proc/cpuinfo | grep "MHz"
cpu MHz         : 1260.714
cpu MHz         : 1070.646
cpu MHz         : 1124.995
cpu MHz         : 1234.689

This command shows the current "average" (as observed by myself, purely based on trial) clock between cores (CPU MHz), and the max normal clock (CPU max MHZ).

$ lscpu | grep "MHz"
CPU MHz:                         1181.650
CPU max MHz:                     2200.0000
CPU min MHz:                     800.0000

Note that the current clock speed (both average and for each core) varies greatly over time (and possibly many times per second), as the system normally continuously throttles the CPU clock for powersaving (down to CPU min MHZ). I believe it is normal that this varies among CPU cores as well.

This command also shows the max normal clock (capacity - should be the same as CPU max MHz above).

$ lshw -c cpu | grep capacity
WARNING: you should run this program as super-user.
       capacity: 2200MHz

However, for my Intel Atom CPU this is only correctly reported without sudo (2200 MHz). With sudo, it reports a higher number (in this case also 3800 - this may be the max boosted clock, but I'm not sure in the case of an Atom CPU):

$ sudo lshw -c cpu | grep capacity
       capacity: 3800MHz

For a Broadcom ARM CPU (on a Raspberry Pi 4), the value is the same both with and without sudo (1500 MHZ). I would guess this is because the Pi Arm CPU does not have boost/turbo mode.

Artur Meinild
  • 26,018
  • 1
    Thanks for the detail. I have rewritten the question, with a more precise elaboration of the data. I am not sure what you posted answers the questions, nor if it is supported by the output:
    1. The "average" of the cpu freq for the 4 processors does not match the other figures.
    2. Max cpu freq "is only correctly reported without sudo"... do you have any source to support this?
    – sancho.s ReinstateMonicaCellio Mar 30 '22 at 12:47
  • 1
    I elaborated my answer to make it clear that it is based on my own observations, and not based on any official sources. I also tried to make it clear what I believe are reliable numbers, again based on my observations. If someone can chime in with official reports it would be handy indeed. – Artur Meinild Mar 30 '22 at 13:07
  • Thanks Doug. However, in this case, even on my 2,2 GHz Atom CPU, doing sudo su, and then followed by lshw -c cpu | grep capacity still gets me 3800 MHz, which is clearly not correct. – Artur Meinild Mar 30 '22 at 13:35
  • Agreed, it is incorrect. I deleted my comment. – Doug Smythies Mar 30 '22 at 14:40
5

Updated the answer at Any way to check the clock speed of my processor?

But in summary:

All the commands above will also give you the CURRENT cpu Hertz, meaning, if you expect to see the same one on lscpu and when doing the cat /proc/cpuinfo it will be near impossible. you CAN compare the maximum because that should show the same for any of the ways you can analyze the CPU, but the current will always be literally "the current CPU hertz" at the moment you execute it.

Lastly do note that dmidecode reads information from the ACPI tables which is not always the same as the real time ones done by the other tools.

So you got a couple of ways of getting the REAL current CPU and then you also have methods of getting what the ACPI Table registers (which in my case is super wrong).

This is why if you run lscpu multiple times, the current speed will always change, same for the /proc/cpuinfo. But for dmidecode it will stay (on many cases) with the same value, even if the value is a false positive.

Luis Alvarado
  • 211,503