[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230628102949.2598096-8-john.g.garry@oracle.com>
Date: Wed, 28 Jun 2023 10:29:47 +0000
From: John Garry <john.g.garry@...cle.com>
To: acme@...nel.org, irogers@...gle.com, namhyung@...nel.org,
jolsa@...nel.org
Cc: linux-arm-kernel@...ts.infradead.org,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
renyu.zj@...ux.alibaba.com, shangxiaojing@...wei.com,
zhangshaokun@...ilicon.com, qiangqing.zhang@....com,
kjain@...ux.ibm.com, kan.liang@...ux.intel.com,
John Garry <john.g.garry@...cle.com>
Subject: [PATCH RFC 7/9] perf metrics: Test metric match in metricgroup__sys_event_iter()
When we add a metric in metricgroup__add_metric(), we first iter through
all metrics in each table from pmu_sys_event_tables tables and call
metricgroup_sys_metric_supported() to test whether we support that metric.
The second step is to call metricgroup__add_metric_sys_event_iter() ->
match_pm_metric() to check if this is actually the metric we're looking
for. It would be better before calling metricgroup_sys_metric_supported()
at all to first test whether we're interested in that metric.
Add metricgroup_iter_data.metric_name, which will be set when we're
looking for a specific metric in the iter, and check for that in
metricgroup__sys_event_iter(). In a way this duplicates the
metricgroup__add_metric_sys_event_iter() -> match_pm_metric() check, but
that is needed for other cases.
Signed-off-by: John Garry <john.g.garry@...cle.com>
---
tools/perf/util/metricgroup.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 6be410363099..111ad4e3eb6b 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -483,6 +483,7 @@ static int metricgroup__add_to_mep_groups(const struct pmu_metric *pm,
struct metricgroup_iter_data {
pmu_metric_iter_fn fn;
+ const char *metric_name;
void *data;
};
@@ -495,6 +496,10 @@ static int metricgroup__sys_event_iter(const struct pmu_metric *pm,
{
struct metricgroup_iter_data *d = data;
+ /* We may be only interested in a specific metric */
+ if (d->metric_name && strcasecmp(d->metric_name, pm->metric_name))
+ return 0;
+
if (metricgroup_sys_metric_supported(pm, table))
return d->fn(pm, table, d->data);
@@ -1291,6 +1296,7 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con
.has_match = &has_match,
.ret = &ret,
},
+ .metric_name = metric_name,
};
pmu_for_each_sys_metric(metricgroup__sys_event_iter, &data);
--
2.35.3
Powered by blists - more mailing lists