18

I found two commands to output information about my CPU: cat /proc/cpuinfo and lscpu. /proc/cpuinfo shows that my CPU speed is 2.1 Ghz, whereas lspcu says it is 3167 Mhz. Which one is correct?

This is my exact output from cat /proc/cpuinfo about my processor speed:

model name  : Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz

And this is from lscpu:

CPU MHz:               3225.234

(For some reason, lscpu outputs differently every time, varying between 3100 and 3300 MHz)

  • 3
    Your /proc/cpuinfo should also have a line that says cpu MHZ: ... which is the current speed. The 2.1 after the @ is the base speed (without turbo boost). – don_crissti Feb 20 '16 at 20:02
  • What is turbo boost? And so does this mean my speed is actually around 3.2 GHz? – Rohan Feb 20 '16 at 20:06
  • 2
    It's Intel's way of "hitting the gas" when needed. I guess your actual speed at the time was indeed around 3.2 GHz, you could also try e.g. for cpu0 with cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq (as root). – don_crissti Feb 20 '16 at 20:14
  • 2
    Turbo Boost is a technology that changes the frequency of the processor depending of the number of cores you are using. If you use few cores, the frequency is increased to boost the performance and maintain a low temperature. You may check the Turbo Boost frequency tables to check how it increases. – Jaime Sep 16 '17 at 17:07
33

To see the current speed of each core I do this:

watch -n.1 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""

Note:

If your watch command does not work with intervals smaller than one second, modify the interval like so:

watch -n1 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""

This displays the cpu speed of each core in real time.

By running the following command, one or more times, from another terminal one can see the speed change with the above watch command, assuming SpeedStep is enabled (Cool'n'Quiet for AMD).

echo "scale=10000; 4*a(1)" | bc -l &

(This command uses bc to calculate pi to 10000 places.)

  • I had to remove the . in your first command to make it work: watch -n1 "cat /proc/cpuinfo | grep \"^[c]pu MHz\"" – n1k31t4 Mar 30 '17 at 14:36
  • 1
    this is a nifty way to do it, but I'd caution against running any command every .1 seconds, that is itself going to impact the cpu speed report. 1 second is plenty. – Lizardx Mar 30 '17 at 21:49
  • @Lizardx Ordinarily I agree but in this case the CPU speed can increase and decrease faster than a 1 second interval, resulting in a lack of visible speed changes. Since modern processors are so fast, I initially thought my SpeedStep was not working when using 1 second as the interval. At a minimum, .5 should be used if one doesn't want to go as fast as .1 second (although I have still missed seeing many of the speed changes at that rate. – Timothy Martin Oct 20 '17 at 17:02
  • 1
    Try running top with the timers set to less than 1 second, you can see the cpu usage visibly. My guess is that what you may actually be seeing is the system generating your cpu speed info, that is, the generation of the cpu speed output is causing the cpu movement. I find that anything less than a second starts to directly cause the cpu speeds you are watching. For example, top at -d5 is 1% of cpu. At -d2 it's about 5%. You might find you're actually fooling yourself into thinking the cpu is doing something that you're making it do, heh. Output to shell is expensive too. – Lizardx Oct 21 '17 at 0:52
  • Could try watch -n0.1, might work. Failing that, while true; do cat /proc/cpuinfo | grep MHz; sleep 0.1; clear; done, it flickers more than watch though. – Steven Lu Jan 11 '18 at 18:47
6

For intel i3, i5 and i7 based cpus there is a dedicated tool called i7z that shows current speed for all cpu cores.

From man page (description):

i7z runs the i7z, ncurses based, program without any options. i7z will print out the C-states and temperature for i3, i5 and i7 based Core processors from Intel (including Nehalems, Sandy Bridge and Ivy Bridge).

For ubuntu-based distributions you can install it by issuing this command:

sudo apt-get install i7z

then just run it (tool needs to be run with sudo):

sudo i7z
  • 4
    This is the best solution if you have an Intel CPU. Cat'ing the cpuinfo gives you incorrect clock speeds. Just a note, you forgot to put the dash in "apt-get". – fgblomqvist Jan 11 '18 at 19:22
  • Well... it works with my Xeon processor only the output is garbled, maybe because I have two CPUs (I have a dual Xeon motherboard). – Alexis Wilke 2 days ago
4

CPU frequencies are kept in the kernel but they can be a little "off". You can see them using:

$ cd /sys/devices/system/cpu
$ paste <(cat cpu*/cpufreq/affected_cpus) <(cat cpu*/cpufreq/scaling_cur_freq) | column -s $'\t' -t
0  833914
1  800021
2  800086
3  800029
4  800036
5  800460
6  800118
7  800141

