diff options
author | Quentin Monnet <quentin@isovalent.com> | 2021-07-29 17:20:25 +0100 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2021-07-29 17:23:52 -0700 |
commit | 86f4b7f2578f69284fa782be54e700c42c757897 (patch) | |
tree | 9944eb0e0bfd66dae5ccbe9d91b8c0beed0ace82 /tools/perf/util/bpf_counter.c | |
parent | 369e955b3d1c12f6ec2e51a95911bb80ada55d79 (diff) | |
download | linux-86f4b7f2578f69284fa782be54e700c42c757897.tar.gz linux-86f4b7f2578f69284fa782be54e700c42c757897.tar.bz2 linux-86f4b7f2578f69284fa782be54e700c42c757897.zip |
tools: Replace btf__get_from_id() with btf__load_from_kernel_by_id()
Replace the calls to function btf__get_from_id(), which we plan to
deprecate before the library reaches v1.0, with calls to
btf__load_from_kernel_by_id() in tools/ (bpftool, perf, selftests).
Update the surrounding code accordingly (instead of passing a pointer to
the btf struct, get it as a return value from the function).
Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210729162028.29512-6-quentin@isovalent.com
Diffstat (limited to 'tools/perf/util/bpf_counter.c')
-rw-r--r-- | tools/perf/util/bpf_counter.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c index beca55129b0b..ba0f20853651 100644 --- a/tools/perf/util/bpf_counter.c +++ b/tools/perf/util/bpf_counter.c @@ -74,12 +74,17 @@ static char *bpf_target_prog_name(int tgt_fd) return NULL; } - if (info_linear->info.btf_id == 0 || - btf__get_from_id(info_linear->info.btf_id, &btf)) { + if (info_linear->info.btf_id == 0) { pr_debug("prog FD %d doesn't have valid btf\n", tgt_fd); goto out; } + btf = btf__load_from_kernel_by_id(info_linear->info.btf_id); + if (libbpf_get_error(btf)) { + pr_debug("failed to load btf for prog FD %d\n", tgt_fd); + goto out; + } + func_info = u64_to_ptr(info_linear->info.func_info); t = btf__type_by_id(btf, func_info[0].type_id); if (!t) { |