Skip to content

Commit 19ba5a8

Browse files
authored
Merge pull request #2690 from iwankgb/read_frequency_before_giving_up
Try to read from sysfs before giving up on non-x86_64
2 parents cd0ae40 + 6e8c72e commit 19ba5a8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

machine/machine.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ func GetSockets(procInfo []byte) int {
9090

9191
// GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file.
9292
func GetClockSpeed(procInfo []byte) (uint64, error) {
93-
// s390/s390x, mips64, riscv64, aarch64 and arm32 changes
94-
if isMips64() || isSystemZ() || isAArch64() || isArm32() || isRiscv64() {
95-
return 0, nil
96-
}
97-
9893
// First look through sys to find a max supported cpu frequency.
9994
if utils.FileExists(maxFreqFile) {
10095
val, err := ioutil.ReadFile(maxFreqFile)
@@ -108,6 +103,11 @@ func GetClockSpeed(procInfo []byte) (uint64, error) {
108103
}
109104
return maxFreq, nil
110105
}
106+
// s390/s390x, mips64, riscv64, aarch64 and arm32 changes
107+
if isMips64() || isSystemZ() || isAArch64() || isArm32() || isRiscv64() {
108+
return 0, nil
109+
}
110+
111111
// Fall back to /proc/cpuinfo
112112
matches := cpuClockSpeedMHz.FindSubmatch(procInfo)
113113
if len(matches) != 2 {

0 commit comments

Comments
 (0)