1. 20 3月, 2009 1 次提交
  2. 18 3月, 2009 3 次提交
  3. 17 3月, 2009 2 次提交
    • S
      tracing: stop comm recording on tracing off · 6adaad14
      Steven Rostedt 提交于
      Impact: fix for losing comms in trace
      
      The command lines of tasks are cached at sched switch to not need
      to record them at every trace point.  Disabling the tracing on stops
      the recording of traces, but does not stop the caching of command lines.
      When the tracing is off the cache may overflow and cause the tracing
      to show incorrect tasks matching the PIDs.
      
      This patch disables prevents updates to the comm cache when the ring buffer
      is off.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      6adaad14
    • S
      tracing: protect reader of cmdline output · 4ca53085
      Steven Rostedt 提交于
      Impact: fix to one cause of incorrect comm outputs in trace
      
      The spinlock only protected the creation of a comm <=> pid pair.
      But it was possible that a reader could look up a pid, and get the
      wrong comm because it had no locking.
      
      This also required changing trace_find_cmdline to copy the comm cache
      and not just send back a pointer to it.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      4ca53085
  4. 16 3月, 2009 2 次提交
  5. 13 3月, 2009 5 次提交
    • S
      tracing: move binary buffers into per cpu directory · 7f96f93f
      Steven Rostedt 提交于
      The binary_buffers directory in /debugfs/tracing held the files
      to read the trace buffers in a binary format. This held one file
      per CPU buffer. But we also have a per_cpu directory that holds
      a way to read the pretty-print formats.
      
      This patch moves the binary buffers into the per_cpu_directory:
      
       # ls /debug/tracing/per_cpu/cpu1/
      trace  trace_pipe  trace_pipe_raw
      
      The new name is called "trace_pipe_raw". The binary buffers always
      acted similar to trace_pipe, except that they produce raw data.
      Requested-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      7f96f93f
    • F
      tracing/core: bring back raw trace_printk for dynamic formats strings · 48ead020
      Frederic Weisbecker 提交于
      Impact: fix callsites with dynamic format strings
      
      Since its new binary implementation, trace_printk() internally uses static
      containers for the format strings on each callsites. But the value is
      assigned once at build time, which means that it can't take dynamic
      formats.
      
      So this patch unearthes the raw trace_printk implementation for the callers
      that will need trace_printk to be able to carry these dynamic format
      strings. The trace_printk() macro will use the appropriate implementation
      for each callsite. Most of the time however, the binary implementation will
      still be used.
      
      The other impact of this patch is that mmiotrace_printk() will use the old
      implementation because it calls the low level trace_vprintk and we can't
      guess here whether the format passed in it is dynamic or not.
      
      Some parts of this patch have been written by Steven Rostedt (most notably
      the part that chooses the appropriate implementation for each callsites).
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      48ead020
    • S
      tracing: show that buffer size is not expanded · db526ca3
      Steven Rostedt 提交于
      Impact: do not confuse user on small trace buffer sizes
      
      When the system boots up, the trace buffer is small to conserve memory.
      It is only two pages per online CPU. When the tracer is used, it expands
      to the default value.
      
      This can confuse the user if they look at the buffer size and see only
      7, but then later they see 1408.
      
       # cat /debug/tracing/buffer_size_kb
      7
      
       # echo sched_switch > /debug/tracing/current_tracer
      
       # cat /debug/tracing/buffer_size_kb
      1408
      
      This patch tries to help remove this confustion by showing that the
      buffer has not been expanded.
      
       # cat /debug/tracing/buffer_size_kb
      7 (expanded: 1408)
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      db526ca3
    • S
      tracing: protect ring_buffer_expanded with trace_types_lock · 1027fcb2
      Steven Rostedt 提交于
      Impact: prevent races with ring_buffer_expanded
      
      This patch places the expanding of the tracing buffer under the
      protection of the trace_types_lock mutex. It is highly unlikely
      that there would be any contention, but better safe than sorry.
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      1027fcb2
    • S
      tracing: fix comments about trace buffer resizing · a123c52b
      Steven Rostedt 提交于
      Impact: cleanup
      
      Some of the comments about the trace buffer resizing is gobbledygook.
      And I wonder why people question if I'm a native English speaker.
      
      This patch makes the comments make a bit more sense.
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      a123c52b
  6. 12 3月, 2009 4 次提交
    • S
      ring-buffer: only allocate buffers for online cpus · 554f786e
      Steven Rostedt 提交于
      Impact: save on memory
      
      Currently, a ring buffer was allocated for each "possible_cpus". On
      some systems, this is the same as NR_CPUS. Thus, if a system defined
      NR_CPUS = 64 but it only had 1 CPU, we could have possibly 63 useless
      ring buffers taking up space. With a default buffer of 3 megs, this
      could be quite drastic.
      
      This patch changes the ring buffer code to only allocate ring buffers
      for online CPUs.  If a CPU goes off line, we do not free the buffer.
      This is because the user may still have trace data in that buffer
      that they would like to look at.
      
      Perhaps in the future we could add code to delete a ring buffer if
      the CPU is offline and the ring buffer becomes empty.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      554f786e
    • S
      tracing: fix trace_wait to know to wait on all cpus or just one · 9aba60fe
      Steven Rostedt 提交于
      Impact: fix to task live locking on reading trace_pipe on one CPU
      
      The same code is used for both trace_pipe (all CPUS) and the per_cpu
      trace_pipe file. When there is no data to read, it will check for
      signals and wait on the trace wait queue.
      
      The problem happens with the per_cpu wait. The trace_wait code checks
      all CPUs. Thus, if there's data in another CPU buffer, then it will
      exit the wait, without checking for signals or waiting on the wait queue.
      
      It would then try to read the empty buffer, and since that will just
      return nothing, then it will try to wait again. Unfortunately, that will
      again fail due to there still being data in the other buffers. This
      ends up with a live lock for the task.
      
      This patch fixes the trace_wait to be aware that the iterator may only
      be waiting on a single buffer.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      9aba60fe
    • S
      tracing: expand the ring buffers when an event is activated · 1852fcce
      Steven Rostedt 提交于
      To save memory, the tracer ring buffers are set to a minimum.
      The activating of a trace expands the ring buffer size. This patch
      adds this expanding, when an event is activated.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      1852fcce
    • S
      tracing: keep ring buffer to minimum size till used · 73c5162a
      Steven Rostedt 提交于
      Impact: less memory impact on systems not using tracer
      
      When the kernel boots up that has tracing configured, it allocates
      the default size of the ring buffer. This currently happens to be
      1.4Megs per possible CPU. This is quite a bit of wasted memory if
      the system is never using the tracer.
      
      The current solution is to keep the ring buffers to a minimum size
      until the user uses them. Once a tracer is piped into the current_tracer
      the ring buffer will be expanded to the default size. If the user
      changes the size of the ring buffer, it will take the size given
      by the user immediately.
      
      If the user adds a "ftrace=" to the kernel command line, then the ring
      buffers will be set to the default size on initialization.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      73c5162a
  7. 11 3月, 2009 2 次提交
  8. 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
  9. 07 3月, 2009 3 次提交
    • 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
  10. 06 3月, 2009 1 次提交
  11. 05 3月, 2009 8 次提交
    • 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: 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
      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
  12. 04 3月, 2009 1 次提交
    • S
      tracing: add binary buffer files for use with splice · 2cadf913
      Steven Rostedt 提交于
      Impact: new feature
      
      This patch creates a directory of files that correspond to the
      per CPU ring buffers. These are binary files and are made to
      be used with splice. This is the fastest way to extract data from
      the ftrace ring buffers.
      
      Thanks to Jiaying Zhang for pushing me to get this code fixed,
       and to Eduard - Gabriel Munteanu for his splice code that helped
       me debug my code.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      2cadf913
  13. 03 3月, 2009 1 次提交
  14. 28 2月, 2009 1 次提交
    • 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
  15. 27 2月, 2009 5 次提交