Re: [PATCH v1 2/2] perf-stat: enable counting events for BPF programs

From: Song Liu
Date: Thu Dec 03 2020 - 23:08:48 EST




> On Dec 3, 2020, at 3:31 PM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Wed, Dec 02, 2020 at 01:37:09AM -0800, Song Liu wrote:
>> Introduce perf-stat -b option, which counts events for BPF programs, like:
>>
>> [root@localhost ~]# ~/perf stat -e ref-cycles,cycles -b 254 -I 1000
>> 1.487903822 115,200 ref-cycles
>> 1.487903822 86,012 cycles
>> 2.489147029 80,560 ref-cycles
>> 2.489147029 73,784 cycles
>> 3.490341825 60,720 ref-cycles
>> 3.490341825 37,797 cycles
>> 4.491540887 37,120 ref-cycles
>> 4.491540887 31,963 cycles
>
> hi,
> I'm getting compile fail with gcc 10:
>
> builtin-stat.c: In function ‘cmd_stat’:
> builtin-stat.c:2429:7: error: declaration of ‘err’ shadows a previous local [-Werror=shadow]
> 2429 | int err = perf_event__synthesize_kernel_mmap((void *)&perf_stat,
> | ^~~
> builtin-stat.c:2104:33: note: shadowed declaration is here
> 2104 | int status = -EINVAL, run_idx, err;
> | ^~~

gcc 9 didn't complain about it. Let me fix it in the next version.

Thanks,
Song