bpf: inline bpf_get_branch_snapshot() helper
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 4 Apr 2024 00:26:40 +0000 (17:26 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 4 Apr 2024 20:08:01 +0000 (13:08 -0700)
commit314a53623cd4e62e1b88126e5ed2bc87073d90ee
tree05376a14c790f914df2197a0431c3608ac025e66
parent5e6a3c1ee693da1793739bb378b224bcf33d7f14
bpf: inline bpf_get_branch_snapshot() helper

Inline bpf_get_branch_snapshot() helper using architecture-agnostic
inline BPF code which calls directly into underlying callback of
perf_snapshot_branch_stack static call. This callback is set early
during kernel initialization and is never updated or reset, so it's ok
to fetch actual implementation using static_call_query() and call
directly into it.

This change eliminates a full function call and saves one LBR entry
in PERF_SAMPLE_BRANCH_ANY LBR mode.

Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240404002640.1774210-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c