Re: [PATCH 13/54] perf tools: Support perf event alias name

From: Arnaldo Carvalho de Melo
Date: Wed Feb 03 2016 - 18:36:06 EST


Em Mon, Jan 25, 2016 at 09:56:00AM +0000, Wang Nan escreveu:
> From: He Kuang <hekuang@xxxxxxxxxx>
>
> This patch is useful when trying to pass a perf event to BPF map.
> Before this patch we are unable to pass an event with config term to
> BPF maps. For example:
>
> # perf record -a -e cycles/no-inherit,period=0x7fffffffffffffff/ \
> -e './test_bpf_map_2.c/maps:pmu_map.event=cycles/no-inherit,period=0x7fffffffffffffff//' ls /
> event syntax error: '..ps:pmu_map.event=cycles/'
> \___ Event not found for map setting
>
> Because those '/' and ',' embarrass parser.
>
> This patch adds new bison rules for specifying an alias name to a perf
> event, which allows cmdline refer to previous defined perf event through
> its name. With this patch user can give alias name to a perf event using
> following cmdline. The above goal can be achieved using:
>
> # perf record -a -e cyc=cycles/no-inherit,period=0x7fffffffffffffff/ \
> -e './test_bpf_map_2.c/maps:pmu_map.event=cyc/' ls /

In another thread Jiri suggested this as a way to get an alias
associated with some event:

-----------------------------------------------------------------
On Tue, Feb 02, 2016 at 05:24:16PM +0100, Andreas Hollmann wrote:
> Jiri, how do you handle raw counters with this python stat__*
> callback? What is the name of the callback?

you can use 'name' term like:
perf stat -e cycles,"cpu/config=0x6530160,name=krava/"

and use following callback in your script:
def stat__krava(cpu, thread, time, val, ena, run):

-----------------------------------------------------------------

Can't we go with that existing syntax? Jiri?

That would be:

# perf record -a -e cycles/no-inherit,period=0x7fffffffffffffff,name=cyc/ \
-e './test_bpf_map_2.c/maps:pmu_map.event=cyc/' ls /

Your way is shorter, but we already have this name=foo method :-\

- Arnaldo