Re: [PATCH v2 2/2] perf-stat: enable counting events for BPF programs

From: Jiri Olsa
Date: Tue Dec 08 2020 - 05:26:45 EST


On Tue, Dec 08, 2020 at 01:36:57AM +0000, Song Liu wrote:

SNIP

> >
> > I'm still getting
> >
> > [root@dell-r440-01 perf]# ./perf stat -b 38
> > libbpf: elf: skipping unrecognized data section(9) .eh_frame
> > libbpf: elf: skipping relo section(15) .rel.eh_frame for section(9) .eh_frame
> > libbpf: XXX is not found in vmlinux BTF
> > libbpf: failed to load object 'bpf_prog_profiler_bpf'
> > libbpf: failed to load BPF skeleton 'bpf_prog_profiler_bpf': -2
> > ...
> >
> > with id 38 being:
> >
> > 38: tracepoint name sys_enter tag 03418b72a610af75 gpl
> > loaded_at 2020-12-07T22:54:05+0100 uid 0
> > xlated 272B jited 153B memlock 4096B map_ids 1
> >
> > how is this supposed to work when there's XXX in the
> > program's section? libbpf is trying to find XXX in
> > kernel BTF and fails of course
>
> I think this is because this program doesn't have BTF. The actual failed
> function was bpf_program__set_attach_target(). So the error message above
> should be "Failed to _open_ bpf skeleton". I will fix the error messages.

ah right, it's bpftrace program, so there's no BTF loaded for the program
I'll check if there's a way to add it, it'd be shame not to have this
feature for bpftrace programs

there's no way around it, right? we need btf id of the program to attach
fentry/fexit to it

I think we need to fail the function if there's error detected,
and also check on the prog_name and fail if it's not found

plus change all those pr_debug to pr_err in bpf_program_profiler_load_one

jirka