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>,
"Ravi Bangoria" <ravi.bangoria@amd.com>,
"Weilin Wang" <weilin.wang@intel.com>,
"Jing Zhang" <renyu.zj@linux.alibaba.com>,
"Xu Yang" <xu.yang_2@nxp.com>,
"Sandipan Das" <sandipan.das@amd.com>,
"Benjamin Gray" <bgray@linux.ibm.com>,
"Athira Jajeev" <atrajeev@linux.vnet.ibm.com>,
"Howard Chu" <howardchu95@gmail.com>,
"Dominique Martinet" <asmadeus@codewreck.org>,
"Yang Jihong" <yangjihong@bytedance.com>,
"Colin Ian King" <colin.i.king@gmail.com>,
"Veronika Molnarova" <vmolnaro@redhat.com>,
"Dr. David Alan Gilbert" <linux@treblig.org>,
"Oliver Upton" <oliver.upton@linux.dev>,
"Changbin Du" <changbin.du@huawei.com>,
"Ze Gao" <zegao2021@gmail.com>, "Andi Kleen" <ak@linux.intel.com>,
"Clément Le Goffic" <clement.legoffic@foss.st.com>,
"Sun Haiyong" <sunhaiyong@loongson.cn>,
"Junhao He" <hejunhao3@huawei.com>,
"Tiezhu Yang" <yangtiezhu@loongson.cn>,
"Yicong Yang" <yangyicong@hisilicon.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 05/13] perf tool_pmu: Rename enum perf_tool_event to tool_pmu_event
Date: Thu, 12 Sep 2024 12:03:32 -0700 [thread overview]
Message-ID: <20240912190341.919229-6-irogers@google.com> (raw)
In-Reply-To: <20240912190341.919229-1-irogers@google.com>
To better reflect the events listed are from the tool PMU. Rename the
enum values from PERF_TOOL_* to TOOL_PMU__EVENT_*.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/builtin-stat.c | 6 ++---
tools/perf/util/evsel.c | 4 ++--
tools/perf/util/metricgroup.c | 12 +++++-----
tools/perf/util/pmu.c | 2 +-
tools/perf/util/stat-shadow.c | 10 ++++----
tools/perf/util/tool_pmu.c | 44 +++++++++++++++++------------------
tools/perf/util/tool_pmu.h | 22 +++++++++---------
7 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index ae525fdcfbde..a6b4d1b98b3a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -295,14 +295,14 @@ static int read_single_counter(struct evsel *counter, int cpu_map_idx, int threa
* terminates. Use the wait4 values in that case.
*/
if (err && cpu_map_idx == 0 &&
- (evsel__tool_event(counter) == PERF_TOOL_USER_TIME ||
- evsel__tool_event(counter) == PERF_TOOL_SYSTEM_TIME)) {
+ (evsel__tool_event(counter) == TOOL_PMU__EVENT_USER_TIME ||
+ evsel__tool_event(counter) == TOOL_PMU__EVENT_SYSTEM_TIME)) {
u64 val, *start_time;
struct perf_counts_values *count =
perf_counts(counter->counts, cpu_map_idx, thread);
start_time = xyarray__entry(counter->start_times, cpu_map_idx, thread);
- if (evsel__tool_event(counter) == PERF_TOOL_USER_TIME)
+ if (evsel__tool_event(counter) == TOOL_PMU__EVENT_USER_TIME)
val = ru_stats.ru_utime_usec_stat.mean;
else
val = ru_stats.ru_stime_usec_stat.mean;
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index b75c4a4c7aa7..c0b49c5dd3cf 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1471,8 +1471,8 @@ void evsel__exit(struct evsel *evsel)
evsel->per_pkg_mask = NULL;
zfree(&evsel->metric_events);
perf_evsel__object.fini(evsel);
- if (evsel__tool_event(evsel) == PERF_TOOL_SYSTEM_TIME ||
- evsel__tool_event(evsel) == PERF_TOOL_USER_TIME)
+ if (evsel__tool_event(evsel) == TOOL_PMU__EVENT_SYSTEM_TIME ||
+ evsel__tool_event(evsel) == TOOL_PMU__EVENT_USER_TIME)
xyarray__delete(evsel->start_times);
}
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 9181548e8881..0e21e2f9c170 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -674,20 +674,20 @@ static int metricgroup__build_event_string(struct strbuf *events,
struct hashmap_entry *cur;
size_t bkt;
bool no_group = true, has_tool_events = false;
- bool tool_events[PERF_TOOL_MAX] = {false};
+ bool tool_events[TOOL_PMU__EVENT_MAX] = {false};
int ret = 0;
#define RETURN_IF_NON_ZERO(x) do { if (x) return x; } while (0)
hashmap__for_each_entry(ctx->ids, cur, bkt) {
const char *sep, *rsep, *id = cur->pkey;
- enum perf_tool_event ev;
+ enum tool_pmu_event ev;
pr_debug("found event %s\n", id);
/* Always move tool events outside of the group. */
ev = perf_tool_event__from_str(id);
- if (ev != PERF_TOOL_NONE) {
+ if (ev != TOOL_PMU__EVENT_NONE) {
has_tool_events = true;
tool_events[ev] = true;
continue;
@@ -1375,7 +1375,7 @@ static void metricgroup__free_metrics(struct list_head *metric_list)
* to true if tool event is found.
*/
static void find_tool_events(const struct list_head *metric_list,
- bool tool_events[PERF_TOOL_MAX])
+ bool tool_events[TOOL_PMU__EVENT_MAX])
{
struct metric *m;
@@ -1447,7 +1447,7 @@ static int build_combined_expr_ctx(const struct list_head *metric_list,
*/
static int parse_ids(bool metric_no_merge, bool fake_pmu,
struct expr_parse_ctx *ids, const char *modifier,
- bool group_events, const bool tool_events[PERF_TOOL_MAX],
+ bool group_events, const bool tool_events[TOOL_PMU__EVENT_MAX],
struct evlist **out_evlist)
{
struct parse_events_error parse_error;
@@ -1536,7 +1536,7 @@ static int parse_groups(struct evlist *perf_evlist,
struct evlist *combined_evlist = NULL;
LIST_HEAD(metric_list);
struct metric *m;
- bool tool_events[PERF_TOOL_MAX] = {false};
+ bool tool_events[TOOL_PMU__EVENT_MAX] = {false};
bool is_default = !strcmp(str, "Default");
int ret;
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index f17e21455498..fadb705fd9a7 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1832,7 +1832,7 @@ bool perf_pmu__have_event(struct perf_pmu *pmu, const char *name)
if (!name)
return false;
if (perf_pmu__is_tool(pmu))
- return perf_tool_event__from_str(name) != PERF_TOOL_NONE;
+ return perf_tool_event__from_str(name) != TOOL_PMU__EVENT_NONE;
if (perf_pmu__find_alias(pmu, name, /*load=*/ true) != NULL)
return true;
if (pmu->cpu_aliases_added || !pmu->events_table)
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 2d653f91400e..e56969d1e39d 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -382,22 +382,22 @@ static int prepare_metric(const struct metric_expr *mexp,
double scale;
switch (evsel__tool_event(metric_events[i])) {
- case PERF_TOOL_DURATION_TIME:
+ case TOOL_PMU__EVENT_DURATION_TIME:
stats = &walltime_nsecs_stats;
scale = 1e-9;
break;
- case PERF_TOOL_USER_TIME:
+ case TOOL_PMU__EVENT_USER_TIME:
stats = &ru_stats.ru_utime_usec_stat;
scale = 1e-6;
break;
- case PERF_TOOL_SYSTEM_TIME:
+ case TOOL_PMU__EVENT_SYSTEM_TIME:
stats = &ru_stats.ru_stime_usec_stat;
scale = 1e-6;
break;
- case PERF_TOOL_NONE:
+ case TOOL_PMU__EVENT_NONE:
pr_err("Invalid tool event 'none'");
abort();
- case PERF_TOOL_MAX:
+ case TOOL_PMU__EVENT_MAX:
pr_err("Invalid tool event 'max'");
abort();
default:
diff --git a/tools/perf/util/tool_pmu.c b/tools/perf/util/tool_pmu.c
index 702c1131a2a8..7ef559532f5b 100644
--- a/tools/perf/util/tool_pmu.c
+++ b/tools/perf/util/tool_pmu.c
@@ -12,7 +12,7 @@
#include <fcntl.h>
#include <strings.h>
-static const char *const tool_pmu__event_names[PERF_TOOL_MAX] = {
+static const char *const tool_pmu__event_names[TOOL_PMU__EVENT_MAX] = {
NULL,
"duration_time",
"user_time",
@@ -20,15 +20,15 @@ static const char *const tool_pmu__event_names[PERF_TOOL_MAX] = {
};
-const char *perf_tool_event__to_str(enum perf_tool_event ev)
+const char *perf_tool_event__to_str(enum tool_pmu_event ev)
{
- if (ev > PERF_TOOL_NONE && ev < PERF_TOOL_MAX)
+ if (ev > TOOL_PMU__EVENT_NONE && ev < TOOL_PMU__EVENT_MAX)
return tool_pmu__event_names[ev];
return NULL;
}
-enum perf_tool_event perf_tool_event__from_str(const char *str)
+enum tool_pmu_event perf_tool_event__from_str(const char *str)
{
int i;
@@ -36,7 +36,7 @@ enum perf_tool_event perf_tool_event__from_str(const char *str)
if (!strcasecmp(str, tool_pmu__event_names[i]))
return i;
}
- return PERF_TOOL_NONE;
+ return TOOL_PMU__EVENT_NONE;
}
static int tool_pmu__config_term(struct perf_event_attr *attr,
@@ -44,9 +44,9 @@ static int tool_pmu__config_term(struct perf_event_attr *attr,
struct parse_events_error *err)
{
if (term->type_term == PARSE_EVENTS__TERM_TYPE_USER) {
- enum perf_tool_event ev = perf_tool_event__from_str(term->config);
+ enum tool_pmu_event ev = perf_tool_event__from_str(term->config);
- if (ev == PERF_TOOL_NONE)
+ if (ev == TOOL_PMU__EVENT_NONE)
goto err_out;
attr->config = ev;
@@ -120,12 +120,12 @@ bool evsel__is_tool(const struct evsel *evsel)
return perf_pmu__is_tool(evsel->pmu);
}
-enum perf_tool_event evsel__tool_event(const struct evsel *evsel)
+enum tool_pmu_event evsel__tool_event(const struct evsel *evsel)
{
if (!evsel__is_tool(evsel))
- return PERF_TOOL_NONE;
+ return TOOL_PMU__EVENT_NONE;
- return (enum perf_tool_event)evsel->core.attr.config;
+ return (enum tool_pmu_event)evsel->core.attr.config;
}
const char *evsel__tool_pmu_event_name(const struct evsel *evsel)
@@ -231,8 +231,8 @@ int evsel__tool_pmu_prepare_open(struct evsel *evsel,
struct perf_cpu_map *cpus,
int nthreads)
{
- if ((evsel__tool_event(evsel) == PERF_TOOL_SYSTEM_TIME ||
- evsel__tool_event(evsel) == PERF_TOOL_USER_TIME) &&
+ if ((evsel__tool_event(evsel) == TOOL_PMU__EVENT_SYSTEM_TIME ||
+ evsel__tool_event(evsel) == TOOL_PMU__EVENT_USER_TIME) &&
!evsel->start_times) {
evsel->start_times = xyarray__new(perf_cpu_map__nr(cpus),
nthreads,
@@ -249,10 +249,10 @@ int evsel__tool_pmu_open(struct evsel *evsel,
struct perf_thread_map *threads,
int start_cpu_map_idx, int end_cpu_map_idx)
{
- enum perf_tool_event ev = evsel__tool_event(evsel);
+ enum tool_pmu_event ev = evsel__tool_event(evsel);
int pid = -1, idx = 0, thread = 0, nthreads, err = 0, old_errno;
- if (ev == PERF_TOOL_DURATION_TIME) {
+ if (ev == TOOL_PMU__EVENT_DURATION_TIME) {
if (evsel->core.attr.sample_period) /* no sampling */
return -EINVAL;
evsel->start_time = rdclock();
@@ -271,8 +271,8 @@ int evsel__tool_pmu_open(struct evsel *evsel,
if (!evsel->cgrp && !evsel->core.system_wide)
pid = perf_thread_map__pid(threads, thread);
- if (ev == PERF_TOOL_USER_TIME || ev == PERF_TOOL_SYSTEM_TIME) {
- bool system = ev == PERF_TOOL_SYSTEM_TIME;
+ if (ev == TOOL_PMU__EVENT_USER_TIME || ev == TOOL_PMU__EVENT_SYSTEM_TIME) {
+ bool system = ev == TOOL_PMU__EVENT_SYSTEM_TIME;
__u64 *start_time = NULL;
int fd;
@@ -340,7 +340,7 @@ int evsel__read_tool(struct evsel *evsel, int cpu_map_idx, int thread)
count = perf_counts(evsel->counts, cpu_map_idx, thread);
switch (evsel__tool_event(evsel)) {
- case PERF_TOOL_DURATION_TIME:
+ case TOOL_PMU__EVENT_DURATION_TIME:
/*
* Pretend duration_time is only on the first CPU and thread, or
* else aggregation will scale duration_time by the number of
@@ -352,9 +352,9 @@ int evsel__read_tool(struct evsel *evsel, int cpu_map_idx, int thread)
else
cur_time = *start_time;
break;
- case PERF_TOOL_USER_TIME:
- case PERF_TOOL_SYSTEM_TIME: {
- bool system = evsel__tool_event(evsel) == PERF_TOOL_SYSTEM_TIME;
+ case TOOL_PMU__EVENT_USER_TIME:
+ case TOOL_PMU__EVENT_SYSTEM_TIME: {
+ bool system = evsel__tool_event(evsel) == TOOL_PMU__EVENT_SYSTEM_TIME;
start_time = xyarray__entry(evsel->start_times, cpu_map_idx, thread);
fd = FD(evsel, cpu_map_idx, thread);
@@ -379,8 +379,8 @@ int evsel__read_tool(struct evsel *evsel, int cpu_map_idx, int thread)
adjust = true;
break;
}
- case PERF_TOOL_NONE:
- case PERF_TOOL_MAX:
+ case TOOL_PMU__EVENT_NONE:
+ case TOOL_PMU__EVENT_MAX:
default:
err = -EINVAL;
}
diff --git a/tools/perf/util/tool_pmu.h b/tools/perf/util/tool_pmu.h
index 05a4052c8b9d..b27a26133927 100644
--- a/tools/perf/util/tool_pmu.h
+++ b/tools/perf/util/tool_pmu.h
@@ -8,25 +8,25 @@ struct evsel;
struct perf_thread_map;
struct print_callbacks;
-enum perf_tool_event {
- PERF_TOOL_NONE = 0,
- PERF_TOOL_DURATION_TIME = 1,
- PERF_TOOL_USER_TIME = 2,
- PERF_TOOL_SYSTEM_TIME = 3,
+enum tool_pmu_event {
+ TOOL_PMU__EVENT_NONE = 0,
+ TOOL_PMU__EVENT_DURATION_TIME = 1,
+ TOOL_PMU__EVENT_USER_TIME = 2,
+ TOOL_PMU__EVENT_SYSTEM_TIME = 3,
- PERF_TOOL_MAX,
+ TOOL_PMU__EVENT_MAX,
};
#define perf_tool_event__for_each_event(ev) \
- for ((ev) = PERF_TOOL_DURATION_TIME; (ev) < PERF_TOOL_MAX; ev++)
+ for ((ev) = TOOL_PMU__EVENT_DURATION_TIME; (ev) < TOOL_PMU__EVENT_MAX; ev++)
static inline size_t tool_pmu__num_events(void)
{
- return PERF_TOOL_MAX - 1;
+ return TOOL_PMU__EVENT_MAX - 1;
}
-const char *perf_tool_event__to_str(enum perf_tool_event ev);
-enum perf_tool_event perf_tool_event__from_str(const char *str);
+const char *perf_tool_event__to_str(enum tool_pmu_event ev);
+enum tool_pmu_event perf_tool_event__from_str(const char *str);
int tool_pmu__config_terms(struct perf_event_attr *attr,
struct parse_events_terms *terms,
struct parse_events_error *err);
@@ -36,7 +36,7 @@ bool perf_pmu__is_tool(const struct perf_pmu *pmu);
bool evsel__is_tool(const struct evsel *evsel);
-enum perf_tool_event evsel__tool_event(const struct evsel *evsel);
+enum tool_pmu_event evsel__tool_event(const struct evsel *evsel);
const char *evsel__tool_pmu_event_name(const struct evsel *evsel);
int evsel__tool_pmu_prepare_open(struct evsel *evsel,
struct perf_cpu_map *cpus,
--
2.46.0.662.g92d0881bb0-goog
next prev parent reply other threads:[~2024-09-12 19:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 19:03 [PATCH v2 00/13] Tool and hwmon PMUs Ian Rogers
2024-09-12 19:03 ` [PATCH v2 01/13] perf pmu: Simplify an asprintf error message Ian Rogers
2024-09-12 19:18 ` Arnaldo Carvalho de Melo
2024-09-12 19:03 ` [PATCH v2 02/13] perf pmu: Allow hardcoded terms to be applied to attributes Ian Rogers
2024-09-12 19:03 ` [PATCH v2 03/13] perf parse-events: Expose/rename config_term_name Ian Rogers
2024-09-12 19:03 ` [PATCH v2 04/13] perf tool_pmu: Factor tool events into their own PMU Ian Rogers
2024-09-12 19:03 ` Ian Rogers [this message]
2024-09-12 19:03 ` [PATCH v2 06/13] perf tool_pmu: Rename perf_tool_event__* to tool_pmu__* Ian Rogers
2024-09-12 19:03 ` [PATCH v2 07/13] perf tool_pmu: Move expr literals to tool_pmu Ian Rogers
2024-09-12 19:03 ` [PATCH v2 08/13] perf jevents: Add tool event json under a common architecture Ian Rogers
2024-09-12 19:03 ` [PATCH v2 09/13] perf tool_pmu: Switch to standard pmu functions and json descriptions Ian Rogers
2024-09-12 19:03 ` [PATCH v2 10/13] perf tests: Add tool PMU test Ian Rogers
2024-09-12 19:03 ` [PATCH v2 11/13] perf hwmon_pmu: Add a tool PMU exposing events from hwmon in sysfs Ian Rogers
2024-09-12 19:03 ` [PATCH v2 12/13] perf test: Add hwmon "PMU" test Ian Rogers
2024-09-12 19:03 ` [PATCH v2 13/13] perf docs: Document tool and hwmon events Ian Rogers
2024-09-12 22:50 ` [PATCH v2 00/13] Tool and hwmon PMUs Namhyung Kim
2024-09-13 14:34 ` Ian Rogers
2024-09-26 19:47 ` Ian Rogers
2024-09-27 17:22 ` Namhyung Kim
2024-09-27 18:09 ` Ian Rogers
2024-09-29 7:21 ` Namhyung Kim
2024-10-01 4:56 ` Ian Rogers
2024-10-01 23:39 ` 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=20240912190341.919229-6-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=asmadeus@codewreck.org \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=bgray@linux.ibm.com \
--cc=changbin.du@huawei.com \
--cc=clement.legoffic@foss.st.com \
--cc=colin.i.king@gmail.com \
--cc=hejunhao3@huawei.com \
--cc=howardchu95@gmail.com \
--cc=james.clark@linaro.org \
--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@treblig.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=renyu.zj@linux.alibaba.com \
--cc=sandipan.das@amd.com \
--cc=sunhaiyong@loongson.cn \
--cc=vmolnaro@redhat.com \
--cc=weilin.wang@intel.com \
--cc=will@kernel.org \
--cc=xu.yang_2@nxp.com \
--cc=yangjihong@bytedance.com \
--cc=yangtiezhu@loongson.cn \
--cc=yangyicong@hisilicon.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;
as well as URLs for NNTP newsgroup(s).