diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2024-03-19 16:38:49 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-03-19 23:05:33 -0700 |
commit | d4dfc5700e867b22ab94f960f9a9972696a637d5 (patch) | |
tree | fa2c0c39612987fdcab3cd17e8f34b5908fe7d31 /include/trace | |
parent | 6b9c2950c912780ce113079c9c52041b1e2a611a (diff) | |
download | linux-d4dfc5700e867b22ab94f960f9a9972696a637d5.tar.gz linux-d4dfc5700e867b22ab94f960f9a9972696a637d5.tar.bz2 linux-d4dfc5700e867b22ab94f960f9a9972696a637d5.zip |
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>
Diffstat (limited to 'include/trace')
-rw-r--r-- | include/trace/bpf_probe.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index e609cd7da47e..a2ea11cc912e 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -46,8 +46,7 @@ static notrace void \ __bpf_trace_##call(void *__data, proto) \ { \ - struct bpf_prog *prog = __data; \ - CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args)); \ + CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(__data, CAST_TO_U64(args)); \ } #undef DECLARE_EVENT_CLASS |