Re: [RFC 1/2] perf: support build BPF skeletons with perf

From: Song Liu
Date: Tue Nov 24 2020 - 18:48:53 EST




> On Nov 22, 2020, at 3:27 PM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Wed, Nov 18, 2020 at 08:50:45PM -0800, Song Liu wrote:
>
> SNIP
>
>> # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
>> # of all feature tests
>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>> index ce8516e4de34f..1c2c0f4badd85 100644
>> --- a/tools/perf/Makefile.config
>> +++ b/tools/perf/Makefile.config
>> @@ -619,6 +619,13 @@ ifndef NO_LIBBPF
>> msg := $(warning BPF API too old. Please install recent kernel headers. BPF support in 'perf record' is disabled.)
>> NO_LIBBPF := 1
>> endif
>> +
>> + ifndef NO_BPF_SKEL
>> + ifeq ($(feature-clang-bpf-co-re), 1)
>> + BUILD_BPF_SKEL := 1
>> + $(call detected,CONFIG_PERF_BPF_SKEL)
>> + endif
>> + endif
>> endif
>>
>> dwarf-post-unwind := 1
>> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
>> index 7ce3f2e8b9c74..9a9fc71e2ffa4 100644
>> --- a/tools/perf/Makefile.perf
>> +++ b/tools/perf/Makefile.perf
>> @@ -126,6 +126,8 @@ include ../scripts/utilities.mak
>> #
>> # Define NO_LIBDEBUGINFOD if you do not want support debuginfod
>> #
>> +# Define NO_BPF_SKEL if you do not want build BPF skeletons
>
> we will need to make this the other way round and disable it
> by default before we figure out al lthe dependencies,
> my build's failing on:
>
> [jolsa@krava perf]$ make JOBS=1
> BUILD: Doing 'make -j1' parallel build
> CC /home/jolsa/kernel/linux-perf/tools/perf/util/bpf_skel/.tmp/prog.o
> CLANG /home/jolsa/kernel/linux-perf/tools/perf/util/bpf_skel/.tmp/pid_iter.bpf.o
> In file included from skeleton/pid_iter.bpf.c:4:
> In file included from /home/jolsa/kernel/linux-perf/tools/lib/bpf/bpf_helpers.h:11:
> /home/jolsa/kernel/linux-perf/tools/lib/bpf/bpf_helper_defs.h:3560:57: warning: declaration of 'struct bpf_redir_neigh' will not be visible outside of this function [-Wvisibility]
> static long (*bpf_redirect_neigh)(__u32 ifindex, struct bpf_redir_neigh *params, int plen, __u64 flags) = (void *) 152;
> ^
> skeleton/pid_iter.bpf.c:35:48: error: no member named 'id' in 'struct bpf_link'
> return BPF_CORE_READ((struct bpf_link *)ent, id);
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
> /home/jolsa/kernel/linux-perf/tools/lib/bpf/bpf_core_read.h:339:18: note: expanded from macro 'BPF_CORE_READ'
> ___type((src), a, ##__VA_ARGS__) __r; \
> ...

I guess this was caused by older vmlinux.h. Could you please try build
vmlinux first?

Thanks,
Song