perf stat: Remove evsel metric_name/expr
Metrics are their own unit and these variables held broken metrics previously and now just hold the value NULL. Remove code that used these variables. Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Caleb Biggers <caleb.biggers@intel.com> Cc: Florian Fischer <florian.fischer@muhq.space> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Kang Minchul <tegongkang@gmail.com> Cc: Kim Phillips <kim.phillips@amd.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Perry Taylor <perry.taylor@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Will Deacon <will@kernel.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20230126233645.200509-8-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d9dc8874d6
commit
6f8f98ab6c
|
@ -2524,7 +2524,6 @@ int cmd_stat(int argc, const char **argv)
|
|||
&stat_config.metric_events);
|
||||
zfree(&metrics);
|
||||
}
|
||||
perf_stat__collect_metric_expr(evsel_list);
|
||||
perf_stat__init_shadow_stats();
|
||||
|
||||
if (add_default_attributes())
|
||||
|
|
|
@ -481,7 +481,6 @@ int evlist__expand_cgroup(struct evlist *evlist, const char *str,
|
|||
nr_cgroups++;
|
||||
|
||||
if (metric_events) {
|
||||
perf_stat__collect_metric_expr(tmp_list);
|
||||
if (metricgroup__copy_metric_events(tmp_list, cgrp,
|
||||
metric_events,
|
||||
&orig_metric_events) < 0)
|
||||
|
|
|
@ -285,8 +285,6 @@ void evsel__init(struct evsel *evsel,
|
|||
evsel->sample_size = __evsel__sample_size(attr->sample_type);
|
||||
evsel__calc_id_pos(evsel);
|
||||
evsel->cmdline_group_boundary = false;
|
||||
evsel->metric_expr = NULL;
|
||||
evsel->metric_name = NULL;
|
||||
evsel->metric_events = NULL;
|
||||
evsel->per_pkg_mask = NULL;
|
||||
evsel->collect_stat = false;
|
||||
|
|
|
@ -105,8 +105,6 @@ struct evsel {
|
|||
* metric fields are similar, but needs more care as they can have
|
||||
* references to other metric (evsel).
|
||||
*/
|
||||
const char * metric_expr;
|
||||
const char * metric_name;
|
||||
struct evsel **metric_events;
|
||||
struct evsel *metric_leader;
|
||||
|
||||
|
|
|
@ -76,13 +76,6 @@ const char *perf_env__arch(struct perf_env *env __maybe_unused)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add this one here not to drag util/stat-shadow.c
|
||||
*/
|
||||
void perf_stat__collect_metric_expr(struct evlist *evsel_list)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* These ones are needed not to drag the PMU bandwagon, jevents generated
|
||||
* pmu_sys_event_tables, etc and evsel__find_pmu() is used so far just for
|
||||
|
|
|
@ -346,114 +346,6 @@ static const char *get_ratio_color(enum grc_type type, double ratio)
|
|||
return color;
|
||||
}
|
||||
|
||||
static struct evsel *perf_stat__find_event(struct evlist *evsel_list,
|
||||
const char *name)
|
||||
{
|
||||
struct evsel *c2;
|
||||
|
||||
evlist__for_each_entry (evsel_list, c2) {
|
||||
if (!strcasecmp(c2->name, name) && !c2->collect_stat)
|
||||
return c2;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Mark MetricExpr target events and link events using them to them. */
|
||||
void perf_stat__collect_metric_expr(struct evlist *evsel_list)
|
||||
{
|
||||
struct evsel *counter, *leader, **metric_events, *oc;
|
||||
bool found;
|
||||
struct expr_parse_ctx *ctx;
|
||||
struct hashmap_entry *cur;
|
||||
size_t bkt;
|
||||
int i;
|
||||
|
||||
ctx = expr__ctx_new();
|
||||
if (!ctx) {
|
||||
pr_debug("expr__ctx_new failed");
|
||||
return;
|
||||
}
|
||||
evlist__for_each_entry(evsel_list, counter) {
|
||||
bool invalid = false;
|
||||
|
||||
leader = evsel__leader(counter);
|
||||
if (!counter->metric_expr)
|
||||
continue;
|
||||
|
||||
expr__ctx_clear(ctx);
|
||||
metric_events = counter->metric_events;
|
||||
if (!metric_events) {
|
||||
if (expr__find_ids(counter->metric_expr,
|
||||
counter->name,
|
||||
ctx) < 0)
|
||||
continue;
|
||||
|
||||
metric_events = calloc(sizeof(struct evsel *),
|
||||
hashmap__size(ctx->ids) + 1);
|
||||
if (!metric_events) {
|
||||
expr__ctx_free(ctx);
|
||||
return;
|
||||
}
|
||||
counter->metric_events = metric_events;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
hashmap__for_each_entry(ctx->ids, cur, bkt) {
|
||||
const char *metric_name = cur->pkey;
|
||||
|
||||
found = false;
|
||||
if (leader) {
|
||||
/* Search in group */
|
||||
for_each_group_member (oc, leader) {
|
||||
if (!strcasecmp(oc->name,
|
||||
metric_name) &&
|
||||
!oc->collect_stat) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
/* Search ignoring groups */
|
||||
oc = perf_stat__find_event(evsel_list,
|
||||
metric_name);
|
||||
}
|
||||
if (!oc) {
|
||||
/* Deduping one is good enough to handle duplicated PMUs. */
|
||||
static char *printed;
|
||||
|
||||
/*
|
||||
* Adding events automatically would be difficult, because
|
||||
* it would risk creating groups that are not schedulable.
|
||||
* perf stat doesn't understand all the scheduling constraints
|
||||
* of events. So we ask the user instead to add the missing
|
||||
* events.
|
||||
*/
|
||||
if (!printed ||
|
||||
strcasecmp(printed, metric_name)) {
|
||||
fprintf(stderr,
|
||||
"Add %s event to groups to get metric expression for %s\n",
|
||||
metric_name,
|
||||
counter->name);
|
||||
free(printed);
|
||||
printed = strdup(metric_name);
|
||||
}
|
||||
invalid = true;
|
||||
continue;
|
||||
}
|
||||
metric_events[i++] = oc;
|
||||
oc->collect_stat = true;
|
||||
}
|
||||
metric_events[i] = NULL;
|
||||
if (invalid) {
|
||||
free(metric_events);
|
||||
counter->metric_events = NULL;
|
||||
counter->metric_expr = NULL;
|
||||
}
|
||||
}
|
||||
expr__ctx_free(ctx);
|
||||
}
|
||||
|
||||
static double runtime_stat_avg(struct runtime_stat *st,
|
||||
enum stat_type type, int map_idx,
|
||||
struct runtime_stat_data *rsd)
|
||||
|
@ -1299,10 +1191,6 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
|
|||
color = NULL;
|
||||
print_metric(config, ctxp, color, "%8.1f%%", "Core Bound",
|
||||
core_bound * 100.);
|
||||
} else if (evsel->metric_expr) {
|
||||
generic_metric(config, evsel->metric_expr, evsel->metric_events, NULL,
|
||||
evsel->name, evsel->metric_name, NULL, 1,
|
||||
map_idx, out, st);
|
||||
} else if (runtime_stat_n(st, STAT_NSECS, map_idx, &rsd) != 0) {
|
||||
char unit = ' ';
|
||||
char unit_buf[10] = "/sec";
|
||||
|
|
|
@ -257,7 +257,6 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
|
|||
struct perf_stat_output_ctx *out,
|
||||
struct rblist *metric_events,
|
||||
struct runtime_stat *st);
|
||||
void perf_stat__collect_metric_expr(struct evlist *);
|
||||
|
||||
int evlist__alloc_stats(struct perf_stat_config *config,
|
||||
struct evlist *evlist, bool alloc_raw);
|
||||
|
|
Loading…
Reference in New Issue