From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
linux-perf-users@vger.kernel.org
Subject: [PATCH 12/59] libperf: Move unit to perf_evsel
Date: Mon, 8 Nov 2021 14:36:23 +0100 [thread overview]
Message-ID: <20211108133710.1352822-13-jolsa@kernel.org> (raw)
In-Reply-To: <20211108133710.1352822-1-jolsa@kernel.org>
Moving unit to perf_evsel struct.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/lib/perf/include/internal/evsel.h | 1 +
tools/perf/builtin-stat.c | 2 +-
tools/perf/tests/event_update.c | 2 +-
tools/perf/util/evsel.c | 8 ++++----
tools/perf/util/evsel.h | 1 -
| 2 +-
tools/perf/util/parse-events.c | 4 ++--
tools/perf/util/stat-display.c | 8 ++++----
tools/perf/util/synthetic-events.c | 6 +++---
9 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/tools/lib/perf/include/internal/evsel.h b/tools/lib/perf/include/internal/evsel.h
index 105ff0626482..b96c9f4808ca 100644
--- a/tools/lib/perf/include/internal/evsel.h
+++ b/tools/lib/perf/include/internal/evsel.h
@@ -68,6 +68,7 @@ struct perf_evsel {
struct list_head config_terms;
const char *metric_id;
enum perf_tool_event tool_event;
+ const char *unit;
};
};
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f697af989d60..f57a366b7a1a 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -917,7 +917,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
continue;
}
- l = strlen(counter->unit);
+ l = strlen(counter->core.unit);
if (l > stat_config.unit_width)
stat_config.unit_width = l;
diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c
index 44a50527f9d9..556eb8e6b228 100644
--- a/tools/perf/tests/event_update.c
+++ b/tools/perf/tests/event_update.c
@@ -99,7 +99,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
perf_evlist__id_add(&evlist->core, &evsel->core, 0, 0, 123);
- evsel->unit = unit;
+ evsel->core.unit = unit;
TEST_ASSERT_VAL("failed to synthesize attr update unit",
!perf_event__synthesize_event_update_unit(NULL, evsel, process_event_unit));
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 3985e69123d2..133b571e1190 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -241,7 +241,7 @@ void evsel__init(struct evsel *evsel,
{
perf_evsel__init(&evsel->core, attr, idx);
evsel->tracking = !idx;
- evsel->unit = "";
+ evsel->core.unit = "";
evsel->scale = 1.0;
evsel->max_events = ULONG_MAX;
evsel->evlist = NULL;
@@ -282,7 +282,7 @@ struct evsel *evsel__new_idx(struct perf_event_attr *attr, int idx)
*/
static const char *unit = "msec";
- evsel->unit = unit;
+ evsel->core.unit = unit;
evsel->scale = 1e-6;
}
@@ -422,7 +422,7 @@ struct evsel *evsel__clone(struct evsel *orig)
evsel->max_events = orig->max_events;
evsel->core.tool_event = orig->core.tool_event;
- evsel->unit = orig->unit;
+ evsel->core.unit = orig->core.unit;
evsel->scale = orig->scale;
evsel->snapshot = orig->snapshot;
evsel->per_pkg = orig->per_pkg;
@@ -1300,7 +1300,7 @@ void evsel__config(struct evsel *evsel, struct record_opts *opts,
attr->exclude_user = 1;
}
- if (evsel->core.own_cpus || evsel->unit)
+ if (evsel->core.own_cpus || evsel->core.unit)
evsel->core.attr.read_format |= PERF_FORMAT_ID;
/*
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 548d3042fa8b..f6cc1e78903f 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -60,7 +60,6 @@ struct evsel {
char *filter;
unsigned long max_events;
double scale;
- const char *unit;
struct cgroup *cgrp;
/* parse modifier helper */
int exclude_GH;
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 949d24da7000..4610b23fed28 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -4256,7 +4256,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
switch (ev->type) {
case PERF_EVENT_UPDATE__UNIT:
- evsel->unit = strdup(ev->data);
+ evsel->core.unit = strdup(ev->data);
break;
case PERF_EVENT_UPDATE__NAME:
evsel->core.name = strdup(ev->data);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 15d5880df4c2..1878ea1310d3 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -436,7 +436,7 @@ static int add_event_tool(struct list_head *list, int *idx,
return -ENOMEM;
evsel->core.tool_event = tool_event;
if (tool_event == PERF_TOOL_DURATION_TIME)
- evsel->unit = "ns";
+ evsel->core.unit = "ns";
return 0;
}
@@ -1663,7 +1663,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
if (parse_state->fake_pmu)
return 0;
- evsel->unit = info.unit;
+ evsel->core.unit = info.unit;
evsel->scale = info.scale;
evsel->per_pkg = info.per_pkg;
evsel->snapshot = info.snapshot;
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index b00097e86c85..5f5467c55323 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -372,10 +372,10 @@ static void abs_printout(struct perf_stat_config *config,
fprintf(output, fmt, avg, config->csv_sep);
- if (evsel->unit)
+ if (evsel->core.unit)
fprintf(output, "%-*s%s",
config->csv_output ? 0 : config->unit_width,
- evsel->unit, config->csv_sep);
+ evsel->core.unit, config->csv_sep);
fprintf(output, "%-*s", config->csv_output ? 0 : 25, evsel__name(evsel));
@@ -476,7 +476,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
fprintf(config->output, "%-*s%s",
config->csv_output ? 0 : config->unit_width,
- counter->unit, config->csv_sep);
+ counter->core.unit, config->csv_sep);
fprintf(config->output, "%*s",
config->csv_output ? 0 : -25, evsel__name(counter));
@@ -588,7 +588,7 @@ static void collect_all_aliases(struct perf_stat_config *config, struct evsel *c
if (strcmp(evsel__name(alias), evsel__name(counter)) ||
alias->scale != counter->scale ||
alias->cgrp != counter->cgrp ||
- strcmp(alias->unit, counter->unit) ||
+ strcmp(alias->core.unit, counter->core.unit) ||
evsel__is_clock(alias) != evsel__is_clock(counter) ||
!strcmp(alias->pmu_name, counter->pmu_name))
break;
diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index 2528c22792be..27c97f22d855 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -1824,7 +1824,7 @@ static struct perf_record_event_update *event_update_event__new(size_t size, u64
int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evsel *evsel,
perf_event__handler_t process)
{
- size_t size = strlen(evsel->unit);
+ size_t size = strlen(evsel->core.unit);
struct perf_record_event_update *ev;
int err;
@@ -1832,7 +1832,7 @@ int perf_event__synthesize_event_update_unit(struct perf_tool *tool, struct evse
if (ev == NULL)
return -ENOMEM;
- strlcpy(ev->data, evsel->unit, size + 1);
+ strlcpy(ev->data, evsel->core.unit, size + 1);
err = process(tool, (union perf_event *)ev, NULL, NULL);
free(ev);
return err;
@@ -1921,7 +1921,7 @@ int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist,
static bool has_unit(struct evsel *evsel)
{
- return evsel->unit && *evsel->unit;
+ return evsel->core.unit && *evsel->core.unit;
}
static bool has_scale(struct evsel *evsel)
--
2.31.1
next prev parent reply other threads:[~2021-11-08 13:38 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 13:36 [RFC 00/59] libperf: Move in event parse code Jiri Olsa
2021-11-08 13:36 ` [PATCH 01/59] libperf: Move pmu-events.h file to libperf Jiri Olsa
2021-11-08 13:36 ` [PATCH 03/59] libperf: Move pmu-events build " Jiri Olsa
2021-11-08 13:36 ` [PATCH 04/59] libperf: Move perf_pmu__format_parse " Jiri Olsa
2021-11-08 13:36 ` [PATCH 05/59] tools api fs: Move in the fncache from perf Jiri Olsa
2021-11-08 17:46 ` Ian Rogers
2021-11-08 21:15 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 06/59] libperf: Move in the pmu hybrid support Jiri Olsa
2021-11-08 13:36 ` [PATCH 07/59] libperf: Move name to perf_evsel Jiri Olsa
2021-11-08 13:36 ` [PATCH 08/59] libperf: Move auto_merge_stats " Jiri Olsa
2021-11-08 13:36 ` [PATCH 09/59] libperf: Move config_terms " Jiri Olsa
2021-11-08 13:36 ` [PATCH 10/59] libperf: Move metric_id " Jiri Olsa
2021-11-08 13:36 ` [PATCH 11/59] libperf: Move tool_event " Jiri Olsa
2021-11-08 13:36 ` Jiri Olsa [this message]
2021-11-08 13:36 ` [PATCH 13/59] libperf: Move exclude_GH " Jiri Olsa
2021-11-08 17:53 ` Ian Rogers
2021-11-08 21:16 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 14/59] libperf: Move sample_read " Jiri Olsa
2021-11-08 13:36 ` [PATCH 15/59] libperf: Move precise_max " Jiri Olsa
2021-11-08 13:36 ` [PATCH 16/59] libperf: Move weak_group " Jiri Olsa
2021-11-08 13:36 ` [PATCH 17/59] libperf: Move bpf_counter " Jiri Olsa
2021-11-08 13:36 ` [PATCH 18/59] libperf: Move group_name " Jiri Olsa
2021-11-08 17:58 ` Ian Rogers
2021-11-08 18:07 ` Arnaldo Carvalho de Melo
2021-11-08 21:19 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 19/59] perf tools: Fix parse_events_term__num call Jiri Olsa
2021-11-08 18:15 ` Ian Rogers
2021-11-08 21:21 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 20/59] perf tools: Pass parse_state all the way down to __add_event Jiri Olsa
2021-11-08 13:36 ` [PATCH 21/59] perf tools: Pass parse_state all the way down to add_tracepoint Jiri Olsa
2021-11-08 13:36 ` [PATCH 22/59] perf tools: Add evsel__new callback to parse_state_ops Jiri Olsa
2021-11-08 13:36 ` [PATCH 23/59] perf tools: Add evsel__new_tp " Jiri Olsa
2021-11-08 13:36 ` [PATCH 24/59] perf tools: Add loc_term and loc_val helpers to parse_events_term__str Jiri Olsa
2021-11-08 13:36 ` [PATCH 25/59] perf tools: Add loc_term and loc_val helpers to parse_events_term__num Jiri Olsa
2021-11-08 13:36 ` [PATCH 26/59] libperf: Move in the event_symbols_hw/event_symbols_sw Jiri Olsa
2021-11-08 13:36 ` [PATCH 27/59] libperf: Move in struct parse_events_term code Jiri Olsa
2021-11-08 13:36 ` [PATCH 28/59] perf tools: Add perf_evsel__add_event function Jiri Olsa
2021-11-08 13:36 ` [PATCH 29/59] perf tools: Change struct parse_events_state::evlist to perf_evlist Jiri Olsa
2021-11-08 13:36 ` [PATCH 30/59] libperf: Move in struct parse_events_state Jiri Olsa
2021-11-08 18:21 ` Ian Rogers
2021-11-08 21:24 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 31/59] perf tools: Move event_attr_init in evsel__new_idx function Jiri Olsa
2021-11-08 13:36 ` [PATCH 32/59] libperf: Move in perf_pmu__warn_invalid_config function Jiri Olsa
2021-11-08 13:36 ` [PATCH 33/59] libperf: Move in perf_evsel__add_event function Jiri Olsa
2021-11-08 13:36 ` [PATCH 34/59] perf tools: Move parse_events_update_lists to parser unit Jiri Olsa
2021-11-08 13:36 ` [PATCH 35/59] libperf: Add perf_evsel__is_group_leader function Jiri Olsa
2021-11-08 13:36 ` [PATCH 36/59] perf tools: Make parse_events__modifier_event work over perf_evsel Jiri Olsa
2021-11-08 13:36 ` [PATCH 37/59] perf tool: Pass perf_guest in struct parse_events_state Jiri Olsa
2021-11-08 13:36 ` [PATCH 38/59] libperf: Move in parse_events__modifier_group/event functions Jiri Olsa
2021-11-08 13:36 ` [PATCH 39/59] libperf: Move in parse_events__handle_error function Jiri Olsa
2021-11-08 13:36 ` [PATCH 40/59] libperf: Move in parse_events_evlist_error function Jiri Olsa
2021-11-08 13:36 ` [PATCH 41/59] perf tools: Add perf_evsel__delete callback to struct parse_events_ops Jiri Olsa
2021-11-08 13:36 ` [PATCH 42/59] libperf: Move in parse_events_name function Jiri Olsa
2021-11-08 18:23 ` Ian Rogers
2021-11-08 21:24 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 43/59] perf tools: Move out parse_events_add_pmu fallback from parser code Jiri Olsa
2021-11-08 13:36 ` [PATCH 44/59] perf tools: Add add_pmu callback to struct parse_events_ops Jiri Olsa
2021-11-08 13:36 ` [PATCH 45/59] perf tools: Add add_pmu_multi " Jiri Olsa
2021-11-08 13:36 ` [PATCH 46/59] perf tools: Add add_numeric " Jiri Olsa
2021-11-08 18:27 ` Ian Rogers
2021-11-08 21:34 ` Jiri Olsa
2021-11-08 13:36 ` [PATCH 47/59] perf tools: Add add_cache " Jiri Olsa
2021-11-08 13:36 ` [PATCH 48/59] perf tools: Add add_breakpoint " Jiri Olsa
2021-11-08 13:37 ` [PATCH 49/59] perf tools: Add add_tracepoint " Jiri Olsa
2021-11-08 13:37 ` [PATCH 50/59] perf tools: Add add_bpf " Jiri Olsa
2021-11-08 13:37 ` [PATCH 51/59] perf tools: Add add_tool " Jiri Olsa
2021-11-08 13:37 ` [PATCH 52/59] perf tools: Add set_leader " Jiri Olsa
2021-11-08 13:37 ` [PATCH 53/59] perf tools: Add parse_check " Jiri Olsa
2021-11-08 13:37 ` [PATCH 54/59] perf tools: Move PE_* enums in parse_events__scanner Jiri Olsa
2021-11-08 13:37 ` [PATCH 55/59] libperf: Move in parse-events flex/bison parser Jiri Olsa
2021-11-08 13:37 ` [PATCH 56/59] libperf: Move in parse_events_add_breakpoint function Jiri Olsa
2021-11-08 13:37 ` [PATCH 57/59] libperf: Move in some lib objects from perf Jiri Olsa
2021-11-08 13:37 ` [PATCH 58/59] libperf: Add libperf_parse_events function Jiri Olsa
2021-11-08 13:37 ` [PATCH 59/59] libperf: Add parse-events test Jiri Olsa
2021-11-08 18:32 ` Ian Rogers
2021-11-08 21:37 ` Jiri Olsa
2021-11-08 18:50 ` [RFC 00/59] libperf: Move in event parse code Ian Rogers
2021-11-08 21:50 ` Jiri Olsa
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=20211108133710.1352822-13-jolsa@kernel.org \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
/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).