aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <[email protected]>2024-08-05 12:44:24 -0700
committerArnaldo Carvalho de Melo <[email protected]>2024-08-06 10:37:12 -0300
commit4bd380390fcce5c77610bc9067a9a97cfd999402 (patch)
treefc1ce19a05b305b729a4a4849fde909cec6f9291
parentc4f74bb61ae01b30067ae3878ca8ba7d677283ae (diff)
perf jevents.py: Ensure event names aren't duplicated
Duplicate event names break invariants in 'perf list'. Assert that an event name isn't duplicated so that broken JSON won't build. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Albert Ou <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Atish Patra <[email protected]> Cc: Changbin Du <[email protected]> Cc: Charles Ci-Jyun Wu <[email protected]> Cc: Eric Lin <[email protected]> Cc: Greentime Hu <[email protected]> Cc: Guilherme Amadio <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Inochi Amaoto <[email protected]> Cc: James Clark <[email protected]> Cc: Ji Sheng Teoh <[email protected]> Cc: Jing Zhang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Locus Wei-Han Chen <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Samuel Holland <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Vincent Chen <[email protected]> Cc: Will Deacon <[email protected]> Cc: Xu Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rwxr-xr-xtools/perf/pmu-events/jevents.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index fcf0158438b5..1d96b2204e52 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -503,8 +503,11 @@ def print_pending_events() -> None:
first = True
last_pmu = None
+ last_name = None
pmus = set()
for event in sorted(_pending_events, key=event_cmp_key):
+ if last_pmu and last_pmu == event.pmu:
+ assert event.name != last_name, f"Duplicate event: {last_pmu}/{last_name}/ in {_pending_events_tblname}"
if event.pmu != last_pmu:
if not first:
_args.output_file.write('};\n')
@@ -516,6 +519,7 @@ def print_pending_events() -> None:
pmus.add((event.pmu, pmu_name))
_args.output_file.write(event.to_c_string(metric=False))
+ last_name = event.name
_pending_events = []
_args.output_file.write(f"""