path: root/tools/testing/selftests/bpf/progs/test_overhead.c
diff options
authorMartin KaFai Lau <kafai@fb.com>2019-11-23 12:25:04 -0800
committerAlexei Starovoitov <ast@kernel.org>2019-11-24 17:12:11 -0800
commitf9a7cf6eb17cd0110c8c47d9e7969fc2716e5772 (patch)
tree9db74c8c6aaa198f2d163d066abe228f24bb22d5 /tools/testing/selftests/bpf/progs/test_overhead.c
parentbpf: Add bpf_jit_blinding_enabled for !CONFIG_BPF_JIT (diff)
bpf: Introduce BPF_TRACE_x helper for the tracing tests
For BPF_PROG_TYPE_TRACING, the bpf_prog's ctx is an array of u64. This patch borrows the idea from BPF_CALL_x in filter.h to convert a u64 to the arg type of the traced function. The new BPF_TRACE_x has an arg to specify the return type of a bpf_prog. It will be used in the future TCP-ops bpf_prog that may return "void". The new macros are defined in the new header file "bpf_trace_helpers.h". It is under selftests/bpf/ for now. It could be moved to libbpf later after seeing more upcoming non-tracing use cases. The tests are changed to use these new macros also. Hence, the k[s]u8/16/32/64 are no longer needed and they are removed from the bpf_helpers.h. Signed-off-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191123202504.1502696-1-kafai@fb.com
Diffstat (limited to '')
1 files changed, 6 insertions, 10 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_overhead.c b/tools/testing/selftests/bpf/progs/test_overhead.c
index ef06b2693f96..96c0124a04ba 100644
--- a/tools/testing/selftests/bpf/progs/test_overhead.c
+++ b/tools/testing/selftests/bpf/progs/test_overhead.c
@@ -3,6 +3,7 @@
#include <linux/bpf.h>
#include "bpf_helpers.h"
#include "bpf_tracing.h"
+#include "bpf_trace_helpers.h"
int prog1(struct pt_regs *ctx)
@@ -22,20 +23,15 @@ int prog3(struct bpf_raw_tracepoint_args *ctx)
return 0;
-struct __set_task_comm_args {
- struct task_struct *tsk;
- const char *buf;
- ku8 exec;
-int prog4(struct __set_task_comm_args *ctx)
+struct task_struct;
+BPF_TRACE_3("fentry/__set_task_comm", prog4,
+ struct task_struct *, tsk, const char *, buf, __u8, exec)
return 0;
-int prog5(struct __set_task_comm_args *ctx)
+BPF_TRACE_3("fexit/__set_task_comm", prog5,
+ struct task_struct *, tsk, const char *, buf, __u8, exec)
return 0;