Re: [PATCH] perf, tools: Improve error messages for missing PMUs

From: Jiri Olsa
Date: Fri Sep 15 2017 - 14:45:17 EST


On Wed, Sep 13, 2017 at 02:50:06PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> When a PMU is missing print a better error message mentioning
> the missing PMU.
>
> % mkdir empty
> % mount --bind empty /sys/devices/msr
> % perf stat -M Summary true
> event syntax error: '{inst_retired.any,cycles}:W,{cpu_clk_unhalted.thread}:W,{inst_retired.any}:W,{cpu_clk_unhalted.ref_tsc,msr/tsc/}:W,{fp_comp_ops_exe.sse_scalar..'
> \___ Cannot find PMU `msr'. Missing kernel support?
>
> It still cannot find the right column for aliases, but it's already a vast improvement.
>
> v2: Check asprintf
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> ---
> tools/perf/util/metricgroup.c | 2 +-
> tools/perf/util/parse-events.c | 18 ++++++++++++------
> tools/perf/util/parse-events.h | 3 +++
> 3 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 2d60114f1870..0794f02cbb8f 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -477,7 +477,7 @@ int metricgroup__parse_groups(const struct option *opt,
> memset(&parse_error, 0, sizeof(struct parse_events_error));
> ret = parse_events(perf_evlist, extra_events.buf, &parse_error);
> if (ret) {
> - pr_err("Cannot set up events %s\n", extra_events.buf);
> + parse_events_print_error(&parse_error, extra_events.buf);

nit, mixed tabs/spaces indent, other than that:

Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>

thanks,
jirka