bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libbpf/BTF loading issue with fentry/fexit selftests
@ 2020-03-25 22:16 Matt Cover
  2020-03-25 22:23 ` KP Singh
  2020-03-26  1:31 ` Andrii Nakryiko
  0 siblings, 2 replies; 5+ messages in thread
From: Matt Cover @ 2020-03-25 22:16 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Yonghong Song, John Fastabend, bpf

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`
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
[vagrant@localhost bpf]$ ~/bpftool btf dump file
/sys/kernel/btf/vmlinux | grep -i fexit
    'BPF_TRAMP_FEXIT' val=1
    'BPF_TRACE_FEXIT' val=25


The fexit_test.o file also has BTF information.


[vagrant@localhost bpf]$ ~/bpftool btf dump file fexit_test.o | grep FUNC_PROTO
[4] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
[7] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
[9] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
[11] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
[13] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
[15] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1


However, I get libbpf/BTF load errors when trying to run any
fentry/fexit tests.


[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


I saw in a similar thread that -vvv output was requested. Figured the
same applies here.


[vagrant@localhost bpf]$ sudo ./test_progs -vvv -t fexit_test | grep
'^libbpf\|FAIL'
libbpf: loading ./test_pkt_access.o
libbpf: section(1) .strtab, size 290, link 0, flags 0, type=3
libbpf: skip section(1) .strtab
libbpf: section(2) .text, size 48, link 0, flags 6, type=1
libbpf: found program .text
libbpf: section(3) classifier/test_pkt_access, size 448, link 0, flags 6, type=1
libbpf: found program classifier/test_pkt_access
libbpf: section(4) .relclassifier/test_pkt_access, size 32, link 22,
flags 0, type=9
libbpf: section(5) version, size 4, link 0, flags 3, type=1
libbpf: kernel version of ./test_pkt_access.o is 1
libbpf: section(6) .debug_str, size 1151, link 0, flags 30, type=1
libbpf: skip section(6) .debug_str
libbpf: section(7) .debug_loc, size 605, link 0, flags 0, type=1
libbpf: skip section(7) .debug_loc
libbpf: section(8) .rel.debug_loc, size 144, link 22, flags 0, type=9
libbpf: skip relo .rel.debug_loc(8) for section(7)
libbpf: section(9) .debug_abbrev, size 390, link 0, flags 0, type=1
libbpf: skip section(9) .debug_abbrev
libbpf: section(10) .debug_info, size 2122, link 0, flags 0, type=1
libbpf: skip section(10) .debug_info
libbpf: section(11) .rel.debug_info, size 128, link 22, flags 0, type=9
libbpf: skip relo .rel.debug_info(11) for section(10)
libbpf: section(12) .debug_ranges, size 48, link 0, flags 0, type=1
libbpf: skip section(12) .debug_ranges
libbpf: section(13) .rel.debug_ranges, size 64, link 22, flags 0, type=9
libbpf: skip relo .rel.debug_ranges(13) for section(12)
libbpf: section(14) .BTF, size 2070, link 0, flags 0, type=1
libbpf: section(15) .rel.BTF, size 16, link 22, flags 0, type=9
libbpf: skip relo .rel.BTF(15) for section(14)
libbpf: section(16) .BTF.ext, size 752, link 0, flags 0, type=1
libbpf: section(17) .rel.BTF.ext, size 704, link 22, flags 0, type=9
libbpf: skip relo .rel.BTF.ext(17) for section(16)
libbpf: section(18) .debug_frame, size 88, link 0, flags 0, type=1
libbpf: skip section(18) .debug_frame
libbpf: section(19) .rel.debug_frame, size 48, link 22, flags 0, type=9
libbpf: skip relo .rel.debug_frame(19) for section(18)
libbpf: section(20) .debug_line, size 496, link 0, flags 0, type=1
libbpf: skip section(20) .debug_line
libbpf: section(21) .rel.debug_line, size 32, link 22, flags 0, type=9
libbpf: skip relo .rel.debug_line(21) for section(20)
libbpf: section(22) .symtab, size 288, link 1, flags 0, type=2
libbpf: Error loading BTF: Invalid argument(22)
libbpf: magic: 0xeb9f
libbpf: Error loading .BTF into kernel: -22.
libbpf: collecting relocating info for: 'classifier/test_pkt_access'
libbpf: relo for shdr 2, symb 8, value 0, type 3, bind 0, name 0 (''), insn 32
libbpf: relo for shdr 2, symb 8, value 0, type 3, bind 0, name 0 (''), insn 37
libbpf: added 6 insn from .text to prog classifier/test_pkt_access
libbpf: verifier log:
libbpf: loading ./fexit_test.o
libbpf: section(1) .strtab, size 503, link 0, flags 0, type=3
libbpf: skip section(1) .strtab
libbpf: section(2) .text, size 0, link 0, flags 6, type=1
libbpf: skip section(2) .text
libbpf: section(3) fexit/bpf_fentry_test1, size 112, link 0, flags 6, type=1
libbpf: found program fexit/bpf_fentry_test1
libbpf: section(4) .relfexit/bpf_fentry_test1, size 16, link 33, flags 0, type=9
libbpf: section(5) fexit/bpf_fentry_test2, size 152, link 0, flags 6, type=1
libbpf: found program fexit/bpf_fentry_test2
libbpf: section(6) .relfexit/bpf_fentry_test2, size 16, link 33, flags 0, type=9
libbpf: section(7) fexit/bpf_fentry_test3, size 200, link 0, flags 6, type=1
libbpf: found program fexit/bpf_fentry_test3
libbpf: section(8) .relfexit/bpf_fentry_test3, size 16, link 33, flags 0, type=9
libbpf: section(9) fexit/bpf_fentry_test4, size 152, link 0, flags 6, type=1
libbpf: found program fexit/bpf_fentry_test4
libbpf: section(10) .relfexit/bpf_fentry_test4, size 16, link 33,
flags 0, type=9
libbpf: section(11) fexit/bpf_fentry_test5, size 168, link 0, flags 6, type=1
libbpf: found program fexit/bpf_fentry_test5
libbpf: section(12) .relfexit/bpf_fentry_test5, size 16, link 33,
flags 0, type=9
libbpf: section(13) fexit/bpf_fentry_test6, size 184, link 0, flags 6, type=1
libbpf: found program fexit/bpf_fentry_test6
libbpf: section(14) .relfexit/bpf_fentry_test6, size 16, link 33,
flags 0, type=9
libbpf: section(15) license, size 4, link 0, flags 3, type=1
libbpf: license of ./fexit_test.o is GPL
libbpf: section(16) .bss, size 48, link 0, flags 3, type=8
libbpf: section(17) .debug_str, size 362, link 0, flags 30, type=1
libbpf: skip section(17) .debug_str
libbpf: section(18) .debug_loc, size 1326, link 0, flags 0, type=1
libbpf: skip section(18) .debug_loc
libbpf: section(19) .rel.debug_loc, size 416, link 33, flags 0, type=9
libbpf: skip relo .rel.debug_loc(19) for section(18)
libbpf: section(20) .debug_abbrev, size 211, link 0, flags 0, type=1
libbpf: skip section(20) .debug_abbrev
libbpf: section(21) .debug_info, size 1170, link 0, flags 0, type=1
libbpf: skip section(21) .debug_info
libbpf: section(22) .rel.debug_info, size 208, link 33, flags 0, type=9
libbpf: skip relo .rel.debug_info(22) for section(21)
libbpf: section(23) .debug_ranges, size 544, link 0, flags 0, type=1
libbpf: skip section(23) .debug_ranges
libbpf: section(24) .rel.debug_ranges, size 864, link 33, flags 0, type=9
libbpf: skip relo .rel.debug_ranges(24) for section(23)
libbpf: section(25) .BTF, size 1732, link 0, flags 0, type=1
libbpf: section(26) .rel.BTF, size 112, link 33, flags 0, type=9
libbpf: skip relo .rel.BTF(26) for section(25)
libbpf: section(27) .BTF.ext, size 1208, link 0, flags 0, type=1
libbpf: section(28) .rel.BTF.ext, size 1120, link 33, flags 0, type=9
libbpf: skip relo .rel.BTF.ext(28) for section(27)
libbpf: section(29) .debug_frame, size 160, link 0, flags 0, type=1
libbpf: skip section(29) .debug_frame
libbpf: section(30) .rel.debug_frame, size 96, link 33, flags 0, type=9
libbpf: skip relo .rel.debug_frame(30) for section(29)
libbpf: section(31) .debug_line, size 494, link 0, flags 0, type=1
libbpf: skip section(31) .debug_line
libbpf: section(32) .rel.debug_line, size 96, link 33, flags 0, type=9
libbpf: skip relo .rel.debug_line(32) for section(31)
libbpf: section(33) .symtab, size 792, link 1, flags 0, type=2
libbpf: map 'fexit_te.bss' (global data): at sec_idx 16, offset 0, flags 400.
libbpf: map 0 is "fexit_te.bss"
libbpf: Error loading BTF: Invalid argument(22)
libbpf: magic: 0xeb9f
libbpf: Error loading .BTF into kernel: -22.
libbpf: collecting relocating info for: 'fexit/bpf_fentry_test1'
libbpf: relo for shdr 16, symb 22, value 0, type 1, bind 1, name 99
('test1_result'), insn 9
libbpf: found data map 0 (fexit_te.bss, sec 16, off 0) for insn 9
libbpf: collecting relocating info for: 'fexit/bpf_fentry_test2'
libbpf: relo for shdr 16, symb 24, value 8, type 1, bind 1, name 86
('test2_result'), insn 14
libbpf: found data map 0 (fexit_te.bss, sec 16, off 0) for insn 14
libbpf: collecting relocating info for: 'fexit/bpf_fentry_test3'
libbpf: relo for shdr 16, symb 26, value 16, type 1, bind 1, name 73
('test3_result'), insn 20
libbpf: found data map 0 (fexit_te.bss, sec 16, off 0) for insn 20
libbpf: collecting relocating info for: 'fexit/bpf_fentry_test4'
libbpf: relo for shdr 16, symb 28, value 24, type 1, bind 1, name 60
('test4_result'), insn 14
libbpf: found data map 0 (fexit_te.bss, sec 16, off 0) for insn 14
libbpf: collecting relocating info for: 'fexit/bpf_fentry_test5'
libbpf: relo for shdr 16, symb 30, value 32, type 1, bind 1, name 47
('test5_result'), insn 16
libbpf: found data map 0 (fexit_te.bss, sec 16, off 0) for insn 16
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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libbpf/BTF loading issue with fentry/fexit selftests
  2020-03-25 22:16 libbpf/BTF loading issue with fentry/fexit selftests Matt Cover
@ 2020-03-25 22:23 ` KP Singh
  2020-03-25 23:42   ` Matt Cover
  2020-03-26  1:31 ` Andrii Nakryiko
  1 sibling, 1 reply; 5+ messages in thread
