From: Steven Rostedt <rostedt@goodmis.org>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@fb.com>,
davem@davemloft.net, torvalds@linux-foundation.org,
peterz@infradead.org, netdev@vger.kernel.org, kernel-team@fb.com,
linux-api@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT
Date: Fri, 23 Mar 2018 21:39:36 -0400 [thread overview]
Message-ID: <20180323213936.0a2a7591@vmware.local.home> (raw)
In-Reply-To: <eb46ee44-3010-4c4e-1020-9b4fbdd34101@iogearbox.net>
On Sat, 24 Mar 2018 00:13:28 +0100
Daniel Borkmann <daniel@iogearbox.net> wrote:
> #define UNPACK(...) __VA_ARGS__
> #define REPEAT_1(FN, DL, X, ...) FN(X)
> #define REPEAT_2(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_1(FN, DL, __VA_ARGS__)
> #define REPEAT_3(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_2(FN, DL, __VA_ARGS__)
> #define REPEAT_4(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_3(FN, DL, __VA_ARGS__)
> #define REPEAT_5(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_4(FN, DL, __VA_ARGS__)
> #define REPEAT_6(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_5(FN, DL, __VA_ARGS__)
> #define REPEAT_7(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_6(FN, DL, __VA_ARGS__)
> #define REPEAT_8(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_7(FN, DL, __VA_ARGS__)
> #define REPEAT_9(FN, DL, X, ...) FN(X) UNPACK DL REPEAT_8(FN, DL, __VA_ARGS__)
> #define REPEAT(X, FN, DL, ...) REPEAT_##X(FN, DL, __VA_ARGS__)
>
> #define SARG(X) u64 arg##X
> #define COPY(X) args[X] = arg##X
>
> #define __DL_COM (,)
> #define __DL_SEM (;)
>
> #define __SEQ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
>
> #define BPF_TRACE_DECL_x(x) \
> void bpf_trace_run##x(struct bpf_prog *prog, \
> REPEAT(x, SARG, __DL_COM, __SEQ))
> #define BPF_TRACE_DEFN_x(x) \
> void bpf_trace_run##x(struct bpf_prog *prog, \
> REPEAT(x, SARG, __DL_COM, __SEQ)) \
> { \
> u64 args[x]; \
> REPEAT(x, COPY, __DL_SEM, __SEQ); \
> __bpf_trace_run(prog, args); \
> } \
> EXPORT_SYMBOL_GPL(bpf_trace_run##x)
>
> So doing a ...
>
> BPF_TRACE_DECL_x(5);
> BPF_TRACE_DEFN_x(5);
>
> ... will generate in kernel/trace/bpf_trace.i:
>
> void bpf_foo_trace_run5(struct bpf_prog *prog, u64 arg0 , u64 arg1 , u64 arg2 , u64 arg3 , u64 arg4);
> void bpf_foo_trace_run5(struct bpf_prog *prog, u64 arg0 , u64 arg1 , u64 arg2 , u64 arg3 , u64 arg4)
> {
> u64 args[5];
> args[0] = arg0 ;
> args[1] = arg1 ;
> args[2] = arg2 ;
> args[3] = arg3 ;
> args[4] = arg4;
> __bpf_trace_run(prog, args);
> } [...]
>
> Meaning, the EVALx() macros could be removed from there, too. Potentially, the
> REPEAT() macro could sit in its own include/linux/ header for others to reuse
> or such.
And people think my macro magic in include/trace/ftrace_event.h is
funky. Now I know who stole my MACRO MAGIC HAT.
-- Steve
next prev parent reply other threads:[~2018-03-24 1:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 18:54 [PATCH v2 bpf-next 0/8] bpf, tracing: introduce bpf raw tracepoints Alexei Starovoitov
2018-03-21 18:54 ` [PATCH v2 bpf-next 1/8] treewide: remove struct-pass-by-value from tracepoints arguments Alexei Starovoitov
2018-03-21 18:54 ` [PATCH v2 bpf-next 2/8] net/mediatek: disambiguate mt76 vs mt7601u trace events Alexei Starovoitov
2018-03-21 18:54 ` [PATCH v2 bpf-next 3/8] net/mac802154: disambiguate mac80215 vs mac802154 " Alexei Starovoitov
2018-03-21 18:54 ` [PATCH v2 bpf-next 4/8] tracepoint: compute num_args at build time Alexei Starovoitov
2018-03-21 19:44 ` Linus Torvalds
2018-03-21 22:05 ` Alexei Starovoitov
2018-03-22 13:36 ` Steven Rostedt
2018-03-22 15:51 ` Alexei Starovoitov
2018-03-22 16:14 ` Steven Rostedt
2018-03-21 18:54 ` [PATCH v2 bpf-next 5/8] bpf: introduce BPF_RAW_TRACEPOINT Alexei Starovoitov
2018-03-22 9:43 ` Daniel Borkmann
2018-03-22 15:41 ` Alexei Starovoitov
2018-03-23 23:13 ` Daniel Borkmann
2018-03-24 0:58 ` Alexei Starovoitov
2018-03-24 1:43 ` Alexei Starovoitov
2018-03-24 2:01 ` Linus Torvalds
2018-03-26 7:53 ` Daniel Borkmann
2018-03-24 1:39 ` Steven Rostedt [this message]
2018-03-21 18:54 ` [PATCH v2 bpf-next 6/8] libbpf: add bpf_raw_tracepoint_open helper Alexei Starovoitov
2018-03-21 18:54 ` [PATCH v2 bpf-next 7/8] samples/bpf: raw tracepoint test Alexei Starovoitov
2018-03-21 18:54 ` [PATCH v2 bpf-next 8/8] selftests/bpf: test for bpf_get_stackid() from raw tracepoints Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180323213936.0a2a7591@vmware.local.home \
--to=rostedt@goodmis.org \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=linux-api@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).