config-tools: bring all cores online

Bring all the cores up in the beginning of the board_inspector.py
It is expected to run board_inspector in clean and native environment.
To resolve the issue that user may run other jobs which puts cores
offline, bringing up all cores online so tool can run cpuid to extract
all available cores information.

Tracked-On: #7119
Signed-off-by: Yang,Yu-chu <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Yang,Yu-chu
2022-02-11 11:02:51 -08:00
committed by acrnsi-robot
parent c952c00324
commit 2e20494db1
2 changed files with 23 additions and 4 deletions

View File

@@ -60,14 +60,21 @@ def parse_cpuid(leaf, subleaf, cpu_id):
else:
return None
def get_online_cpu_ids():
def parse_cpu_ids(file):
acc = list()
with open("/sys/devices/system/cpu/online", "r") as f:
with open(file, "r") as f:
line = f.read().strip()
for r in line.split(","):
if r.find("-") > 0:
first, last = tuple(map(int, r.split("-")))
acc.extend(range(first, last + 1))
else:
acc.append(int(r))
if r:
acc.append(int(r))
return acc
def get_online_cpu_ids():
return parse_cpu_ids("/sys/devices/system/cpu/online")
def get_offline_cpu_ids():
return parse_cpu_ids("/sys/devices/system/cpu/offline")