-/* Copyright (C) 2011-2014 Oracle, Inc. */
+/* Copyright (C) 2011 -- 2016 Oracle, Inc. */
#ifndef _LINUX_SDT_H_
#define _LINUX_SDT_H_
-#ifdef CONFIG_DTRACE
-
-#ifndef __KERNEL__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DTRACE_PROBE(provider, name) { \
- extern void __dtrace_##provider##___##name(void); \
- __dtrace_##provider##___##name(); \
-}
-
-#define DTRACE_PROBE1(provider, name, arg1) { \
- extern void __dtrace_##provider##___##name(unsigned long); \
- __dtrace_##provider##___##name((unsigned long)arg1); \
-}
-
-#define DTRACE_PROBE2(provider, name, arg1, arg2) { \
- extern void __dtrace_##provider##___##name(unsigned long, \
- unsigned long); \
- __dtrace_##provider##___##name((unsigned long)arg1, \
- (unsigned long)arg2); \
-}
-
-#define DTRACE_PROBE3(provider, name, arg1, arg2, arg3) { \
- extern void __dtrace_##provider##___##name(unsigned long, \
- unsigned long, unsigned long); \
- __dtrace_##provider##___##name((unsigned long)arg1, \
- (unsigned long)arg2, (unsigned long)arg3); \
-}
-
-#define DTRACE_PROBE4(provider, name, arg1, arg2, arg3, arg4) { \
- extern void __dtrace_##provider##___##name(unsigned long, \
- unsigned long, unsigned long, unsigned long); \
- __dtrace_##provider##___##name((unsigned long)arg1, \
- (unsigned long)arg2, (unsigned long)arg3, \
- (unsigned long)arg4); \
-}
-
-#define DTRACE_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) { \
- extern void __dtrace_##provider##___##name(unsigned long, \
- unsigned long, unsigned long, unsigned long, unsigned long);\
- __dtrace_##provider##___##name((unsigned long)arg1, \
- (unsigned long)arg2, (unsigned long)arg3, \
- (unsigned long)arg4, (unsigned long)arg5); \
-}
-
-#ifdef __cplusplus
-}
-#endif
+#include <linux/sdt_internal.h>
-#else /* __KERNEL__ */
+#ifdef CONFIG_DTRACE
#include <linux/stringify.h>
-#define PROBENAME_STR(str) ".ascii \"" __stringify(str) "\"\n"
-#define ARG_STR(str) ".ascii \"" __stringify(str) ",\"\n"
-
-#define DTRACE_PROBE(name) { \
- extern void __dtrace_probe_##name(void); \
- __dtrace_probe_##name(); \
-}
-
-#define DTRACE_PROBE1(name, type1, arg1) { \
- extern void __dtrace_probe_##name(uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1)); \
+#define DTRACE_PROBE(name, ...) { \
+ extern void __dtrace_probe_##name(__DTRACE_TYPE_APPLY_DEFAULT(__DTRACE_UINTPTR_EACH, void, ## __VA_ARGS__)); \
+ __dtrace_probe_##name(__DTRACE_ARG_APPLY(__DTRACE_UINTCAST_EACH, ## __VA_ARGS__)); \
asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
+ ".ascii \"" __stringify(name) "\"\n" \
".byte 0\n" \
".popsection\n" \
".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
+ __DTRACE_TYPE_APPLY_NOCOMMA(__DTRACE_TYPE_EACH, ## __VA_ARGS__) \
".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE2(name, type1, arg1, type2, arg2) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
- (uintptr_t)(arg3)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ARG_STR(type3) \
- ".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
- uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
- (uintptr_t)(arg3), (uintptr_t)(arg4)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ARG_STR(type3) \
- ARG_STR(type4) \
- ".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
- uintptr_t, uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
- (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ARG_STR(type3) \
- ARG_STR(type4) \
- ARG_STR(type5) \
- ".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
- uintptr_t, uintptr_t, uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
- (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \
- (uintptr_t)(arg6)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ARG_STR(type3) \
- ARG_STR(type4) \
- ARG_STR(type5) \
- ARG_STR(type6) \
- ".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE7(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
- uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
- (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \
- (uintptr_t)(arg6), (uintptr_t)(arg7)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ARG_STR(type3) \
- ARG_STR(type4) \
- ARG_STR(type5) \
- ARG_STR(type6) \
- ARG_STR(type7) \
- ".byte 0\n" \
- ".popsection\n"); \
-}
-
-#define DTRACE_PROBE8(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) { \
- extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
- uintptr_t, uintptr_t, uintptr_t, uintptr_t, \
- uintptr_t, uintptr_t); \
- __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
- (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \
- (uintptr_t)(arg6), (uintptr_t)(arg7), (uintptr_t)(arg8)); \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- PROBENAME_STR(name) \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ARG_STR(type1) \
- ARG_STR(type2) \
- ARG_STR(type3) \
- ARG_STR(type4) \
- ARG_STR(type5) \
- ARG_STR(type6) \
- ARG_STR(type7) \
- ARG_STR(type8) \
- ".byte 0\n" \
- ".popsection\n"); \
+ ".popsection\n"); \
}
#ifdef CONFIG_DT_SDT_PERF
-/*
- * This counts the number of args.
- */
-#define DTRACE_NARGS_SEQ(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,N,...) N
-#define DTRACE_NARGS(...) DTRACE_NARGS_SEQ(__VA_ARGS__, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
-
-/*
- * This will let macros expand before concatting them.
- */
-#define DTRACE_PRIMITIVE_CAT(x, y) x ## y
-#define DTRACE_CAT(x, y) DTRACE_PRIMITIVE_CAT(x, y)
-
-/*
- * This will call a macro on each argument passed in.
- */
-#define DTRACE_APPLY(macro, ...) DTRACE_CAT(DTRACE_APPLY_, DTRACE_NARGS(__VA_ARGS__))(macro, __VA_ARGS__)
-#define DTRACE_APPLY_1(m, x1) m(x1)
-#define DTRACE_APPLY_2(m, x1, x2) m(x1), m(x2)
-#define DTRACE_APPLY_3(m, x1, x2, x3) m(x1), m(x2), m(x3)
-#define DTRACE_APPLY_4(m, x1, x2, x3, x4) m(x1), m(x2), m(x3), m(x4)
-#define DTRACE_APPLY_5(m, x1, x2, x3, x4, x5) m(x1), m(x2), m(x3), m(x4), m(x5)
-#define DTRACE_APPLY_6(m, x1, x2, x3, x4, x5, x6) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6)
-#define DTRACE_APPLY_7(m, x1, x2, x3, x4, x5, x6, x7) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7)
-#define DTRACE_APPLY_8(m, x1, x2, x3, x4, x5, x6, x7, x8) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-
-/*
- * Without investigation I went ahead and assumed the most arguments that could
- * be passed would be 8, but this is purely arbitrary. However, inexplicably
- * there are existing tracepoints that pass as many as 18 arguments!
- */
-
-#define DTRACE_APPLY_9(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_10(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_11(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_12(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_13(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_14(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_15(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_16(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_17(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-#define DTRACE_APPLY_18(m, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
-
-/*
- * Convert everything to the appropriate integral type, unless too large to fit
- * into any of them, in which case its address is taken instead.
- */
-
-#define DTRACE_UINTPTR_CAST_EACH(x) ({ \
+#define __DTRACE_UINTPTR_CAST_EACH(x) ({ \
union { \
typeof((x)) __val; \
unsigned char __c; \
__builtin_choose_expr(sizeof(__u.__val) == sizeof(__u.__l), __u.__l, \
__builtin_choose_expr(sizeof(__u.__val) == sizeof(__u.__ll), __u.__ll,\
(uintptr_t)&(__u.__val))))));})
-#define DTRACE_UINTPTR_EACH(x) uintptr_t
-#define DTRACE_PROBE_TRACEPOINT(name, args...) { \
- extern void __dtrace_probe___perf_##name(DTRACE_APPLY(DTRACE_UINTPTR_EACH, args)); \
- __dtrace_probe___perf_##name(DTRACE_APPLY(DTRACE_UINTPTR_CAST_EACH, args)); \
+#define DTRACE_PROBE_TRACEPOINT(name, ...) { \
+ extern void __dtrace_probe___perf_##name(__DTRACE_APPLY(__DTRACE_UINTPTR_EACH, ## __VA_ARGS__)); \
+ __dtrace_probe___perf_##name(__DTRACE_APPLY(__DTRACE_UINTPTR_CAST_EACH, ## __VA_ARGS__)); \
}
-#define DTRACE_PROTO_TRACEPOINT(name, proto...) { \
- asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n" \
- ".ascii \"" __stringify(__perf_##name) "\"\n" \
- ".byte 0\n" \
- ".popsection\n" \
- ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
- ".asciz \"" __stringify(proto) "\"\n" \
- ".popsection\n"); \
+#define DTRACE_PROTO_TRACEPOINT(name, ...) { \
+ asm volatile(".pushsection _dtrace_sdt_names, \"a\", @progbits\n"\
+ ".ascii \"" __stringify(__perf_##name) "\"\n" \
+ ".byte 0\n" \
+ ".popsection\n" \
+ ".pushsection _dtrace_sdt_args, \"a\", @progbits\n" \
+ ".ascii \"" __stringify(__VA_ARGS__) "\"\n" \
+ ".byte 0\n" \
+ ".popsection\n"); \
}
#else
-#define DTRACE_PROBE_TRACEPOINT(name, args...)
-#define DTRACE_PROTO_TRACEPOINT(name, proto...)
+#define DTRACE_PROBE_TRACEPOINT(name, ...)
+#define DTRACE_PROTO_TRACEPOINT(name, ...)
#endif
char *sdpd_name; /* probe name */
char *sdpd_func; /* probe function */
#ifndef __GENKSYMS__
- char *sdpd_args; /* arg string */
+ const char *sdpd_args; /* arg string */
#endif
unsigned long sdpd_offset; /* offset of call in text */
struct sdt_probedesc *sdpd_next; /* next static probe */
} sdt_probedesc_t;
-#endif /* __KERNEL__ */
-
#else /* ! CONFIG_DTRACE */
-#define DTRACE_PROBE(name) do { } while (0)
-#define DTRACE_PROBE1(name, type1, arg1) DTRACE_PROBE(name)
-#define DTRACE_PROBE2(name, type1, arg1, type2, arg2) DTRACE_PROBE(name)
-#define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE(name)
-#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4) DTRACE_PROBE(name)
-#define DTRACE_PROBE5(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5) DTRACE_PROBE(name)
-#define DTRACE_PROBE6(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6) DTRACE_PROBE(name)
-#define DTRACE_PROBE7(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
- DTRACE_PROBE(name)
-#define DTRACE_PROBE8(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \
- DTRACE_PROBE(name)
-#define DTRACE_PROBE_TRACEPOINT(name, args...)
-#define DTRACE_PROTO_TRACEPOINT(name, proto)
+/*
+ * This apparently redundant call serves to validate the DTRACE_PROBE has the
+ * right number of args even when dtrace is turned off.
+ */
+#define DTRACE_PROBE(name, ...) \
+ __DTRACE_DOUBLE_APPLY_NOCOMMA(__DTRACE_NONE, __DTRACE_NONE, ## __VA_ARGS__) \
+ do { } while (0)
+#define DTRACE_PROBE_TRACEPOINT(name, ...)
+#define DTRACE_PROTO_TRACEPOINT(name, ...)
#endif /* CONFIG_DTRACE */
-#define DTRACE_SCHED(name) \
- DTRACE_PROBE(__sched_##name);
-
-#define DTRACE_SCHED1(name, type1, arg1) \
- DTRACE_PROBE1(__sched_##name, type1, arg1);
-
-#define DTRACE_SCHED2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__sched_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_PROC(name) \
- DTRACE_PROBE(__proc_##name);
-
-#define DTRACE_PROC1(name, type1, arg1) \
- DTRACE_PROBE1(__proc_##name, type1, arg1);
-
-#define DTRACE_PROC2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__proc_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_PROC4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_IO(name) \
- DTRACE_PROBE(__io_##name);
-
-#define DTRACE_IO1(name, type1, arg1) \
- DTRACE_PROBE1(__io_##name, type1, arg1);
-
-#define DTRACE_IO2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__io_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_IO4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_ISCSI_2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__iscsi_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_ISCSI_3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__iscsi_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_ISCSI_4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__iscsi_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_ISCSI_5(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5) \
- DTRACE_PROBE5(__iscsi_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5);
-
-#define DTRACE_ISCSI_6(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
- DTRACE_PROBE6(__iscsi_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6);
-
-#define DTRACE_ISCSI_7(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
- DTRACE_PROBE7(__iscsi_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
- type7, arg7);
-
-#define DTRACE_ISCSI_8(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
- type7, arg7, type8, arg8) \
- DTRACE_PROBE8(__iscsi_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
- type7, arg7, type8, arg8);
-
-#define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \
- type3, arg3) \
- DTRACE_PROBE3(__nfsv3_##name, type1, arg1, type2, arg2, \
- type3, arg3);
-#define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_NFSV4_1(name, type1, arg1) \
- DTRACE_PROBE1(__nfsv4_##name, type1, arg1);
-
-#define DTRACE_NFSV4_2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__nfsv4_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_NFSV4_3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__nfsv4_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_SMB_1(name, type1, arg1) \
- DTRACE_PROBE1(__smb_##name, type1, arg1);
-
-#define DTRACE_SMB_2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__smb_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_IP(name) \
- DTRACE_PROBE(__ip_##name);
-
-#define DTRACE_IP1(name, type1, arg1) \
- DTRACE_PROBE1(__ip_##name, type1, arg1);
-
-#define DTRACE_IP2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__ip_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_IP4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_IP5(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5) \
- DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5);
-
-#define DTRACE_IP6(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
- DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6);
-
-#define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
- DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
- type7, arg7);
-
-#define DTRACE_TCP(name) \
- DTRACE_PROBE(__tcp_##name);
-
-#define DTRACE_TCP1(name, type1, arg1) \
- DTRACE_PROBE1(__tcp_##name, type1, arg1);
-
-#define DTRACE_TCP2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__tcp_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__tcp_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_TCP4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__tcp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_TCP5(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5) \
- DTRACE_PROBE5(__tcp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5);
-
-#define DTRACE_TCP6(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
- DTRACE_PROBE6(__tcp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6);
-
-#define DTRACE_UDP(name) \
- DTRACE_PROBE(__udp_##name);
-
-#define DTRACE_UDP1(name, type1, arg1) \
- DTRACE_PROBE1(__udp_##name, type1, arg1);
-
-#define DTRACE_UDP2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__udp_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_UDP3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__udp_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_UDP4(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__udp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
-
-#define DTRACE_UDP5(name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5) \
- DTRACE_PROBE5(__udp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5);
-
-
-#define DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_XPV(name) \
- DTRACE_PROBE(__xpv_##name);
-
-#define DTRACE_XPV1(name, type1, arg1) \
- DTRACE_PROBE1(__xpv_##name, type1, arg1);
-
-#define DTRACE_XPV2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2);
-
-#define DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3);
-
-#define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4) \
- DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
+#define DTRACE_SCHED(name, ...) \
+ DTRACE_PROBE(__sched_##name, ## __VA_ARGS__);
-#define DTRACE_FC_1(name, type1, arg1) \
- DTRACE_PROBE1(__fc_##name, type1, arg1);
+#define DTRACE_PROC(name, ...) \
+ DTRACE_PROBE(__proc_##name, ## __VA_ARGS__);
-#define DTRACE_FC_2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__fc_##name, type1, arg1, type2, arg2);
+#define DTRACE_IO(name, ...) \
+ DTRACE_PROBE(__io_##name, ## __VA_ARGS__);
-#define DTRACE_FC_3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__fc_##name, type1, arg1, type2, arg2, type3, arg3);
+#define DTRACE_ISCSI(name, ...) \
+ DTRACE_PROBE(__iscsi_##name, ## __VA_ARGS__);
-#define DTRACE_FC_4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \
- DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4);
+#define DTRACE_NFSV3(name, ...) \
+ DTRACE_PROBE(__nfsv3_##name, ## __VA_ARGS__);
-#define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5) \
- DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5);
+#define DTRACE_NFSV4(name, ...) \
+ DTRACE_PROBE(__nfsv4_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_1(name, type1, arg1) \
- DTRACE_PROBE1(__srp_##name, type1, arg1);
+#define DTRACE_SMB(name, ...) \
+ DTRACE_PROBE(__smb_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_2(name, type1, arg1, type2, arg2) \
- DTRACE_PROBE2(__srp_##name, type1, arg1, type2, arg2);
+#define DTRACE_IP(name, ...) \
+ DTRACE_PROBE(__ip_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_3(name, type1, arg1, type2, arg2, type3, arg3) \
- DTRACE_PROBE3(__srp_##name, type1, arg1, type2, arg2, type3, arg3);
+#define DTRACE_TCP(name, ...) \
+ DTRACE_PROBE(__tcp_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4) \
- DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4);
+#define DTRACE_UDP(name, ...) \
+ DTRACE_PROBE(__udp_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5) \
- DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5);
+#define DTRACE_SYSEVENT(name, ...) \
+ DTRACE_PROBE(__sysevent_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6) \
- DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6);
+#define DTRACE_XPV(name, ...) \
+ DTRACE_PROBE(__xpv_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
- DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7);
+#define DTRACE_FC(name, ...) \
+ DTRACE_PROBE(__fc_##name, ## __VA_ARGS__);
-#define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \
- type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \
- DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \
- type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
- type7, arg7, type8, arg8);
+#define DTRACE_SRP(name, ...) \
+ DTRACE_PROBE(__srp_##name, ## __VA_ARGS__);
#endif /* _LINUX_SDT_H_ */
--- /dev/null
+/*
+ * Hide away all the terrible macro magic.
+ *
+ * Copyright (C) 2016 Oracle, Inc.
+ */
+
+#ifndef _LINUX_SDT_INTERNAL_H_
+#define _LINUX_SDT_INTERNAL_H_
+
+/*
+ * This counts the number of args.
+ */
+#define __DTRACE_NARGS_SEQ(dummy,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,N,...) N
+#define __DTRACE_NARGS(...) \
+ __DTRACE_NARGS_SEQ(dummy, ##__VA_ARGS__, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+
+/*
+ * This will let macros expand before concatting them.
+ */
+#define __DTRACE_PRIMITIVE_CAT(x, y) x ## y
+#define __DTRACE_CAT(x, y) __DTRACE_PRIMITIVE_CAT(x, y)
+
+#define __DTRACE_COMMA ,
+#define __DTRACE_NO_COMMA
+#define __DTRACE_NONE(x)
+
+/*
+ * This will call two macros on each argument-pair passed in (the first two args
+ * are the names of the macros to call). Its TYPE and NAME variants will throw
+ * away the name and type arguments, respectively. __DTRACE_*_APPLY_NOCOMMA
+ * are like DTRACE_*_APPLY, but also omit the comma between arguments in the
+ * expansion of the macro. DTRACE_TYPE_APPLY_DEFAULT lets you specify a default
+ * if no variadic args are provided.
+ */
+#define __DTRACE_DOUBLE_APPLY(type_macro, arg_macro, ...) \
+ __DTRACE_CAT(__DTRACE_DOUBLE_APPLY_, \
+ __DTRACE_NARGS(__VA_ARGS__))(type_macro, \
+ arg_macro, __DTRACE_COMMA, \
+ __DTRACE_COMMA, , ## __VA_ARGS__)
+#define __DTRACE_DOUBLE_APPLY_NOCOMMA(type_macro, arg_macro, ...) \
+ __DTRACE_CAT(__DTRACE_DOUBLE_APPLY_, \
+ __DTRACE_NARGS(__VA_ARGS__))(type_macro, \
+ arg_macro, __DTRACE_NO_COMMA, \
+ __DTRACE_NO_COMMA, , ## __VA_ARGS__)
+#define __DTRACE_TYPE_APPLY(type_macro, ...) \
+ __DTRACE_CAT(__DTRACE_DOUBLE_APPLY_, \
+ __DTRACE_NARGS(__VA_ARGS__))(type_macro, \
+ __DTRACE_NONE, __DTRACE_NO_COMMA, \
+ __DTRACE_COMMA, , ## __VA_ARGS__)
+#define __DTRACE_TYPE_APPLY_NOCOMMA(type_macro, ...) \
+ __DTRACE_CAT(__DTRACE_DOUBLE_APPLY_, \
+ __DTRACE_NARGS(__VA_ARGS__))(type_macro, \
+ __DTRACE_NONE, __DTRACE_NO_COMMA, \
+ __DTRACE_NO_COMMA, , ## __VA_ARGS__)
+#define __DTRACE_TYPE_APPLY_DEFAULT(type_macro, def, ...) \
+ __DTRACE_CAT(__DTRACE_DOUBLE_APPLY_, \
+ __DTRACE_NARGS(__VA_ARGS__))(type_macro, \
+ __DTRACE_NONE, __DTRACE_NO_COMMA, \
+ __DTRACE_COMMA, def, ## __VA_ARGS__)
+#define __DTRACE_ARG_APPLY(arg_macro, ...) \
+ __DTRACE_CAT(__DTRACE_DOUBLE_APPLY_, \
+ __DTRACE_NARGS(__VA_ARGS__))(__DTRACE_NONE, \
+ arg_macro, __DTRACE_NO_COMMA, \
+ __DTRACE_COMMA, , ## __VA_ARGS__)
+#define __DTRACE_DOUBLE_APPLY_0(t, a, comma_t, comma_a, def) def
+#define __DTRACE_DOUBLE_APPLY_2(t, a, comma_t, comma_a, def, type1, arg1) \
+ t(type1) comma_t a(arg1)
+#define __DTRACE_DOUBLE_APPLY_4(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2)
+#define __DTRACE_DOUBLE_APPLY_6(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2, type3, arg3) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2) comma_a \
+ t(type3) comma_t a(arg3)
+#define __DTRACE_DOUBLE_APPLY_8(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2) comma_a \
+ t(type3) comma_t a(arg3) comma_a t(type4) comma_t a(arg4)
+#define __DTRACE_DOUBLE_APPLY_10(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2) comma_a \
+ t(type3) comma_t a(arg3) comma_a t(type4) comma_t a(arg4) comma_a \
+ t(type5) comma_t a(arg5)
+#define __DTRACE_DOUBLE_APPLY_12(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2) comma_a \
+ t(type3) comma_t a(arg3) comma_a t(type4) comma_t a(arg4) comma_a \
+ t(type5) comma_t a(arg5) comma_a t(type6) comma_t a(arg6)
+#define __DTRACE_DOUBLE_APPLY_14(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2) comma_a \
+ t(type3) comma_t a(arg3) comma_a t(type4) comma_t a(arg4) comma_a \
+ t(type5) comma_t a(arg5) comma_a t(type6) comma_t a(arg6) comma_a \
+ t(type7) comma_t a(arg7)
+#define __DTRACE_DOUBLE_APPLY_16(t, a, comma_t, comma_a, def, type1, arg1, type2, arg2, type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \
+ t(type1) comma_t a(arg1) comma_a t(type2) comma_t a(arg2) comma_a \
+ t(type3) comma_t a(arg3) comma_a t(type4) comma_t a(arg4) comma_a \
+ t(type5) comma_t a(arg5) comma_a t(type6) comma_t a(arg6) comma_a \
+ t(type7) comma_t a(arg7) comma_a t(type8) comma_t a(arg8)
+
+#define __DTRACE_DOUBLE_APPLY_ERROR Error: type specified without arg.
+#define __DTRACE_DOUBLE_APPLY_1 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_3 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_5 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_7 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_9 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_11 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_13 __DTRACE_DOUBLE_APPLY_ERROR
+#define __DTRACE_DOUBLE_APPLY_15 __DTRACE_DOUBLE_APPLY_ERROR
+
+#define __DTRACE_UINTPTR_EACH(x) uintptr_t
+
+#define __DTRACE_UINTCAST_EACH(x) (uintptr_t)(x)
+#define __DTRACE_TYPE_EACH(x) ".ascii \"" __stringify(x) ",\"\n"
+
+/*
+ * Convert everything to the appropriate integral type, unless too large to fit
+ * into any of them, in which case its address is taken instead.
+ */
+
+/*
+ * This will call a macro on each argument passed in, with optional default for
+ * zero args.
+ */
+#define __DTRACE_APPLY(macro, ...) __DTRACE_CAT(__DTRACE_APPLY_, __DTRACE_NARGS(__VA_ARGS__))(macro, , ## __VA_ARGS__)
+#define __DTRACE_APPLY_DEFAULT(macro, def, ...) __DTRACE_CAT(__DTRACE_APPLY_, __DTRACE_NARGS(__VA_ARGS__))(macro, def, ## __VA_ARGS__)
+#define __DTRACE_APPLY_0(m, def) def
+#define __DTRACE_APPLY_1(m, def, x1) m(x1)
+#define __DTRACE_APPLY_2(m, def, x1, x2) m(x1), m(x2)
+#define __DTRACE_APPLY_3(m, def, x1, x2, x3) m(x1), m(x2), m(x3)
+#define __DTRACE_APPLY_4(m, def, x1, x2, x3, x4) m(x1), m(x2), m(x3), m(x4)
+#define __DTRACE_APPLY_5(m, def, x1, x2, x3, x4, x5) m(x1), m(x2), m(x3), m(x4), m(x5)
+#define __DTRACE_APPLY_6(m, def, x1, x2, x3, x4, x5, x6) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6)
+#define __DTRACE_APPLY_7(m, def, x1, x2, x3, x4, x5, x6, x7) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7)
+#define __DTRACE_APPLY_8(m, def, x1, x2, x3, x4, x5, x6, x7, x8) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+
+/*
+ * DTrace probe args currently top out at 8, but this is purely
+ * arbitrary. However, there are existing perf tracepoints that pass as many as
+ * 18 arguments, so we must extend APPLY that far.
+ */
+
+#define __DTRACE_APPLY_9(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_10(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_11(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_12(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_13(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_14(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_15(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_16(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_17(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+#define __DTRACE_APPLY_18(m, def, x1, x2, x3, x4, x5, x6, x7, x8, ...) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
+
+#endif /* _LINUX_SDT_INTERNAL_H */