FS#72203 - [bpftrace] kfunc probe types fail - build issue?

Attached to Project: Community Packages
Opened by Toke Høiland-Jørgensen (tohojo) - Tuesday, 21 September 2021, 22:40 GMT
Last edited by Toolybird (Toolybird) - Saturday, 25 March 2023, 20:57 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Anatol Pomozov (anatolik)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

The packaged version of bpftrace seems to think kfunc probes are not available:

$ sudo bpftrace -l 'kfunc:*'
stdin:1:1-8: ERROR: kfunc/kretfunc not available for your kernel version.
kfunc:*
~~~~~~~

It works fine with the official bpftrace binary distributed by upstream:

$ sudo ./bpftrace -l 'kfunc:*' | head
kfunc:FSE_NCountWriteBound
kfunc:FSE_buildCTable_raw
kfunc:FSE_buildCTable_rle
kfunc:FSE_buildCTable_wksp
kfunc:FSE_buildDTable_raw
kfunc:FSE_buildDTable_rle
kfunc:FSE_buildDTable_wksp
kfunc:FSE_compressBound
kfunc:FSE_compress_usingCTable
kfunc:FSE_compress_usingCTable_generic


...so it has to be a build issue, I suppose. The --info output from the two wags
its finger suggestively at 'libbpf btf dump':

Upstream version:

$ sudo ./bpftrace --info
System
OS: Linux 5.14.2-arch1-2 #1 SMP PREEMPT Thu, 09 Sep 2021 09:42:35 +0000
Arch: x86_64

Build
version: v0.13.0
LLVM: 12.0.0
ORC: v2
foreach_sym: yes
unsafe uprobe: no
bfd: yes
bpf_attach_kfunc: yes
bcc_usdt_addsem: yes
bcc bpf_attach_uprobe refcount: yes
libbpf: yes
libbpf btf dump: yes
libbpf btf dump type decl: yes

Kernel helpers
probe_read: yes
probe_read_str: yes
probe_read_user: yes
probe_read_user_str: yes
probe_read_kernel: yes
probe_read_kernel_str: yes
get_current_cgroup_id: yes
send_signal: yes
override_return: yes
get_boot_ns: yes
dpath: yes

Kernel features
Instruction limit: 1000000
Loop support: yes
btf (depends on Build:libbpf): yes
map batch (depends on Build:libbpf): yes
uprobe refcount (depends on Build:bcc bpf_attach_uprobe refcount): yes

Map types
hash: yes
percpu hash: yes
array: yes
percpu array: yes
stack_trace: yes
perf_event_array: yes

Probe types
kprobe: yes
tracepoint: yes
perf_event: yes
kfunc: yes
iter:task: yes
iter:task_file: yes



Packaged version:
$ sudo bpftrace --info
System
OS: Linux 5.14.2-arch1-2 #1 SMP PREEMPT Thu, 09 Sep 2021 09:42:35 +0000
Arch: x86_64

Build
version: v0.13.0
LLVM: 12.0.1
ORC: v2
foreach_sym: yes
unsafe uprobe: no
bfd: yes
bpf_attach_kfunc: yes
bcc_usdt_addsem: yes
bcc bpf_attach_uprobe refcount: yes
libbpf: yes
libbpf btf dump: no
libbpf btf dump type decl: no

Kernel helpers
probe_read: yes
probe_read_str: yes
probe_read_user: yes
probe_read_user_str: yes
probe_read_kernel: yes
probe_read_kernel_str: yes
get_current_cgroup_id: yes
send_signal: yes
override_return: yes
get_boot_ns: yes
dpath: yes

Kernel features
Instruction limit: 1000000
Loop support: yes
btf (depends on Build:libbpf): no
map batch (depends on Build:libbpf): yes
uprobe refcount (depends on Build:bcc bpf_attach_uprobe refcount): yes

Map types
hash: yes
percpu hash: yes
array: yes
percpu array: yes
stack_trace: yes
perf_event_array: yes

Probe types
kprobe: yes
tracepoint: yes
perf_event: yes
kfunc: yes
iter:task: yes
iter:task_file: yes




Additional info:
* package version(s): bpftrace 0.13.0-1 linux 5.14.2.arch1-2
This task depends upon

Closed by  Toolybird (Toolybird)
Saturday, 25 March 2023, 20:57 GMT
Reason for closing:  Fixed
Comment by Anatol Pomozov (anatolik) - Friday, 24 September 2021, 20:46 GMT
Looking at https://github.com/iovisor/bpftrace/blob/master/cmake/FindLibBpf.cmake I see

```
check_symbol_exists(btf_dump__new "${LIBBPF_INCLUDE_DIRS}/bpf/btf.h" HAVE_BTF_DUMP)
if (HAVE_BTF_DUMP)
set(LIBBPF_BTF_DUMP_FOUND TRUE)
endif()
```

I am checking the btf.h from the latest libbpf package and the symbol is there:

```
grep btf_dump__new /usr/include/bpf/btf.h
LIBBPF_API struct btf_dump *btf_dump__new(const struct btf *btf,
```

So it looks like bpftrace build system does not pick the right header file for some reason...
Comment by Ronan Pigott (Brocellous) - Saturday, 25 March 2023, 02:08 GMT
This doesn't seem reproducible with with current release. I think this bug can be closed.

Loading...