mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-07 11:14:53 +00:00
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:
parent
c952c00324
commit
2e20494db1
@ -11,7 +11,7 @@ import subprocess # nosec
|
||||
import lxml.etree
|
||||
import argparse
|
||||
from importlib import import_module
|
||||
from cpuparser import parse_cpuid, get_online_cpu_ids
|
||||
from cpuparser import parse_cpuid, get_online_cpu_ids, get_offline_cpu_ids
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.append(os.path.join(script_dir))
|
||||
@ -48,6 +48,15 @@ def native_check():
|
||||
logging.warning(f"Board inspector is running inside a Virtual Machine (VM). Running ACRN inside a VM is only" \
|
||||
"supported under KVM/QEMU. Unexpected results may occur when deviating from that combination.")
|
||||
|
||||
def bring_up_cores():
|
||||
cpu_ids = get_offline_cpu_ids()
|
||||
for id in cpu_ids:
|
||||
try:
|
||||
with open("/sys/devices/system/cpu/cpu{}/online".format(id), "w") as f:
|
||||
f.write("1")
|
||||
except :
|
||||
logging.warning("Cannot bring up core with cpu id {}.".format(id))
|
||||
|
||||
def main(board_name, board_xml, args):
|
||||
# Check that the dependencies are met
|
||||
check_deps()
|
||||
@ -55,6 +64,9 @@ def main(board_name, board_xml, args):
|
||||
# Check if this is native os
|
||||
native_check()
|
||||
|
||||
# Bring up all cores
|
||||
bring_up_cores()
|
||||
|
||||
try:
|
||||
# First invoke the legacy board parser to create the board XML ...
|
||||
legacy_parser = os.path.join(script_dir, "legacy", "board_parser.py")
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user