From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:33942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbeCXBjj (ORCPT ); Fri, 23 Mar 2018 21:39:39 -0400 Date: Fri, 23 Mar 2018 21:39:36 -0400 From: Steven Rostedt To: Daniel Borkmann Cc: Alexei Starovoitov , 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 Message-ID: <20180323213936.0a2a7591@vmware.local.home> In-Reply-To: References: <20180321185448.2806324-1-ast@fb.com> <20180321185448.2806324-6-ast@fb.com> <580e6dcd-7deb-9fe2-5e37-6ce9ad0593a4@iogearbox.net> <79700812-58e2-2534-081e-015db6630155@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On Sat, 24 Mar 2018 00:13:28 +0100 Daniel Borkmann 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