Skip to content

Commit

Permalink
Fixes #2783 - takes package ID into consideration when calculating co…
Browse files Browse the repository at this point in the history
…unt of unique properties

Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
  • Loading branch information
iwankgb committed Feb 6, 2021
1 parent e35449d commit 9dedba6
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 @@ -485,7 +486,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 9dedba6

Please sign in to comment.