* [PATCH v1] perf jevents: Provide better path information for broken json
@ 2024-11-14 17:23 Ian Rogers
2024-12-20 18:59 ` Ian Rogers
0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2024-11-14 17:23 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, John Garry, Sandipan Das,
Benjamin Gray, Xu Yang, linux-perf-users, linux-kernel
Cc: Stephane Eranian
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 <irogers@google.com>
---
tools/perf/pmu-events/jevents.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 6e71b09dbc2a..caeddd939cfe 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -461,12 +461,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)
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1] perf jevents: Provide better path information for broken json
2024-11-14 17:23 [PATCH v1] perf jevents: Provide better path information for broken json Ian Rogers
@ 2024-12-20 18:59 ` Ian Rogers
0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2024-12-20 18:59 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, John Garry, Sandipan Das,
Benjamin Gray, Xu Yang, linux-perf-users, linux-kernel
Cc: Stephane Eranian
On Thu, Nov 14, 2024 at 9:23 AM Ian Rogers <irogers@google.com> wrote:
>
> 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 <irogers@google.com>
Ping.
Thanks,
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-20 18:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-14 17:23 [PATCH v1] perf jevents: Provide better path information for broken json Ian Rogers
2024-12-20 18:59 ` Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®