1. 04 Sep, 2009 10 commits
    • Steven Rostedt's avatar
      tracing: disable buffers and synchronize_sched before resetting · 621968cd
      Steven Rostedt authored
      Resetting the ring buffers while traces are happening can corrupt
      the ring buffer and disable it (no kernel crash to worry about).
      
      The safest thing to do is disable the ring buffers, call synchronize_sched()
      to wait for all current writers to finish and then reset the buffer.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      621968cd
    • Steven Rostedt's avatar
      tracing: disable update max tracer while reading trace · b8de7bd1
      Steven Rostedt authored
      When reading the tracer from the trace file, updating the max latency
      may corrupt the output. This patch disables the tracing of the max
      latency while reading the trace file.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      b8de7bd1
    • Steven Rostedt's avatar
      tracing: print out start and stop in latency traces · 8248ac05
      Steven Rostedt authored
      During development of the tracer, we would copy information from
      the live tracer to the max tracer with one memcpy. Since then we
      added a generic ring buffer and we handle the copies differently now.
      Unfortunately, we never copied the critical section information, and
      we lost the output:
      
       #  => started at: kmem_cache_alloc
       #  => ended at:   kmem_cache_alloc
      
      This patch adds back the critical start and end copying as well as
      removes the unused "trace_idx" and "overrun" fields of the
      trace_array_cpu structure.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      8248ac05
    • Steven Rostedt's avatar
      ring-buffer: disable all cpu buffers when one finds a problem · 077c5407
      Steven Rostedt authored
      Currently the way RB_WARN_ON works, is to disable either the current
      CPU buffer or all CPU buffers, depending on whether a ring_buffer or
      ring_buffer_per_cpu struct was passed into the macro.
      
      Most users of the RB_WARN_ON pass in the CPU buffer, so only the one
      CPU buffer gets disabled but the rest are still active. This may
      confuse users even though a warning is sent to the console.
      
      This patch changes the macro to disable the entire buffer even if
      the CPU buffer is passed in.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      077c5407
    • Steven Rostedt's avatar
      ring-buffer: do not count discarded events · a1863c21
      Steven Rostedt authored
      The latency tracers report the number of items in the trace buffer.
      This uses the ring buffer data to calculate this. Because discarded
      events are also counted, the numbers do not match the number of items
      that are printed. The ring buffer also adds a "padding" item to the
      end of each buffer page which also gets counted as a discarded item.
      
      This patch decrements the counter to the page entries on a discard.
      This allows us to ignore discarded entries while reading the buffer.
      
      Decrementing the counter is still safe since it can only happen while
      the committing flag is still set.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      a1863c21
    • Steven Rostedt's avatar
      ring-buffer: remove ring_buffer_event_discard · dc892f73
      Steven Rostedt authored
      The function ring_buffer_event_discard can be used on any item in the
      ring buffer, even after the item was committed. This function provides
      no safety nets and is very race prone.
      
      An item may be safely removed from the ring buffer before it is committed
      with the ring_buffer_discard_commit.
      
      Since there are currently no users of this function, and because this
      function is racey and error prone, this patch removes it altogether.
      
      Note, removing this function also allows the counters to ignore
      all discarded events (patches will follow).
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      dc892f73
    • Steven Rostedt's avatar
      ring-buffer: fix ring_buffer_read crossing pages · 7e9391cf
      Steven Rostedt authored
      When the ring buffer uses an iterator (static read mode, not on the
      fly reading), when it crosses a page boundery, it will skip the first
      entry on the next page. The reason is that the last entry of a page
      is usually padding if the page is not full. The padding will not be
      returned to the user.
      
      The problem arises on ring_buffer_read because it also increments the
      iterator. Because both the read and peek use the same rb_iter_peek,
      the rb_iter_peak will return the padding but also increment to the next
      item. This is because the ring_buffer_peek will not incerment it
      itself.
      
      The ring_buffer_read will increment it again and then call rb_iter_peek
      again to get the next item. But that will be the second item, not the
      first one on the page.
      
      The reason this never showed up before, is because the ftrace utility
      always calls ring_buffer_peek first and only uses ring_buffer_read
      to increment to the next item. The ring_buffer_peek will always keep
      the pointer to a valid item and not padding. This just hid the bug.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      7e9391cf
    • Steven Rostedt's avatar
      ring-buffer: remove unnecessary cpu_relax · 1b959e18
      Steven Rostedt authored
      The loops in the ring buffer that use cpu_relax are not dependent on
      other CPUs. They simply came across some padding in the ring buffer and
      are skipping over them. It is a normal loop and does not require a
      cpu_relax.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      1b959e18
    • Steven Rostedt's avatar
      ring-buffer: do not swap buffers during a commit · 98277991
      Steven Rostedt authored
      If a commit is taking place on a CPU ring buffer, do not allow it to
      be swapped. Return -EBUSY when this is detected instead.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      98277991
    • Steven Rostedt's avatar
      ring-buffer: do not reset while in a commit · 41b6a95d
      Steven Rostedt authored
      The callers of reset must ensure that no commit can be taking place
      at the time of the reset. If it does then we may corrupt the ring buffer.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      41b6a95d
  2. 31 Aug, 2009 1 commit
    • Li Zefan's avatar
      tracing/filters: Defer pred allocation · 8e254c1d
      Li Zefan authored
      init_preds() allocates about 5392 bytes of memory (on x86_32) for
      a TRACE_EVENT. With my config, at system boot total memory occupied
      is:
      
      	5392 * (642 + 15) == 3459KB
      
      642 == cat available_events | wc -l
      15 == number of dirs in events/ftrace
      
      That's quite a lot, so we'd better defer memory allocation util
      it's needed, that's when filter is used.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Cc: Masami Hiramatsu <mhiramat@redhat.com>
      LKML-Reference: <4A9B8EA5.6020700@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      8e254c1d
  3. 29 Aug, 2009 1 commit
  4. 28 Aug, 2009 2 commits
    • Frederic Weisbecker's avatar
      tracing: Fix double CPP substitution in TRACE_EVENT_FN · 0dd7b747
      Frederic Weisbecker authored
      TRACE_EVENT_FN relays on TRACE_EVENT by reprocessing its parameters
      into the ftrace events CPP macro. This leads to a double substitution
      in some cases.
      
      For example, a bad consequence is a format always prefixed by
      "%s, %s\n" for every TRACE_EVENT_FN based events.
      
      Eg:
      	cat /debug/tracing/events/syscalls/sys_enter/format
      	[...]
      	print fmt: "%s, %s\n", "\"NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)\"",\
      	"REC->id, REC->args[0], REC->args[1], REC->args[2], REC->args[3],\
      	REC->args[4], REC->args[5]"
      
      This creates a failure in post-processing tools such as perf trace or
      trace-cmd.
      
      Then drop this double substitution and replace it by a new __cpparg()
      macro that relays CPP arguments containing commas.
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Josh Stone <jistone@redhat.com>
      Cc: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Jason Baron <jbaron@redhat.com>
      LKML-Reference: <1251413406-6704-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      0dd7b747
    • Ingo Molnar's avatar
      Merge branch 'tracing/core' of... · 66c6e29f
      Ingo Molnar authored
      Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/core
      66c6e29f
  5. 27 Aug, 2009 3 commits
    • Steven Rostedt's avatar
      tracing: only show tracing_max_latency when latency tracer configured · 5d4a9dba
      Steven Rostedt authored
      The tracing_max_latency file should only be present when one of the
      latency tracers ({preempt|irqs}off, wakeup*) are enabled.
      
      This patch also removes tracing_thresh when latency tracers are not
      enabled, as well as compiles out code that is only used for latency
      tracers.
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      5d4a9dba
    • Steven Rostedt's avatar
      tracing: remove legacy select of MARKERS by context switch tracing · c0729be9
      Steven Rostedt authored
      The context switch tracer was made before tracepoints were mature, and
      the original version used markers. This is no longer true and this
      patch removes the select.
      Reported-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      c0729be9
    • 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>
      6c347d43
  6. 26 Aug, 2009 16 commits
    • Jason Baron's avatar
      tracing: Remove FTRACE_SYSCALL_MAX definitions · 117226d1
      Jason Baron authored
      Remove the FTRACE_SYSCALL_MAX definitions now that we have converted the
      syscall event tracing code to use NR_syscalls.
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Josh Stone <jistone@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: H. Peter Anwin <hpa@zytor.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      LKML-Reference: <f2240cdc8f0b1ca7617390c8f5ec90ba2bd348cf.1251146513.git.jbaron@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      117226d1
    • Jason Baron's avatar
      tracing: Convert event tracing code to use NR_syscalls · 57421dbb
      Jason Baron authored
      Convert the syscalls event tracing code to use NR_syscalls, instead of
      FTRACE_SYSCALL_MAX. NR_syscalls is standard accross most arches, and
      reduces code confusion/complexity.
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Josh Stone <jistone@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: H. Peter Anwin <hpa@zytor.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      LKML-Reference: <9b4f1a84ecae57cc6599412772efa36f0d2b815b.1251146513.git.jbaron@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      57421dbb
    • Jason Baron's avatar
      tracing: Define NR_syscalls for x86_64 · a5a2f8e2
      Jason Baron authored
      Express the available number of syscalls in a standard way by defining
      NR_syscalls.
      
      The common way to define it is to place its definition in asm/unistd.h
      However, the number of syscalls is defined using __NR_syscall_max in
      x86-64 after building a dynamic header file "asm-offsets.h"
      
      The source file that generates this header, asm-offsets-64.c includes
      unistd.h, then if we want to express NR_syscalls from __NR_syscall_max
      in unistd.h only after generating the dynamic header file, we need a
      watchguard.
      
      If unistd.h is included from asm-offsets-64.c, then we are generating
      asm-offset.h which defines __NR_syscall_max. At this time, we don't
      want to (we can't) define NR_syscalls, then we do nothing.
      Otherwise we define NR_syscalls because we know asm-offsets.h has
      been generated.
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
      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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Josh Stone <jistone@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: H. Peter Anwin <hpa@zytor.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      LKML-Reference: <20090826160910.GB2658@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      a5a2f8e2
    • Jason Baron's avatar
      tracing: Define NR_syscalls for x86 (32) · dd86dda2
      Jason Baron authored
      Add a NR_syscalls #define for x86. This is used in the syscall events
      tracing code. Todo: make it dynamic like x86_64.
      
      NR_syscalls is the usual name used to determine the number of syscalls
      supported by the current arch. We want to unify the use of this number
      across archs that support the syscall tracing. This also prepare to move
      some of the arch code to core code in the syscall tracing area.
      Signed-off-by: default avatarJason Baron <jbaron@redhat.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Josh Stone <jistone@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: H. Peter Anwin <hpa@zytor.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      LKML-Reference: <0f33c0f96d198fccc3ddd9ff7f5334ff5cb42706.1251146513.git.jbaron@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      dd86dda2
    • Hendrik Brueckner's avatar
      tracing: Don't trace kernel thread syscalls · cc3b13c1
      Hendrik Brueckner authored
      Kernel threads don't call syscalls using the sysenter/sysexit
      path. Instead they directly call the sys_* or do_* functions
      that implement the syscalls inside the kernel.
      
      The current syscall tracepoints only bind the sysenter/sysexit
      path, then it has no effect to trace the kernel thread calls
      to syscalls in that path.
      Setting the TIF_SYSCALL_TRACEPOINT flag is then useless for these.
      
      Actually there is only one case when a kernel thread can reach the
      usual syscall exit tracing path: when we create a kernel thread, the
      child comes to ret_from_fork and is the fork() return is then traced.
      But this information alone is useless, then we don't want to set the
      TIF flags for these threads.
      
      Kernel threads have task_struct->mm set to NULL.
      (Thanks to Heiko for that hint ;-)
      The idea is then to check the mm field in syscall_regfunc() and
      set the flag accordingly.
      Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      LKML-Reference: <20090825160237.GG4639@cetus.boeblingen.de.ibm.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      cc3b13c1
    • Hendrik Brueckner's avatar
      tracing: Check invalid syscall nr while tracing syscalls · cd0980fc
      Hendrik Brueckner authored
      Most arch syscall_get_nr() implementations returns -1 if the syscall
      number is not valid.  Accessing the bit field without a check might
      result in a kernel oops (at least I saw it on s390 for ftrace selftest).
      
      Before this change, this problem did not occur, because the invalid
      syscall number (-1) caused syscall_nr_to_meta() to return NULL.
      
      There are at least two scenarios where syscall_get_nr() can return -1:
      
      1. For example, ptrace stores an invalid syscall number, and thus,
         tracing code resets it.
         (see do_syscall_trace_enter in arch/s390/kernel/ptrace.c)
      
      2. The syscall_regfunc() (kernel/tracepoint.c) sets the
         TIF_SYSCALL_FTRACE (now: TIF_SYSCALL_TRACEPOINT) flag for all threads
         which include kernel threads.
         However, the ftrace selftest triggers a kernel oops when testing
         syscall trace points:
            - The kernel thread is started as ususal (do_fork()),
            - tracing code sets TIF_SYSCALL_FTRACE,
            - the ret_from_fork() function is triggered and starts
      	ftrace_syscall_exit() with an invalid syscall number.
      
      To avoid these scenarios, I suggest to check the syscall_nr.
      
      For instance, the ftrace selftest fails for s390 (with config option
      CONFIG_FTRACE_SYSCALLS set) and produces the following kernel oops.
      
      Unable to handle kernel pointer dereference at virtual kernel address 2000000000
      
      Oops: 0038 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 Not tainted 2.6.31-rc6-next-20090819-dirty #18
      Process kthreadd (pid: 818, task: 000000003ea207e8, ksp: 000000003e813eb8)
      Krnl PSW : 0704100180000000 00000000000ea54c (ftrace_syscall_exit+0x58/0xdc)
                 R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:0 CC:1 PM:0 EA:3
      Krnl GPRS: 0000000000000000 00000000000e0000 ffffffffffffffff 20000000008c2650
                 0000000000000007 0000000000000000 0000000000000000 0000000000000000
                 0000000000000000 0000000000000000 ffffffffffffffff 000000003e813d78
                 000000003e813f58 0000000000505ba8 000000003e813e18 000000003e813d78
      Krnl Code: 00000000000ea540: e330d0000008       ag      %r3,0(%r13)
                 00000000000ea546: a7480007           lhi     %r4,7
                 00000000000ea54a: 1442               nr      %r4,%r2
                >00000000000ea54c: e31030000090       llgc    %r1,0(%r3)
                 00000000000ea552: 5410d008           n       %r1,8(%r13)
                 00000000000ea556: 8a104000           sra     %r1,0(%r4)
                 00000000000ea55a: 5410d00c           n       %r1,12(%r13)
                 00000000000ea55e: 1211               ltr     %r1,%r1
      Call Trace:
      ([<0000000000000000>] 0x0)
       [<000000000001fa22>] do_syscall_trace_exit+0x132/0x18c
       [<000000000002d0c4>] sysc_return+0x0/0x8
       [<000000000001c738>] kernel_thread_starter+0x0/0xc
      Last Breaking-Event-Address:
       [<00000000000ea51e>] ftrace_syscall_exit+0x2a/0xdc
      Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      LKML-Reference: <20090825125027.GE4639@cetus.boeblingen.de.ibm.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      cd0980fc
    • Hendrik Brueckner's avatar
      tracing: Add syscall tracepoints - s390 arch update · 7515bf59
      Hendrik Brueckner authored
      This patch includes s390 arch updates to synchronize with latest
      core changes in the syscalls tracing area.
      
      - tracing: Map syscall name to number (syscall_name_to_nr())
      - tracing: Call arch_init_ftrace_syscalls at boot
      - tracing: add support tracepoint ids (set_syscall_{enter,exit}_id())
      Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Lai Jiangshan <laijs@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: Li Zefan <lizf@cn.fujitsu.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Paul Mundt <lethal@linux-sh.org>
      LKML-Reference: <20090825123111.GD4639@cetus.boeblingen.de.ibm.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      7515bf59
    • Ingo Molnar's avatar
      Merge branch 'tracing/core' of... · 35dce1a9
      Ingo Molnar authored
      Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/core
      
      Conflicts:
      	include/linux/tracepoint.h
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      35dce1a9
    • Steven Rostedt's avatar
      tracing: add comments to explain TRACE_EVENT out of protection · 7cb2e3ee
      Steven Rostedt authored
      The commit:
        commit 5ac35daa
        Author: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
        tracing/events: fix the include file dependencies
      
      Moved the TRACE_EVENT out of the ifdef protection of tracepoints.h
      but uses the define of TRACE_EVENT itself as protection. This patch
      adds comments to explain why.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      7cb2e3ee
    • Xiao Guangrong's avatar
      tracing/events: fix the include file dependencies · 5ac35daa
      Xiao Guangrong authored
      The TRACE_EVENT depends on the include/linux/tracepoint.h first
      and include/trace/ftrace.h later, if we include the ftrace.h early,
      a building error will occur.
      
      Both define TRACE_EVENT in trace_a.h and trace_b.h, if we include
      those in .c file, like this:
      
      #define CREATE_TRACE_POINTS
      include <trace/events/trace_a.h>
      include <trace/events/trace_b.h>
      
      The above will not work, because the TRACE_EVENT was re-defined by
      the previous .h file.
      Reported-by: default avatarWei Yongjun <yjwei@cn.fujitsu.com>
      Signed-off-by: default avatarXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
      LKML-Reference: <4A937F5E.3020802@cn.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      5ac35daa
    • Zhaolei's avatar
      ftrace: Move setting of clock-source out of options · 5079f326
      Zhaolei authored
      There are many clock sources for the tracing system but we can only
      enable/disable one at a time with the trace/options file.
      We can move the setting of clock-source out of options and add a separate
      file for it:
       # cat trace_clock
       [local] global
       # echo global > trace_clock
       # cat trace_clock
       local [global]
      Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
      LKML-Reference: <4A939D08.6050604@cn.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      5079f326
    • Li Zefan's avatar
      tracing/filters: Support filtering for char * strings · 87a342f5
      Li Zefan authored
      Usually, char * entries are dangerous in traces because the string
      can be released whereas a pointer to it can still wait to be read from
      the ring buffer.
      
      But sometimes we can assume it's safe, like in case of RO data
      (eg: __file__ or __line__, used in bkl trace event). If these RO data
      are in a module and so is the call to the trace event, then it's safe,
      because the ring buffer will be flushed once this module get unloaded.
      
      To allow char * to be treated as a string:
      
      	TRACE_EVENT(...,
      
      		TP_STRUCT__entry(
      			__field_ext(const char *, name, FILTER_PTR_STRING)
      			...
      		)
      
      		...
      	);
      
      The filtering will not dereference "char *" unless the developer
      explicitly sets FILTER_PTR_STR in __field_ext.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      LKML-Reference: <4A7B9287.90205@cn.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      87a342f5
    • Li Zefan's avatar
      tracing/filters: Add __field_ext() to TRACE_EVENT · 43b51ead
      Li Zefan authored
      Add __field_ext(), so a field can be assigned to a specific
      filter_type, which matches a corresponding filter function.
      
      For example, a later patch will allow this:
      	__field_ext(const char *, str, FILTER_PTR_STR);
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      LKML-Reference: <4A7B9272.60507095@cn.fujitsu.com>
      
      [
        Fixed a -1 to FILTER_OTHER
        Forward ported to latest kernel.
      ]
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      43b51ead
    • Li Zefan's avatar
      tracing/filters: Add filter_type to struct ftrace_event_field · aa38e9fc
      Li Zefan authored
      The type of a field is stored as a string in @type, and here
      we add @filter_type which is an enum value.
      
      This prepares for later patches, so we can specifically assign
      different @filter_type for the same @type.
      
      For example normally a "char *" field is treated as a ptr,
      but we may want it to be treated as a string when doing filting.
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      LKML-Reference: <4A7B925E.9030605@cn.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      aa38e9fc
    • Josh Triplett's avatar
      tracing: Add vim script to enable folding for function_graph traces · 6591b493
      Josh Triplett authored
      function_graph traces look like nested function calls, complete with
      braces denoting the start and end of functions.  function-graph-fold.vim
      teaches vim how to fold these functions, to make it more convenient to
      browse them.
      
      To use, :source function-graph-fold.vim while viewing a function_graph
      trace, or use "view -S function-graph-fold.vim some-trace" to load it
      from the command-line together with a trace.  You can then use the usual
      vim fold commands, such as "za", to open and close nested functions.
      While closed, a fold will show the total time taken for a call, as would
      normally appear on the line with the closing brace.  Folded functions
      will not include finish_task_switch(), so folding should remain
      relatively sane even through a context switch.
      
      Note that this will almost certainly only work well with a single-CPU
      trace (e.g. trace-cmd report --cpu 1).  It also takes some time to run
      (a few seconds for a large trace on my laptop).  Nevertheless, I found
      it very handy to get an overview of a trace and then drill down on
      problematic calls.
      Signed-off-by: default avatarJosh Triplett <josh@joshtriplett.org>
      LKML-Reference: <20090806145701.GB7661@feather>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      6591b493
    • Steven Rostedt's avatar
      tracing/sched: show CPU task wakes up on in trace event · f0693c8b
      Steven Rostedt authored
      While debugging the scheduler push / pull algorithm, I found
      it very annoying that the sched wake up events did not show
      the CPU that the task was waking on. In order to analyze the
      scheduler, I needed that information.
      
      This patch adds recording of the CPU that a task is waking up
      on.
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      f0693c8b
  7. 25 Aug, 2009 5 commits
    • Josh Stone's avatar
      tracing: Create generic syscall TRACE_EVENTs · 1c569f02
      Josh Stone authored
      This converts the syscall_enter/exit tracepoints into TRACE_EVENTs, so
      you can have generic ftrace events that capture all system calls with
      arguments and return values.  These generic events are also renamed to
      sys_enter/exit, so they're more closely aligned to the specific
      sys_enter_foo events.
      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-5-git-send-email-jistone@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      1c569f02
    • 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>
      97419875
    • Josh Stone's avatar
      tracing: Make syscall tracepoints conditional · 3d27d8cb
      Josh Stone authored
      The syscall enter/exit tracepoints are only supported on archs that
      HAVE_SYSCALL_TRACEPOINTS, so the declarations should be #ifdef'ed.
      Also, the definition of syscall_regfunc and syscall_unregfunc should
      depend on this same config, rather than the ftrace-specific one.
      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>
      LKML-Reference: <1251150194-1713-3-git-send-email-jistone@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      3d27d8cb
    • Josh Stone's avatar
      tracing: Rename FTRACE_SYSCALLS for tracepoints · 66700001
      Josh Stone authored
      s/HAVE_FTRACE_SYSCALLS/HAVE_SYSCALL_TRACEPOINTS/g
      s/TIF_SYSCALL_FTRACE/TIF_SYSCALL_TRACEPOINT/g
      
      The syscall enter/exit tracing is no longer specific to just ftrace, so
      they now have names that reflect their tie to tracepoints instead.
      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-2-git-send-email-jistone@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      66700001
    • Anirban Sinha's avatar
      tracing: Eliminate code duplication in kernel/tracepoint.c · d88cb582
      Anirban Sinha authored
      Signed-off-by: default avatarAnirban Sinha <asinha@zeugmasystems.com>
      Reviewed-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: "Oleg Nesterov" <oleg@tv-sign.ru>
      LKML-Reference: <DDFD17CC94A9BD49A82147DDF7D545C501EA9047@exchange.ZeugmaSystems.local>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      d88cb582
  8. 20 Aug, 2009 1 commit
    • Li Zefan's avatar
      tracing/syscalls: Fix the output of syscalls with no arguments · 4539f077
      Li Zefan authored
      Before:
      
        # echo 1 > events/syscalls/sys_enter_sync/enable
        # cat events/syscalls/sys_enter_sync/format
        ...
              field:int nr;   offset:12;      size:4;
      
        print fmt: "# sync
        # cat trace
        ...
                  sync-8950  [000]  2366.087670: sys_sync(
      
      After:
      
        # echo 1 > events/syscalls/sys_enter_sync/enable
        # cat events/syscalls/sys_enter_sync/format
        ...
              field:int nr;   offset:12;      size:4;
      
        print fmt: ""
        # sync
        # cat trace
                  sync-2134  [001]   136.780735: sys_sync()
      Reported-by: default avatarMasami Hiramatsu <mhiramat@redhat.com>
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@redhat.com>
      LKML-Reference: <4A8D05AF.20103@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      4539f077
  9. 19 Aug, 2009 1 commit
    • Li Zefan's avatar
      tracing/syscalls: Add filtering support · 540b7b8d
      Li Zefan authored
      Add filtering support for syscall events:
      
       # echo 'mode == 0666' > events/syscalls/sys_enter_open
       # echo 'ret == 0' > events/syscalls/sys_exit_open
       # echo 1 > events/syscalls/sys_enter_open
       # echo 1 > events/syscalls/sys_exit_open
       # cat trace
       ...
         modprobe-3084 [001] 117.463140: sys_open(filename: 917d3e8, flags: 0, mode: 1b6)
         modprobe-3084 [001] 117.463176: sys_open -> 0x0
             less-3086 [001] 117.510455: sys_open(filename: 9c6bdb8, flags: 8000, mode: 1b6)
         sendmail-2574 [001] 122.145840: sys_open(filename: b807a365, flags: 0, mode: 1b6)
       ...
      Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <4A8BAFCB.1040006@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      540b7b8d