Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On arm64 machines, cpu.Info returns "mhz": 0 #1323

Open
1 task done
santosh opened this issue Jul 5, 2022 · 3 comments
Open
1 task done

On arm64 machines, cpu.Info returns "mhz": 0 #1323

santosh opened this issue Jul 5, 2022 · 3 comments

Comments

@santosh
Copy link

santosh commented Jul 5, 2022

Describe the bug
I am working on an application which has to deal with compute capacity of the host system. I am using gopsutil to get the capacity.

It works fine on amd64 machines. But when I tested on arm64 machine, the mhz field was 0.

To Reproduce

package main

import (
        "fmt"
        "github.com/shirou/gopsutil/cpu"
)

func main() {
        cores, _ := cpu.Info()

        for i := 0; i < len(cores); i++ {
                fmt.Println(cores[i].Mhz)
        }
}

Expected behavior
On an arbitrary amd64 machine, I get output similar to this:

2199.998
2199.998

On an arm64 machine, I get this:

0
0

Environment (please complete the following information):

  • Linux: [paste contents of /etc/os-release and the result of uname -a]
$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

$ uname -a
Linux ip-10-2-1-38 5.15.0-1014-aws #18-Ubuntu SMP Wed Jun 15 20:06:08 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Additional context

I am testing it on Ubuntu 22.04, but I have also tested the same thing on Ubuntu 18.04 and 20.04.

@shirou
Copy link
Owner

shirou commented Jul 9, 2022

Could you tell us /proc/cpuinfo content? We want to know cpu MHz line exists and the content of that line.

@santosh
Copy link
Author

santosh commented Jul 11, 2022

@shirou No, there is no such line with MHz.

ubuntu@ip-10-2-1-38:~$ cat /proc/cpuinfo 
processor       : 0
BogoMIPS        : 243.75
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x3
CPU part        : 0xd0c
CPU revision    : 1

processor       : 1
BogoMIPS        : 243.75
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x3
CPU part        : 0xd0c
CPU revision    : 1

However, output of dmidecode has the info:

ubuntu@ip-10-2-1-38:~$ sudo dmidecode | grep MHz
        Max Speed: 2500 MHz
        Current Speed: 2500 MHz

@Lomanic
Copy link
Collaborator

Lomanic commented Jul 11, 2022

Adding a fallback to dmidecode to get cpu frequencies was previously discussed in #282 (comment)

It has too many drawbacks in my opinion to be valuable to add it as a fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants