Skip to content

Commit

Permalink
Merge pull request #2690 from iwankgb/read_frequency_before_giving_up
Browse files Browse the repository at this point in the history
Try to read from sysfs before giving up on non-x86_64
  • Loading branch information
bobbypage authored Nov 9, 2020
2 parents cd0ae40 + 6e8c72e commit 19ba5a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 19ba5a8

Please sign in to comment.