mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-27 07:39:05 +01:00
Replace deprecated thread_siblings_list by core_cpus_list
This commit is contained in:
parent
f3ffa29a37
commit
1b06270e9b
@ -16,14 +16,16 @@ import (
|
|||||||
const SYSFS_CPUBASE = `/sys/devices/system/cpu`
|
const SYSFS_CPUBASE = `/sys/devices/system/cpu`
|
||||||
|
|
||||||
// Structure holding all information about a hardware thread
|
// Structure holding all information about a hardware thread
|
||||||
|
// See https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-devices-system-cpu
|
||||||
type HwthreadEntry struct {
|
type HwthreadEntry struct {
|
||||||
CpuID int // CPU hardware threads
|
// for each CPUx:
|
||||||
SMT int // Simultaneous Multithreading ID
|
CpuID int // CPU / hardware thread ID
|
||||||
ThreadSiblingsList []int // Simultaneous Multithreading siblings
|
SMT int // Simultaneous Multithreading ID
|
||||||
Core int // CPU core ID
|
CoreCPUsList []int // CPUs within the same core
|
||||||
Socket int // CPU sockets (physical) ID
|
Core int // Socket local core ID
|
||||||
Die int // CPU Die ID
|
Socket int // Sockets (physical) ID
|
||||||
NumaDomain int // NUMA Domain
|
Die int // Die ID
|
||||||
|
NumaDomain int // NUMA Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
var cache struct {
|
var cache struct {
|
||||||
@ -60,7 +62,7 @@ func fileToInt(path string) int {
|
|||||||
// A range can be a single value or a range of values given by a startValue-endValue
|
// A range can be a single value or a range of values given by a startValue-endValue
|
||||||
// In case of an error nil is returned
|
// In case of an error nil is returned
|
||||||
func fileToList(path string) []int {
|
func fileToList(path string) []int {
|
||||||
// Read thread sibling list
|
// Read list
|
||||||
buffer, err := os.ReadFile(path)
|
buffer, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
@ -200,25 +202,25 @@ func init() {
|
|||||||
cache.DieList[i] = cache.SocketList[i]
|
cache.DieList[i] = cache.SocketList[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup thread siblings list
|
// Lookup List of CPUs within the same core
|
||||||
threadSiblingList := fileToList(filepath.Join(topoBase, "thread_siblings_list"))
|
coreCPUsList := fileToList(filepath.Join(topoBase, "core_cpus_list"))
|
||||||
|
|
||||||
// Find index of CPU ID in thread sibling list
|
// Find index of CPU ID in List of CPUs within the same core
|
||||||
// if not found return -1
|
// if not found return -1
|
||||||
cache.SMTList[i] = slices.Index(threadSiblingList, c)
|
cache.SMTList[i] = slices.Index(coreCPUsList, c)
|
||||||
|
|
||||||
// Lookup NUMA domain id
|
// Lookup NUMA domain id
|
||||||
cache.NumaDomainList[i] = getNumaDomain(cpuBase)
|
cache.NumaDomainList[i] = getNumaDomain(cpuBase)
|
||||||
|
|
||||||
cache.CpuData[i] =
|
cache.CpuData[i] =
|
||||||
HwthreadEntry{
|
HwthreadEntry{
|
||||||
CpuID: cache.HwthreadList[i],
|
CpuID: cache.HwthreadList[i],
|
||||||
SMT: cache.SMTList[i],
|
SMT: cache.SMTList[i],
|
||||||
ThreadSiblingsList: threadSiblingList,
|
CoreCPUsList: coreCPUsList,
|
||||||
Socket: cache.SocketList[i],
|
Socket: cache.SocketList[i],
|
||||||
NumaDomain: cache.NumaDomainList[i],
|
NumaDomain: cache.NumaDomainList[i],
|
||||||
Die: cache.DieList[i],
|
Die: cache.DieList[i],
|
||||||
Core: cache.CoreList[i],
|
Core: cache.CoreList[i],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +307,7 @@ func CpuData() []HwthreadEntry {
|
|||||||
// return a deep copy to protect cache data
|
// return a deep copy to protect cache data
|
||||||
c := slices.Clone(cache.CpuData)
|
c := slices.Clone(cache.CpuData)
|
||||||
for i := range c {
|
for i := range c {
|
||||||
c[i].ThreadSiblingsList = slices.Clone(cache.CpuData[i].ThreadSiblingsList)
|
c[i].CoreCPUsList = slices.Clone(cache.CpuData[i].CoreCPUsList)
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user