Skip to content

Commit 151c79a

Browse files
committed
Read core and physical package ID of the CPUs that are online
Signed-off-by: Kishen V <kishen.viswanathan@ibm.com>
1 parent 835f6a2 commit 151c79a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/cpu/cpu_linux.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
var (
2424
regexForCpulCore = regexp.MustCompile("^cpu([0-9]+)$")
25+
onlineFile = "online"
2526
)
2627

2728
func (i *Info) load() error {
@@ -64,6 +65,10 @@ func processorsGet(ctx *context.Context) []*Processor {
6465
continue
6566
}
6667

68+
onlineFilePath := filepath.Join(paths.SysDevicesSystemCPU, fmt.Sprintf("cpu%d", lpID), onlineFile)
69+
if util.SafeIntFromFile(ctx, onlineFilePath) == 0 {
70+
continue
71+
}
6772
procID := processorIDFromLogicalProcessorID(ctx, lpID)
6873
proc, found := procs[procID]
6974
if !found {
@@ -201,6 +206,10 @@ func CoresForNode(ctx *context.Context, nodeID int) ([]*ProcessorCore, error) {
201206
)
202207
continue
203208
}
209+
onlineFilePath := filepath.Join(cpuPath, onlineFile)
210+
if util.SafeIntFromFile(ctx, onlineFilePath) == 0 {
211+
continue
212+
}
204213
coreIDPath := filepath.Join(cpuPath, "topology", "core_id")
205214
coreID := util.SafeIntFromFile(ctx, coreIDPath)
206215
core := findCoreByID(coreID)

0 commit comments

Comments
 (0)