[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200626194720.2915044-8-jolsa@kernel.org>
Date: Fri, 26 Jun 2020 21:47:17 +0200
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Michael Petlan <mpetlan@...hat.com>,
Andi Kleen <ak@...ux.intel.com>,
Kajol Jain <kjain@...ux.ibm.com>,
John Garry <john.garry@...wei.com>,
"Paul A. Clarke" <pc@...ibm.com>,
Stephane Eranian <eranian@...gle.com>,
Ian Rogers <irogers@...gle.com>
Subject: [PATCH 07/10] perf tools: Collect other metrics in struct metric_expr
Add 'other' metrics into struct metric_expr object,
so they are accessible when computing the metric.
Storing just name and expression itself, so the metric
can be resolved and computed.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/perf/util/metricgroup.c | 27 +++++++++++++++++++++++++++
tools/perf/util/metricgroup.h | 6 ++++++
2 files changed, 33 insertions(+)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index f88fd667cc78..a5d5dcc1b805 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -83,6 +83,7 @@ static void metric_event_delete(struct rblist *rblist __maybe_unused,
struct metric_expr *expr, *tmp;
list_for_each_entry_safe(expr, tmp, &me->head, nd) {
+ free(expr->metric_other);
free(expr);
}
@@ -243,6 +244,7 @@ static int metricgroup__setup_events(struct list_head *groups,
list_for_each_entry (eg, groups, nd) {
struct evsel **metric_events;
+ struct metric_other *other = NULL;
metric_events = calloc(sizeof(void *),
hashmap__size(&eg->pctx.ids) + 1);
@@ -274,6 +276,31 @@ static int metricgroup__setup_events(struct list_head *groups,
free(metric_events);
break;
}
+
+ /*
+ * Collect and store collected 'other' expressions
+ * for metric processing.
+ */
+ if (eg->other_cnt) {
+ struct eother *eo;
+
+ other = zalloc(sizeof(struct metric_other) * (eg->other_cnt + 1));
+ if (!other) {
+ ret = -ENOMEM;
+ free(metric_events);
+ free(other);
+ break;
+ }
+
+ i = 0;
+ list_for_each_entry(eo, &eg->other, list) {
+ other[i].metric_name = eo->metric_name;
+ other[i].metric_expr = eo->metric_expr;
+ i++;
+ }
+ };
+
+ expr->metric_other = other;
expr->metric_expr = eg->metric_expr;
expr->metric_name = eg->metric_name;
expr->metric_unit = eg->metric_unit;
diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h
index 8315bd1a7da4..3a1e320cb2d3 100644
--- a/tools/perf/util/metricgroup.h
+++ b/tools/perf/util/metricgroup.h
@@ -18,12 +18,18 @@ struct metric_event {
struct list_head head; /* list of metric_expr */
};
+struct metric_other {
+ const char *metric_name;
+ const char *metric_expr;
+};
+
struct metric_expr {
struct list_head nd;
const char *metric_expr;
const char *metric_name;
const char *metric_unit;
struct evsel **metric_events;
+ struct metric_other *metric_other;
int runtime;
};
--
2.25.4
Powered by blists - more mailing lists