From 9740fa14e5a2e1dc725f62a8ef619f2ebe119449 Mon Sep 17 00:00:00 2001 From: Kishen V Date: Tue, 20 Feb 2024 16:53:06 +0530 Subject: [PATCH] Read core and physical package ID of the CPUs that are online Signed-off-by: Kishen V Revert changes to fix breaking changes for ARM Signed-off-by: Kishen V --- pkg/cpu/cpu_linux.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/cpu/cpu_linux.go b/pkg/cpu/cpu_linux.go index 7ff48741..3ec2e847 100644 --- a/pkg/cpu/cpu_linux.go +++ b/pkg/cpu/cpu_linux.go @@ -22,6 +22,7 @@ import ( var ( regexForCpulCore = regexp.MustCompile("^cpu([0-9]+)$") + onlineFile = "online" ) func (i *Info) load() error { @@ -64,6 +65,10 @@ func processorsGet(ctx *context.Context) []*Processor { continue } + onlineFilePath := filepath.Join(paths.SysDevicesSystemCPU, fmt.Sprintf("cpu%d", lpID), onlineFile) + if util.SafeIntFromFile(ctx, onlineFilePath) == 0 { + continue + } procID := processorIDFromLogicalProcessorID(ctx, lpID) proc, found := procs[procID] if !found { @@ -201,6 +206,10 @@ func CoresForNode(ctx *context.Context, nodeID int) ([]*ProcessorCore, error) { ) continue } + onlineFilePath := filepath.Join(cpuPath, onlineFile) + if util.SafeIntFromFile(ctx, onlineFilePath) == 0 { + continue + } coreIDPath := filepath.Join(cpuPath, "topology", "core_id") coreID := util.SafeIntFromFile(ctx, coreIDPath) core := findCoreByID(coreID)