summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLeo Yan <leo.yan@arm.com>2026-04-02 19:04:49 +0300
committerNamhyung Kim <namhyung@kernel.org>2026-04-03 04:11:00 +0300
commite0f4767bf403131f7ec7378d0d23ad6c29b01936 (patch)
treef944bffd08e8b0c938c92772357e652186d05c89 /tools
parentd148934beeacaf074e1e6f00fae3be737bbc4089 (diff)
downloadlinux-e0f4767bf403131f7ec7378d0d23ad6c29b01936.tar.xz
perf metricgroup: Refine error logs
Return -ENOENT when no metric/group matches, and directly use the return value from expr__find_ids(), so -EINVAL is reserved for parse failures. Print separate logs to make it clear. Before: perf stat -C 5 -vvv Using CPUID 0x00000000410fd490 metric expr 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) for backend_bound parsing metric: 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) Failure to read '#slots' literal: #slots = nan syntax error Cannot find metric or group `Default' After: perf stat -C 5 -vvv Using CPUID 0x00000000410fd490 metric expr 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) for backend_bound parsing metric: 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) Failure to read '#slots' literal: #slots = nan syntax error Fail to parse metric or group `Default' Signed-off-by: Leo Yan <leo.yan@arm.com> Reviewed-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/metricgroup.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index f7d53b4e46f4..4db9578efd81 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -914,10 +914,9 @@ static int __add_metric(struct list_head *metric_list,
expr = metric_no_threshold ? pm->metric_name : pm->metric_threshold;
visited_node.name = "__threshold__";
}
- if (expr__find_ids(expr, NULL, root_metric->pctx) < 0) {
- /* Broken metric. */
- ret = -EINVAL;
- }
+
+ ret = expr__find_ids(expr, NULL, root_metric->pctx);
+
if (!ret) {
/* Resolve referenced metrics. */
struct perf_pmu *pmu;
@@ -1101,7 +1100,7 @@ static int metricgroup__add_metric(const char *pmu, const char *metric_name, con
*/
ret = metricgroup__for_each_metric(table, metricgroup__add_metric_callback, &data);
if (!ret && !data.has_match)
- ret = -EINVAL;
+ ret = -ENOENT;
/*
* add to metric_list so that they can be released
@@ -1152,6 +1151,8 @@ static int metricgroup__add_metric_list(const char *pmu, const char *list,
user_requested_cpu_list,
system_wide, metric_list, table);
if (ret == -EINVAL)
+ pr_err("Fail to parse metric or group `%s'\n", metric_name);
+ else if (ret == -ENOENT)
pr_err("Cannot find metric or group `%s'\n", metric_name);
if (ret)