[PATCH] perf trace: sys_enter_openat.c fix libbpf 1.0+ compatibility
From: Leo Yan
Date: Fri Nov 11 2022 - 07:02:24 EST
Avoid use of tools/perf/include/bpf/bpf.h and use the more regular BPF
headers.
With fixing:
# ./perf trace -e examples/bpf/sys_enter_openat.c
0.000 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY)
1.596 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY)
1.832 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY)
1.864 irqbalance/1025 syscalls:sys_enter_openat(AT_FDCWD, "", O_RDONLY)
Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>
---
tools/perf/examples/bpf/sys_enter_openat.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/perf/examples/bpf/sys_enter_openat.c b/tools/perf/examples/bpf/sys_enter_openat.c
index c4481c390d23..8edfa7c147d1 100644
--- a/tools/perf/examples/bpf/sys_enter_openat.c
+++ b/tools/perf/examples/bpf/sys_enter_openat.c
@@ -14,7 +14,9 @@
* the return value.
*/
-#include <bpf/bpf.h>
+#include <linux/bpf.h>
+#include <linux/limits.h>
+#include <bpf/bpf_helpers.h>
struct syscall_enter_openat_args {
unsigned long long unused;
@@ -25,9 +27,10 @@ struct syscall_enter_openat_args {
long mode;
};
-int syscall_enter(openat)(struct syscall_enter_openat_args *args)
+SEC("syscalls:sys_enter_openat")
+int syscall_enter_openat(struct syscall_enter_openat_args *args)
{
return 1;
}
-license(GPL);
+char _license[] SEC("license") = "GPL";