11

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>

17
  • 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
  • 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. Instead, paste the text directly into your question and use the formatting tools to format it as code. – terdon May 28 '20 at 12:00
  • 2
    Might be interesting to know which concrete CPU you are using. – SubOptimal Jun 2 '20 at 20:44
2
1
+50

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/
6
  • 3
    Following the OP it does not exist on his system. quote: there is no /sys/devices/system/cpu/cpu*/cpufreq directory on my Ubuntu system. – SubOptimal Jun 3 '20 at 15:37
  • 1
    Maybe you need to load some cpufreq module? – JucaPirama Jun 5 '20 at 2:15
  • @SubOptimal True but it does demonstrait that ARM processors (can) have this. – Philip Couling Jun 5 '20 at 15:34
  • Sure. And I'm sure the OP is aware of this, hence he realiced that it's missed on his device. I believe it's some kernel config thingy. – SubOptimal Jun 7 '20 at 12:18
  • 1
    Though it is still not solved,but thanks all of you. – sunshilong369 Jun 8 '20 at 6:06
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

1
0

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!

6
  • I could not get current cpu frequency from the output of lscpu.Kernel: 4.9.18 OS: Ubuntu 16.0.4 – sunshilong369 Jun 2 '20 at 1: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 2 '20 at 2:47
  • I see.Is there any kernel config may inflence on getting current cpu frenqency ? – sunshilong369 Jun 2 '20 at 4: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 2 '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 6 '20 at 2:11
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.
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.