From: KP Singh @ 2020-03-25 22:23 UTC (permalink / raw)
  To: Matt Cover
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Yonghong Song, John Fastabend, bpf

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).

- 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libbpf/BTF loading issue with fentry/fexit selftests
  2020-03-25 22:23 ` KP Singh
@ 2020-03-25 23:42   ` Matt Cover
  0 siblings, 0 replies; 5+ messages in thread
From: Matt Cover @ 2020-03-25 23:42 UTC (permalink / raw)
  To: KP Singh
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Yonghong Song, John Fastabend, bpf

On Wed, Mar 25, 2020 at 3:23 PM KP Singh <kpsingh@chromium.org> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libbpf/BTF loading issue with fentry/fexit selftests
  2020-03-25 22:16 libbpf/BTF loading issue with fentry/fexit selftests Matt Cover
  2020-03-25 22:23 ` KP Singh
@ 2020-03-26  1:31 ` Andrii Nakryiko
  2020-03-26  2:50   ` Matt Cover
  1 sibling, 1 reply; 5+ messages in thread
From: Andrii Nakryiko @ 2020-03-26  1:31 UTC (permalink / raw)
  To: Matt Cover
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Yonghong Song, John Fastabend, bpf

On Wed, Mar 25, 2020 at 3:16 PM Matt Cover <werekraken@gmail.com> 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.

BTF is, but that BTF doesn't have information about FUNCs (only
FUNC_PROTOs). You need pahole 1.16 for fentry/fexit.

>
>
> [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`
> 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
> [vagrant@localhost bpf]$ ~/bpftool btf dump file
> /sys/kernel/btf/vmlinux | grep -i fexit
>     'BPF_TRAMP_FEXIT' val=1
>     'BPF_TRACE_FEXIT' val=25
>
>
> The fexit_test.o file also has BTF information.
>
>
> [vagrant@localhost bpf]$ ~/bpftool btf dump file fexit_test.o | grep FUNC_PROTO
> [4] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> [7] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> [9] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> [11] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> [13] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> [15] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
>
>
> However, I get libbpf/BTF load errors when trying to run any
> fentry/fexit tests.
>
>
> [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
>
>
> I saw in a similar thread that -vvv output was requested. Figured the
> same applies here.

Yeah, for tricky issues that good. In this case it was pretty obvious,
but generally it's a good idea for sure, thanks!
>
>
> [vagrant@localhost bpf]$ sudo ./test_progs -vvv -t fexit_test | grep
> '^libbpf\|FAIL'

[...]

>
>
> Any hints on the issue?
>
> -Matt C.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libbpf/BTF loading issue with fentry/fexit selftests
  2020-03-26  1:31 ` Andrii Nakryiko
@ 2020-03-26  2:50   ` Matt Cover
  0 siblings, 0 replies; 5+ messages in thread
From: Matt Cover @ 2020-03-26  2:50 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Yonghong Song, John Fastabend, bpf

On Wed, Mar 25, 2020 at 6:31 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Wed, Mar 25, 2020 at 3:16 PM Matt Cover <werekraken@gmail.com> 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.
>
> BTF is, but that BTF doesn't have information about FUNCs (only
> FUNC_PROTOs). You need pahole 1.16 for fentry/fexit.

