On Wed, Jun 28, 2023 at 3:30 AM John Garry<john.g.garry@xxxxxxxxxx> wrote:
In metricgroup__add_metric() we still iter the sys metrics if we already
found a match from the CPU table, which is pretty pointless, so don't
bother.
Signed-off-by: John Garry<john.g.garry@xxxxxxxxxx>
---
tools/perf/util/metricgroup.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 4389ccd29fe7..8d2ac2513530 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -1261,6 +1261,12 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con
has_match = data.has_match;
}
+I think this can just be:
+ if (has_match) {
+ ret = 0;
+ goto out;
+ }
+
if (!has_match)
However, I'm not sure I agree with the intent of the change. We may
have a metric like IPC and want it to apply to all types of CPU, GPU,
etc. If we short-cut here then that won't be possible.