Re: [PATCH 2/2] perf, tools: Don't force MetricExprs to lower case

Arnaldo Carvalho de Melo
2017-10-03T16:06:09Z

Em Tue, Sep 12, 2017 at 12:56:43PM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
>
> There are still problems with BPF misinterpreting some events
> that include .c. An earlier fix made it work for stand alone
> aliases, but it still fails for more complex constructs.

Hi Wang, Jiri,

Can you please take a look at this and see if there is something
we can do to help Andi?

- Arnaldo

> REJECT keeps trying and trying a shorter string until
> .c is matched and it appears like a valid BPF path.
>
> % perf stat -e cpu/uops_executed.core,cmask=1/ true
> bpf: builtin compilation failed: -95, try external compiler
> ERROR: problems with path cpu/uops_executed.c: No such file or directory
> event syntax error: 'cpu/uops_executed.core,cmask=1/'
> \___ Failed to load cpu/uops_executed.c from source: Error when compiling BPF scriptlet
>
> I tried to fix it, but it exceeds my flex knowledge, because
> REJECT does not interact well with BEGIN states.
>
> The BPF syntax in its current form really causes an ambigious
> grammar.
>
> A workaround for this is to spell the event upper case,
> because upper case .C does not match the BPF rules.
>
> This currently affects some of the ILP metrics. The previous
> patch changed the ILP metrics to use upper case. Now if we
> don't force everything to lower case the matching works.
>
> This makes ILP work correctly on my IvyBridge:
>
> % ./perf stat -M ILP true
>
> Performance counter stats for 'true':
>
> 711,067 UOPS_EXECUTED.THREAD # 2.3 ILP
> 311,680 cpu/UOPS_EXECUTED.CORE,cmask=1/
> 311,680 UOPS_EXECUTED.CYCLES_GE_1_UOP_EXEC
>
> 0.000371554 seconds time elapsed
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> tools/perf/pmu-events/jevents.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index 9eb7047bafe4..07c0f9a46180 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -488,8 +488,6 @@ int json_events(const char *fn,
> addfield(map, &metric_group, "", "", val);
> } else if (json_streq(map, field, "MetricExpr")) {
> addfield(map, &metric_expr, "", "", val);
> - for (s = metric_expr; *s; s++)
> - *s = tolower(*s);
> }
> /* ignore unknown fields */
> }
> --
> 2.9.5