1. 17 2月, 2009 5 次提交
    • S
      ftrace: add module command function filter selection · 64e7c440
      Steven Rostedt 提交于
      This patch adds a "command" syntax to the function filtering files:
      
        /debugfs/tracing/set_ftrace_filter
        /debugfs/tracing/set_ftrace_notrace
      
      Of the format:  <function>:<command>:<parameter>
      
      The command is optional, and dependent on the command, so are
      the parameters.
      
       echo do_fork > set_ftrace_filter
      
      Will only trace 'do_fork'.
      
       echo 'sched_*' > set_ftrace_filter
      
      Will only trace functions starting with the letters 'sched_'.
      
       echo '*:mod:ext3' > set_ftrace_filter
      
      Will trace only the ext3 module functions.
      
       echo '*write*:mod:ext3' > set_ftrace_notrace
      
      Will prevent the ext3 functions with the letters 'write' in
      the name from being traced.
      
       echo '!*_allocate:mod:ext3' > set_ftrace_filter
      
      Will remove the functions in ext3 that end with the letters
      '_allocate' from the ftrace filter.
      
      Although this patch implements the 'command' format, only the
      'mod' command is supported. More commands to follow.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      64e7c440
    • S
      ftrace: break up ftrace_match_records into smaller components · 9f4801e3
      Steven Rostedt 提交于
      Impact: clean up
      
      ftrace_match_records does a lot of things that other features
      can use. This patch breaks up ftrace_match_records and pulls
      out ftrace_setup_glob and ftrace_match_record.
      
      ftrace_setup_glob prepares a simple glob expression for use with
      ftrace_match_record. ftrace_match_record compares a single record
      with a glob type.
      
      Breaking this up will allow for more features to run on individual
      records.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      9f4801e3
    • S
      ftrace: rename ftrace_match to ftrace_match_records · 7f24b31b
      Steven Rostedt 提交于
      Impact: clean up
      
      ftrace_match is too generic of a name. What it really does is
      search all records and matches the records with the given string,
      and either sets or unsets the functions to be traced depending
      on if the parameter 'enable' is set or not.
      
      This allows us to make another function called ftrace_match that
      can be used to test a single record.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      7f24b31b
    • S
      ftrace: add do_for_each_ftrace_rec and while_for_each_ftrace_rec · 265c831c
      Steven Rostedt 提交于
      Impact: clean up
      
      To iterate over all the functions that dynamic trace knows about
      it requires two for loops. One to iterate over the pages and the
      other to iterate over the records within the page.
      
      There are several duplications of these loops in ftrace.c. This
      patch creates the macros do_for_each_ftrace_rec and
      while_for_each_ftrace_rec to handle this logic, and removes the
      duplicate code.
      
      While making this change, I also discovered and fixed a small
      bug that one of the iterations should exit the loop after it found the
      record it was searching for. This used a break when it should have
      used a goto, since there were two loops it needed to break out
      from.  No real harm was done by this bug since it would only continue
      to search the other records, and the code was in a slow path anyway.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      265c831c
    • S
      ftrace: state that all functions are enabled in set_ftrace_filter · 0c75a3ed
      Steven Rostedt 提交于
      Impact: clean up, make set_ftrace_filter less confusing
      
      The set_ftrace_filter shows only the functions that will be traced.
      But when it is empty, it will trace all functions. This can be a bit
      confusing.
      
      This patch makes set_ftrace_filter show:
      
        #### all functions enabled ####
      
      When all functions will be traced, and we do not filter only a select
      few.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      0c75a3ed
  2. 13 2月, 2009 1 次提交
    • S
      ring-buffer: rename label out_unlock to out_reset · 45141d46
      Steven Rostedt 提交于
      Impact: clean up
      
      While reviewing the ring buffer code, I thougth I saw a bug with
      
      	if (!__raw_spin_trylock(&cpu_buffer->lock))
      		goto out_unlock;
      
      But I forgot that we use a variable "lock_taken" that is set if
      the spinlock is taken, and only unlock it if that variable is set.
      
      To avoid further confusion from other reviewers, this patch
      renames the label out_unlock with out_reset, which is the more
      appropriate name.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      45141d46
  3. 11 2月, 2009 9 次提交
    • A
      ring_buffer: pahole struct ring_buffer · 00f62f61
      Arnaldo Carvalho de Melo 提交于
      While fixing some bugs in pahole (built-in.o files were not being
      processed due to relocation problems) I found out about these packable
      structures:
      
      $ pahole --packable kernel/trace/ring_buffer.o  | grep ring
      ring_buffer	72	64	8
      ring_buffer_per_cpu	112	104	8
      
      If we take a look at the current layout of struct ring_buffer we can see
      that we have two 4 bytes holes.
      
      $ pahole -C ring_buffer kernel/trace/ring_buffer.o
      struct ring_buffer {
      	unsigned int               pages;           /*     0     4 */
      	unsigned int               flags;           /*     4     4 */
      	int                        cpus;            /*     8     4 */
      
      	/* XXX 4 bytes hole, try to pack */
      
      	cpumask_var_t              cpumask;         /*    16     8 */
      	atomic_t                   record_disabled; /*    24     4 */
      
      	/* XXX 4 bytes hole, try to pack */
      
      	struct mutex               mutex;           /*    32    32 */
      	/* --- cacheline 1 boundary (64 bytes) --- */
      	struct ring_buffer_per_cpu * * buffers;     /*    64     8 */
      
      	/* size: 72, cachelines: 2, members: 7 */
      	/* sum members: 64, holes: 2, sum holes: 8 */
      	/* last cacheline: 8 bytes */
      };
      
      So, if I ask pahole to reorganize it:
      
      $ pahole -C ring_buffer --reorganize kernel/trace/ring_buffer.o
      
      struct ring_buffer {
      	unsigned int               pages;           /*     0     4 */
      	unsigned int               flags;           /*     4     4 */
      	int                        cpus;            /*     8     4 */
      	atomic_t                   record_disabled; /*    12     4 */
      	cpumask_var_t              cpumask;         /*    16     8 */
      	struct mutex               mutex;           /*    24    32 */
      	struct ring_buffer_per_cpu * * buffers;     /*    56     8 */
      	/* --- cacheline 1 boundary (64 bytes) --- */
      
      	/* size: 64, cachelines: 1, members: 7 */
      };   /* saved 8 bytes and 1 cacheline! */
      
      We get it using just one 64 bytes cacheline.
      
      To see what it did:
      
      $ pahole -C ring_buffer --reorganize --show_reorg_steps \
      	kernel/trace/ring_buffer.o | grep \/
      /* Moving 'record_disabled' from after 'cpumask' to after 'cpus' */
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      00f62f61
    • F
      tracing/sysprof: add missing tracing_{start,stop}_record_cmdline() · b22f4858
      Frederic Weisbecker 提交于
      Add the missing pair tracing_{start,stop}_record_cmdline() to record well
      the cmdline associated with pid.
      
      Changes in v2:
      
      - fix a build error, the sched_switch tracer is needed to record the
        cmdline.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b22f4858
    • H
      tracing: fix sparse warning: attribute function with __acquires/__releases · e7669b8e
      Hannes Eder 提交于
      Fix this sparse warning:
      
        kernel/trace/trace.c:458:9: warning: context imbalance in 'register_tracer' - unexpected unlock
      Signed-off-by: NHannes Eder <hannes@hanneseder.net>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      e7669b8e
    • H
      tracing: fix sparse warnings: fix (un-)signedness · 5e39841c
      Hannes Eder 提交于
      Fix these sparse warnings:
      
        kernel/trace/ring_buffer.c:70:37: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:84:39: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:96:43: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2475:13: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2475:13: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2478:42: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2478:42: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2500:40: warning: incorrect type in argument 3 (different signedness)
        kernel/trace/ring_buffer.c:2505:44: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/ring_buffer.c:2507:46: warning: incorrect type in argument 2 (different signedness)
        kernel/trace/trace.c:2130:40: warning: incorrect type in argument 3 (different signedness)
        kernel/trace/trace.c:2280:40: warning: incorrect type in argument 3 (different signedness)
      Signed-off-by: NHannes Eder <hannes@hanneseder.net>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5e39841c
    • H
      tracing: fix sparse warnings: make symbols static · 4fd27358
      Hannes Eder 提交于
      Impact: make global variables and a global function static
      
      The function '__trace_userstack' does not seem to have a caller, so it
      is commented out.
      
      Fix this sparse warnings:
        kernel/trace/trace.c:82:5: warning: symbol 'tracing_disabled' was not declared. Should it be static?
        kernel/trace/trace.c:600:10: warning: symbol 'trace_record_cmdline_disabled' was not declared. Should it be static?
        kernel/trace/trace.c:957:6: warning: symbol '__trace_userstack' was not declared. Should it be static?
        kernel/trace/trace.c:1694:5: warning: symbol 'tracing_release' was not declared. Should it be static?
      Signed-off-by: NHannes Eder <hannes@hanneseder.net>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      4fd27358
    • W
      tracing: fix typos in comments · c3706f00
      Wenji Huang 提交于
      Impact: clean up.
      
      Fix typos in the comments.
      Signed-off-by: NWenji Huang <wenji.huang@oracle.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      c3706f00
    • W
      tracing: provide correct return value after outputting the event · 810dc732
      Wenji Huang 提交于
      This patch is to make the function return early on failure, and give
      correct return value on success.
      Signed-off-by: NWenji Huang <wenji.huang@oracle.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      810dc732
    • W
      tracing: remove unneeded variable · f54fc98a
      Wenji Huang 提交于
      Impact: clean up.
      
      Remove the unnecessary variable ret.
      Signed-off-by: NWenji Huang <wenji.huang@oracle.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      f54fc98a
    • T
      tracing: storage class should be before const qualifier · 4543ae7c
      Tobias Klauser 提交于
      The C99 specification states in section 6.11.5:
      
      The placement of a storage-class specifier other than at the beginning
      of the declaration specifiers in a declaration is an obsolescent
      feature.
      Signed-off-by: NTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      4543ae7c
  4. 10 2月, 2009 5 次提交
  5. 09 2月, 2009 6 次提交
  6. 08 2月, 2009 4 次提交
    • W
      trace: trivial fixes in comment typos. · 57794a9d
      Wenji Huang 提交于
      Impact: clean up
      
      Fixed several typos in the comments.
      Signed-off-by: NWenji Huang <wenji.huang@oracle.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      57794a9d
    • S
      ring-buffer: use generic version of in_nmi · a81bd80a
      Steven Rostedt 提交于
      Impact: clean up
      
      Now that a generic in_nmi is available, this patch removes the
      special code in the ring_buffer and implements the in_nmi generic
      version instead.
      
      With this change, I was also able to rename the "arch_ftrace_nmi_enter"
      back to "ftrace_nmi_enter" and remove the code from the ring buffer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      a81bd80a
    • S
      ring-buffer: add NMI protection for spinlocks · 78d904b4
      Steven Rostedt 提交于
      Impact: prevent deadlock in NMI
      
      The ring buffers are not yet totally lockless with writing to
      the buffer. When a writer crosses a page, it grabs a per cpu spinlock
      to protect against a reader. The spinlocks taken by a writer are not
      to protect against other writers, since a writer can only write to
      its own per cpu buffer. The spinlocks protect against readers that
      can touch any cpu buffer. The writers are made to be reentrant
      with the spinlocks disabling interrupts.
      
      The problem arises when an NMI writes to the buffer, and that write
      crosses a page boundary. If it grabs a spinlock, it can be racing
      with another writer (since disabling interrupts does not protect
      against NMIs) or with a reader on the same CPU. Luckily, most of the
      users are not reentrant and protects against this issue. But if a
      user of the ring buffer becomes reentrant (which is what the ring
      buffers do allow), if the NMI also writes to the ring buffer then
      we risk the chance of a deadlock.
      
      This patch moves the ftrace_nmi_enter called by nmi_enter() to the
      ring buffer code. It replaces the current ftrace_nmi_enter that is
      used by arch specific code to arch_ftrace_nmi_enter and updates
      the Kconfig to handle it.
      
      When an NMI is called, it will set a per cpu variable in the ring buffer
      code and will clear it when the NMI exits. If a write to the ring buffer
      crosses page boundaries inside an NMI, a trylock is used on the spin
      lock instead. If the spinlock fails to be acquired, then the entry
      is discarded.
      
      This bug appeared in the ftrace work in the RT tree, where event tracing
      is reentrant. This workaround solved the deadlocks that appeared there.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      78d904b4
    • S
      trace: remove deprecated entry->cpu · 1830b52d
      Steven Rostedt 提交于
      Impact: fix to prevent developers from using entry->cpu
      
      With the new ring buffer infrastructure, the cpu for the entry is
      implicit with which CPU buffer it is on.
      
      The original code use to record the current cpu into the generic
      entry header, which can be retrieved by entry->cpu. When the
      ring buffer was introduced, the users were convert to use the
      the cpu number of which cpu ring buffer was in use (this was passed
      to the tracers by the iterator: iter->cpu).
      
      Unfortunately, the cpu item in the entry structure was never removed.
      This allowed for developers to use it instead of the proper iter->cpu,
      unknowingly, using an uninitialized variable. This was not the fault
      of the developers, since it would seem like the logical place to
      retrieve the cpu identifier.
      
      This patch removes the cpu item from the entry structure and fixes
      all the users that should have been using iter->cpu.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      1830b52d
  7. 06 2月, 2009 3 次提交
    • A
      trace: Call tracing_reset_online_cpus before tracer->init() · b6f11df2
      Arnaldo Carvalho de Melo 提交于
      Impact: cleanup
      
      To make it easy for ftrace plugin writers, as this was open coded in
      the existing plugins
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NFrédéric Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b6f11df2
    • A
      tracing: Introduce trace_buffer_{lock_reserve,unlock_commit} · 51a763dd
      Arnaldo Carvalho de Melo 提交于
      Impact: new API
      
      These new functions do what previously was being open coded, reducing
      the number of details ftrace plugin writers have to worry about.
      
      It also standardizes the handling of stacktrace, userstacktrace and
      other trace options we may introduce in the future.
      
      With this patch, for instance, the blk tracer (and some others already
      in the tree) can use the "userstacktrace" /d/tracing/trace_options
      facility.
      
      $ codiff /tmp/vmlinux.before /tmp/vmlinux.after
      linux-2.6-tip/kernel/trace/trace.c:
        trace_vprintk              |   -5
        trace_graph_return         |  -22
        trace_graph_entry          |  -26
        trace_function             |  -45
        __ftrace_trace_stack       |  -27
        ftrace_trace_userstack     |  -29
        tracing_sched_switch_trace |  -66
        tracing_stop               |   +1
        trace_seq_to_user          |   -1
        ftrace_trace_special       |  -63
        ftrace_special             |   +1
        tracing_sched_wakeup_trace |  -70
        tracing_reset_online_cpus  |   -1
       13 functions changed, 2 bytes added, 355 bytes removed, diff: -353
      
      linux-2.6-tip/block/blktrace.c:
        __blk_add_trace |  -58
       1 function changed, 58 bytes removed, diff: -58
      
      linux-2.6-tip/kernel/trace/trace.c:
        trace_buffer_lock_reserve  |  +88
        trace_buffer_unlock_commit |  +86
       2 functions changed, 174 bytes added, diff: +174
      
      /tmp/vmlinux.after:
       16 functions changed, 176 bytes added, 413 bytes removed, diff: -237
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NFrédéric Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      51a763dd
    • A
      ring_buffer: remove unused flags parameter · 0a987751
      Arnaldo Carvalho de Melo 提交于
      Impact: API change, cleanup
      
      >From ring_buffer_{lock_reserve,unlock_commit}.
      
      $ codiff /tmp/vmlinux.before /tmp/vmlinux.after
      linux-2.6-tip/kernel/trace/trace.c:
        trace_vprintk              |  -14
        trace_graph_return         |  -14
        trace_graph_entry          |  -10
        trace_function             |   -8
        __ftrace_trace_stack       |   -8
        ftrace_trace_userstack     |   -8
        tracing_sched_switch_trace |   -8
        ftrace_trace_special       |  -12
        tracing_sched_wakeup_trace |   -8
       9 functions changed, 90 bytes removed, diff: -90
      
      linux-2.6-tip/block/blktrace.c:
        __blk_add_trace |   -1
       1 function changed, 1 bytes removed, diff: -1
      
      /tmp/vmlinux.after:
       10 functions changed, 91 bytes removed, diff: -91
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NFrédéric Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0a987751
  8. 05 2月, 2009 6 次提交
  9. 04 2月, 2009 1 次提交