1. 09 3月, 2009 1 次提交
    • K
      tracing: Don't use tracing_record_cmdline() in workqueue tracer · c3ffc7a4
      KOSAKI Motohiro 提交于
      Impact: improve workqueue tracer output
      
      Currently, /sys/kernel/debug/tracing/trace_stat/workqueues can display
      wrong and strange thread names.
      
      Why?
      
      Currently, ftrace has tracing_record_cmdline()/trace_find_cmdline()
      convenience function that implements a task->comm string cache.
      
      This can avoid unnecessary memcpy overhead and the workqueue tracer
      uses it.
      
      However, in general, any trace statistics feature shouldn't use
      tracing_record_cmdline() because trace statistics can display
      very old process. Then comm cache can return wrong string because
      recent process overrides the cache.
      
      Fortunately, workqueue trace guarantees that displayed processes
      are live. Thus we can search comm string from PID at display time.
      
      <before>
      
      % cat workqueues
       # CPU  INSERTED  EXECUTED   NAME
       # |      |         |          |
      
         7 431913     431913       kondemand/7
         7      0          0       tail
         7     21         21       git
         7      0          0       ls
         7      9          9       cat
         7 832632     832632       unix_chkpwd
         7 236292     236292       ls
      
      Note: tail, git, ls, cat unix_chkpwd are obiously not workqueue thread.
      
      <after>
      
      % cat workqueues
       # CPU  INSERTED  EXECUTED   NAME
       # |      |         |          |
      
         7    510        510       kondemand/7
         7      0          0       kmpathd/7
         7     15         15       ata/7
         7      0          0       aio/7
         7     11         11       kblockd/7
         7   1063       1063       work_on_cpu/7
         7    167        167       events/7
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      c3ffc7a4
  2. 08 3月, 2009 1 次提交
    • K
      ftrace: tracing header should put '#' at the beginning of a line · 888b55dc
      KOSAKI Motohiro 提交于
      In a recent discussion, Andrew Morton pointed out that tracing header
      should put '#' at the beginning of a line.
      
      Then, we can easily filtered the header by following grep usage:
      
        cat trace | grep -v '^#'
      
      Wakeup trace also has the same header problem.
      
      Comparison of headers displayed:
      
      before this patch:
      
       # tracer: wakeup
       #
       wakeup latency trace v1.1.5 on 2.6.29-rc7-tip-tip
       --------------------------------------------------------------------
        latency: 19059 us, #21277/21277, CPU#1 | (M:desktop VP:0, KP:0, SP:0 HP:0 #P:4)
           -----------------
           | task: kondemand/1-1644 (uid:0 nice:-5 policy:0 rt_prio:0)
           -----------------
      
       #                  _------=> CPU#
       #                 / _-----=> irqs-off
       #                | / _----=> need-resched
       #                || / _---=> hardirq/softirq
       #                ||| / _--=> preempt-depth
       #                |||| /
       #                |||||     delay
       #  cmd     pid   ||||| time  |   caller
       #     \   /      |||||   \   |   /
       irqbalan-1887    1d.s.    0us :   1887:120:R   + [001]  1644:115:S kondemand/1
       irqbalan-1887    1d.s.    1us : default_wake_function <-autoremove_wake_function
       irqbalan-1887    1d.s.    2us : check_preempt_wakeup <-try_to_wake_up
      
      after this patch:
      
       # tracer: wakeup
       #
       # wakeup latency trace v1.1.5 on 2.6.29-rc7-tip-tip
       # --------------------------------------------------------------------
       # latency: 529 us, #530/530, CPU#0 | (M:desktop VP:0, KP:0, SP:0 HP:0 #P:4)
       #    -----------------
       #    | task: kondemand/0-1641 (uid:0 nice:-5 policy:0 rt_prio:0)
       #    -----------------
       #
       #                  _------=> CPU#
       #                 / _-----=> irqs-off
       #                | / _----=> need-resched
       #                || / _---=> hardirq/softirq
       #                ||| / _--=> preempt-depth
       #                |||| /
       #                |||||     delay
       #  cmd     pid   ||||| time  |   caller
       #     \   /      |||||   \   |   /
           sshd-2496    0d.s.    0us :   2496:120:R   + [000]  1641:115:S kondemand/0
           sshd-2496    0d.s.    1us : default_wake_function <-autoremove_wake_function
           sshd-2496    0d.s.    1us : check_preempt_wakeup <-try_to_wake_up
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      LKML-Reference: <20090308124421.23C3.A69D9226@jp.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      888b55dc
  3. 07 3月, 2009 4 次提交
    • I
      tracing: trace_bprintk() cleanups · 9de36825
      Ingo Molnar 提交于
      Impact: cleanup
      
      Remove a few leftovers and clean up the code a bit.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-5-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      9de36825
    • F
      tracing/core: drop the old trace_printk() implementation in favour of trace_bprintk() · 769b0441
      Frederic Weisbecker 提交于
      Impact: faster and lighter tracing
      
      Now that we have trace_bprintk() which is faster and consume lesser
      memory than trace_printk() and has the same purpose, we can now drop
      the old implementation in favour of the binary one from trace_bprintk(),
      which means we move all the implementation of trace_bprintk() to
      trace_printk(), so the Api doesn't change except that we must now use
      trace_seq_bprintk() to print the TRACE_PRINT entries.
      
      Some changes result of this:
      
      - Previously, trace_bprintk depended of a single tracer and couldn't
        work without. This tracer has been dropped and the whole implementation
        of trace_printk() (like the module formats management) is now integrated
        in the tracing core (comes with CONFIG_TRACING), though we keep the file
        trace_printk (previously trace_bprintk.c) where we can find the module
        management. Thus we don't overflow trace.c
      
      - changes some parts to use trace_seq_bprintk() to print TRACE_PRINT entries.
      
      - change a bit trace_printk/trace_vprintk macros to support non-builtin formats
        constants, and fix 'const' qualifiers warnings. But this is all transparent for
        developers.
      
      - etc...
      
      V2:
      
      - Rebase against last changes
      - Fix mispell on the changelog
      
      V3:
      
      - Rebase against last changes (moving trace_printk() to kernel.h)
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-5-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      769b0441
    • L
      tracing: add trace_bprintk() · 1ba28e02
      Lai Jiangshan 提交于
      Impact: add a generic printk() for tracing, like trace_printk()
      
      trace_bprintk() uses the infrastructure to record events on ring_buffer.
      
      [ fweisbec@gmail.com: ported to latest -tip, made it work if
        !CONFIG_MODULES, never free the format strings from modules
        because we can't keep track of them and conditionnaly create
        the ftrace format strings section (reported by Steven Rostedt) ]
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-4-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1ba28e02
    • L
      tracing: infrastructure for supporting binary record · 1427cdf0
      Lai Jiangshan 提交于
      Impact: save on memory for tracing
      
      Current tracers are typically using a struct(like struct ftrace_entry,
      struct ctx_switch_entry, struct special_entr etc...)to record a binary
      event. These structs can only record a their own kind of events.
      A new kind of tracer need a new struct and a lot of code too handle it.
      
      So we need a generic binary record for events. This infrastructure
      is for this purpose.
      
      [fweisbec@gmail.com: rebase against latest -tip, make it safe while sched
      tracing as reported by Steven Rostedt]
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1236356510-8381-3-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1427cdf0
  4. 06 3月, 2009 6 次提交
    • K
      tracing: fix deadlock when setting set_ftrace_pid · 10dd3ebe
      KOSAKI Motohiro 提交于
      Impact: fix deadlock while using set_ftrace_pid
      
      Reproducer:
      
      	# cd /sys/kernel/debug/tracing
      	# echo $$ > set_ftrace_pid
      
      	then, console becomes hung.
      
      Details:
      
      when writing set_ftracepid, kernel callstack is following
      
      	ftrace_pid_write()
      		mutex_lock(&ftrace_lock);
      		ftrace_update_pid_func()
      			mutex_lock(&ftrace_lock);
      			mutex_unlock(&ftrace_lock);
      		mutex_unlock(&ftrace_lock);
      
      then, system always deadlocks when ftrace_pid_write() is called.
      
      In past days, ftrace_pid_write() used ftrace_start_lock, but
      commit e6ea44e9 consolidated
      ftrace_start_lock to ftrace_lock.
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Reviewed-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <20090306151155.0778.A69D9226@jp.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      10dd3ebe
    • K
      tracing: current tip/master can't enable ftrace · 422d3c7a
      KOSAKI Motohiro 提交于
      After commit 40ada30f,
      "make menuconfig" doesn't display "Tracer" item.
      
      Following modification restores it.
      422d3c7a
    • S
      tracing: add format files for ftrace default entries · 770cb243
      Steven Rostedt 提交于
      Impact: allow user apps to read binary format of basic ftrace entries
      
      Currently, only defined raw events export their formats so a binary
      reader can parse them. There's no reason that the default ftrace entries
      can't export their formats.
      
      This patch adds a subsystem called "ftrace" in the events directory
      that includes the ftrace entries for basic ftrace recorded items.
      
      These only have three files in the events directory:
      
       type             : printf
       available_types  : printf
       format           : format for the event entry
      
      For example:
      
       # cat /debug/tracing/events/ftrace/wakeup/format
      name: wakeup
      ID: 3
      format:
              field:unsigned char type;       offset:0;       size:1;
              field:unsigned char flags;      offset:1;       size:1;
              field:unsigned char preempt_count;      offset:2;       size:1;
              field:int pid;  offset:4;       size:4;
              field:int tgid; offset:8;       size:4;
      
              field:unsigned int prev_pid;    offset:12;      size:4;
              field:unsigned char prev_prio;  offset:16;      size:1;
              field:unsigned char prev_state; offset:17;      size:1;
              field:unsigned int next_pid;    offset:20;      size:4;
              field:unsigned char next_prio;  offset:24;      size:1;
              field:unsigned char next_state; offset:25;      size:1;
              field:unsigned int next_cpu;    offset:28;      size:4;
      
      print fmt: "%u:%u:%u  ==+ %u:%u:%u [%03u]"
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      770cb243
    • S
      tracing: move print of event format to separate file · 33b0c229
      Steven Rostedt 提交于
      Impact: clean up
      
      Move the macro that creates the event format file to a separate header.
      This will allow the default ftrace events to use this same macro
      to create the formats to read those events.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      33b0c229
    • S
      tracing: make all file_operations const · 5e2336a0
      Steven Rostedt 提交于
      Impact: cleanup
      
      All file_operations structures should be constant. No one is going to
      change them.
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      5e2336a0
    • I
      tracing: clean up menu · 40ada30f
      Ingo Molnar 提交于
      Clean up menu structure, introduce TRACING_SUPPORT switch that signals
      whether an architecture supports various instrumentation mechanisms.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      40ada30f
  5. 05 3月, 2009 11 次提交
    • F
      tracing/function-graph-tracer: use the more lightweight local clock · 0012693a
      Frederic Weisbecker 提交于
      Impact: decrease hangs risks with the graph tracer on slow systems
      
      Since the function graph tracer can spend too much time on timer
      interrupts, it's better now to use the more lightweight local
      clock. Anyway, the function graph traces are more reliable on a
      per cpu trace.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      LKML-Reference: <49af243d.06e9300a.53ad.ffff840c@mx.google.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0012693a
    • I
      tracing: rename ftrace_printk() => trace_printk() · 5e1607a0
      Ingo Molnar 提交于
      Impact: cleanup
      
      Use a more generic name - this also allows the prototype to move
      to kernel.h and be generally available to kernel developers who
      want to do some quick tracing.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5e1607a0
    • S
      tracing: have latency tracers set the latency format · e9d25fe6
      Steven Rostedt 提交于
      The latency tracers (irqsoff, preemptoff, preemptirqsoff, and wakeup)
      are pretty useless with the default output format. This patch makes them
      automatically enable the latency format when they are selected. They
      also record the state of the latency option, and if it was not enabled
      when selected, they disable it on reset.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      e9d25fe6
    • S
      tracing: consolidate print_lat_fmt and print_trace_fmt · 27d48be8
      Steven Rostedt 提交于
      Impact: clean up
      
      Both print_lat_fmt and print_trace_fmt do pretty much the same thing
      except for one different function call. This patch consolidates the
      two functions and adds an if statement to perform the difference.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      27d48be8
    • S
      tracing: remove extra latency_trace method from trace structure · 5fd73f86
      Steven Rostedt 提交于
      Impact: clean up
      
      The trace and latency_trace function pointers are identical for
      every tracer but the function tracer. The differences in the function
      tracer are trivial (latency output puts paranthesis around parent).
      
      This patch removes the latency_trace pointer and all prints will
      now just use the trace output function pointer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      5fd73f86
    • S
      tracing: add latency output format option · c032ef64
      Steven Rostedt 提交于
      With the removal of the latency_trace file, we lost the ability
      to see some of the finer details in a trace. Like the state of
      interrupts enabled, the preempt count, need resched, and if we
      are in an interrupt handler, softirq handler or not.
      
      This patch simply creates an option to bring back the old format.
      This also removes the warning about an unused variable that held
      the latency_trace file operations.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      c032ef64
    • S
      tracing: fix seq read from trace files · e74da523
      Steven Rostedt 提交于
      The buffer used by trace_seq was updated incorrectly. Instead
      of consuming what was actually read, it consumed the rest of the
      buffer on reads.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      e74da523
    • S
      tracing: do not return EFAULT if read copied anything · 2dc5d12b
      Steven Rostedt 提交于
      Impact: fix trace read to conform to standards
      
      Andrew Morton, Theodore Tso and H. Peter Anvin brought to my attention
      that a userspace read should not return -EFAULT if it succeeded in
      copying anything. It should only return -EFAULT if it failed to copy
      at all.
      
      This patch modifies the check of copy_from_user and updates the return
      code appropriately.
      
      I also used H. Peter Anvin's short cut rule to just test ret == count.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      2dc5d12b
    • S
      ring-buffer: fix timestamp in partial ring_buffer_page_read · 4f3640f8
      Steven Rostedt 提交于
      If a partial ring_buffer_page_read happens, then some of the
      incremental timestamps may be lost. This patch writes the
      recent timestamp into the page that is passed back to the caller.
      
      A partial ring_buffer_page_read is where the full page would not
      be written back to the user, and instead, just part of the page
      is copied to the user. A full page would be a page swap with the
      ring buffer and the timestamps would be correct.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      4f3640f8
    • S
      tracing: add cpu_file intialization for ftrace_dump · e543ad76
      Steven Rostedt 提交于
      Impact: fix to ftrace_dump output corruption
      
      The commit: b04cc6b1
        tracing/core: introduce per cpu tracing files
      
      added a new field to the iterator called cpu_file. This was a handle
      to differentiate between the per cpu trace output files and the
      all cpu "trace" file. The all cpu "trace" file required setting this
      to TRACE_PIPE_ALL_CPU.
      
      The problem is that the ftrace_dump sets up its own iterator but was
      not updated to handle this change. The result was only CPU 0 printing
      out on crash and a lot of "<0>"'s also being printed.
      Reported-by: NThomas Gleixner <tglx@linuxtronix.de>
      Tested-by: NDarren Hart <dvhtc@us.ibm.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      e543ad76
    • P
      tracing: add lockdep tracepoints for lock acquire/release · efed792d
      Peter Zijlstra 提交于
      Augment the traces with lock names when lockdep is available:
      
       1)               |  down_read_trylock() {
       1)               |    _spin_lock_irqsave() {
       1)               |      /* lock_acquire: &sem->wait_lock */
       1)   4.201 us    |    }
       1)               |    _spin_unlock_irqrestore() {
       1)               |      /* lock_release: &sem->wait_lock */
       1)   3.523 us    |    }
       1)               |  /* lock_acquire: try read &mm->mmap_sem */
       1) + 13.386 us   |  }
       1)   1.635 us    |  find_vma();
       1)               |  handle_mm_fault() {
       1)               |    __do_fault() {
       1)               |      filemap_fault() {
       1)               |        find_lock_page() {
       1)               |          find_get_page() {
       1)               |            /* lock_acquire: read rcu_read_lock */
       1)               |            /* lock_release: rcu_read_lock */
       1)   5.697 us    |          }
       1)   8.158 us    |        }
       1) + 11.079 us   |      }
       1)               |      _spin_lock() {
       1)               |        /* lock_acquire: __pte_lockptr(page) */
       1)   3.949 us    |      }
       1)   1.460 us    |      page_add_file_rmap();
       1)               |      _spin_unlock() {
       1)               |        /* lock_release: __pte_lockptr(page) */
       1)   3.115 us    |      }
       1)               |      unlock_page() {
       1)   1.421 us    |        page_waitqueue();
       1)   1.220 us    |        __wake_up_bit();
       1)   6.519 us    |      }
       1) + 34.328 us   |    }
       1) + 37.452 us   |  }
       1)               |  up_read() {
       1)               |  /* lock_release: &mm->mmap_sem */
       1)               |    _spin_lock_irqsave() {
       1)               |      /* lock_acquire: &sem->wait_lock */
       1)   3.865 us    |    }
       1)               |    _spin_unlock_irqrestore() {
       1)               |      /* lock_release: &sem->wait_lock */
       1)   8.562 us    |    }
       1) + 17.370 us   |  }
      Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: =?ISO-8859-1?Q?T=F6r=F6k?= Edwin <edwintorok@gmail.com>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1236166375.5330.7209.camel@laptop>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      efed792d
  6. 04 3月, 2009 5 次提交
  7. 03 3月, 2009 7 次提交
    • S
      tracing: fix return value to registering events · 633ddaa7
      Steven Rostedt 提交于
      The registering of events had the return value check backwards.
      A zero returned is success, the check had it as a failure.
      
      This patch also fixes a missing "\n" in the warning that the check
      failed.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      633ddaa7
    • S
      tracing: add print format to event trace format files · 96ccd21c
      Steven Rostedt 提交于
      This patch adds the internal print format used to print the raw events
      to the event trace point format file.
      
       # cat /debug/tracing/events/sched/sched_switch/format
      name: sched_switch
      ID: 29
      format:
              field:unsigned char type;       offset:0;       size:1;
              field:unsigned char flags;      offset:1;       size:1;
              field:unsigned char preempt_count;      offset:2;       size:1;
              field:int pid;  offset:4;       size:4;
              field:int tgid; offset:8;       size:4;
      
              field:pid_t prev_pid;   offset:12;      size:4;
              field:int prev_prio;    offset:16;      size:4;
              field special:char next_comm[TASK_COMM_LEN];    offset:20;      size:16;
              field:pid_t next_pid;   offset:36;      size:4;
              field:int next_prio;    offset:40;      size:4;
      
      print fmt: "prev %d:%d ==> next %s:%d:%d"
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      96ccd21c
    • S
      tracing: add trace name and id to event formats · c5e4e192
      Steven Rostedt 提交于
      To be able to identify the trace in the binary format output, the
      id of the trace event (which is dynamically assigned) must also be listed.
      
      This patch adds the name of the trace point as well as the id assigned.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      c5e4e192
    • S
      tracing: add ftrace headers to event format files · 91729ef9
      Steven Rostedt 提交于
      This patch includes the ftrace header to the event formats files:
      
       # cat /debug/tracing/events/sched/sched_switch/format
              field:unsigned char type;       offset:0;       size:1;
              field:unsigned char flags;      offset:1;       size:1;
              field:unsigned char preempt_count;      offset:2;       size:1;
              field:int pid;  offset:4;       size:4;
              field:int tgid; offset:8;       size:4;
      
              field:pid_t prev_pid;   offset:12;      size:4;
              field:int prev_prio;    offset:16;      size:4;
              field special:char next_comm[TASK_COMM_LEN];    offset:20;      size:16;
              field:pid_t next_pid;   offset:36;      size:4;
              field:int next_prio;    offset:40;      size:4;
      
      A blank line is used as a deliminator between the ftrace header and the
      trace point fields.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      91729ef9
    • S
      tracing: add format file to describe event struct fields · 981d081e
      Steven Rostedt 提交于
      This patch adds the "format" file to the trace point event directory.
      This is based off of work by Tom Zanussi, in which a file is exported
      to be tread from user land such that a user space app may read the
      binary record stored in the ring buffer.
      
       # cat /debug/tracing/events/sched/sched_switch/format
              field:pid_t prev_pid;   offset:12;      size:4;
              field:int prev_prio;    offset:16;      size:4;
              field special:char next_comm[TASK_COMM_LEN];    offset:20;      size:16;
              field:pid_t next_pid;   offset:36;      size:4;
              field:int next_prio;    offset:40;      size:4;
      
      Idea-from: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      981d081e
    • S
      tracing: make trace_seq_reset global and rename to trace_seq_init · f9520750
      Steven Rostedt 提交于
      Impact: clean up
      
      The trace_seq functions may be used separately outside of the ftrace
      iterator. The trace_seq_reset is needed for these operations.
      
      This patch also renames trace_seq_reset to the more appropriate
      trace_seq_init.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      f9520750
    • S
      tracing: add protection around modify trace event fields · 11a241a3
      Steven Rostedt 提交于
      The trace event objects are currently not proctected against
      reentrancy. This patch adds a mutex around the modifications of
      the trace event fields.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      11a241a3
  8. 02 3月, 2009 1 次提交
    • S
      tracing: add TRACE_FIELD_SPECIAL to record complex entries · d20e3b03
      Steven Rostedt 提交于
      Tom Zanussi pointed out that the simple TRACE_FIELD was not enough to
      record trace data that required memcpy. This patch addresses this issue
      by adding a TRACE_FIELD_SPECIAL. The format is similar to TRACE_FIELD
      but looks like so:
      
        TRACE_FIELD_SPECIAL(type_item, item, cmd)
      
      What TRACE_FIELD gave was:
      
        TRACE_FIELD(type, item, assign)
      
      The TRACE_FIELD would be used in declaring a structure:
      
        struct {
      	type	item;
        };
      
      And later assign it via:
      
        entry->item = assign;
      
      What TRACE_FIELD_SPECIAL gives us is:
      
      In the declaration of the structure:
      
        struct {
      	type_item;
        };
      
      And the assignment:
      
        cmd;
      
      This change log will explain the one example used in the patch:
      
       TRACE_EVENT_FORMAT(sched_switch,
      	TPPROTO(struct rq *rq, struct task_struct *prev,
      		struct task_struct *next),
      	TPARGS(rq, prev, next),
      	TPFMT("task %s:%d ==> %s:%d",
      	      prev->comm, prev->pid, next->comm, next->pid),
      	TRACE_STRUCT(
      		TRACE_FIELD(pid_t, prev_pid, prev->pid)
      		TRACE_FIELD(int, prev_prio, prev->prio)
      		TRACE_FIELD_SPECIAL(char next_comm[TASK_COMM_LEN],
      				    next_comm,
      				    TPCMD(memcpy(TRACE_ENTRY->next_comm,
      						 next->comm,
      						 TASK_COMM_LEN)))
      		TRACE_FIELD(pid_t, next_pid, next->pid)
      		TRACE_FIELD(int, next_prio, next->prio)
      	),
      	TPRAWFMT("prev %d:%d ==> next %s:%d:%d")
      	);
      
       The struct will be create as:
      
        struct {
      	pid_t		prev_pid;
      	int		prev_prio;
      	char next_comm[TASK_COMM_LEN];
      	pid_t		next_pid;
      	int		next_prio;
        };
      
      Note the TRACE_ENTRY in the cmd part of TRACE_SPECIAL. TRACE_ENTRY will
      be set by the tracer to point to the structure inside the trace buffer.
      
        entry->prev_pid	= prev->pid;
        entry->prev_prio	= prev->prio;
        memcpy(entry->next_comm, next->comm, TASK_COMM_LEN);
        entry->next_pid	= next->pid;
        entry->next_prio	= next->prio
      Reported-by: NTom Zanussi <tzanussi@gmail.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      d20e3b03
  9. 28 2月, 2009 4 次提交
    • S
      tracing: add raw fast tracing interface for trace events · fd994989
      Steven Rostedt 提交于
      This patch adds the interface to enable the C style trace points.
      In the directory /debugfs/tracing/events/subsystem/event
      We now have three files:
      
       enable : values 0 or 1 to enable or disable the trace event.
      
       available_types: values 'raw' and 'printf' which indicate the tracing
             types available for the trace point. If a developer does not
             use the TRACE_EVENT_FORMAT macro and just uses the TRACE_FORMAT
             macro, then only 'printf' will be available. This file is
             read only.
      
       type: values 'raw' or 'printf'. This indicates which type of tracing
             is active for that trace point. 'printf' is the default and
             if 'raw' is not available, this file is read only.
      
       # echo raw > /debug/tracing/events/sched/sched_wakeup/type
       # echo 1 > /debug/tracing/events/sched/sched_wakeup/enable
      
       Will enable the C style tracing for the sched_wakeup trace point.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      fd994989
    • S
      tracing: add raw trace point recording infrastructure · c32e827b
      Steven Rostedt 提交于
      Impact: lower overhead tracing
      
      The current event tracer can automatically pick up trace points
      that are registered with the TRACE_FORMAT macro. But it required
      a printf format string and parsing. Although, this adds the ability
      to get guaranteed information like task names and such, it took
      a hit in overhead processing. This processing can add about 500-1000
      nanoseconds overhead, but in some cases that too is considered
      too much and we want to shave off as much from this overhead as
      possible.
      
      Tom Zanussi recently posted tracing patches to lkml that are based
      on a nice idea about capturing the data via C structs using
      STRUCT_ENTER, STRUCT_EXIT type of macros.
      
      I liked that method very much, but did not like the implementation
      that required a developer to add data/code in several disjoint
      locations.
      
      This patch extends the event_tracer macros to do a similar "raw C"
      approach that Tom Zanussi did. But instead of having the developers
      needing to tweak a bunch of code all over the place, they can do it
      all in one macro - preferably placed near the code that it is
      tracing. That makes it much more likely that tracepoints will be
      maintained on an ongoing basis by the code they modify.
      
      The new macro TRACE_EVENT_FORMAT is created for this approach. (Note,
      a developer may still utilize the more low level DECLARE_TRACE macros
      if they don't care about getting their traces automatically in the event
      tracer.)
      
      They can also use the existing TRACE_FORMAT if they don't need to code
      the tracepoint in C, but just want to use the convenience of printf.
      
      So if the developer wants to "hardwire" a tracepoint in the fastest
      possible way, and wants to acquire their data via a user space utility
      in a raw binary format, or wants to see it in the trace output but not
      sacrifice any performance, then they can implement the faster but
      more complex TRACE_EVENT_FORMAT macro.
      
      Here's what usage looks like:
      
        TRACE_EVENT_FORMAT(name,
      	TPPROTO(proto),
      	TPARGS(args),
      	TPFMT(fmt, fmt_args),
      	TRACE_STUCT(
      		TRACE_FIELD(type1, item1, assign1)
      		TRACE_FIELD(type2, item2, assign2)
      			[...]
      	),
      	TPRAWFMT(raw_fmt)
      	);
      
      Note name, proto, args, and fmt, are all identical to what TRACE_FORMAT
      uses.
      
       name: is the unique identifier of the trace point
       proto: The proto type that the trace point uses
       args: the args in the proto type
       fmt: printf format to use with the event printf tracer
       fmt_args: the printf argments to match fmt
      
       TRACE_STRUCT starts the ability to create a structure.
       Each item in the structure is defined with a TRACE_FIELD
      
        TRACE_FIELD(type, item, assign)
      
       type: the C type of item.
       item: the name of the item in the stucture
       assign: what to assign the item in the trace point callback
      
       raw_fmt is a way to pretty print the struct. It must match
        the order of the items are added in TRACE_STUCT
      
       An example of this would be:
      
       TRACE_EVENT_FORMAT(sched_wakeup,
      	TPPROTO(struct rq *rq, struct task_struct *p, int success),
      	TPARGS(rq, p, success),
      	TPFMT("task %s:%d %s",
      	      p->comm, p->pid, success?"succeeded":"failed"),
      	TRACE_STRUCT(
      		TRACE_FIELD(pid_t, pid, p->pid)
      		TRACE_FIELD(int, success, success)
      	),
      	TPRAWFMT("task %d success=%d")
      	);
      
       This creates us a unique struct of:
      
       struct {
      	pid_t		pid;
      	int		success;
       };
      
       And the way the call back would assign these values would be:
      
      	entry->pid = p->pid;
      	entry->success = success;
      
      The nice part about this is that the creation of the assignent is done
      via macro magic in the event tracer.  Once the TRACE_EVENT_FORMAT is
      created, the developer will then have a faster method to record
      into the ring buffer. They do not need to worry about the tracer itself.
      
      The developer would only need to touch the files in include/trace/*.h
      
      Again, I would like to give special thanks to Tom Zanussi for this
      nice idea.
      
      Idea-from: Tom Zanussi <tzanussi@gmail.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      c32e827b
    • S
      tracing: add interface to write into current tracer buffer · ef5580d0
      Steven Rostedt 提交于
      Right now all tracers must manage their own trace buffers. This was
      to enforce tracers to be independent in case we finally decide to
      allow each tracer to have their own trace buffer.
      
      But now we are adding event tracing that writes to the current tracer's
      buffer. This adds an interface to allow events to write to the current
      tracer buffer without having to manage its own. Since event tracing
      has no "tracer", and is just a way to hook into any other tracer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      ef5580d0
    • S
      tracing: make the set_event and available_events subsystem aware · b628b3e6
      Steven Rostedt 提交于
      This patch makes the event files, set_event and available_events
      aware of the subsystem.
      
      Now you can enable an entire subsystem with:
      
        echo 'irq:*' > set_event
      
      Note: the '*' is not needed.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      b628b3e6