All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,  Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	 Kan Liang <kan.liang@linux.intel.com>,
	John Garry <john.g.garry@oracle.com>,
	 Will Deacon <will@kernel.org>,
	James Clark <james.clark@linaro.org>,
	 Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linux.dev>,
	 Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 Albert Ou <aou@eecs.berkeley.edu>,
	Samuel Holland <samuel.holland@sifive.com>,
	 Charles Ci-Jyun Wu <dminus@andestech.com>,
	Locus Wei-Han Chen <locus84@andestech.com>,
	 Atish Patra <atishp@rivosinc.com>,
	Ji Sheng Teoh <jisheng.teoh@starfivetech.com>,
	 Inochi Amaoto <inochiama@outlook.com>,
	Jing Zhang <renyu.zj@linux.alibaba.com>,
	 Xu Yang <xu.yang_2@nxp.com>, Sandipan Das <sandipan.das@amd.com>,
	 Guilherme Amadio <amadio@gentoo.org>,
	Changbin Du <changbin.du@huawei.com>,
	 linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org,  vincent.chen@sifive.com,
	greentime.hu@sifive.com,  Eric Lin <eric.lin@sifive.com>
Subject: [PATCH v1 5/5] perf jevents.py: Ensure event names aren't duplicated
Date: Mon,  5 Aug 2024 12:44:24 -0700	[thread overview]
Message-ID: <20240805194424.597244-5-irogers@google.com> (raw)
In-Reply-To: <20240805194424.597244-1-irogers@google.com>

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 <irogers@google.com>
---
 tools/perf/pmu-events/jevents.py | 4 ++++
 1 file changed, 4 insertions(+)

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"""
-- 
2.46.0.rc2.264.g509ed76dc8-goog


WARNING: multiple messages have this Message-ID (diff)
From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,  Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	 Kan Liang <kan.liang@linux.intel.com>,
	John Garry <john.g.garry@oracle.com>,
	 Will Deacon <will@kernel.org>,
	James Clark <james.clark@linaro.org>,
	 Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linux.dev>,
	 Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	 Albert Ou <aou@eecs.berkeley.edu>,
	Samuel Holland <samuel.holland@sifive.com>,
	 Charles Ci-Jyun Wu <dminus@andestech.com>,
	Locus Wei-Han Chen <locus84@andestech.com>,
	 Atish Patra <atishp@rivosinc.com>,
	Ji Sheng Teoh <jisheng.teoh@starfivetech.com>,
	 Inochi Amaoto <inochiama@outlook.com>,
	Jing Zhang <renyu.zj@linux.alibaba.com>,
	 Xu Yang <xu.yang_2@nxp.com>, Sandipan Das <sandipan.das@amd.com>,
	 Guilherme Amadio <amadio@gentoo.org>,
	Changbin Du <changbin.du@huawei.com>,
	 linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org,  vincent.chen@sifive.com,
	greentime.hu@sifive.com,  Eric Lin <eric.lin@sifive.com>
Subject: [PATCH v1 5/5] perf jevents.py: Ensure event names aren't duplicated
Date: Mon,  5 Aug 2024 12:44:24 -0700	[thread overview]
Message-ID: <20240805194424.597244-5-irogers@google.com> (raw)
In-Reply-To: <20240805194424.597244-1-irogers@google.com>

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 <irogers@google.com>
---
 tools/perf/pmu-events/jevents.py | 4 ++++
 1 file changed, 4 insertions(+)

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"""
-- 
2.46.0.rc2.264.g509ed76dc8-goog


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2024-08-05 19:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-05 19:44 [PATCH v1 1/5] perf test: Add build test for JEVENTS_ARCH=all Ian Rogers
2024-08-05 19:44 ` Ian Rogers
2024-08-05 19:44 ` [PATCH v1 2/5] perf pmu-events: Change dependencies for empty-pmu-events.c test Ian Rogers
2024-08-05 19:44   ` Ian Rogers
2024-08-05 20:03   ` Arnaldo Carvalho de Melo
2024-08-05 20:03     ` Arnaldo Carvalho de Melo
2024-08-05 19:44 ` [PATCH v1 3/5] perf pmu-events: Remove duplicated ampereone event Ian Rogers
2024-08-05 19:44   ` Ian Rogers
2024-08-05 19:44 ` [PATCH v1 4/5] perf pmu-events: Remove duplicated riscv firmware event Ian Rogers
2024-08-05 19:44   ` Ian Rogers
2024-08-06  3:54   ` Eric Lin
2024-08-06  3:54     ` Eric Lin
2024-08-06  4:05     ` Ian Rogers
2024-08-06  4:05       ` Ian Rogers
2024-08-06 13:38       ` Arnaldo Carvalho de Melo
2024-08-06 13:38         ` Arnaldo Carvalho de Melo
2024-08-06 13:50         ` Arnaldo Carvalho de Melo
2024-08-06 13:50           ` Arnaldo Carvalho de Melo
2024-08-06 13:51         ` Arnaldo Carvalho de Melo
2024-08-06 13:51           ` Arnaldo Carvalho de Melo
2024-08-06 15:50           ` Eric Lin
2024-08-06 15:50             ` Eric Lin
2024-08-06 17:04             ` Arnaldo Carvalho de Melo
2024-08-06 17:04               ` Arnaldo Carvalho de Melo
2024-08-05 19:44 ` Ian Rogers [this message]
2024-08-05 19:44   ` [PATCH v1 5/5] perf jevents.py: Ensure event names aren't duplicated Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240805194424.597244-5-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=amadio@gentoo.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@rivosinc.com \
    --cc=changbin.du@huawei.com \
    --cc=dminus@andestech.com \
    --cc=eric.lin@sifive.com \
    --cc=greentime.hu@sifive.com \
    --cc=inochiama@outlook.com \
    --cc=james.clark@linaro.org \
    --cc=jisheng.teoh@starfivetech.com \
    --cc=john.g.garry@oracle.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=leo.yan@linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=locus84@andestech.com \
    --cc=mark.rutland@arm.com \
    --cc=mike.leach@linaro.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.org \
    --cc=renyu.zj@linux.alibaba.com \
    --cc=samuel.holland@sifive.com \
    --cc=sandipan.das@amd.com \
    --cc=vincent.chen@sifive.com \
    --cc=will@kernel.org \
    --cc=xu.yang_2@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.