1

I saw that /proc/cpuinfo update all the time, especially the field "cpu MHz"? I assumed that these details should be constant.

When did /proc/cpuinfo begin to update all the time, especially the field "cpu MHz"? Is it depend linux systems or versions?

Example :

  • First run
    [omerha@hroor tmp]$ cat /proc/cpuinfo  | grep "cpu MHz" | tail -1
    cpu MHz         : 1406.195
    
  • Second run
    [omerha@hroor tmp]$ cat /proc/cpuinfo  | grep "cpu MHz" | tail -1
    cpu MHz         : 1675.964
    
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175

2 Answers2

2

It depends on the processor architecture. For x86 (32-bit a.k.a. i386 or 64-bit a.k.a x86_64 a.k.a. amd64), it was generalized in kernel 2.6.16 which came out in March 2006. The patch generalizing it had been under discussion and review for a while.

In the code (for 32-bit x86): 2.6.16 calls cpufreq_quick_get which looks up the current value for each CPU. 2.6.15 reads a global variable which is only updated on some processors and is never updated on multiprocessor machines.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • ... and the x86 code has changed quite a bit since then, see especially [x86 / CPU: Always show current CPU frequency in /proc/cpuinfo](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7d5905dc14a87805a59f3c5bf70173aac2bb18f8). – Stephen Kitt Sep 30 '20 at 11:56
  • I think it would be helpful to also clarify that the value in `/proc/cpuinfo` is the _current_ clock speed, and is constantly updated, not a static value. – terdon Sep 30 '20 at 11:56
  • @terdon Uh? The question is asking since when this is the case, so that's already established. – Gilles 'SO- stop being evil' Sep 30 '20 at 12:02
  • @StephenKitt Oh, so this was no longer the case in 4.13 and 4.14, then back in 4.15? – Gilles 'SO- stop being evil' Sep 30 '20 at 12:06
  • The situation evolved quite a bit between 2.6.16 and 4.12, with different meanings for the `cpu MHz` value depending on the frequency governor, specific CPU, ACPI support etc. Len Brown tried to [make things consistent](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=51204e0639c4), but that got [reverted](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=890da9cf0983), and Rafael J. Wysocki introduced [the `arch_freq_prepare_all` system](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7d5905dc14a8) in 4.15. – Stephen Kitt Sep 30 '20 at 12:15
  • All that happened in the 4.13, 4.414 and 4.15 cycles, but the situation was already complicated before then ;-). – Stephen Kitt Sep 30 '20 at 12:17
  • @Gilles'SO-stopbeingevil' the question also says " I assumed that these details should be constant.", so I think this is part of what is confusing the OP. – terdon Sep 30 '20 at 12:17
1

There is no file to update. The CPU frequency changes when it changes.

The "file", it looks like a file but is not a file: it does not exist on disk or SSD. It has a filename, it has content (so it is a file, and so is a directory, a sym-link, a hard-disk, a serial-port, … ). In general values in /proc are generated dynamically whenever they are read.

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102