Skip to content

Commit

Permalink
Fixes google#2783 - takes package ID into consideration when calculat…
Browse files Browse the repository at this point in the history
…ing count of unique properties

Signed-off-by: Maciej "Iwan" Iwanowski <[email protected]>
  • Loading branch information
iwankgb committed Mar 4, 2021
1 parent ed2ea85 commit b4a8b2f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion utils/sysfs/sysfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package sysfs

import (
"bytes"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -483,7 +484,14 @@ func GetUniqueCPUPropertyCount(cpuBusPath string, propertyName string) int {
klog.Warningf("Cannot open %s, assuming 0 for %s of CPU %d", propertyPath, propertyName, cpuID)
propertyVal = []byte("0")
}
uniques[string(propertyVal)] = true
packagePath := filepath.Join(sysCPUPath, sysFsCPUTopology, CPUPhysicalPackageID)
packageVal, err := ioutil.ReadFile(packagePath)
if err != nil {
klog.Warningf("Cannot open %s, assuming 0 %s of CPU %d", packagePath, CPUPhysicalPackageID, cpuID)
packageVal = []byte("0")

}
uniques[fmt.Sprintf("%s_%s", bytes.TrimSpace(propertyVal), bytes.TrimSpace(packageVal))] = true
}
return len(uniques)
}

0 comments on commit b4a8b2f

Please sign in to comment.