Reuse information from /proc/cpuinfo

This commit is contained in:
Holger Obermaier 2023-09-07 10:24:43 +02:00
parent ae106566dd
commit 1f5856c671

View File

@ -92,16 +92,6 @@ func init() {
slices.Sort(cache.uniqSocketList)
cache.uniqSocketList = slices.Compact(cache.uniqSocketList)
getCore :=
func(basePath string) int {
return fileToInt(filepath.Join(basePath, "core_id"))
}
getSocket :=
func(basePath string) int {
return fileToInt(filepath.Join(basePath, "physical_package_id"))
}
getDie :=
func(basePath string) int {
return fileToInt(filepath.Join(basePath, "die_id"))
@ -149,18 +139,16 @@ func init() {
return 0
}
for _, c := range cache.HwthreadList {
cache.CpuData =
append(
cache.CpuData,
cache.CpuData = make([]HwthreadEntry, len(cache.HwthreadList))
for i := range cache.HwthreadList {
cache.CpuData[i] =
HwthreadEntry{
CpuID: c,
Socket: -1,
CpuID: cache.HwthreadList[i],
Socket: cache.SocketList[i],
NumaDomain: -1,
Die: -1,
Core: -1,
},
)
Core: cache.CoreList[i],
}
}
for i := range cache.CpuData {
cEntry := &cache.CpuData[i]
@ -170,12 +158,6 @@ func init() {
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
topoBase := filepath.Join(base, "topology")
// Lookup CPU core id
cEntry.Core = getCore(topoBase)
// Lookup CPU socket id
cEntry.Socket = getSocket(topoBase)
// Lookup CPU die id
cEntry.Die = getDie(topoBase)
if cEntry.Die < 0 {