7

The answer seems pretty obvious I guess but none of the possible answers given in https://superuser.com/questions/406141/how-to-get-an-arm-cpu-clock-speed-in-linux applies to me.

cat /proc/cpuinfo 

only gives me

processor   : 0
model name  : ARMv7 Processor rev 2 (v7l)
Features    : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x3
CPU part    : 0xc08
CPU revision    : 2

Hardware    : Generic AM33XX (Flattened Device Tree)
Revision    : 0000
Serial      : 0000000000000000

and there is no file called cpuinfo_*_freq below /sys/devices/system/cpu. I don't have hwinfo or dmidecode or any executable called cpu* on this machine :)

Do you know how to retrieve or 'measure' a CPU's actual frequency programatically?

Community
  • 1
  • 1
frans
  • 8,868
  • 11
  • 58
  • 132
  • 4
    Note that ARM CPUs are just cores, the clock control is part of the larger SoC built around them, and differs from vendor to vendor (i.e. it matters far more that this is an OMAP-something than that it contains a Cortex-A8). Without a cpufreq driver which actually knows the relationship between that clock controller's parameters and the resulting CPU frequency, you're left fumbling around in the dark trying to infer things. If you're lucky, your kernel might have perf event support so you can estimate via counting cycles. – Notlikethat Sep 09 '15 at 08:55
  • 2
    Either way, there's not really a robust, portable solution, so you may want to rethink if your code _really_ needs to know the CPU clock. If it's purely personal curiosity, then checking the bootloader/early kernel output on startup, or grovelling about in the Device Tree, might also reveal something you can piece together. – Notlikethat Sep 09 '15 at 09:02
  • 1
    @Notlikethat: can you elaborate on the perf/counting cycles approach? E.g. provide a link? – frans Sep 09 '15 at 11:52
  • 1
    @paulsm4: as stated in the question - I have neither `hwinfo` nor `dmidecode` installed. It's an embedded (yocto) Linux with kernel version 3.12. – frans Sep 09 '15 at 11:56
  • Sorry, I assumed it would be sufficiently obvious - read cycle count; wait known time period; read cycle count again; do simple maths - that it didn't need explaining ;) In the absence of cpufreq it should be safe to assume that the CPU is running at a fixed rate relative to the timer clocksource. – Notlikethat Sep 09 '15 at 11:58
  • 4
    In fact [perf tools](https://perf.wiki.kernel.org/index.php/Main_Page) can even do that all for you - I just tried `perf stat sleep 1` on an arm64 kernel built with perf events but without cpufreq or cpuidle, and its cycle-based frequency estimate was only about 1% off. – Notlikethat Sep 09 '15 at 20:23
  • Doesn't work for me: I get different values between 580MHz and 790MHz for a CPU which should have a fixed frequency of 800MHz.. – frans Apr 21 '16 at 10:03

1 Answers1

0

you could try dmidecode|grep MHz

qiaochu li
  • 25
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 30 '22 at 23:12