mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-31 11:25:30 +00:00
board_inspector: add a cmdline option to inject LLC CAT capability
This patch adds the command line option --add-llc-cat to the board inspector to allow users adding CAT capabilities of the last level cache to the generated board XML even when the hardware does not report so for any reason. Tracked-On: #6690 Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
parent
db17992293
commit
7ca33206fb
@ -6,10 +6,12 @@
|
||||
#
|
||||
|
||||
import sys, os
|
||||
import re
|
||||
import logging
|
||||
import subprocess # nosec
|
||||
import lxml.etree
|
||||
import argparse
|
||||
from collections import namedtuple
|
||||
from importlib import import_module
|
||||
from cpuparser import parse_cpuid, get_online_cpu_ids, get_offline_cpu_ids
|
||||
|
||||
@ -18,6 +20,20 @@ sys.path.append(os.path.join(script_dir))
|
||||
|
||||
from inspectorlib import validator
|
||||
|
||||
class AddLLCCATAction(argparse.Action):
|
||||
CATInfo = namedtuple("CATInfo", ["capacity_mask_length", "clos_number", "has_CDP"])
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
pattern = re.compile("([0-9]+),([0-9]+),(true|false|y|n|yes|no)")
|
||||
if option_string:
|
||||
m = pattern.match(values.lower())
|
||||
if not m:
|
||||
parser.error(f"{values} is ill-formed. The expected format is: <capacity_mask_length:int>,<clos_number:int>,<has_CDP:bool>")
|
||||
v = self.CATInfo(int(m.group(1)), int(m.group(2)), m.group(3) in ["true", "y", "yes"])
|
||||
else:
|
||||
v = None
|
||||
setattr(namespace, self.dest, v)
|
||||
|
||||
def check_deps():
|
||||
# Check that the required tools are installed on the system
|
||||
BIN_LIST = ['cpuid', 'rdmsr', 'lspci', ' dmidecode', 'blkid', 'stty']
|
||||
@ -136,6 +152,8 @@ if __name__ == "__main__":
|
||||
parser.add_argument("--basic", action="store_true", default=False, help="do not extract advanced information such as ACPI namespace")
|
||||
parser.add_argument("--loglevel", default="warning", help="choose log level, e.g. info, warning or error")
|
||||
parser.add_argument("--check-device-status", action="store_true", default=False, help="filter out devices whose _STA object evaluates to 0")
|
||||
parser.add_argument("--add-llc-cat", default=None, action=AddLLCCATAction,
|
||||
metavar="<capacity_mask_length:int>,<clos_number:int>,<has_CDP:bool>", help="manually set the Cache Allocation Technology capability of the last level cache")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
logging.basicConfig(level=args.loglevel.upper())
|
||||
|
@ -100,3 +100,16 @@ def extract(args, board_etree):
|
||||
caches_node = get_node(board_etree, "//caches")
|
||||
extract_topology(root_node, caches_node)
|
||||
extract_tcc_capabilities(caches_node)
|
||||
|
||||
# Inject the explicitly specified CAT capability if exists
|
||||
if args.add_llc_cat:
|
||||
llc_node = get_node(root_node, "//caches/cache[@level='3']")
|
||||
llc_cat_node = get_node(llc_node, "capability[@id='CAT']")
|
||||
if llc_cat_node is None:
|
||||
llc_cat_node = add_child(llc_node, "capability", None, id="CAT")
|
||||
add_child(llc_cat_node, "capacity_mask_length", str(args.add_llc_cat.capacity_mask_length))
|
||||
add_child(llc_cat_node, "clos_number", str(args.add_llc_cat.clos_number))
|
||||
if args.add_llc_cat.has_CDP:
|
||||
add_child(llc_node, "capability", None, id="CDP")
|
||||
else:
|
||||
logging.warning("The last level cache already reports CAT capability. The explicit settings from the command line options are ignored.")
|
||||
|
Loading…
Reference in New Issue
Block a user