Skip to content

Commit 4bd3803

Browse files
captain5050acmel
authored andcommitted
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]>
1 parent c4f74bb commit 4bd3803

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/perf/pmu-events/jevents.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,11 @@ def fix_none(s: Optional[str]) -> str:
503503

504504
first = True
505505
last_pmu = None
506+
last_name = None
506507
pmus = set()
507508
for event in sorted(_pending_events, key=event_cmp_key):
509+
if last_pmu and last_pmu == event.pmu:
510+
assert event.name != last_name, f"Duplicate event: {last_pmu}/{last_name}/ in {_pending_events_tblname}"
508511
if event.pmu != last_pmu:
509512
if not first:
510513
_args.output_file.write('};\n')
@@ -516,6 +519,7 @@ def fix_none(s: Optional[str]) -> str:
516519
pmus.add((event.pmu, pmu_name))
517520

518521
_args.output_file.write(event.to_c_string(metric=False))
522+
last_name = event.name
519523
_pending_events = []
520524

521525
_args.output_file.write(f"""

0 commit comments

Comments
 (0)