[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1588852671-61996-13-git-send-email-john.garry@huawei.com>
Date: Thu, 7 May 2020 19:57:51 +0800
From: John Garry <john.garry@...wei.com>
To: <peterz@...radead.org>, <mingo@...hat.com>, <acme@...nel.org>,
<mark.rutland@....com>, <alexander.shishkin@...ux.intel.com>,
<jolsa@...hat.com>, <namhyung@...nel.org>
CC: <will@...nel.org>, <ak@...ux.intel.com>, <linuxarm@...wei.com>,
<linux-kernel@...r.kernel.org>, <qiangqing.zhang@....com>,
<irogers@...gle.com>, <robin.murphy@....com>,
<zhangshaokun@...ilicon.com>,
<linux-arm-kernel@...ts.infradead.org>,
John Garry <john.garry@...wei.com>
Subject: [PATCH RFC v3 12/12] perf metricgroup: Support adding metrics for system PMUs
Currently only adding metrics for core- or uncore-based events is
supported. Extend this for system events.
Signed-off-by: John Garry <john.garry@...wei.com>
---
tools/perf/util/metricgroup.c | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index ecf14aa01a59..4062bb33912a 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -598,6 +598,25 @@ static int metricgroup__add_metric_pmu_event(struct pmu_event *pe,
return 0;
}
+struct metricgroup_add_iter_data {
+ const char *metric;
+ struct strbuf *events;
+ struct list_head *group_list;
+ int *ret;
+};
+
+static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe,
+ void *data)
+{
+ struct metricgroup_add_iter_data *d = data;
+
+ if (!match_pe_metric(pe, d->metric))
+ return 0;
+
+ return (*d->ret = metricgroup__add_metric_pmu_event(pe, d->events,
+ d->group_list));
+}
+
static int metricgroup__add_metric(const char *metric, struct strbuf *events,
struct list_head *group_list)
{
@@ -605,10 +624,7 @@ static int metricgroup__add_metric(const char *metric, struct strbuf *events,
struct pmu_event *pe;
int i, ret = -EINVAL;
- if (!map)
- return 0;
-
- for (i = 0; ; i++) {
+ for (i = 0; map; i++) {
pe = &map->table[i];
if (!pe->name && !pe->metric_group && !pe->metric_name)
@@ -623,6 +639,21 @@ static int metricgroup__add_metric(const char *metric, struct strbuf *events,
return ret;
}
}
+
+ {
+ struct metricgroup_iter_data data = {
+ .fn = metricgroup__add_metric_sys_event_iter,
+ .data = (void *) &(struct metricgroup_add_iter_data){
+ .metric = metric,
+ .events = events,
+ .group_list = group_list,
+ .ret = &ret,
+ },
+ };
+
+ pmu_for_each_sys_event(metricgroup__sys_event_iter, &data);
+ }
+
return ret;
}
--
2.16.4
Powered by blists - more mailing lists