[Bugfix] fix parse_lscpu_topology bug (#18520)

This commit is contained in:
Jiayi Yan
2026-03-04 07:15:36 +08:00
committed by GitHub
parent 069c7e4188
commit 753da27535

View File

@@ -3378,7 +3378,12 @@ def parse_lscpu_topology():
cpu_info = []
for line in output.splitlines():
if not line.startswith("#"):
cpu, core, socket, node = map(int, line.strip().split(","))
parts = line.strip().split(",")
if len(parts) != 4:
logger.warning("Skipping malformed lscpu line: %s", line.strip())
continue
cpu = int(parts[0]) # CPU id must always be present
core, socket, node = [int(p) if p else 0 for p in parts[1:]]
cpu_info.append((cpu, core, socket, node))
# [(0,0,0,0),(1,1,0,0),...,(43,43,0,1),...,(256,0,0,0),...]