From 3a7f6d689dbc1279acc9d4e5eaabacc3c1089cc3 Mon Sep 17 00:00:00 2001 From: Yazen Ghannam Date: Fri, 20 Nov 2015 08:43:32 -0600 Subject: [PATCH] ClockSpeed not defined in /proc/cpuinfo for AArch64, so return 0. Signed-off-by: Yazen Ghannam --- utils/machine/machine.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/machine/machine.go b/utils/machine/machine.go index c483b051..def6844d 100644 --- a/utils/machine/machine.go +++ b/utils/machine/machine.go @@ -43,8 +43,8 @@ var swapCapacityRegexp = regexp.MustCompile("SwapTotal: *([0-9]+) kB") // GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file. func GetClockSpeed(procInfo []byte) (uint64, error) { - // s390/s390x changes - if true == isSystemZ() { + // s390/s390x and aarch64 changes + if true == isSystemZ() || true == isAArch64() { return 0, nil } @@ -273,6 +273,17 @@ func getMachineArch() (string, error) { return arch, nil } +// aarch64 changes +func isAArch64() bool { + arch, err := getMachineArch() + if err == nil { + if true == strings.Contains(arch, "aarch64") { + return true + } + } + return false +} + // s390/s390x changes func isSystemZ() bool { arch, err := getMachineArch()