If you don't need to know the CPU #'s a shorter method is simply using:

$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
1396354
800058
800050
800024
800005
800017
800001
1392006
  • This method seems to work on the raspberry pi running Raspbian – Jon Jul 31 at 14:53
3

The Intel Core i7-4600U Processor supports Turbo Boost technology. It has a base frequency of 2.10GHz and a Max Turbo Frequency of 3.30GHz. That means that,

  • If you disable the Turbo Boost (in the BIOS setup menu), the CPU will work at 2.10GHz all the time.
  • When Turbo Boost is enabled and only one of the cores is working, the CPU will work at a maximum of 3.30GHz.
  • If Turbo Boost is enabled and all the cores are working, the CPU will work at 2.10GHz.

Obtaining current frequency

To determine if the Turbo Boost is activated and which is the current frequency, you can use cpupower frequency-info. For instance, for an old Intel Core i5-660 with Turbo Boost enabled, you will get the following.

$ cpupower frequency-info
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.20 GHz - 3.47 GHz
  available frequency steps: 3.47 GHz, 3.33 GHz, 2.53 GHz, 1.87 GHz, 1.20 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance
  current policy: frequency should be within 1.20 GHz and 3.47 GHz.
              The governor "ondemand" may decide which speed to use
              within this range.
  current CPU frequency is 1.87 GHz.
  cpufreq stats: 3.47 GHz:82,67%, 3.33 GHz:0,00%, 2.53 GHz:0,00%, 1.87 GHz:0,06%, 1.20 GHz:17,28%  (3)
  boost state support:
    Supported: yes
    Active: yes
    25500 MHz max turbo 4 active cores
    25500 MHz max turbo 3 active cores
    25500 MHz max turbo 2 active cores
    25500 MHz max turbo 1 active cores

Note that the information states the hardware limits (1.20 GHz - 3.47 GHz), the possible frequencies (3.47 GHz, 3.33 GHz, 2.53 GHz, 1.87 GHz, 1.20 GHz) and the current frequency (1.87 GHz). You may find the technical information of these frequencies at the Intel website.

Frequency when TurboBoost is disabled

Note the difference when you run the same command with Turbo Boost disabled: In the boost state support section, the values for Supported and Active are no. Here, the CPU will be at the nominal/minimal value (1.20Ghz) all the time.

$ cpupower frequency-info
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.20 GHz - 3.47 GHz
  available frequency steps: 3.47 GHz, 3.33 GHz, 2.53 GHz, 1.87 GHz, 1.20 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance
  current policy: frequency should be within 1.20 GHz and 3.47 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.20 GHz.
  cpufreq stats: 3.47 GHz:40,86%, 3.33 GHz:0,01%, 2.53 GHz:0,06%, 1.87 GHz:0,22%, 1.20 GHz:58,85%  (493)
  boost state support:
    Supported: no
    Active: no
    25500 MHz max turbo 4 active cores
    25500 MHz max turbo 3 active cores
    25500 MHz max turbo 2 active cores
    25500 MHz max turbo 1 active cores

You can disable the Turbo Boost using the BIOS or some Linux options/commands. The kernel support can be enabled/disabled using the /sys/devices/system/cpu/cpufreq/boost file.

  • Haypo has a blog entry with more information about the Intel p-state driver, the C-states, the Turbo Boost and the commands to obtain frequency information. – Jaime Sep 17 '17 at 4:07
  • that link is now broken... – Mikhail T. Aug 1 '18 at 23:16
  • 1
    The link for haypo blog entry is broken. You may find a copy in the Victor Stinner's notes: part 1 and part 2. – Jaime Aug 2 '18 at 10:49
2

To get informations about your CPU type the following command:

dmidecode -t 4
  • 2
    Cuspy. Now I see 4 different numbers here ;-) – vonbrand Feb 20 '16 at 23:11
  • Also, the "current speed" seems to be misleading, as the current speed is currently always reported as a large number (3.7GHz), when the machine is idle. – ragerdl Jan 9 '17 at 18:09
  • @vonbrand A person with one watch knows what time it is. A person with two watches can never be quite certain. – Kusalananda Sep 16 '17 at 17:58
0

Depends on what you are using the information for; the output line from cat /proc/cpuinfo` is the "Advertised" speed, the speed in the brochure, etc. If you are comparing server A to server B, that may be sufficient. If you are monitoring workloads on the system, the comments to your question and the answer by @gad3r would be what to look at.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.