]> www.infradead.org Git - users/jedix/linux-maple.git/commit
dtrace: eliminate need for arg counting in sdt macros
authorNick Alcock <nick.alcock@oracle.com>
Fri, 16 Sep 2016 09:17:18 +0000 (10:17 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 28 Oct 2016 12:45:45 +0000 (13:45 +0100)
commit1932a5e746c4d36a7d887a447af36537eba9fe74
tree828a27a8532dd49d7e4c40bda31f098be6aa04f5
parentba0174a4b14de9c5d14214b2cab72d4d8d44174a
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
fs/buffer.c
fs/exec.c
include/linux/sdt.h
include/linux/sdt_internal.h [new file with mode: 0644]
kernel/dtrace/dtrace_os.c
kernel/exit.c
kernel/fork.c
kernel/sched/core.c
kernel/signal.c
kernel/time/timer.c