bpf: pass whole link instead of prog when triggering raw tracepoint
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 19 Mar 2024 23:38:49 +0000 (16:38 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 20 Mar 2024 06:05:33 +0000 (23:05 -0700)
commitd4dfc5700e867b22ab94f960f9a9972696a637d5
treefa2c0c39612987fdcab3cd17e8f34b5908fe7d31
parent6b9c2950c912780ce113079c9c52041b1e2a611a
bpf: pass whole link instead of prog when triggering raw tracepoint

Instead of passing prog as an argument to bpf_trace_runX() helpers, that
are called from tracepoint triggering calls, store BPF link itself
(struct bpf_raw_tp_link for raw tracepoints). This will allow to pass
extra information like BPF cookie into raw tracepoint registration.

Instead of replacing `struct bpf_prog *prog = __data;` with
corresponding `struct bpf_raw_tp_link *link = __data;` assignment in
`__bpf_trace_##call` I just passed `__data` through into underlying
bpf_trace_runX() call. This works well because we implicitly cast `void *`,
and it also avoids naming clashes with arguments coming from
tracepoint's "proto" list. We could have run into the same problem with
"prog", we just happened to not have a tracepoint that has "prog" input
argument. We are less lucky with "link", as there are tracepoints using
"link" argument name already. So instead of trying to avoid naming
conflicts, let's just remove intermediate local variable. It doesn't
hurt readibility, it's either way a bit of a maze of calls and macros,
that requires careful reading.

Acked-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Message-ID: <20240319233852.1977493-3-andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf.h
include/linux/trace_events.h
include/trace/bpf_probe.h
kernel/bpf/syscall.c
kernel/trace/bpf_trace.c