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>,
James Clark <james.clark@linaro.org>,
Ze Gao <zegao2021@gmail.com>,
Weilin Wang <weilin.wang@intel.com>,
Dominique Martinet <asmadeus@codewreck.org>,
Jean-Philippe Romain <jean-philippe.romain@foss.st.com>,
Junhao He <hejunhao3@huawei.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, Aditya Bodkhe <Aditya.Bodkhe1@ibm.com>
Cc: Leo Yan <leo.yan@arm.com>, Atish Patra <atishp@rivosinc.com>
Subject: [PATCH v5 1/4] perf evsel: Add pmu_name helper
Date: Thu, 9 Jan 2025 14:21:06 -0800 [thread overview]
Message-ID: <20250109222109.567031-2-irogers@google.com> (raw)
In-Reply-To: <20250109222109.567031-1-irogers@google.com>
Add helper to get the name of the evsel's PMU. This handles the case
where there's no sysfs PMU via parse_events event_type helper.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Tested-by: Leo Yan <leo.yan@arm.com>
Tested-by: Atish Patra <atishp@rivosinc.com>
---
tools/perf/util/evsel.c | 10 ++++++++++
tools/perf/util/evsel.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bc144388f892..026cf9a9893c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -237,6 +237,16 @@ int evsel__object_config(size_t object_size, int (*init)(struct evsel *evsel),
return 0;
}
+const char *evsel__pmu_name(const struct evsel *evsel)
+{
+ struct perf_pmu *pmu = evsel__find_pmu(evsel);
+
+ if (pmu)
+ return pmu->name;
+
+ return event_type(evsel->core.attr.type);
+}
+
#define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))
int __evsel__sample_size(u64 sample_type)
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 5e789fa80590..2dd108a14b89 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -236,6 +236,7 @@ int evsel__object_config(size_t object_size,
void (*fini)(struct evsel *evsel));
struct perf_pmu *evsel__find_pmu(const struct evsel *evsel);
+const char *evsel__pmu_name(const struct evsel *evsel);
bool evsel__is_aux_event(const struct evsel *evsel);
struct evsel *evsel__new_idx(struct perf_event_attr *attr, int idx);
--
2.47.1.613.gc27f4b7a9f-goog
next prev parent reply other threads:[~2025-01-09 22:21 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 22:21 [PATCH v5 0/4] Prefer sysfs/JSON events also when no PMU is provided Ian Rogers
2025-01-09 22:21 ` Ian Rogers [this message]
2025-01-09 22:21 ` [PATCH v5 2/4] perf stat: Fix find_stat for mixed legacy/non-legacy events Ian Rogers
2025-01-09 22:21 ` [PATCH v5 3/4] perf record: Skip don't fail for events that don't open Ian Rogers
2025-01-10 1:25 ` Namhyung Kim
2025-01-10 4:44 ` Ian Rogers
2025-01-10 18:55 ` Namhyung Kim
2025-01-10 19:18 ` Ian Rogers
2025-01-14 19:29 ` Namhyung Kim
2025-01-14 23:55 ` Ian Rogers
2025-01-15 22:14 ` Namhyung Kim
2025-01-15 22:40 ` Ian Rogers
2025-01-10 14:18 ` Arnaldo Carvalho de Melo
2025-01-10 16:42 ` Ian Rogers
2025-01-10 19:26 ` Namhyung Kim
2025-01-10 21:33 ` Ian Rogers
2025-01-13 20:51 ` Namhyung Kim
2025-01-13 23:04 ` Ian Rogers
2025-01-15 17:31 ` Namhyung Kim
2025-01-15 17:56 ` Ian Rogers
2025-01-29 21:24 ` Namhyung Kim
2025-01-09 22:21 ` [PATCH v5 4/4] perf parse-events: Reapply "Prefer sysfs/JSON hardware events over legacy" Ian Rogers
2025-01-10 19:40 ` Namhyung Kim
2025-01-10 19:52 ` Atish Kumar Patra
2025-01-13 20:56 ` Namhyung Kim
2025-01-10 22:15 ` Ian Rogers
2025-01-13 22:01 ` Namhyung Kim
2025-01-13 22:51 ` Ian Rogers
2025-01-14 2:31 ` Ian Rogers
2025-01-15 17:59 ` Namhyung Kim
2025-01-15 21:20 ` Ian Rogers
2025-01-29 21:55 ` Namhyung Kim
2025-01-30 1:16 ` Ian Rogers
2025-01-30 5:16 ` Namhyung Kim
2025-01-30 6:03 ` Ian Rogers
2025-01-31 22:28 ` Namhyung Kim
2025-01-30 6:12 ` Atish Kumar Patra
2025-01-31 22:42 ` Namhyung Kim
2025-02-01 8:45 ` Ian Rogers
2025-02-04 0:15 ` Namhyung Kim
2025-02-04 0:41 ` Ian Rogers
2025-02-05 1:57 ` Namhyung Kim
2025-02-05 4:48 ` Ian Rogers
2025-02-06 5:09 ` Namhyung Kim
2025-02-06 7:44 ` Ian Rogers
2025-02-07 4:44 ` Namhyung Kim
2025-02-07 6:15 ` Ian Rogers
2025-02-07 17:18 ` Atish Kumar Patra
2025-02-19 23:22 ` Namhyung Kim
2025-02-19 23:32 ` Ian Rogers
2025-02-03 5:47 ` Atish Kumar Patra
2025-01-29 22:05 ` [PATCH v5 0/4] Prefer sysfs/JSON events also when no PMU is provided Namhyung Kim
2025-01-30 17:46 ` Namhyung Kim
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=20250109222109.567031-2-irogers@google.com \
--to=irogers@google.com \
--cc=Aditya.Bodkhe1@ibm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=asmadeus@codewreck.org \
--cc=atishp@rivosinc.com \
--cc=bpf@vger.kernel.org \
--cc=hejunhao3@huawei.com \
--cc=james.clark@linaro.org \
--cc=jean-philippe.romain@foss.st.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=weilin.wang@intel.com \
--cc=zegao2021@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome