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>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Howard Chu <howardchu95@gmail.com>,
James Clark <james.clark@linaro.org>,
Zhongqiu Han <quic_zhonhan@quicinc.com>,
Anubhav Shelat <ashelat@redhat.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 2/3] perf pmu: Add PMU kind to simplify differentiating
Date: Fri, 14 Nov 2025 14:05:46 -0800 [thread overview]
Message-ID: <20251114220547.496562-2-irogers@google.com> (raw)
In-Reply-To: <20251114220547.496562-1-irogers@google.com>
Rather than perf_pmu__is_xxx calls, and a notion of kind so that a
single call can be used.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/pmu.h | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 1ebcf0242af8..cfcaba3e2e75 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -37,6 +37,19 @@ struct perf_pmu_caps {
struct list_head list;
};
+enum pmu_kind {
+ /* A perf event syscall PMU. */
+ PERF_PMU_KIND_PE,
+ /* A perf tool provided DRM PMU. */
+ PERF_PMU_KIND_DRM,
+ /* A perf tool provided HWMON PMU. */
+ PERF_PMU_KIND_HWMON,
+ /* Perf tool provided PMU for tool events like time. */
+ PERF_PMU_KIND_TOOL,
+ /* A testing PMU kind. */
+ PERF_PMU_KIND_FAKE
+};
+
enum {
PERF_PMU_TYPE_PE_START = 0,
PERF_PMU_TYPE_PE_END = 0xFFFDFFFF,
@@ -306,4 +319,25 @@ void perf_pmu__delete(struct perf_pmu *pmu);
const char *perf_pmu__name_from_config(struct perf_pmu *pmu, u64 config);
bool perf_pmu__is_fake(const struct perf_pmu *pmu);
+static inline enum pmu_kind perf_pmu__kind(const struct perf_pmu *pmu)
+{
+ __u32 type;
+
+ if (!pmu)
+ return PERF_PMU_KIND_PE;
+
+ type = pmu->type;
+ if (type <= PERF_PMU_TYPE_PE_END)
+ return PERF_PMU_KIND_PE;
+ if (type <= PERF_PMU_TYPE_DRM_END)
+ return PERF_PMU_KIND_DRM;
+ if (type <= PERF_PMU_TYPE_DRM_END)
+ return PERF_PMU_KIND_DRM;
+ if (type <= PERF_PMU_TYPE_HWMON_END)
+ return PERF_PMU_KIND_HWMON;
+ if (type == PERF_PMU_TYPE_TOOL)
+ return PERF_PMU_KIND_TOOL;
+ return PERF_PMU_KIND_FAKE;
+}
+
#endif /* __PMU_H */
--
2.52.0.rc1.455.g30608eb744-goog
next prev parent reply other threads:[~2025-11-14 22:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 22:05 [PATCH v1 1/3] perf header: Switch "cpu" for find_core_pmu in caps feature writing Ian Rogers
2025-11-14 22:05 ` Ian Rogers [this message]
2025-11-24 12:34 ` [PATCH v1 2/3] perf pmu: Add PMU kind to simplify differentiating Anubhav Shelat
2025-11-24 20:22 ` Namhyung Kim
2025-11-25 11:41 ` [PATCH] perf pmu: fix duplicate conditional statement Anubhav Shelat
2025-11-26 1:33 ` Mi, Dapeng
2025-11-26 2:27 ` Ian Rogers
2025-11-27 20:58 ` Namhyung Kim
2025-11-14 22:05 ` [PATCH v1 3/3] perf evsel: Skip store_evsel_ids for non-perf-event PMUs Ian Rogers
2025-11-17 19:47 ` Falcon, Thomas
2025-11-20 19:02 ` [PATCH v1 1/3] perf header: Switch "cpu" for find_core_pmu in caps feature writing 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=20251114220547.496562-2-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ashelat@redhat.com \
--cc=howardchu95@gmail.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=quic_zhonhan@quicinc.com \
--cc=ravi.bangoria@amd.com \
--cc=thomas.falcon@intel.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;
as well as URLs for NNTP newsgroup(s).