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 Feb 5, 2021
1 parent 1dba1ec commit dd45fea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 7 additions & 1 deletion utils/sysfs/sysfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ func GetUniqueCPUPropertyCount(cpuBusPath string, propertyName string) int {
klog.Errorf("Cannot open %s, number of unique %s set to 0", propertyPath, propertyName)
return 0
}
uniques[string(propertyVal)] = true
packagePath := filepath.Join(sysCPUPath, sysFsCPUTopology, CPUPhysicalPackageID)
packageVal, err := ioutil.ReadFile(packagePath)
if err != nil {
klog.Errorf("Cannot open %s, number of unique %s set to 0", packagePath, CPUPhysicalPackageID)
return 0
}
uniques[fmt.Sprintf("%s_%s", propertyVal, packageVal)] = true
}
return len(uniques)
}
Expand Down
4 changes: 0 additions & 4 deletions utils/sysfs/sysfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ func TestGetUniqueCPUPropertyCountOnRaspberryPi4(t *testing.T) {
assert.Equal(t, 1, count)
}


func TestGetUniqueCPUPropertyCountOnEpyc7402(t *testing.T) {
// Mock unix.Uname() so it does not return x86_64, no matter what.
unameOrig := uname
Expand All @@ -282,7 +281,6 @@ func TestGetUniqueCPUPropertyCountOnEpyc7402(t *testing.T) {
assert.Equal(t, 24, count)
}


func TestGetUniqueCPUPropertyCountOnEpyc7402NoHT(t *testing.T) {
// Mock unix.Uname() so it does not return x86_64, no matter what.
unameOrig := uname
Expand All @@ -299,7 +297,6 @@ func TestGetUniqueCPUPropertyCountOnEpyc7402NoHT(t *testing.T) {
assert.Equal(t, 24, count)
}


func TestGetUniqueCPUPropertyCountOnXeon4214(t *testing.T) {
// Mock unix.Uname() so it does not return x86_64, no matter what.
unameOrig := uname
Expand All @@ -316,7 +313,6 @@ func TestGetUniqueCPUPropertyCountOnXeon4214(t *testing.T) {
assert.Equal(t, 24, count)
}


func TestGetUniqueCPUPropertyCountOnXeon5218NoHT(t *testing.T) {
// Mock unix.Uname() so it does not return x86_64, no matter what.
unameOrig := uname
Expand Down

0 comments on commit dd45fea

Please sign in to comment.