Skip to content

Commit

Permalink
WiP: pkg/sysfs: implement CPU cluster detection.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
  • Loading branch information
klihub committed Feb 26, 2024
1 parent 620f724 commit 06663c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/sysfs/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type CPU interface {
ID() idset.ID
PackageID() idset.ID
DieID() idset.ID
ClusterID() idset.ID
NodeID() idset.ID
CoreID() idset.ID
ThreadCPUSet() cpuset.CPUSet
Expand All @@ -186,6 +187,7 @@ type cpu struct {
id idset.ID // CPU id
pkg idset.ID // package id
die idset.ID // die id
cluster idset.ID // cluster id
node idset.ID // node id
core idset.ID // core id
threads idset.IDSet // sibling/hyper-threads
Expand Down Expand Up @@ -353,6 +355,7 @@ func (sys *system) Discover(flags DiscoveryFlag) error {
sys.Debug("CPU #%d:", id)
sys.Debug(" pkg: %d", cpu.pkg)
sys.Debug(" die: %d", cpu.die)
sys.Debug(" cluster: %d", cpu.cluster)
sys.Debug(" node: %d", cpu.node)
sys.Debug(" core: %d", cpu.core)
sys.Debug(" threads: %s", cpu.threads)
Expand Down Expand Up @@ -589,6 +592,7 @@ func (sys *system) discoverCPU(path string) error {
return err
}
readSysfsEntry(path, "topology/die_id", &cpu.die)
readSysfsEntry(path, "topology/cluster_id", &cpu.cluster)
if _, err := readSysfsEntry(path, "topology/core_id", &cpu.core); err != nil {
return err
}
Expand Down Expand Up @@ -659,6 +663,11 @@ func (c *cpu) DieID() idset.ID {
return c.die
}

// ClusterID returns the cluster id of this CPU.
func (c *cpu) ClusterID() idset.ID {
return c.cluster
}

// NodeID returns the node id of this CPU.
func (c *cpu) NodeID() idset.ID {
return c.node
Expand Down

0 comments on commit 06663c7

Please # to comment.