84

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)

5
  • 7
    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). Commented Feb 20, 2016 at 20:02
  • What is turbo boost? And so does this mean my speed is actually around 3.2 GHz?
    – Rohan
    Commented Feb 20, 2016 at 20:06
  • 4
    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). Commented Feb 20, 2016 at 20:14
  • 4
    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
    Commented Sep 16, 2017 at 17:07
  • Related: Linux utility to bench mark clock speed of CPU Commented Apr 25, 2020 at 17:10

6 Answers 6

146

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

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

Notes:

This does not work on server CPUs such as the Intel Xeon series. On such machines it will show the base frequency only. To show the turbo frequency, you'll need cpupower or turbostat. See @Maxim Egorushkin's answer.

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

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

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.)

6
  • 1
    I had to remove the . in your first command to make it work: watch -n1 "cat /proc/cpuinfo | grep \"^[c]pu MHz\""
    – n1k31t4
    Commented Mar 30, 2017 at 14:36
  • 5
    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
    Commented Mar 30, 2017 at 21:49
  • 1
    @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. Commented Oct 20, 2017 at 17:02
  • 3
    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
    Commented Oct 21, 2017 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
    Commented Jan 11, 2018 at 18:47
20

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
5
  • 5
    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". Commented Jan 11, 2018 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). Commented Oct 14, 2019 at 18:12
  • 1
    Unfortunately, i7z doesn't seem to work properly on my Core i7-1165G7 – it says "unknown processor" (among other things) and aborts.
    – balu
    Commented Jul 26, 2021 at 8:45
  • 1
    @balu You need to start it with sudo! Without sudo it also shows Unknown processor for me. Commented Jul 26, 2021 at 20:41
  • Another good tool from Intel itself is turbostat (from the linux-cpupower package). But this one has nicer output.
    – rustyx
    Commented Apr 11, 2023 at 11:57
15

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.

4
  • 1
    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
    Commented Sep 17, 2017 at 4:07
  • that link is now broken...
    – Mikhail T.
    Commented Aug 1, 2018 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
    Commented Aug 2, 2018 at 10:49
  • @Jaime hi, you are mentioning that: "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." Is there no way to have all the cores simultaneously working on the max speed 3.3GHz? Or is there any specification that exactly says that it's not possible? Commented Apr 19, 2020 at 11:06
12

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
2
  • This method seems to work on the raspberry pi running Raspbian
    – Jon
    Commented Jul 31, 2019 at 14:53
  • This will not work on a server with intel_idle.max_cstate=0 processor.max_cstate=0 in the boot command line, as there is no cpufreq subdirectory. For such a machine, cpupower or turbostat seem to be the only available tools.
    – Mike S
    Commented Jan 27, 2023 at 17:23
5

To get informations about your CPU type the following command:

dmidecode -t processor | grep -i mhz
3
  • 3
    Cuspy. Now I see 4 different numbers here ;-)
    – vonbrand
    Commented Feb 20, 2016 at 23:11
  • 1
    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. Commented Jan 9, 2017 at 18:09
  • 4
    @vonbrand A person with one watch knows what time it is. A person with two watches can never be quite certain.
    – Kusalananda
    Commented Sep 16, 2017 at 17:58
4

cpupower application measures average CPU frequency over specified time intervals (1 second by default).

Average values differ from current instantaneous values from /proc/cpuinfo. Instantaneous values can show the minimum and maximum CPU frequency values, which are quite useful for CPU performance tuning. Average values rarely reach minimum and maximum extremes due to process scheduler migrating threads/processes to other CPU cores to spread heat and wear evenly across all CPU cores (unless threads are pinned to specific cores); they are useful for examining sustained CPU frequencies during long-running (30+ minutes) full loads.

For example, during a workload utilizing half of available CPU cores at 100%, instantaneous core frequencies are everywhere between minimum and maximum, whereas average frequencies are similar and slightly below maximum for all cores. This is the workload used in the examples below.

The following command continuously displays average CPU core frequencies over last 2 seconds (-i2 option):

$ sudo watch -n0 cpupower monitor -i2
Every 0.1s: cpupower monitor -i2    supernova2: Sun Jul 30 01:05:07 2023

    | Mperf              || Idle_Stats
 CPU| C0   | Cx   | Freq  || POLL | C1   | C2   | C3
   0| 60.27| 39.73|  2295||  0.00|  0.00|  0.07| 39.71
   1| 40.35| 59.65|  2295||  0.00|  0.00|  0.00| 59.73
   2| 84.22| 15.78|  2297||  0.00|  0.00|  0.07| 15.71
   3| 16.74| 83.26|  2286||  0.00|  0.00|  0.06| 83.24
   4| 21.42| 78.58|  2286||  0.00|  0.00|  0.00| 78.59
   5| 78.70| 21.30|  2298||  0.00|  0.00|  0.03| 21.27
   6| 99.98|  0.02|  2295||  0.00|  0.00|  0.00|  0.00
   7|  0.47| 99.53|  2262||  0.00|  0.00|  0.06| 99.48
   8| 84.02| 15.98|  2294||  0.00|  0.00|  0.00| 15.97
   9| 16.23| 83.77|  2299||  0.00|  0.00|  0.05| 83.74
  10| 99.98|  0.02|  2295||  0.00|  0.00|  0.00|  0.00
  11|  0.58| 99.42|  2278||  0.00|  0.00|  0.85| 98.55
  12| 99.98|  0.02|  2295||  0.00|  0.00|  0.00|  0.00
  13|  0.15| 99.85|  2278||  0.00|  0.00|  0.01| 99.84
  14| 10.87| 89.13|  2292||  0.00|  0.00|  0.08| 89.06
  15| 89.30| 10.70|  2296||  0.00|  0.00|  0.00| 10.70

instantaneous CPU core frequencies for comparison:

watch -n2 fgrep MHz /proc/cpuinfo
Every 2.0s: fgrep MHz /proc/cpuinfo    supernova2: Sun Jul 30 01:05:33 2023

cpu MHz         : 1600.000
cpu MHz         : 2305.026
cpu MHz         : 2294.830
cpu MHz         : 2305.022
cpu MHz         : 1600.000
cpu MHz         : 2305.033
cpu MHz         : 2305.035
cpu MHz         : 1600.000
cpu MHz         : 2305.026
cpu MHz         : 2318.834
cpu MHz         : 2305.038
cpu MHz         : 2309.039
cpu MHz         : 2000.000
cpu MHz         : 2305.027
cpu MHz         : 1600.000
cpu MHz         : 2305.026

cpupower application package name depends on Linux distribution (from comments):

  • linux-tools-$(uname -r) in Ubuntu.
  • kernel-tools in Red Hat.
  • linux-cpupower in Debian.

htop since version 3 displays instantaneous CPU frequency next to CPU utilization at the top. (Open the image in the new tab to view it at 100% scale, if it displays too small.)

htop-3

5
  • 1
    To install this run: sudo apt-get install -y linux-tools-$(uname -r) Commented Jul 12, 2022 at 18:43
  • 1
    @SurpriseDog Thank you, the answer has been updated. Commented Jul 12, 2022 at 20:40
  • 1
    On Red Hat 7, 8, and 9 systems, the package is kernel-tools . Other goodies like turbostat can be found there.
    – Mike S
    Commented Jan 27, 2023 at 17:13
  • 1
    On Debian its in the package linux-cpupower
    – Pierre H.
    Commented Jul 25, 2023 at 7:51
  • I had to turn on "Also show CPU frequency" under Display Options in htop's setup; it wasn't enabled on a fresh install.
    – smitelli
    Commented Jan 10 at 2:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .