On Wed, Mar 25, 2020 at 3:23 PM KP Singh <kpsingh@xxxxxxxxxxxx> wrote: > > On 25-Mär 15:16, Matt Cover wrote: > > I'm looking to explore the bpf trampoline Alexei introduced for > > tracing progs, but am encountering a libbpf/BTF issue with loading > > the selftests. Hoping you guys might have a pointer or two. > > > > The kernel build used pahole 1.15. All llvm-project components used > > in compiling the selftests were 10.0.0-rc6. > > > > I believe the following confirms that BTF is indeed present in this kernel. > > > > > > [vagrant@localhost bpf]$ uname -r > > 5.5.9-1.btf.el7.x86_64 > > [vagrant@localhost bpf]$ grep CONFIG_DEBUG_INFO_BTF /boot/config-`uname -r` > > It seems like you might have CONFIG_TEST_BPF disabled. > > This is explained in Documentation/filter.txt: > > Testing > ------- > > Next to the BPF toolchain, the kernel also ships a test module that > contains various test cases for classic and internal BPF that can be > executed against the BPF interpreter and JIT compiler. It can be found > in lib/test_bpf.c and enabled via Kconfig: > > CONFIG_TEST_BPF=m > > After the module has been built and installed, the test suite can be > executed via insmod or modprobe against 'test_bpf' module. Results of > the test cases including timings in nsec can be found in the kernel > log (dmesg). Thanks for the info KP. Unfortunately, the issue remains with CONFIG_TEST_BPF=m and test_bpf loaded. [vagrant@localhost bpf]$ uname -r 5.5.9-1.btf.1.el7.x86_64 [vagrant@localhost bpf]$ grep CONFIG_TEST_BPF /boot/config-`uname -r` CONFIG_TEST_BPF=m [vagrant@localhost bpf]$ sudo modprobe test_bpf [vagrant@localhost bpf]$ ~/bpftool btf dump file /sys/kernel/btf/vmlinux | grep -i 'fentry\|fexit' 'BPF_TRAMP_FENTRY' val=0 'BPF_TRAMP_FEXIT' val=1 'BPF_TRACE_FENTRY' val=24 'BPF_TRACE_FEXIT' val=25 [vagrant@localhost bpf]$ sudo ./test_progs -t fexit_test | grep '^libbpf\|FAIL' libbpf: Error loading BTF: Invalid argument(22) libbpf: magic: 0xeb9f libbpf: Error loading .BTF into kernel: -22. libbpf: Error loading BTF: Invalid argument(22) libbpf: magic: 0xeb9f libbpf: Error loading .BTF into kernel: -22. libbpf: fexit/bpf_fentry_test1 is not found in vmlinux BTF test_fexit_test:FAIL:prog_load fail err -2 errno 22 #10 fexit_test:FAIL Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED The -vvv output didn't change, so forgoing a second copy. > > - KP > > > CONFIG_DEBUG_INFO_BTF=y > > [vagrant@localhost bpf]$ ~/bpftool btf dump file ~/vmlinux-`uname -r` > > | grep -i fexit > > 'BPF_TRAMP_FEXIT' val=1 > > 'BPF_TRACE_FEXIT' val=25 > > [...] > > > libbpf: collecting relocating info for: 'fexit/bpf_fentry_test6' > > libbpf: relo for shdr 16, symb 32, value 40, type 1, bind 1, name 34 > > ('test6_result'), insn 18 > > libbpf: found data map 0 (fexit_te.bss, sec 16, off 0) for insn 18 > > libbpf: loading kernel BTF '/sys/kernel/btf/vmlinux': 0 > > libbpf: fexit/bpf_fentry_test1 is not found in vmlinux BTF > > test_fexit_test:FAIL:prog_load fail err -2 errno 22 > > #10 fexit_test:FAIL > > Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED > > > > > > Any hints on the issue? > > > > -Matt C.