Message ID | 20210930091355.2794601-2-houtao1@huawei.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | add support for writable bare tracepoint | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-PR | success | PR summary |
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 5 maintainers not CCed: rostedt@goodmis.org kpsingh@kernel.org mingo@redhat.com john.fastabend@gmail.com songliubraving@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 907 this patch: 907 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | fail | ERROR: Macros with complex values should be enclosed in parentheses |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 913 this patch: 913 |
netdev/header_inline | success | Link |
bpf/vmtest-bpf-next | success | VM_Test |
On Thu, Sep 30, 2021 at 2:00 AM Hou Tao <houtao1@huawei.com> wrote: > > Commit 9df1c28bb752 ("bpf: add writable context for raw tracepoints") > supports writable context for tracepoint, but it misses the support > for bare tracepoint which has no associated trace event. > > Bare tracepoint is defined by DECLARE_TRACE(), so adding a corresponding > DECLARE_TRACE_WRITABLE() macro to generate a definition in __bpf_raw_tp_map > section for bare tracepoint in a similar way to DEFINE_TRACE_WRITABLE(). > > Signed-off-by: Hou Tao <houtao1@huawei.com> > --- LGTM. Acked-by: Andrii Nakryiko <andrii@kernel.org> > include/trace/bpf_probe.h | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h > index a23be89119aa..a8e97f84b652 100644 > --- a/include/trace/bpf_probe.h > +++ b/include/trace/bpf_probe.h > @@ -93,8 +93,7 @@ __section("__bpf_raw_tp_map") = { \ > > #define FIRST(x, ...) x > > -#undef DEFINE_EVENT_WRITABLE > -#define DEFINE_EVENT_WRITABLE(template, call, proto, args, size) \ > +#define __CHECK_WRITABLE_BUF_SIZE(call, proto, args, size) \ > static inline void bpf_test_buffer_##call(void) \ > { \ > /* BUILD_BUG_ON() is ignored if the code is completely eliminated, but \ > @@ -103,8 +102,12 @@ static inline void bpf_test_buffer_##call(void) \ > */ \ > FIRST(proto); \ > (void)BUILD_BUG_ON_ZERO(size != sizeof(*FIRST(args))); \ > -} \ > -__DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) > +} > + > +#undef DEFINE_EVENT_WRITABLE > +#define DEFINE_EVENT_WRITABLE(template, call, proto, args, size) \ > + __CHECK_WRITABLE_BUF_SIZE(call, PARAMS(proto), PARAMS(args), size) \ > + __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) > > #undef DEFINE_EVENT > #define DEFINE_EVENT(template, call, proto, args) \ > @@ -119,9 +122,17 @@ __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) > __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) \ > __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0) > > +#undef DECLARE_TRACE_WRITABLE > +#define DECLARE_TRACE_WRITABLE(call, proto, args, size) \ > + __CHECK_WRITABLE_BUF_SIZE(call, PARAMS(proto), PARAMS(args), size) \ > + __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) \ > + __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), size) > + > #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) > > +#undef DECLARE_TRACE_WRITABLE > #undef DEFINE_EVENT_WRITABLE > +#undef __CHECK_WRITABLE_BUF_SIZE > #undef __DEFINE_EVENT > #undef FIRST > > -- > 2.29.2 >
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index a23be89119aa..a8e97f84b652 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -93,8 +93,7 @@ __section("__bpf_raw_tp_map") = { \ #define FIRST(x, ...) x -#undef DEFINE_EVENT_WRITABLE -#define DEFINE_EVENT_WRITABLE(template, call, proto, args, size) \ +#define __CHECK_WRITABLE_BUF_SIZE(call, proto, args, size) \ static inline void bpf_test_buffer_##call(void) \ { \ /* BUILD_BUG_ON() is ignored if the code is completely eliminated, but \ @@ -103,8 +102,12 @@ static inline void bpf_test_buffer_##call(void) \ */ \ FIRST(proto); \ (void)BUILD_BUG_ON_ZERO(size != sizeof(*FIRST(args))); \ -} \ -__DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) +} + +#undef DEFINE_EVENT_WRITABLE +#define DEFINE_EVENT_WRITABLE(template, call, proto, args, size) \ + __CHECK_WRITABLE_BUF_SIZE(call, PARAMS(proto), PARAMS(args), size) \ + __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) #undef DEFINE_EVENT #define DEFINE_EVENT(template, call, proto, args) \ @@ -119,9 +122,17 @@ __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) \ __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0) +#undef DECLARE_TRACE_WRITABLE +#define DECLARE_TRACE_WRITABLE(call, proto, args, size) \ + __CHECK_WRITABLE_BUF_SIZE(call, PARAMS(proto), PARAMS(args), size) \ + __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) \ + __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), size) + #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) +#undef DECLARE_TRACE_WRITABLE #undef DEFINE_EVENT_WRITABLE +#undef __CHECK_WRITABLE_BUF_SIZE #undef __DEFINE_EVENT #undef FIRST
Commit 9df1c28bb752 ("bpf: add writable context for raw tracepoints") supports writable context for tracepoint, but it misses the support for bare tracepoint which has no associated trace event. Bare tracepoint is defined by DECLARE_TRACE(), so adding a corresponding DECLARE_TRACE_WRITABLE() macro to generate a definition in __bpf_raw_tp_map section for bare tracepoint in a similar way to DEFINE_TRACE_WRITABLE(). Signed-off-by: Hou Tao <houtao1@huawei.com> --- include/trace/bpf_probe.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)