mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 12:37:25 +01:00
Replace deprecated thread_siblings_list by core_cpus_list
This commit is contained in:
parent
f3ffa29a37
commit
1b06270e9b
@ -16,13 +16,15 @@ 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:
|
||||||
|
CpuID int // CPU / hardware thread ID
|
||||||
SMT int // Simultaneous Multithreading ID
|
SMT int // Simultaneous Multithreading ID
|
||||||
ThreadSiblingsList []int // Simultaneous Multithreading siblings
|
CoreCPUsList []int // CPUs within the same core
|
||||||
Core int // CPU core ID
|
Core int // Socket local core ID
|
||||||
Socket int // CPU sockets (physical) ID
|
Socket int // Sockets (physical) ID
|
||||||
Die int // CPU Die ID
|
Die int // Die ID
|
||||||
NumaDomain int // NUMA Domain
|
NumaDomain int // NUMA Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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,12 +202,12 @@ 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)
|
||||||
@ -214,7 +216,7 @@ func init() {
|
|||||||
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],
|
||||||
@ -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