From 6e8c72e535c0d355b3eee20b83adaa6e4f725678 Mon Sep 17 00:00:00 2001 From: "Maciej \"Iwan\" Iwanowski" Date: Sun, 4 Oct 2020 19:06:31 +0200 Subject: [PATCH] Try to read from sysfs before giving up on non-x86_64 Signed-off-by: Maciej "Iwan" Iwanowski --- machine/machine.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/machine/machine.go b/machine/machine.go index 4330d69502..917569377d 100644 --- a/machine/machine.go +++ b/machine/machine.go @@ -90,11 +90,6 @@ func GetSockets(procInfo []byte) int { // GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file. func GetClockSpeed(procInfo []byte) (uint64, error) { - // s390/s390x, mips64, riscv64, aarch64 and arm32 changes - if isMips64() || isSystemZ() || isAArch64() || isArm32() || isRiscv64() { - return 0, nil - } - // First look through sys to find a max supported cpu frequency. if utils.FileExists(maxFreqFile) { val, err := ioutil.ReadFile(maxFreqFile) @@ -108,6 +103,11 @@ func GetClockSpeed(procInfo []byte) (uint64, error) { } return maxFreq, nil } + // s390/s390x, mips64, riscv64, aarch64 and arm32 changes + if isMips64() || isSystemZ() || isAArch64() || isArm32() || isRiscv64() { + return 0, nil + } + // Fall back to /proc/cpuinfo matches := cpuClockSpeedMHz.FindSubmatch(procInfo) if len(matches) != 2 {