2009-04-10 13:36:00 +00:00
|
|
|
/*
|
2012-09-01 17:31:09 +00:00
|
|
|
* Trace files that want to automate creation of all tracepoints defined
|
2009-04-10 13:36:00 +00:00
|
|
|
* in their file should include this file. The following are macros that the
|
|
|
|
* trace file may define:
|
|
|
|
*
|
|
|
|
* TRACE_SYSTEM defines the system the tracepoint is for
|
|
|
|
*
|
|
|
|
* TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h
|
|
|
|
* This macro may be defined to tell define_trace.h what file to include.
|
|
|
|
* Note, leave off the ".h".
|
|
|
|
*
|
|
|
|
* TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace
|
|
|
|
* then this macro can define the path to use. Note, the path is relative to
|
|
|
|
* define_trace.h, not the file including it. Full path names for out of tree
|
|
|
|
* modules must be used.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CREATE_TRACE_POINTS
|
|
|
|
|
|
|
|
/* Prevent recursion */
|
|
|
|
#undef CREATE_TRACE_POINTS
|
|
|
|
|
|
|
|
#include <linux/stringify.h>
|
|
|
|
|
|
|
|
#undef TRACE_EVENT
|
|
|
|
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
2010-12-02 21:46:18 +00:00
|
|
|
#undef TRACE_EVENT_CONDITION
|
|
|
|
#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
|
|
|
|
TRACE_EVENT(name, \
|
|
|
|
PARAMS(proto), \
|
|
|
|
PARAMS(args), \
|
|
|
|
PARAMS(tstruct), \
|
|
|
|
PARAMS(assign), \
|
|
|
|
PARAMS(print))
|
|
|
|
|
2009-08-24 21:43:13 +00:00
|
|
|
#undef TRACE_EVENT_FN
|
|
|
|
#define TRACE_EVENT_FN(name, proto, args, tstruct, \
|
|
|
|
assign, print, reg, unreg) \
|
|
|
|
DEFINE_TRACE_FN(name, reg, unreg)
|
|
|
|
|
tracing: Create new TRACE_EVENT_TEMPLATE
There are some places in the kernel that define several tracepoints and
they are all identical besides the name. The code to enable, disable and
record is created for every trace point even if most of the code is
identical.
This patch adds TRACE_EVENT_TEMPLATE that lets the developer create
a template TRACE_EVENT and create trace points with DEFINE_EVENT, which
is based off of a given template. Each trace point used by this
will share most of the code, and bring down the size of the kernel
when there are several duplicate events.
Usage is:
TRACE_EVENT_TEMPLATE(name, proto, args, tstruct, assign, print);
Which would be the same as defining a normal TRACE_EVENT.
To create the trace events that the trace points will use:
DEFINE_EVENT(template, name, proto, args) is done. The template
is the name of the TRACE_EVENT_TEMPLATE to use. The name is the
name of the trace point. The parameters proto and args must be the same
as the proto and args of the template. If they are not the same,
then a compile error will result. I tried hard removing this duplication
but the C preprocessor is not powerful enough (or my CPP magic
experience points is not at a high enough level) to not need them.
A lot of trace events are coming in with new XFS development. Most of
the trace points are identical except for the name. The following shows
the advantage of having TRACE_EVENT_TEMPLATE:
$ size fs/xfs/xfs.o.*
text data bss dec hex filename
452114 2788 3520 458422 6feb6 fs/xfs/xfs.o.old
638482 38116 3744 680342 a6196 fs/xfs/xfs.o.template
996954 38116 4480 1039550 fdcbe fs/xfs/xfs.o.trace
xfs.o.old is without any tracepoints.
xfs.o.template uses the new TRACE_EVENT_TEMPLATE.
xfs.o.trace uses the current TRACE_EVENT macros.
Requested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2009-11-19 01:27:27 +00:00
|
|
|
#undef DEFINE_EVENT
|
|
|
|
#define DEFINE_EVENT(template, name, proto, args) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
2013-06-20 15:44:44 +00:00
|
|
|
#undef DEFINE_EVENT_FN
|
|
|
|
#define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
|
|
|
|
DEFINE_TRACE_FN(name, reg, unreg)
|
|
|
|
|
2009-11-19 01:36:26 +00:00
|
|
|
#undef DEFINE_EVENT_PRINT
|
|
|
|
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
2010-12-02 21:46:18 +00:00
|
|
|
#undef DEFINE_EVENT_CONDITION
|
|
|
|
#define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
|
|
|
|
DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
|
|
|
|
|
2009-04-10 13:36:00 +00:00
|
|
|
#undef DECLARE_TRACE
|
|
|
|
#define DECLARE_TRACE(name, proto, args) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
|
|
|
#undef TRACE_INCLUDE
|
|
|
|
#undef __TRACE_INCLUDE
|
|
|
|
|
|
|
|
#ifndef TRACE_INCLUDE_FILE
|
|
|
|
# define TRACE_INCLUDE_FILE TRACE_SYSTEM
|
|
|
|
# define UNDEF_TRACE_INCLUDE_FILE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef TRACE_INCLUDE_PATH
|
2009-04-14 23:39:12 +00:00
|
|
|
# define __TRACE_INCLUDE(system) <trace/events/system.h>
|
2009-04-24 03:26:18 +00:00
|
|
|
# define UNDEF_TRACE_INCLUDE_PATH
|
2009-04-10 13:36:00 +00:00
|
|
|
#else
|
|
|
|
# define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
# define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
|
|
|
|
|
|
|
|
/* Let the trace headers be reread */
|
|
|
|
#define TRACE_HEADER_MULTI_READ
|
|
|
|
|
|
|
|
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
|
|
|
|
|
2010-05-05 14:52:31 +00:00
|
|
|
/* Make all open coded DECLARE_TRACE nops */
|
|
|
|
#undef DECLARE_TRACE
|
|
|
|
#define DECLARE_TRACE(name, proto, args)
|
|
|
|
|
2009-04-17 17:02:22 +00:00
|
|
|
#ifdef CONFIG_EVENT_TRACING
|
2009-04-13 16:25:37 +00:00
|
|
|
#include <trace/ftrace.h>
|
|
|
|
#endif
|
|
|
|
|
2009-08-25 06:06:22 +00:00
|
|
|
#undef TRACE_EVENT
|
2009-08-27 16:17:34 +00:00
|
|
|
#undef TRACE_EVENT_FN
|
2010-12-02 21:46:18 +00:00
|
|
|
#undef TRACE_EVENT_CONDITION
|
2009-11-26 08:04:55 +00:00
|
|
|
#undef DECLARE_EVENT_CLASS
|
tracing: Create new TRACE_EVENT_TEMPLATE
There are some places in the kernel that define several tracepoints and
they are all identical besides the name. The code to enable, disable and
record is created for every trace point even if most of the code is
identical.
This patch adds TRACE_EVENT_TEMPLATE that lets the developer create
a template TRACE_EVENT and create trace points with DEFINE_EVENT, which
is based off of a given template. Each trace point used by this
will share most of the code, and bring down the size of the kernel
when there are several duplicate events.
Usage is:
TRACE_EVENT_TEMPLATE(name, proto, args, tstruct, assign, print);
Which would be the same as defining a normal TRACE_EVENT.
To create the trace events that the trace points will use:
DEFINE_EVENT(template, name, proto, args) is done. The template
is the name of the TRACE_EVENT_TEMPLATE to use. The name is the
name of the trace point. The parameters proto and args must be the same
as the proto and args of the template. If they are not the same,
then a compile error will result. I tried hard removing this duplication
but the C preprocessor is not powerful enough (or my CPP magic
experience points is not at a high enough level) to not need them.
A lot of trace events are coming in with new XFS development. Most of
the trace points are identical except for the name. The following shows
the advantage of having TRACE_EVENT_TEMPLATE:
$ size fs/xfs/xfs.o.*
text data bss dec hex filename
452114 2788 3520 458422 6feb6 fs/xfs/xfs.o.old
638482 38116 3744 680342 a6196 fs/xfs/xfs.o.template
996954 38116 4480 1039550 fdcbe fs/xfs/xfs.o.trace
xfs.o.old is without any tracepoints.
xfs.o.template uses the new TRACE_EVENT_TEMPLATE.
xfs.o.trace uses the current TRACE_EVENT macros.
Requested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2009-11-19 01:27:27 +00:00
|
|
|
#undef DEFINE_EVENT
|
2013-06-20 15:44:44 +00:00
|
|
|
#undef DEFINE_EVENT_FN
|
2009-11-19 01:36:26 +00:00
|
|
|
#undef DEFINE_EVENT_PRINT
|
2010-12-02 21:46:18 +00:00
|
|
|
#undef DEFINE_EVENT_CONDITION
|
2009-04-10 13:36:00 +00:00
|
|
|
#undef TRACE_HEADER_MULTI_READ
|
2010-05-05 14:52:31 +00:00
|
|
|
#undef DECLARE_TRACE
|
2009-04-10 13:36:00 +00:00
|
|
|
|
|
|
|
/* Only undef what we defined in this file */
|
|
|
|
#ifdef UNDEF_TRACE_INCLUDE_FILE
|
2009-04-24 03:26:18 +00:00
|
|
|
# undef TRACE_INCLUDE_FILE
|
2009-04-10 13:36:00 +00:00
|
|
|
# undef UNDEF_TRACE_INCLUDE_FILE
|
|
|
|
#endif
|
|
|
|
|
2009-04-24 03:26:18 +00:00
|
|
|
#ifdef UNDEF_TRACE_INCLUDE_PATH
|
2009-04-10 13:36:00 +00:00
|
|
|
# undef TRACE_INCLUDE_PATH
|
2009-04-24 03:26:18 +00:00
|
|
|
# undef UNDEF_TRACE_INCLUDE_PATH
|
2009-04-10 13:36:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We may be processing more files */
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
|
|
|
|
|
|
#endif /* CREATE_TRACE_POINTS */
|