16

How can I get the current CPU frequency of an ARM processor on Ubuntu? Neither /proc/cpuinfo nor /sys/devices/system/cpu/cpu*/cpufreq helps.

In fact, there is no /sys/devices/system/cpu/cpu*/cpufreq directory on my Ubuntu system. And there is no CPU MHz information in /proc/cpuinfo either.

The platform specs are: NVIDIA® Jetson™ TX2, ubuntu16.04, linux 4.9.18.

Could anybody give some hints on acquiring the current CPU frequency of an ARM processor?

Is there any kernel configuration may inflence on getting current cpu frenqency?

part output of <code>cat /proc/cpuinfo</code>

sunshilong369
  • 211
  • 1
  • 2
  • 8
  • Are you _sure_ you don't have this in `/proc/cpuinfo`? Can you [edit] your question and add the contents of the file? It seems very strange that you don't have this there. – terdon May 28 '20 at 11:13
  • @terdon Yes, i am quite sure.The platform is not at hand at now. – sunshilong369 May 28 '20 at 11:20
  • Can you show us the contents of the file please? What is the output of `grep -i mhz /proc/cpuinfo`? I just checked on two Ubuntu systems (Ubuntu server 18.04.4 LTS (Bionic Beaver)) and both had it. – terdon May 28 '20 at 11:20
  • @terdon The output is nothing.I have checked it many times. – sunshilong369 May 28 '20 at 11:28
  • 3
    Ah! You have an ARM processor! I've deleted my answer since it isn't applicable here and edited this crucial missing piece of information into your question. If possible, please [don't post images of text](https://unix.meta.stackexchange.com/q/4086/22222). Instead, paste the text directly into your question and use the [formatting tools](https://unix.meta.stackexchange.com/help/formatting) to format it as code. – terdon May 28 '20 at 12:00
  • I choose to post the image because the hardware is not at hand right now. – sunshilong369 May 28 '20 at 12:05
  • Please add examples what excactly did you try and what failed. This is not enough. – tukan Jun 01 '20 at 10:28
  • I have posted the methods which i have tried in the question.On most platform, `cat /proc/cpuinfo` could give you the answer indeed. – sunshilong369 Jun 01 '20 at 11:47
  • 2
    Might be interesting to know which concrete CPU you are using. – SubOptimal Jun 02 '20 at 20:44
  • Assuming that it's one of the NVIDIA Jetson boards it might be that the related module (maybe tegra186-cpufreq) is not loaded. – SubOptimal Jun 04 '20 at 06:30
  • @SubOptimal Sorry for long time no reply.Yes, it's one of the NVIDIA Jetson boards.I will try, i think it is very likely the reason. – sunshilong369 Jun 05 '20 at 05:10
  • Would you mind including the output of `lsmod`. As I mentioned there's noting intrinsic about an ARM processor which should hide this information. If it is hardware dependent then, as SubOptimal mentioned, knowing exactly what hardware (which CPU which SBC) would be useful. – Philip Couling Jun 05 '20 at 15:33
  • I do not intend to hide such information.The platform is not at hand now.I would provide such information tomorrow. – sunshilong369 Jun 05 '20 at 16:50
  • Please **edit question** to tell us what CPU and what system. – ctrl-alt-delor Jun 05 '20 at 22:35
  • @SubOptimal & ctrl-alt-delor & Philip Couling I have reedited the quesion already.The platform specs is `NVIDIA® Jetson™ TX2` – sunshilong369 Jun 06 '20 at 02:13
  • How did you build the image for your device? Maybe CPU_FREQ is not configured in the kernel. Could you please add the output for `uname -a` and `gzip < /proc/config.gz | grep CPU_FREQ`. – SubOptimal Jun 07 '20 at 12:16
  • Why you have not just used the NVIDIA SDK manager to create an image? – SubOptimal Jun 09 '20 at 05:20
  • I face the same problem on AWS graviton processors (arm64 arch). – 0xc0de Dec 27 '21 at 13:06

5 Answers5

3
2

According to kernel documentation:

3. How to change the CPU cpufreq policy and/or speed
====================================================

3.1 Preferred Interface: sysfs
------------------------------

The preferred interface is located in the sysfs filesystem. If you
mounted it at /sys, the cpufreq interface is located in a subdirectory
"cpufreq" within the cpu-device directory (e.g.
/sys/devices/system/cpu/cpu0/cpufreq/ for the first CPU).

<...snip>

cpuinfo_cur_freq :        Current frequency of the CPU as obtained from
              the hardware, in KHz. This is the frequency
              the CPU actually runs at.

I've tested this on a Raspberry Pi V4 and confirmed that cpuinfo_cur_freq is present. For me it does list the same speed as cpuinfo_max_freq but I can't claim to know if that's correct or not.

You may wish to read up on this interface and deliberately slow your CPU to prove that it's not running at max speed.

The interface should be located at:

/sys/devices/system/cpu/cpu0/cpufreq/
Philip Couling
  • 17,591
  • 5
  • 42
  • 82
1

upgrade to kernel4.9 , get L4T and read below ...

From nVidia Documentation:

In kernel 4.9 and following, the common clock framework (CCF) is supported. As a result:

  • All device drivers use the public CCF APIs include/linux/clk.h, and include/linux/clk-provider.h, including functions such as clk_get, clk_enable, devm_clk_get, clk_prepare_enable, clk_prepare_disable, clk_disable, and others, instead of platform-specific APIs.
  • All clock drivers, including the Jetson custom clk driver, implement clk_ops.
  • Clock sources and clocks required by devices are defined in the Device Tree.
  • Clocks are controlled by an R5 called the Boot and Power Management Processor. It runs RTOS software from bpmp.bin. The Linux kernel running on CCPLEX requests this software for clock programming. The NVIDIA® Jetson™ Linux Driver Package (L4T) clock driver wrapper is available in the nvidia/drivers/clk/tegra/ directory.

To check clock status

Applies to: Jetson AGX Xavier series and Jetson TX2 series

  • On the device, enter the following command to launch debugfs and check the clock:

sudo -s

cat /sys/kernel/debug/bpmp/debug/clk/clk_tree


there is also another good article on elinux wiki

0

The utility cpufreq-info should help.

  1. Install it

    sudo apt install cpufrequtils
    
  2. Run it

    $ cpufreq-info
    analyzing CPU 126:
      driver: cppc_cpufreq
      CPUs which run at the same hardware frequency: 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
      CPUs which need to have their frequency coordinated by software: 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
      maximum transition latency: 4294.55 ms.
      hardware limits: 200 MHz - 2.60 GHz
      available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
      current policy: frequency should be within 400 MHz and 2.60 GHz.
                      The governor "ondemand" may decide which speed to use
                      within this range.
      current CPU frequency is 400 MHz.
    
AdminBee
  • 21,637
  • 21
  • 47
  • 71
kucer
  • 1
  • 1
-1

All anyone can suggest to you with the information given is something like try command x.

With that in mind you can try: lscpu (though I expect it will pull back the same info as can be found in /proc/cpuinfo; worth a shot though)

To get a better answer the community would likely need additional information such as the kernel version of the system. Maybe the version of Ubuntu as well.

You can find the kernel version with: uname -r

You can find the OS version with: lsb_release -a

Please let us know what you find!

roaima
  • 107,089
  • 14
  • 139
  • 261
  • I could not get current cpu frequency from the output of `lscpu`.Kernel: 4.9.18 OS: Ubuntu 16.0.4 – sunshilong369 Jun 02 '20 at 01:47
  • Ok another command you can try is: "sudo dmidecode | grep MHz". If that doesn't work you might consider upgrading the kernel or the OS, which may not be practical depending on your circumstances. – SimiliarProblem Jun 02 '20 at 02:47
  • I see.Is there any kernel config may inflence on getting current cpu frenqency ? – sunshilong369 Jun 02 '20 at 04:54
  • Not 100% sure what the problem is, but my guess is the kernel might not support getting the freq. Since your on an older OS and kernel, upgrading may resolve this. Another possibility would be lacking the necessary kernel module/s to get the freq. Which may get added with a update. You can check your currently loaded modules with lsmod. Might not help at all though. dmidecode pulls from the system's DMI/SMBIOS Table, so I thought that might actually work. – SimiliarProblem Jun 02 '20 at 10:25
  • Thank you.But i can't upgrade the OS and kernel.It's not feasible.And i have tested `sudo lsmod | grep freq`, no such modules has been installed indeed.But i could get the current cpu frequency on that platform indeed. – sunshilong369 Jun 06 '20 at 02:11
  • Your welcome! Not being able to upgrade is understandable. Your system does seem to have configuration or kernel issues though. According to [link](https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html#page/Tegra%2520Linux%2520Driver%2520Package%2520Development%2520Guide%2Fpower_management_tx2_32.html%23wwpID0E0GD0HA) '/sys/devices/system/cpu/cpu*/cpufreq' should exist; at least for supported Linux OSes. – SimiliarProblem Jun 06 '20 at 14:42