Skip to content

Commit f41fd1e

Browse files
committed
Added the “IRQ Lanes” and “Class” columns
1 parent 231ebb2 commit f41fd1e

6 files changed

Lines changed: 496 additions & 270 deletions

File tree

app.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ func main() {
268268
Name: "FriendlyName",
269269
Title: "Friendly Name",
270270
},
271+
272+
{
273+
Name: "Class",
274+
},
271275
{
272276
Name: "LocationInformation",
273277
Title: "Location Info",
@@ -389,6 +393,15 @@ func main() {
389393
}
390394
},
391395
},
396+
397+
{
398+
Name: "IRQLanes",
399+
Title: "IRQ Lanes",
400+
FormatFunc: func(value any) string {
401+
return strings.Join(value.([]string), ", ")
402+
},
403+
},
404+
392405
{
393406
Name: "DevObjName",
394407
Title: "DevObj Name",

cpusetinformation.go

Lines changed: 85 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package main
22

33
import (
4-
"log"
5-
6-
"golang.org/x/sys/windows"
4+
"fmt"
5+
"sort"
76
)
87

98
var SystemCpuSets = []SYSTEM_CPU_SET_INFORMATION{}
@@ -14,20 +13,15 @@ const (
1413
ToolTipTextEfficiencyClass = "A value indicating the intrinsic energy efficiency of a processor for systems that support heterogeneous processors (such as ARM big.LITTLE systems). CPU Sets with higher numerical values of this field have home processors that are faster but less power-efficient than ones with lower values."
1514
)
1615

17-
type CoreLayout struct {
18-
Rows int
19-
Cols int
20-
}
21-
2216
type CpuSets struct {
23-
HyperThreading bool
24-
CoreCount int
2517
MaxThreadsPerCore int
18+
CPU []CpuSet
19+
CoreGroups []CoreGroups
20+
CoreLayout *CoreLayout
21+
HyperThreading bool
2622
NumaNode bool // A group-relative value indicating which NUMA node a CPU Set is on. All CPU Sets in a given group that are on the same NUMA node will have the same value for this field.
2723
LastLevelCache bool // A group-relative value indicating which CPU Sets share at least one level of cache with each other. This value is the same for all CPU Sets in a group that are on processors that share cache with each other.
2824
EfficiencyClass bool // A value indicating the intrinsic energy efficiency of a processor for systems that support heterogeneous processors (such as ARM big.LITTLE systems). CPU Sets with higher numerical values of this field have home processors that are faster but less power-efficient than ones with lower values.
29-
CPU []CpuSet
30-
Layout []CoreLayout
3125
}
3226

3327
type CpuSet struct {
@@ -39,38 +33,66 @@ type CpuSet struct {
3933
NumaNodeIndex byte // A group-relative value indicating which NUMA node a CPU Set is on. All CPU Sets in a given group that are on the same NUMA node will have the same value for this field.
4034
}
4135

42-
func (cs *CpuSets) Init() {
43-
var SystemCpuSets = make([]SYSTEM_CPU_SET_INFORMATION, 1)
44-
var length uint32
45-
var hProcess windows.Handle
36+
type CoreGroups struct {
37+
Rows int
38+
Cols int
39+
}
40+
41+
type CoreLayout struct {
42+
Numa []NumaItem
43+
}
4644

47-
GetSystemCpuSetInformation(&SystemCpuSets[0], 1, &length, uintptr(hProcess), 0)
45+
type NumaItem struct {
46+
Ccd []CcdItem
47+
}
48+
49+
type CcdItem struct {
50+
Eff EffFields
51+
}
4852

49-
SystemCpuSets = make([]SYSTEM_CPU_SET_INFORMATION, length)
50-
success := GetSystemCpuSetInformation(&SystemCpuSets[0], uint32(length), &length, uintptr(hProcess), 0)
51-
if success != 1 {
52-
log.Println("err")
53+
type EffFields struct {
54+
Nums map[int][][]int
55+
}
56+
57+
func (item *EffFields) isNil() bool {
58+
if item.Nums == nil {
59+
return true
5360
}
61+
return false
62+
}
5463

55-
/// debug
56-
// Fake13900()
57-
// Fake13900WithoutHT()
58-
// Fake5900x()
59-
// Fake8Threads()
60-
// FakeNumaCCD12Core()
61-
// Fake2CCD12CoreHT()
62-
// Fake13600KF()
64+
func (item *CoreLayout) add(numa, ccd, effClass, core, thread int) {
65+
if len(item.Numa) <= numa {
66+
item.Numa = append(item.Numa, make([]NumaItem, numa+1-len(item.Numa))...)
67+
}
68+
69+
if len(item.Numa[numa].Ccd) <= ccd {
70+
item.Numa[numa].Ccd = append(item.Numa[numa].Ccd, make([]CcdItem, ccd+1-len(item.Numa[numa].Ccd))...)
71+
}
72+
73+
if item.Numa[numa].Ccd[ccd].Eff.Nums == nil {
74+
item.Numa[numa].Ccd[ccd].Eff.Nums = make(map[int][][]int)
75+
}
76+
rows := item.Numa[numa].Ccd[ccd].Eff.Nums[effClass]
77+
78+
if len(rows) <= core {
79+
rows = append(rows, make([][]int, core+1-len(rows))...)
80+
}
81+
82+
rows[core] = append(rows[core], thread)
83+
84+
item.Numa[numa].Ccd[ccd].Eff.Nums[effClass] = rows
85+
}
86+
87+
func (cs *CpuSets) Init() {
88+
SystemCpuSets = GetCpuInformation()
89+
90+
cs.CoreLayout = new(CoreLayout)
6391

64-
cs.CoreCount = int(uint32(len(SystemCpuSets)) / SystemCpuSets[0].Size)
65-
var lastEfficiencyClass, lastLevelCache, lastNumaNodeIndex byte
66-
var LogicalCores int
6792
var ClassGroup = []int{}
68-
for i := 0; i < cs.CoreCount; i++ {
93+
var lastEfficiencyClass, lastLevelCache, lastNumaNodeIndex byte
94+
for i := 0; i < int(uint32(len(SystemCpuSets))/SystemCpuSets[0].Size); i++ {
6995
cpu := SystemCpuSets[i].CpuSet()
70-
if i == 0 { // The EfficiencyClass starts with 1 on the Intel Gen12+
71-
lastEfficiencyClass = cpu.EfficiencyClass
72-
}
73-
7496
cs.CPU = append(cs.CPU, CpuSet{
7597
Id: cpu.Id,
7698
CoreIndex: cpu.CoreIndex,
@@ -80,22 +102,21 @@ func (cs *CpuSets) Init() {
80102
NumaNodeIndex: cpu.NumaNodeIndex,
81103
})
82104

83-
// fmt.Printf("(%02d) [%d/%x] %02d/%02d Eff%d CCD%d NUMA%d\n", i, cpu.Id, cpu.Id, cpu.CoreIndex, cpu.LogicalProcessorIndex, cpu.EfficiencyClass, cpu.LastLevelCacheIndex, cpu.NumaNodeIndex)
84-
85-
if cpu.CoreIndex != cpu.LogicalProcessorIndex {
86-
if !cs.HyperThreading {
87-
cs.HyperThreading = true
88-
}
89-
if cs.MaxThreadsPerCore < int(cpu.LogicalProcessorIndex-cpu.CoreIndex) {
90-
cs.MaxThreadsPerCore = int(cpu.LogicalProcessorIndex - cpu.CoreIndex)
91-
}
92-
} else {
93-
LogicalCores++
94-
95-
for len(ClassGroup) <= int(cpu.EfficiencyClass) {
96-
ClassGroup = append(ClassGroup, 0)
97-
}
98-
ClassGroup[int(cpu.EfficiencyClass)]++
105+
fmt.Printf("(%02d) [%d/%x] %02d/%02d Eff%d CCD%d NUMA%d\n", i, cpu.Id, cpu.Id, cpu.CoreIndex, cpu.LogicalProcessorIndex, cpu.EfficiencyClass, cpu.LastLevelCacheIndex, cpu.NumaNodeIndex)
106+
107+
cs.CoreLayout.add(int(cpu.NumaNodeIndex), int(cpu.LastLevelCacheIndex), int(cpu.EfficiencyClass), int(cpu.CoreIndex), int(cpu.LogicalProcessorIndex))
108+
109+
if cs.MaxThreadsPerCore < int(cpu.LogicalProcessorIndex-cpu.CoreIndex) {
110+
cs.MaxThreadsPerCore = int(cpu.LogicalProcessorIndex-cpu.CoreIndex) + 1
111+
}
112+
113+
for len(ClassGroup) <= int(cpu.EfficiencyClass) {
114+
ClassGroup = append(ClassGroup, 0)
115+
}
116+
ClassGroup[int(cpu.EfficiencyClass)]++
117+
118+
if !cs.HyperThreading && cpu.CoreIndex != cpu.LogicalProcessorIndex {
119+
cs.HyperThreading = true
99120
}
100121

101122
if !cs.EfficiencyClass && lastEfficiencyClass != cpu.EfficiencyClass {
@@ -109,17 +130,20 @@ func (cs *CpuSets) Init() {
109130
if !cs.NumaNode && lastNumaNodeIndex != cpu.NumaNodeIndex {
110131
cs.NumaNode = true
111132
}
112-
113-
lastEfficiencyClass = cpu.EfficiencyClass
114-
lastLevelCache = cpu.LastLevelCacheIndex
115-
lastNumaNodeIndex = cpu.NumaNodeIndex
116133
}
117134

135+
sort.Slice(cs.CPU, func(i, j int) bool {
136+
if cs.CPU[i].EfficiencyClass != cs.CPU[j].EfficiencyClass {
137+
return cs.CPU[i].EfficiencyClass < cs.CPU[j].EfficiencyClass
138+
}
139+
if cs.CPU[i].CoreIndex != cs.CPU[j].CoreIndex {
140+
return cs.CPU[i].CoreIndex < cs.CPU[j].CoreIndex
141+
}
142+
return cs.CPU[i].LogicalProcessorIndex < cs.CPU[j].LogicalProcessorIndex
143+
})
144+
118145
rows, cols := getLayout(ClassGroup...)
119146
for _, col := range cols {
120-
cs.Layout = append(cs.Layout, CoreLayout{
121-
Rows: rows,
122-
Cols: col,
123-
})
147+
cs.CoreGroups = append(cs.CoreGroups, CoreGroups{Rows: rows, Cols: col})
124148
}
125149
}

0 commit comments

Comments
 (0)