Re: Need help: a function symbol can't be found in bpf object file when generating skeleton

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 6, 2022 at 4:27 PM Yifei Ma <yifeima@xxxxxxxxxxxxx> wrote:
>
> Hi all,
>
> I hit an issue when a function symbol can't be found in bpf object file when generating skeleton. if anyone can kindly give me some suggestions on it, that would be a big help.
> Here is what I am doing:
> - I am playing with the patch from Roman "bpf: sched: basic infrastructure for scheduler bpf"
> - It adds three hooks in CFS scheduler, and three BPF helper functions.
> - I patched his work on the kerenl and libbpf and bpftool (v5.16)
> - When I compiled this example BPF code (https://github.com/rgushchin/atc), BPF skeleton generator can't find the BTF for the helper function.
> -----------------------------------------------
> More information about my environment:
> - on linux 5.16 with the patch
> - enabled "CONFIG_DEBUG_INFO_BTF=y CONFIG_PAHOLE_HAS_SPLIT_BTF=y CONFIG_DEBUG_INFO_BTF_MODULES=y"
> - rebuilt lib/bpf and bpftool
> - generated vmlinux.h using the bpftool
> - grep bpf_sched_entity_belongs_to_cgrp vmlinux.h ==> Found it
> - clang -g -O2 -target bpf -D__TARGET_ARCH_x86 -I$LINUX/tools/include/uapi -I$LINUX/tools/lib/ -I$LINUX/tools/bpf/bpftool/ -I. -o atc.bpf.o -c atc.bpf.c
> - clang --version ==> Ubuntu clang version 12.0.0-3ubuntu1~20.04.5
> - llvm-strip -g atc.bpf.o
> - bpftool gen skeleton atc.bpf.o > atc.skel.h
> - "libbpf: failed to find BTF for extern 'bpf_sched_entity_belongs_to_cgrp': -2"
> - backtrace where 'bpf_sched_entity_belongs_to_cgrp' can't be found in BTF
> #0 find_extern_btf_id (ext_name= "bpf_sched_entity_belongs_to_cgrp",) at libbpf.c:3589
> #1 bpf_object__collect_externs at libbpf.c:3589
> #2 __bpf_object__open () at libbpf.c:6808
> #3 __bpf_object__open () at libbpf.c:6750
> #4 bpf_object__open_mem () at libbpf.c:6872
> #5 bpf_object__open_mem () at libbpf.c:6866
> #6 in do_skeleton () at libbpf.c:728
> #7 main () at libbpf.c:728
> ------------------------------------
>
>
> Do you have any idea or suggestion on it? Thank you

I think you have to either re-generate bpf_helper_defs.h ([0]) or just
add your own definitions for those new helpers. See [0] for how libbpf
does it for current helpers and just do the same (but with correct
helper ID, of course).

  [0] https://github.com/libbpf/libbpf/blob/master/src/bpf_helper_defs.h#L287

>
> Yifei
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux