• S
    tracing: Create new TRACE_EVENT_TEMPLATE · ff038f5c
    Steven Rostedt 提交于
    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: NChristoph Hellwig <hch@lst.de>
    Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
    ff038f5c
tracepoint.h 8.8 KB