dtrace: eliminate need for arg counting in sdt macros
The existing SDT probe macros are of the form
DTRACE_PROBEn(probe, ...)
where there must be as many args in ... as the 'n'.
This is implemented via terribly repetitive code in include/linux/sdt.h,
made much worse by the recent typed sdt additions. Reduce
repetitiveness, and drop the 'n' variants of the macros.
All the complexity is hidden away in include/linux/sdt_internal.h.
It's derived from the tricks the perf probes were already using, but
improved to handle the zero-argument case and armoured against namespace
pollution with copious __ing. Even when DTrace is turned off, we use a
do-nothing form of the same macro to verify that the number of arguments
in the probe is valid.
There is only one public macro now, DTRACE_PROBE(), and the usual thin
wrappers around it, which have also gone non-numbered (DTRACE_PROC,
DTRACE_IO, etc): all uses have been adjusted.
These macros use a family of semi-public macros, described below.
__DTRACE_DOUBLE_APPLY(type_macro, arg_macro, ...): This takes a type and
arg macro and a set of pairs of arguments and calls the first argument
on each pair with the type macro, the second with the arg macro, etc:
if called with (type, arg, a, b, c, d) it will expand to something like
type(a), arg(b), type(c), arg(d)
__DTRACE_DOUBLE_APPLY_NOCOMMA(type_macro, arg_macro, ...): As above, but
omits all commas between arguments: the example above will yield
type(a) arg(b) type(c) arg(d)
(suitable for string concatenation).
__DTRACE_TYPE_APPLY(type_macro, arg_macro, ...): as above, but only
calls the type_macro:
type(a), type(c)
__DTRACE_ARG_APPLY(type_macro, arg_macro, ...): as above, but only
calls the arg_macro:
arg(b), arg(d)
__DTRACE_TYPE_APPLY_DEFAULT(type_macro, arg_macro, def, ...): as above,
but takes an extra parameter to be used as a default when there are no
args. Calling it with (type, arg, void, a, b, c, d) will yield
type(a), arg(b), type(c), arg(d)
but calling it with (type, arg, void) will yield
void
All the macros above take any number of pairs of arguments up to eight:
providing any other number, including odd numbers, is a compilation
error.
__DTRACE_APPLY(macro, ...): This is pre-existing, and calls the macro
repeatedly with the specified args, comma-separated:
m(a), m(b), m(c), ...
__DTRACE_APPLY_DEFAULT(macro, def, ...): Like DTRACE_TYPE_APPLY_DEFAULT,
takes a default for use when there are no args.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Acked-by: Kris Van Hees <kris.van.hees@oracle.com>
Orabug:
24678897