Re: Building perf with BUILD_BPF_SKEL=1

From: Andrii Nakryiko
Date: Thu Nov 17 2022 - 12:00:49 EST


On Thu, Nov 17, 2022 at 5:11 AM Arnaldo Carvalho de Melo
<arnaldo.melo@xxxxxxxxx> wrote:
>
> Hi guys,
>
> At some point we should switch to building with BPF skels by
> default as there are many features that are implemented that way in
> perf:
>
> ⬢[acme@toolbox perf]$ ls -la tools/perf/util/bpf_skel/
> total 464
> drwxr-xr-x. 1 acme acme 334 Oct 14 10:28 .
> drwxr-xr-x. 1 acme acme 7380 Nov 17 09:22 ..
> -rw-r--r--. 1 acme acme 5581 Oct 14 10:28 bperf_cgroup.bpf.c
> -rw-r--r--. 1 acme acme 1764 Mar 14 2022 bperf_follower.bpf.c
> -rw-r--r--. 1 acme acme 1438 Mar 14 2022 bperf_leader.bpf.c
> -rw-r--r--. 1 acme acme 285 Mar 14 2022 bperf_u.h
> -rw-r--r--. 1 acme acme 2290 Mar 14 2022 bpf_prog_profiler.bpf.c
> -rw-r--r--. 1 acme acme 2164 Mar 27 2022 func_latency.bpf.c
> -rw-r--r--. 1 acme acme 53 Nov 6 2021 .gitignore
> -rw-r--r--. 1 acme acme 9017 Sep 27 09:29 kwork_trace.bpf.c
> -rw-r--r--. 1 acme acme 3691 Oct 6 08:03 lock_contention.bpf.c
> -rw-r--r--. 1 acme acme 6102 Oct 4 08:55 off_cpu.bpf.c
> ⬢[acme@toolbox perf]$
>
>
> Since I'm finally using the Firefly ARM board the fine folks at
> Librecomputer gave us at Kernel Recipes, I'm noticing issues as I go on
> adding the components, for instance:
>
> /bin/sh: 2: llvm-strip: not found
> make[2]: *** [Makefile.perf:1136: /tmp/build/perf/util/bpf_skel/.tmp/bperf_follower.bpf.o] Error 127
> make[2]: *** Waiting for unfinished jobs....
> /bin/sh: 2: llvm-strip: not found
> make[2]: *** [Makefile.perf:1136: /tmp/build/perf/util/bpf_skel/.tmp/bpf_prog_profiler.bpf.o] Error 127
> /bin/sh: 2: llvm-strip: not found
> make[2]: *** [Makefile.perf:1136: /tmp/build/perf/util/bpf_skel/.tmp/bperf_leader.bpf.o] Error 127
> /bin/sh: 2: llvm-strip: not found
> make[2]: *** [Makefile.perf:1136: /tmp/build/perf/util/bpf_skel/.tmp/func_latency.bpf.o] Error 127
> /bin/sh: 2: llvm-strip: not found
> make[2]: *** [Makefile.perf:1136: /tmp/build/perf/util/bpf_skel/.tmp/bperf_cgroup.bpf.o] Error 127
> make[1]: *** [Makefile.perf:240: sub-make] Error 2
> make: *** [Makefile:113: install-bin] Error 2
> make: Leaving directory '/home/acme/git/perf/tools/perf'
>
> So this is just me taking notes, feel free to fix it if you want ;-)
>
> acme@roc-rk3399-pc:~/git/perf$ cat /etc/os-release
> PRETTY_NAME="Ubuntu 22.04.1 LTS"
> NAME="Ubuntu"
> VERSION_ID="22.04"
> VERSION="22.04.1 LTS (Jammy Jellyfish)"
> VERSION_CODENAME=jammy
> ID=ubuntu
> ID_LIKE=debian
> HOME_URL="https://www.ubuntu.com/";
> SUPPORT_URL="https://help.ubuntu.com/";
> BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/";
> PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy";
> UBUNTU_CODENAME=jammy
> acme@roc-rk3399-pc:~/git/perf$
>
> perf should check for that and give per-distro hints on how to overcome
> those, for instance, on ubuntu I had to:

there is no need to use llvm-strip anymore, if you use BPF static
linking (even if for single .bpf.o file). We do `bpftool obj gen` and
that effectively strips away DWARF.

>
> acme@roc-rk3399-pc:~/git/perf$ dpkg -L llvm-14 | grep strip
> /usr/share/man/man1/llvm-strip-14.1.gz
> /usr/bin/llvm-bitcode-strip-14
> /usr/bin/llvm-strip-14
> /usr/lib/llvm-14/bin/llvm-bitcode-strip
> /usr/lib/llvm-14/bin/llvm-strip
> acme@roc-rk3399-pc:~/git/perf$ export PATH=$PATH:/usr/lib/llvm-14/bin
>
>
> and now:
>

[...]