My environment:
- aarch64-linux-5.15.7
- bpf compile tools: clang-11
- bpf compile param:
clang -g -target bpf -Wall -O2 -g3 -g -DBPF_CODE -ggdb -std=gnu99 -D__TARGET_ARCH_arm64 -Wno-compare-distinct-pointer-types
- Using
libbpf 1.0.1/bpf_object__load()
fails after open
Errors
- Using
__sync_add_and_fetch
returnsENOTSUPP
. The Linux kernel code returns the error code as follows:
if (attr->attach_prog_fd) {
dst_prog = bpf_prog_get(attr->attach_prog_fd);
if (IS_ERR(dst_prog)) {
dst_prog = NULL;
attach_btf = btf_get_by_fd(attr->attach_btf_obj_fd);
if (IS_ERR(attach_btf))
return -EINVAL;
if (!btf_is_kernel(attach_btf)) {
/* attaching through specifying bpf_prog's BTF
* objects directly might be supported eventually
*/
btf_put(attach_btf);
return -ENOTSUPP;
}
}
}
I also tried to disabling the btf
type function in the kernel. The exception was still displayed. The same code was running properly on x86.
- Using
atomic64_add
produces the error info as follows:
libbpf: failed to find BTF for extern'atomic64_add': - 2
Check the Linux update description and related code. This version supports atomic operations.