Skip to content

Commit bfc4c50

Browse files
committed
Fixes google#2783 - takes package ID into consideration when calculating count of unique properties
Signed-off-by: Maciej "Iwan" Iwanowski <[email protected]>
1 parent 4bd9aef commit bfc4c50

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

utils/sysfs/sysfs.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,13 @@ func GetUniqueCPUPropertyCount(cpuBusPath string, propertyName string) int {
487487
klog.Errorf("Cannot open %s, number of unique %s set to 0", propertyPath, propertyName)
488488
return 0
489489
}
490-
uniques[string(propertyVal)] = true
490+
packagePath := filepath.Join(sysCPUPath, sysFsCPUTopology, CPUPhysicalPackageID)
491+
packageVal, err := ioutil.ReadFile(packagePath)
492+
if err != nil {
493+
klog.Errorf("Cannot open %s, number of unique %s set to 0", packagePath, CPUPhysicalPackageID)
494+
return 0
495+
}
496+
uniques[fmt.Sprintf("%s_%s", propertyVal, packageVal)] = true
491497
}
492498
return len(uniques)
493499
}

utils/sysfs/sysfs_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ func TestGetUniqueCPUPropertyCountOnRaspberryPi4(t *testing.T) {
265265
assert.Equal(t, 1, count)
266266
}
267267

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

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

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

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

0 commit comments

Comments
 (0)