mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 12:37:25 +01:00
Add DieList
This commit is contained in:
parent
094f124a18
commit
8fedef9024
@ -40,6 +40,9 @@ var cache struct {
|
|||||||
SocketList []int
|
SocketList []int
|
||||||
uniqSocketList []int
|
uniqSocketList []int
|
||||||
|
|
||||||
|
DieList []int
|
||||||
|
uniqDieList []int
|
||||||
|
|
||||||
CpuData []HwthreadEntry
|
CpuData []HwthreadEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +86,20 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache.DieList = make([]int, len(cache.HwthreadList))
|
||||||
|
for i, c := range cache.HwthreadList {
|
||||||
|
// Set base directory for topology lookup
|
||||||
|
cpuStr := fmt.Sprintf("cpu%d", c)
|
||||||
|
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
|
||||||
|
topoBase := filepath.Join(base, "topology")
|
||||||
|
|
||||||
|
// Lookup CPU die id
|
||||||
|
cache.DieList[i] = fileToInt(filepath.Join(topoBase, "die_id"))
|
||||||
|
if cache.DieList[i] < 0 {
|
||||||
|
cache.DieList[i] = cache.SocketList[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cache.uniqHwthreadList = slices.Clone(cache.HwthreadList)
|
cache.uniqHwthreadList = slices.Clone(cache.HwthreadList)
|
||||||
slices.Sort(cache.uniqHwthreadList)
|
slices.Sort(cache.uniqHwthreadList)
|
||||||
cache.uniqHwthreadList = slices.Compact(cache.uniqHwthreadList)
|
cache.uniqHwthreadList = slices.Compact(cache.uniqHwthreadList)
|
||||||
@ -95,10 +112,9 @@ func init() {
|
|||||||
slices.Sort(cache.uniqSocketList)
|
slices.Sort(cache.uniqSocketList)
|
||||||
cache.uniqSocketList = slices.Compact(cache.uniqSocketList)
|
cache.uniqSocketList = slices.Compact(cache.uniqSocketList)
|
||||||
|
|
||||||
getDie :=
|
cache.uniqDieList = slices.Clone(cache.DieList)
|
||||||
func(basePath string) int {
|
slices.Sort(cache.uniqDieList)
|
||||||
return fileToInt(filepath.Join(basePath, "die_id"))
|
cache.uniqDieList = slices.Compact(cache.uniqDieList)
|
||||||
}
|
|
||||||
|
|
||||||
getSMT :=
|
getSMT :=
|
||||||
func(cpuID int, basePath string) int {
|
func(cpuID int, basePath string) int {
|
||||||
@ -149,7 +165,7 @@ func init() {
|
|||||||
CpuID: cache.HwthreadList[i],
|
CpuID: cache.HwthreadList[i],
|
||||||
Socket: cache.SocketList[i],
|
Socket: cache.SocketList[i],
|
||||||
NumaDomain: -1,
|
NumaDomain: -1,
|
||||||
Die: -1,
|
Die: cache.DieList[i],
|
||||||
Core: cache.CoreList[i],
|
Core: cache.CoreList[i],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,12 +177,6 @@ func init() {
|
|||||||
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
|
base := filepath.Join("/sys/devices/system/cpu", cpuStr)
|
||||||
topoBase := filepath.Join(base, "topology")
|
topoBase := filepath.Join(base, "topology")
|
||||||
|
|
||||||
// Lookup CPU die id
|
|
||||||
cEntry.Die = getDie(topoBase)
|
|
||||||
if cEntry.Die < 0 {
|
|
||||||
cEntry.Die = cEntry.Socket
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lookup SMT thread id
|
// Lookup SMT thread id
|
||||||
cEntry.SMT = getSMT(cEntry.CpuID, topoBase)
|
cEntry.SMT = getSMT(cEntry.CpuID, topoBase)
|
||||||
|
|
||||||
@ -309,7 +319,6 @@ func CpuInfo() CpuInformation {
|
|||||||
|
|
||||||
smtList := make([]int, 0)
|
smtList := make([]int, 0)
|
||||||
numaList := make([]int, 0)
|
numaList := make([]int, 0)
|
||||||
dieList := make([]int, 0)
|
|
||||||
for i := range cache.CpuData {
|
for i := range cache.CpuData {
|
||||||
d := &cache.CpuData[i]
|
d := &cache.CpuData[i]
|
||||||
if ok := slices.Contains(smtList, d.SMT); !ok {
|
if ok := slices.Contains(smtList, d.SMT); !ok {
|
||||||
@ -318,14 +327,11 @@ func CpuInfo() CpuInformation {
|
|||||||
if ok := slices.Contains(numaList, d.NumaDomain); !ok {
|
if ok := slices.Contains(numaList, d.NumaDomain); !ok {
|
||||||
numaList = append(numaList, d.NumaDomain)
|
numaList = append(numaList, d.NumaDomain)
|
||||||
}
|
}
|
||||||
if ok := slices.Contains(dieList, d.Die); !ok {
|
|
||||||
dieList = append(dieList, d.Die)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return CpuInformation{
|
return CpuInformation{
|
||||||
NumNumaDomains: len(numaList),
|
NumNumaDomains: len(numaList),
|
||||||
SMTWidth: len(smtList),
|
SMTWidth: len(smtList),
|
||||||
NumDies: len(dieList),
|
NumDies: len(cache.uniqDieList),
|
||||||
NumCores: len(cache.uniqCoreList),
|
NumCores: len(cache.uniqCoreList),
|
||||||
NumSockets: len(cache.uniqSocketList),
|
NumSockets: len(cache.uniqSocketList),
|
||||||
NumHWthreads: len(cache.uniqHwthreadList),
|
NumHWthreads: len(cache.uniqHwthreadList),
|
||||||
@ -382,10 +388,9 @@ func GetHwthreadCore(cpuID int) int {
|
|||||||
|
|
||||||
// GetSocketHwthreads gets all hardware thread IDs associated with a CPU socket
|
// GetSocketHwthreads gets all hardware thread IDs associated with a CPU socket
|
||||||
func GetSocketHwthreads(socket int) []int {
|
func GetSocketHwthreads(socket int) []int {
|
||||||
cpuData := CpuData()
|
|
||||||
cpuList := make([]int, 0)
|
cpuList := make([]int, 0)
|
||||||
for i := range cpuData {
|
for i := range cache.CpuData {
|
||||||
d := &cpuData[i]
|
d := &cache.CpuData[i]
|
||||||
if d.Socket == socket {
|
if d.Socket == socket {
|
||||||
cpuList = append(cpuList, d.CpuID)
|
cpuList = append(cpuList, d.CpuID)
|
||||||
}
|
}
|
||||||
@ -395,10 +400,9 @@ func GetSocketHwthreads(socket int) []int {
|
|||||||
|
|
||||||
// GetNumaDomainHwthreads gets the all hardware thread IDs associated with a NUMA domain
|
// GetNumaDomainHwthreads gets the all hardware thread IDs associated with a NUMA domain
|
||||||
func GetNumaDomainHwthreads(numaDomain int) []int {
|
func GetNumaDomainHwthreads(numaDomain int) []int {
|
||||||
cpuData := CpuData()
|
|
||||||
cpuList := make([]int, 0)
|
cpuList := make([]int, 0)
|
||||||
for i := range cpuData {
|
for i := range cache.CpuData {
|
||||||
d := &cpuData[i]
|
d := &cache.CpuData[i]
|
||||||
if d.NumaDomain == numaDomain {
|
if d.NumaDomain == numaDomain {
|
||||||
cpuList = append(cpuList, d.CpuID)
|
cpuList = append(cpuList, d.CpuID)
|
||||||
}
|
}
|
||||||
@ -408,10 +412,9 @@ func GetNumaDomainHwthreads(numaDomain int) []int {
|
|||||||
|
|
||||||
// GetDieHwthreads gets all hardware thread IDs associated with a CPU die
|
// GetDieHwthreads gets all hardware thread IDs associated with a CPU die
|
||||||
func GetDieHwthreads(die int) []int {
|
func GetDieHwthreads(die int) []int {
|
||||||
cpuData := CpuData()
|
|
||||||
cpuList := make([]int, 0)
|
cpuList := make([]int, 0)
|
||||||
for i := range cpuData {
|
for i := range cache.CpuData {
|
||||||
d := &cpuData[i]
|
d := &cache.CpuData[i]
|
||||||
if d.Die == die {
|
if d.Die == die {
|
||||||
cpuList = append(cpuList, d.CpuID)
|
cpuList = append(cpuList, d.CpuID)
|
||||||
}
|
}
|
||||||
@ -421,10 +424,9 @@ func GetDieHwthreads(die int) []int {
|
|||||||
|
|
||||||
// GetCoreHwthreads get all hardware thread IDs associated with a CPU core
|
// GetCoreHwthreads get all hardware thread IDs associated with a CPU core
|
||||||
func GetCoreHwthreads(core int) []int {
|
func GetCoreHwthreads(core int) []int {
|
||||||
cpuData := CpuData()
|
|
||||||
cpuList := make([]int, 0)
|
cpuList := make([]int, 0)
|
||||||
for i := range cpuData {
|
for i := range cache.CpuData {
|
||||||
d := &cpuData[i]
|
d := &cache.CpuData[i]
|
||||||
if d.Core == core {
|
if d.Core == core {
|
||||||
cpuList = append(cpuList, d.CpuID)
|
cpuList = append(cpuList, d.CpuID)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user