1

My laptop Thinkpad T400 with Ubuntu 16.04 has two cpu cores cpu0 and cpu1.

$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
797963
797963
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed
800000
800000

Then I edit /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed to change its content to 1600000, and then

  1. Why is the realtime frequency of cpu1 also change, without changing its scaling_setspeed file?

    $ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed
    1600000
    800000
    $ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
    1595928
    1595926
    
  2. Why does the following command show a different result than the above:

    $ watch grep \"cpu MHz\" /proc/cpuinfo
    
    Every 2.0s: grep "cpu MHz" /proc/cpuinfo                                                                                                                   Thu Jan 25 17:31:01 2018
    
    cpu MHz         : 1600.000
    cpu MHz         : 800.000
    

Thanks.


It seems that changes should only affect the current core, not both:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/affected_cpus
0
$ cat /sys/devices/system/cpu/cpu1/cpufreq/affected_cpus
1
Tim
  • 101,790

1 Answers1

1

It's probably a hardware limitation. A lot of CPUs require that all cores, or sometimes pairs of cores on the same die, run at the same frequency. The affected_cpus file (in the same directory) should tell you which cores are forced to run at the same frequency.

See https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt for some documentation.

derobert
  • 109,670
  • @Tim not sure about the other command; possibly it's just displaying the desired (configured) speed instead of the actual? – derobert Jan 25 '18 at 22:38
  • I also check affected_cpus file, see my update – Tim Jan 25 '18 at 22:39
  • I guess that means that it doesn't require software coordination, the hardware is doing it... There are a couple of CPU-specific utilities (e.g., i7z for Intel chips) that can verify the frequencies from the hardware. You could confirm with one of them. – derobert Jan 25 '18 at 22:42
  • i7z outputs True Frequency (without accounting Turbo) 680 MHz, doesn't say which core it is. – Tim Jan 25 '18 at 22:55
  • @Tim odd, here it breaks it down by core, giving an actual frequency (and also C0, C1, C3, and C6 stats) per core. Also gives stats on turboboost, etc. Are you trying to run it on a non-Intel chip, maybe? – derobert Jan 25 '18 at 22:57
  • watch grep \"cpu MHz\" /proc/cpuinfo shows realtime cpu frequency https://unix.stackexchange.com/questions/87522/why-do-cpuinfo-cur-freq-and-proc-cpuinfo-report-different-numbers – Tim Jan 25 '18 at 22:57
  • I am using T400, which has Intel(R) Core(TM)2 Duo CPU, not i5 or i7. Does i7z work on T400? – Tim Jan 25 '18 at 22:58
  • @Tim apparently not. It was intended as a diagnostic tool for Turbo Boost in i7 chips (and which later spread to other Intel lines). Core2 Duo is probably too old. – derobert Jan 26 '18 at 00:01
  • What other ways then? – Tim Jan 26 '18 at 00:10