On Wed, Oct 16, 2019 at 4:14 AM Alexei Starovoitov <ast@xxxxxxxxxx> wrote: > > It's a responsiblity of bpf program author to annotate the program > with SEC("tp_btf/name") where "name" is a valid raw tracepoint. > The libbpf will try to find "name" in vmlinux BTF and error out > in case vmlinux BTF is not available or "name" is not found. > If "name" is indeed a valid raw tracepoint then in-kernel BTF > will have "btf_trace_##name" typedef that points to function > prototype of that raw tracepoint. BTF description captures > exact argument the kernel C code is passing into raw tracepoint. > The kernel verifier will check the types while loading bpf program. > > libbpf keeps BTF type id in expected_attach_type, but since > kernel ignores this attribute for tracing programs copy it > into attach_btf_id attribute before loading. > > Later the kernel will use prog->attach_btf_id to select raw tracepoint > during bpf_raw_tracepoint_open syscall command. > > Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> > --- Great, this is much cleaner approach! Acked-by: Andrii Nakryiko <andriin@xxxxxx> > tools/lib/bpf/bpf.c | 3 +++ > tools/lib/bpf/libbpf.c | 38 ++++++++++++++++++++++++++++++++------ > 2 files changed, 35 insertions(+), 6 deletions(-) > [...]