Skip to content

Commit

Permalink
sysfs: survive NUMA nodes without memory.
Browse files Browse the repository at this point in the history
Don't fail for CPU-only NUMA nodes. Treat them as DRAM nodes with 0
bytes of memory attached, but exclude them when calculating average
memory size for memory type approximation.

Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
Krisztian Litkey authored and klihub committed Jun 21, 2024
1 parent 46f5a40 commit 1b22e89
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/sysfs/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,15 @@ func (sys *system) discoverNodes() error {
return fmt.Errorf("failed to parse nodes with memory (%q): %v",
memoryNodeIDs, err)
}
onlineNodeIDs, err := readSysfsEntry(sysNodesPath, "online", nil)
if err != nil {
return fmt.Errorf("failed to discover online nodes: %v", err)
}
onlineNodes, err := cpuset.Parse(onlineNodeIDs)
if err != nil {
return fmt.Errorf("failed to parse online nodes (%q): %v",
onlineNodeIDs, err)
}

cpuNodesSlice := []int{}
for id, node := range sys.nodes {
Expand All @@ -1199,7 +1208,8 @@ func (sys *system) discoverNodes() error {
sys.Logger.Info("NUMA nodes with (any) memory: %s", memoryNodes.String())
sys.Logger.Info("NUMA nodes with normal memory: %s", normalMemNodes.String())

dramNodes := memoryNodes.Intersection(cpuNodes)
noMemNodes := onlineNodes.Difference(memoryNodes)
dramNodes := memoryNodes.Intersection(cpuNodes).Union(noMemNodes)
pmemOrHbmNodes := memoryNodes.Difference(dramNodes)

dramNodeIds := IDSetFromCPUSet(dramNodes)
Expand All @@ -1224,7 +1234,7 @@ func (sys *system) discoverNodes() error {
dramTotal += info.MemTotal
}
}
dramAvg = dramTotal / uint64(len(dramNodeIds))
dramAvg = dramTotal / uint64(len(dramNodeIds)-noMemNodes.Size())
if dramAvg == 0 {
// FIXME: should be no reason to bail out when memory types are properly determined.
return fmt.Errorf("no dram in the system, cannot determine special memory types")
Expand Down

0 comments on commit 1b22e89

Please sign in to comment.