Created
February 25, 2020 18:47
-
-
Save anakryiko/002e00b695540d4d5fde2c76ab070f26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From e4172808f4c4389cf8a86c2753e4a42894798c0a Mon Sep 17 00:00:00 2001 | |
From: Andrii Nakryiko <[email protected]> | |
Date: Tue, 25 Feb 2020 10:41:33 -0800 | |
Subject: [PATCH bpf-next] bpf: use more reliable BTF_TYPE_EMIT to preserve | |
btf_trace_xxx typedefs | |
BTF_TYPE_EMIT has more reliable mechanism to ensure compiler preserve | |
requested type information. It's already used by struct_ops mechanisms with | |
great reliability. Switch raw tracepoints to use the same mechanism. | |
Signed-off-by: Andrii Nakryiko <[email protected]> | |
--- | |
include/trace/bpf_probe.h | 9 +++++++-- | |
1 file changed, 7 insertions(+), 2 deletions(-) | |
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h | |
index b04c29270973..3f55e27dfe63 100644 | |
--- a/include/trace/bpf_probe.h | |
+++ b/include/trace/bpf_probe.h | |
@@ -55,12 +55,18 @@ | |
/* tracepoints with more than 12 arguments will hit build error */ | |
#define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) | |
+#ifndef BTF_TYPE_EMIT | |
+#define BTF_TYPE_EMIT(type) ((void)(type *)0) | |
+#endif | |
+ | |
#undef DECLARE_EVENT_CLASS | |
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ | |
+typedef void (*btf_trace_##call)(void *__data, proto); \ | |
static notrace void \ | |
__bpf_trace_##call(void *__data, proto) \ | |
{ \ | |
struct bpf_prog *prog = __data; \ | |
+ BTF_TYPE_EMIT(btf_trace_##call); \ | |
CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args)); \ | |
} | |
@@ -74,12 +80,11 @@ static inline void bpf_test_probe_##call(void) \ | |
{ \ | |
check_trace_callback_type_##call(__bpf_trace_##template); \ | |
} \ | |
-typedef void (*btf_trace_##call)(void *__data, proto); \ | |
static struct bpf_raw_event_map __used \ | |
__attribute__((section("__bpf_raw_tp_map"))) \ | |
__bpf_trace_tp_map_##call = { \ | |
.tp = &__tracepoint_##call, \ | |
- .bpf_func = (void *)(btf_trace_##call)__bpf_trace_##template, \ | |
+ .bpf_func = __bpf_trace_##template, \ | |
.num_args = COUNT_ARGS(args), \ | |
.writable_size = size, \ | |
}; | |
-- | |
2.17.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment