From: Ian Rogers Date: Mon, 5 Aug 2024 19:44:24 +0000 (-0700) Subject: perf jevents.py: Ensure event names aren't duplicated X-Git-Tag: v6.12-rc1~109^2~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bd380390fcce5c77610bc9067a9a97cfd999402;p=thirdparty%2Fkernel%2Fstable.git 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 Cc: Adrian Hunter Cc: Albert Ou Cc: Alexander Shishkin Cc: Atish Patra Cc: Changbin Du Cc: Charles Ci-Jyun Wu Cc: Eric Lin Cc: Greentime Hu Cc: Guilherme Amadio Cc: Ingo Molnar Cc: Inochi Amaoto Cc: James Clark Cc: Ji Sheng Teoh Cc: Jing Zhang Cc: Jiri Olsa Cc: John Garry Cc: Kan Liang Cc: Leo Yan Cc: Locus Wei-Han Chen Cc: Mark Rutland Cc: Mike Leach Cc: Namhyung Kim Cc: Palmer Dabbelt Cc: Paul Walmsley Cc: Peter Zijlstra Cc: Samuel Holland Cc: Sandipan Das Cc: Vincent Chen Cc: Will Deacon Cc: Xu Yang Link: https://lore.kernel.org/r/20240805194424.597244-5-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 fcf0158438b50..1d96b2204e529 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"""