diff --git a/pkg/sysfs/system.go b/pkg/sysfs/system.go index 7d17ea646..18b4783eb 100644 --- a/pkg/sysfs/system.go +++ b/pkg/sysfs/system.go @@ -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 { @@ -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) @@ -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")