2009-04-10 15:36:00 +02:00
|
|
|
/*
|
|
|
|
* Trace files that want to automate creationg of all tracepoints defined
|
|
|
|
* 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>
|
2011-01-07 21:40:10 +01:00
|
|
|
/*
|
|
|
|
* module.h includes tracepoints, and because ftrace.h
|
|
|
|
* pulls in module.h:
|
|
|
|
* trace/ftrace.h -> linux/ftrace_event.h -> linux/perf_event.h ->
|
|
|
|
* linux/ftrace.h -> linux/module.h
|
|
|
|
* we must include module.h here before we play with any of
|
|
|
|
* the TRACE_EVENT() macros, otherwise the tracepoints included
|
|
|
|
* by module.h may break the build.
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
2009-04-10 15:36:00 +02:00
|
|
|
|
|
|
|
#undef TRACE_EVENT
|
|
|
|
#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
2010-12-02 22:46:18 +01: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 23:43:13 +02: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 02:27:27 +01:00
|
|
|
#undef DEFINE_EVENT
|
|
|
|
#define DEFINE_EVENT(template, name, proto, args) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
2009-11-19 02:36:26 +01:00
|
|
|
#undef DEFINE_EVENT_PRINT
|
|
|
|
#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
|
|
|
|
DEFINE_TRACE(name)
|
|
|
|
|
2010-12-02 22:46:18 +01: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 15:36:00 +02: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-15 01:39:12 +02:00
|
|
|
# define __TRACE_INCLUDE(system) <trace/events/system.h>
|
2009-04-24 05:26:18 +02:00
|
|
|
# define UNDEF_TRACE_INCLUDE_PATH
|
2009-04-10 15:36:00 +02: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 16:52:31 +02:00
|
|
|
/* Make all open coded DECLARE_TRACE nops */
|
|
|
|
#undef DECLARE_TRACE
|
|
|
|
#define DECLARE_TRACE(name, proto, args)
|
|
|
|
|
2009-04-17 19:02:22 +02:00
|
|
|
#ifdef CONFIG_EVENT_TRACING
|
2009-04-13 18:25:37 +02:00
|
|
|
#include <trace/ftrace.h>
|
|
|
|
#endif
|
|
|
|
|
2009-08-25 08:06:22 +02:00
|
|
|
#undef TRACE_EVENT
|
2009-08-27 18:17:34 +02:00
|
|
|
#undef TRACE_EVENT_FN
|
2010-12-02 22:46:18 +01:00
|
|
|
#undef TRACE_EVENT_CONDITION
|
2009-11-26 09:04:55 +01: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 02:27:27 +01:00
|
|
|
#undef DEFINE_EVENT
|
2009-11-19 02:36:26 +01:00
|
|
|
#undef DEFINE_EVENT_PRINT
|
2010-12-02 22:46:18 +01:00
|
|
|
#undef DEFINE_EVENT_CONDITION
|
2009-04-10 15:36:00 +02:00
|
|
|
#undef TRACE_HEADER_MULTI_READ
|
2010-05-05 16:52:31 +02:00
|
|
|
#undef DECLARE_TRACE
|
2009-04-10 15:36:00 +02:00
|
|
|
|
|
|
|
/* Only undef what we defined in this file */
|
|
|
|
#ifdef UNDEF_TRACE_INCLUDE_FILE
|
2009-04-24 05:26:18 +02:00
|
|
|
# undef TRACE_INCLUDE_FILE
|
2009-04-10 15:36:00 +02:00
|
|
|
# undef UNDEF_TRACE_INCLUDE_FILE
|
|
|
|
#endif
|
|
|
|
|
2009-04-24 05:26:18 +02:00
|
|
|
#ifdef UNDEF_TRACE_INCLUDE_PATH
|
2009-04-10 15:36:00 +02:00
|
|
|
# undef TRACE_INCLUDE_PATH
|
2009-04-24 05:26:18 +02:00
|
|
|
# undef UNDEF_TRACE_INCLUDE_PATH
|
2009-04-10 15:36:00 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We may be processing more files */
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
|
|
|
|
|
|
#endif /* CREATE_TRACE_POINTS */
|