Re: [RFC v2 0/2] Introduce perf-stat -b for BPF programs

From: Song Liu
Date: Tue Dec 01 2020 - 15:45:03 EST




> On Dec 1, 2020, at 12:16 PM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Mon, Nov 30, 2020 at 11:36:45PM -0800, Song Liu wrote:
>> This set introduces perf-stat -b option to count events for BPF programs.
>> This is similar to bpftool-prog-profile. But perf-stat makes it much more
>> flexible.
>>
>> Sending as RFC because I haven't addressed some known limitations:
>> 1. Only counting events for one BPF program at a time.
>> 2. Need extra logic in target__validate().
>
> hi,
> I'm getting this eror:
>
> CLANG /home/jolsa/linux-perf/tools/perf/util/bpf_skel/.tmp/dummy.bpf.o
> util/bpf_skel/dummy.bpf.c:4:10: fatal error: 'bpf/bpf_helpers.h' file not found
> #include <bpf/bpf_helpers.h>
> ^~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> I added change below to fix it, but not sure it's the best fix
>
> jirka

The fix looks great to me. I will fold it in.

Thanks!
Song

>
>
> ---
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index d926f0c35ed4..c8f012132d19 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -1022,7 +1022,7 @@ BPFTOOL_CFLAGS := $(filter-out -D_GNU_SOURCE,$(CFLAGS))
> BPFTOOL := $(SKEL_TMP_OUT)/bpftool-bootstrap
> LIBBPF_SRC := $(abspath ../lib/bpf)
> BPFOBJ := $(SKEL_TMP_OUT)/libbpf.a
> -BPF_INCLUDE := $(SKEL_TMP_OUT)
> +BPF_INCLUDE := -I$(LIBBPF_SRC)/..
> submake_extras := feature_display=0
>
> $(SKEL_TMP_OUT):
> @@ -1034,7 +1034,7 @@ $(BPFTOOL): | $(SKEL_TMP_OUT)
>
> $(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(BPFOBJ) | $(SKEL_TMP_OUT)
> $(call QUIET_CLANG, $@)
> - $(Q)$(CLANG) -g -O2 -target bpf -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ && \
> + $(Q)$(CLANG) -g -O2 -target bpf $(BPF_INCLUDE) -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ && \
> $(LLVM_STRIP) -g $@
>
> $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)
>