1. 21 Jun, 2013 1 commit
    • Steven Rostedt's avatar
      tracing: Add DEFINE_EVENT_FN() macro · f5abaa1b
      Steven Rostedt authored
      Each TRACE_EVENT() adds several helper functions. If two or more trace events
      share the same structure and print format, they can also share most of these
      helper functions and save a lot of space from duplicate code. This is why the
      DECLARE_EVENT_CLASS() and DEFINE_EVENT() were created.
      Some events require a trigger to be called at registering and unregistering of
      the event and to do so they use TRACE_EVENT_FN().
      If multiple events require a trigger, they currently have no choice but to use
      TRACE_EVENT_FN() as there's no DEFINE_EVENT_FN() available. This unfortunately
      causes a lot of wasted duplicate code created.
      By adding a DEFINE_EVENT_FN(), these events can still use a
      DECLARE_EVENT_CLASS() and then define their own triggers.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/51C3236C.8030508@hds.com
      Signed-off-by: default avatarSeiji Aguchi <seiji.aguchi@hds.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
  2. 01 Sep, 2012 1 commit
  3. 31 Oct, 2011 1 commit
  4. 07 Jan, 2011 1 commit
  5. 03 Dec, 2010 1 commit
    • Steven Rostedt's avatar
      tracing: Add TRACE_EVENT_CONDITIONAL() · 287050d3
      Steven Rostedt authored
      There are instances in the kernel that we only want to trace
      a tracepoint when a certain condition is set. But we do not
      want to test for that condition in the core kernel.
      If we test for that condition before calling the tracepoin, then
      we will be performing that test even when tracing is not enabled.
      This is 99.99% of the time.
      We currently can just filter out on that condition, but that happens
      after we write to the trace buffer. We just wasted time writing to
      the ring buffer for an event we never cared about.
      This patch adds:
      These have a new TP_CONDITION() argument that comes right after
      the TP_ARGS().  This condition can use the parameters of TP_ARGS()
      in the TRACE_EVENT() to determine if the tracepoint should be traced
      or not. The TP_CONDITION() will be placed in a if (cond) trace;
      For example, for the tracepoint sched_wakeup, it is useless to
      trace a wakeup event where the caller never actually wakes
      anything up (where success == 0). So adding:
      which uses the "success" parameter of the wakeup tracepoint
      will have it only trace when we have successfully woken up a
      Acked-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Arjan van de Ven <arjan@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
  6. 05 May, 2010 1 commit
    • Steven Rostedt's avatar
      tracing: Fix tracepoint.h DECLARE_TRACE() to allow more than one header · 2e26ca71
      Steven Rostedt authored
      When more than one header is included under CREATE_TRACE_POINTS
      the DECLARE_TRACE() macro is not defined back to its original meaning
      and the second include will fail to initialize the TRACE_EVENT()
      and DECLARE_TRACE() correctly.
      To fix this the tracepoint.h file moves the define of DECLARE_TRACE()
      out of the #ifdef _LINUX_TRACEPOINT_H protection (just like the
      define of the TRACE_EVENT()). This way the define_trace.h will undef
      the DECLARE_TRACE() at the end and allow new headers to start
      from scratch.
      This patch also requires fixing the include/events/napi.h
      It currently uses DECLARE_TRACE() and should be converted to a TRACE_EVENT()
      format. But I'll leave that change to the authors of that file.
      But since the napi.h file depends on using the CREATE_TRACE_POINTS
      and does not define its own DEFINE_TRACE() it must use the define_trace.h
      method instead.
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
  7. 26 Nov, 2009 1 commit
    • Ingo Molnar's avatar
      events: Rename TRACE_EVENT_TEMPLATE() to DECLARE_EVENT_CLASS() · 091ad365
      Ingo Molnar authored
      It is not quite obvious at first sight what TRACE_EVENT_TEMPLATE
      does: does it define an event as well beyond defining a template?
      To clarify this, rename it to DECLARE_EVENT_CLASS, which follows
      the various 'DECLARE_*()' idioms we already have in the kernel:
          DEFINE_EVENT(class, event1)
          DEFINE_EVENT(class, event2)
          DEFINE_EVENT(class, event3)
      To complete this logic we should also rename TRACE_EVENT() to:
      ... but in a more quiet moment of the kernel cycle.
      Cc: Pekka Enberg <penberg@cs.helsinki.fi>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <4B0E286A.2000405@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
  8. 24 Nov, 2009 2 commits
    • Steven Rostedt's avatar
      tracing: Create new DEFINE_EVENT_PRINT · e5bc9721
      Steven Rostedt authored
      After creating the TRACE_EVENT_TEMPLATE I started to look at other
      trace points to see what duplication was made. I noticed that there
      are several trace points where they are almost identical except for
      the name and the output format. Since TRACE_EVENT_TEMPLATE was successful
      in bringing down the size of trace events, I added a DEFINE_EVENT_PRINT.
      DEFINE_EVENT_PRINT is used just like DEFINE_EVENT is. That is, the
      DEFINE_EVENT_PRINT also uses a TRACE_EVENT_TEMPLATE, but it allows the
      developer to overwrite the print format. If there are two or more
      TRACE_EVENTS that are identical except for the name and print, then
      they can be converted to use a TRACE_EVENT_TEMPLATE. Since the
      TRACE_EVENT_TEMPLATE already does the print output, the first trace event
      would have its print format held in the TRACE_EVENT_TEMPLATE and
      be defined with a DEFINE_EVENT. The rest will use the DEFINE_EVENT_PRINT
      and override the print format.
      Converting the sched trace points to both DEFINE_EVENT and
      DEFINE_EVENT_PRINT. Five were converted to DEFINE_EVENT and two were
      converted to DEFINE_EVENT_PRINT.
      I was able to get the following:
      $ size kernel/sched.o-*
         text	   data	    bss	    dec	    hex	filename
        79299	   6776	   2520	  88595	  15a13	kernel/sched.o-notrace
       101941	  11896	   2584	 116421	  1c6c5	kernel/sched.o-templ
       104779	  11896	   2584	 119259	  1d1db	kernel/sched.o-trace
      sched.o-notrace is the scheduler compiled with no trace points.
      sched.o-templ is with the use of DEFINE_EVENT and DEFINE_EVENT_PRINT
      sched.o-trace is the current trace events.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    • Steven Rostedt's avatar
      tracing: Create new TRACE_EVENT_TEMPLATE · ff038f5c
      Steven Rostedt authored
      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
      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: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
  9. 27 Aug, 2009 1 commit
    • Frederic Weisbecker's avatar
      tracing: Undef TRACE_EVENT_FN between trace events headers inclusion · 6c347d43
      Frederic Weisbecker authored
      The recent commit:
      	tracing/events: fix the include file dependencies
      fixed a file dependency problem while including more than
      one trace event header file.
      This fix undefined TRACE_EVENT after an event header macro
      preprocessing in order to make tracepoint.h able to correctly declare
      the tracepoints necessary for the next event header file.
      But now we also need to undefine TRACE_EVENT_FN at the end of an event
      header file preprocessing for the same reason.
      This fixes the following build error:
      In file included from include/trace/events/napi.h:5,
                       from net/core/net-traces.c:28:
      include/linux/tracepoint.h:285:1: warning: "TRACE_EVENT_FN" redefined
      In file included from include/trace/define_trace.h:61,
                       from include/trace/events/skb.h:40,
                       from net/core/net-traces.c:27:
      include/trace/ftrace.h:50:1: warning: this is the location of the previous definition
      In file included from include/trace/events/napi.h:5,
                       from net/core/net-traces.c:28:
      include/linux/tracepoint.h:285:1: warning: "TRACE_EVENT_FN" redefined
      In file included from include/trace/define_trace.h:61,
                       from include/trace/events/skb.h:40,
                       from net/core/net-traces.c:27:
      include/trace/ftrace.h:50:1: warning: this is the location of the previous definition
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Masami Hiramatsu <mhiramat@redhat.com>
      Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Li Zefan <lizf@cn.fujitsu.com>
      LKML-Reference: <20090827161732.GA7618@nowhere>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
  10. 26 Aug, 2009 1 commit
  11. 25 Aug, 2009 1 commit
    • Josh Stone's avatar
      tracing: Move tracepoint callbacks from declaration to definition · 97419875
      Josh Stone authored
      It's not strictly correct for the tracepoint reg/unreg callbacks to
      occur when a client is hooking up, because the actual tracepoint may not
      be present yet.  This happens to be fine for syscall, since that's in
      the core kernel, but it would cause problems for tracepoints defined in
      a module that hasn't been loaded yet.  It also means the reg/unreg has
      to be EXPORTed for any modules to use the tracepoint (as in SystemTap).
      This patch removes DECLARE_TRACE_WITH_CALLBACK, and instead introduces
      DEFINE_TRACE_FN which stores the callbacks in struct tracepoint.  The
      callbacks are used now when the active state of the tracepoint changes
      in set_tracepoint & disable_tracepoint.
      This also introduces TRACE_EVENT_FN, so ftrace events can also provide
      registration callbacks if needed.
      Signed-off-by: default avatarJosh Stone <jistone@redhat.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Cc: Jiaying Zhang <jiayingz@google.com>
      Cc: Martin Bligh <mbligh@google.com>
      Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      LKML-Reference: <1251150194-1713-4-git-send-email-jistone@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
  12. 24 Apr, 2009 2 commits
    • Steven Rostedt's avatar
      tracing: remove deprecated TRACE_FORMAT · b8e65554
      Steven Rostedt authored
      The TRACE_FORMAT macro has been deprecated by the TRACE_EVENT macro.
      There are no more users. All new users must use the TRACE_EVENT macro.
      [ Impact: remove old functionality ]
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    • Steven Rostedt's avatar
      tracing: fix cut and paste macro error · c2518c43
      Steven Rostedt authored
      In case a module uses the TRACE_EVENT macro for creating automated
      events in ftrace, it may choose to use a different file name
      than the defined system name, or choose to use a different path than
      the default "include/trace/events" include path.
      If this is done, then before including trace/define_trace.h the
      header would define either "TRACE_INCLUDE_FILE" for the file
      name or "TRACE_INCLUDE_PATH" for the include path.
      If it does not define these, then the define_trace.h defines them
      instead. If define trace defines them, then define_trace.h should
      also undefine them before exiting. To do this a macro is used
      to note this:
       #ifndef TRACE_INCLUDE_FILE
       # undef TRACE_INCLUDE_FILE
      The UNDEF_TRACE_INCLUDE_FILE acts as a CPP variable to know to undef
      the TRACE_INCLUDE_FILE before leaving define_trace.h.
      Unfortunately, due to cut and paste errors, the macros between
      FILE and PATH got mixed up.
      [ Impact: undef TRACE_INCLUDE_FILE and/or TRACE_INCLUDE_PATH when needed ]
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
  13. 17 Apr, 2009 1 commit
    • Steven Rostedt's avatar
      tracing/events: enable code with EVENT_TRACING not EVENT_TRACER · b0afdc12
      Steven Rostedt authored
      The CONFIG_EVENT_TRACER is the way to turn on event tracing when no
      other tracing has been configured. All code to get enabled should
      depend on CONFIG_EVENT_TRACING. That is what is enabled when TRACING
      (or CONFIG_EVENT_TRACER) is selected.
      This patch enables the include/trace/ftrace.h file when
      CONFIG_EVENT_TRACING is enabled.
      [ Impact: fix warning in event tracer selftest ]
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
  14. 15 Apr, 2009 1 commit
    • Steven Rostedt's avatar
      tracing/events: move trace point headers into include/trace/events · ad8d75ff
      Steven Rostedt authored
      Impact: clean up
      Create a sub directory in include/trace called events to keep the
      trace point headers in their own separate directory. Only headers that
      declare trace points should be defined in this directory.
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: Zhao Lei <zhaolei@cn.fujitsu.com>
      Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
      Cc: Pekka Enberg <penberg@cs.helsinki.fi>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
  15. 14 Apr, 2009 2 commits
    • Steven Rostedt's avatar
      tracing/events: move the ftrace event tracing code to core · f42c85e7
      Steven Rostedt authored
      This patch moves the ftrace creation into include/trace/ftrace.h and
      simplifies the work of developers in adding new tracepoints.
      Just the act of creating the trace points in include/trace and including
      define_trace.h will create the events in the debugfs/tracing/events
      This patch removes the need of include/trace/trace_events.h
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    • Steven Rostedt's avatar
      tracing: create automated trace defines · a8d154b0
      Steven Rostedt authored
      This patch lowers the number of places a developer must modify to add
      new tracepoints. The current method to add a new tracepoint
      into an existing system is to write the trace point macro in the
      trace header with one of the macros TRACE_EVENT, TRACE_FORMAT or
      DECLARE_TRACE, then they must add the same named item into the C file
      with the macro DEFINE_TRACE(name) and then add the trace point.
      This change cuts out the needing to add the DEFINE_TRACE(name).
      Every file that uses the tracepoint must still include the trace/<type>.h
      file, but the one C file must also add a define before the including
      of that file.
       #define CREATE_TRACE_POINTS
       #include <trace/mytrace.h>
      This will cause the trace/mytrace.h file to also produce the C code
      necessary to implement the trace point.
      Note, if more than one trace/<type>.h is used to create the C code
      it is best to list them all together.
       #define CREATE_TRACE_POINTS
       #include <trace/foo.h>
       #include <trace/bar.h>
       #include <trace/fido.h>
      Thanks to Mathieu Desnoyers and Christoph Hellwig for coming up with
      the cleaner solution of the define above the includes over my first
      design to have the C code include a "special" header.
      This patch converts sched, irq and lockdep and skb to use this new
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: Zhao Lei <zhaolei@cn.fujitsu.com>
      Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
      Cc: Pekka Enberg <penberg@cs.helsinki.fi>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>