From: Ian Rogers Date: Thu, 14 Nov 2024 17:23:09 +0000 (-0800) Subject: perf jevents: Provide better path information for broken JSON X-Git-Tag: v6.14-rc1~120^2~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26f45ec8f0367f8ee54dff5c7f2cfe8d445f3da8;p=thirdparty%2Flinux.git perf jevents: Provide better path information for broken JSON If the JSON input to jevents.py is broken it can be problematic to work out which particular JSON file is broken. When processing files catch exceptions that occur that re-raise the exception with path details added. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Benjamin Gray Cc: Ingo Molnar Cc: Jiri Olsa Cc: John Garry Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Sandipan Das Cc: Stephane Eranian Cc: Xu Yang Link: https://lore.kernel.org/r/20241114172309.840241-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 139dae1f1f832..3e204700b59af 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -464,12 +464,16 @@ def preprocess_arch_std_files(archpath: str) -> None: """Read in all architecture standard events.""" global _arch_std_events for item in os.scandir(archpath): - if item.is_file() and item.name.endswith('.json'): + if not item.is_file() or not item.name.endswith('.json'): + continue + try: for event in read_json_events(item.path, topic=''): if event.name: _arch_std_events[event.name.lower()] = event if event.metric_name: _arch_std_events[event.metric_name.lower()] = event + except Exception as e: + raise RuntimeError(f'Failure processing \'{item.name}\' in \'{archpath}\'') from e def add_events_table_entries(item: os.DirEntry, topic: str) -> None: @@ -1255,7 +1259,10 @@ def main() -> None: item_path = '/'.join(parents) + ('/' if len(parents) > 0 else '') + item.name if 'test' not in item_path and 'common' not in item_path and item_path not in _args.model.split(','): continue - action(parents, item) + try: + action(parents, item) + except Exception as e: + raise RuntimeError(f'Action failure for \'{item.name}\' in {parents}') from e if item.is_dir(): ftw(item.path, parents + [item.name], action)