Thanks Andrii! pahole 1.16 fixed things up.

[vagrant@localhost bpf]$ uname -r
5.5.9-1.btf.2.el7.x86_64
[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
    'fentry_progs' type_id=1950
    'fentry_cnt' type_id=18
    'fexit_progs' type_id=1950
    'fexit_cnt' type_id=18
[59594] FUNC 'bpf_fentry_test1' type_id=59593
[59596] FUNC 'bpf_fentry_test2' type_id=59595
[59598] FUNC 'bpf_fentry_test3' type_id=59597
[59600] FUNC 'bpf_fentry_test4' type_id=59599
[59602] FUNC 'bpf_fentry_test5' type_id=59601
[59604] FUNC 'bpf_fentry_test6' type_id=59603
[vagrant@localhost bpf]$ sudo ./test_progs -t fexit_test
#10 fexit_test:OK
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED

>
> >
> >
> > [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`
> > 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
> > [vagrant@localhost bpf]$ ~/bpftool btf dump file
> > /sys/kernel/btf/vmlinux | grep -i fexit
> >     'BPF_TRAMP_FEXIT' val=1
> >     'BPF_TRACE_FEXIT' val=25
> >
> >
> > The fexit_test.o file also has BTF information.
> >
> >
> > [vagrant@localhost bpf]$ ~/bpftool btf dump file fexit_test.o | grep FUNC_PROTO
> > [4] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> > [7] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> > [9] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> > [11] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> > [13] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> > [15] FUNC_PROTO '(anon)' ret_type_id=5 vlen=1
> >
> >
> > However, I get libbpf/BTF load errors when trying to run any
> > fentry/fexit tests.
> >
> >
> > [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
> >
> >
> > I saw in a similar thread that -vvv output was requested. Figured the
> > same applies here.
>
> Yeah, for tricky issues that good. In this case it was pretty obvious,
> but generally it's a good idea for sure, thanks!
> >
> >
> > [vagrant@localhost bpf]$ sudo ./test_progs -vvv -t fexit_test | grep
> > '^libbpf\|FAIL'
>
> [...]
>
> >
> >
> > Any hints on the issue?
> >
> > -Matt C.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-26  2:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 22:16 libbpf/BTF loading issue with fentry/fexit selftests Matt Cover
2020-03-25 22:23 ` KP Singh
2020-03-25 23:42   ` Matt Cover
2020-03-26  1:31 ` Andrii Nakryiko
2020-03-26  2:50   ` Matt Cover

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).