summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/bpf-event.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2021-09-10 22:26:53 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-09-10 23:32:04 +0200
commit218e7b775d368f38d85d73e52900b082f004e5f1 (patch)
treec60ee77454f714642aaecb43e2253f360ba7b2c8 /tools/perf/util/bpf-event.c
parenttools include UAPI: Update linux/mount.h copy (diff)
downloadlinux-218e7b775d368f38d85d73e52900b082f004e5f1.tar.xz
linux-218e7b775d368f38d85d73e52900b082f004e5f1.zip
perf bpf: Provide a weak btf__load_from_kernel_by_id() for older libbpf versions
The btf__get_from_id() function was deprecated in favour of btf__load_from_kernel_by_id(), but it is still avaiable, so use it to provide a weak function btf__load_from_kernel_by_id() for older libbpf when building perf with LIBBPF_DYNAMIC=1, i.e. using the system's libbpf package. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/bpf-event.c')
-rw-r--r--tools/perf/util/bpf-event.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 996d025b8ed8..683f6d63560e 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -21,6 +21,14 @@
#include "record.h"
#include "util/synthetic-events.h"
+struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
+{
+ struct btf *btf;
+ int err = btf__get_from_id(id, &btf);
+
+ return err ? ERR_PTR(err) : btf;
+}
+
#define ptr_to_u64(ptr) ((__u64)(unsigned long)(ptr))
static int snprintf_hex(char *buf, size_t size, unsigned char *data, size_t len)