1. 16 5月, 2009 1 次提交
  2. 29 4月, 2009 1 次提交
  3. 10 4月, 2009 4 次提交
    • L
      tracing: fix splice return too large · 93cfb3c9
      Lai Jiangshan 提交于
      I got these from strace:
      
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 12288
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 12288
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 12288
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 16384
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 8192
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 8192
       splice(0x3, 0, 0x5, 0, 0x1000, 0x1) = 8192
      
      I wanted to splice_read 4096 bytes, but it returns 8192 or larger.
      
      It is because the return value of tracing_buffers_splice_read()
      does not include "zero out any left over data" bytes.
      
      But tracing_buffers_read() includes these bytes, we make them
      consistent.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <49D46674.9030804@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      93cfb3c9
    • L
      tracing: update file->f_pos when splice(2) it · c7625a55
      Lai Jiangshan 提交于
      Impact: Cleanup
      
      These two lines:
      
      	if (unlikely(*ppos))
      		return -ESPIPE;
      
      in tracing_buffers_splice_read() are not needed, VFS layer
      has disabled seek(2).
      
      We remove these two lines, and then we can update file->f_pos.
      
      And tracing_buffers_read() updates file->f_pos, this fix
      make tracing_buffers_splice_read() updates file->f_pos too.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <49D46670.4010503@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      c7625a55
    • L
      tracing: allocate page when needed · ddd538f3
      Lai Jiangshan 提交于
      Impact: Cleanup
      
      Sometimes, we open trace_pipe_raw, but we don't read(2) it,
      we just splice(2) it, thus, the page is not used.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <49D4666B.4010608@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ddd538f3
    • L
      tracing: disable seeking for trace_pipe_raw · d1e7e02f
      Lai Jiangshan 提交于
      Impact: disable pread()
      
      We set tracing_buffers_fops.llseek to no_llseek,
      but we can still perform pread() to read this file.
      
      That is not expected.
      
      This fix uses nonseekable_open() to disable it.
      
      tracing_buffers_fops.llseek is still set to no_llseek,
      it mark this file is a "non-seekable device" and is used by
      sys_splice(). See also do_splice() or manual of splice(2):
      
      ERRORS
             EINVAL Target file system doesn't support  splicing;
                    neither  of the descriptors refers to a pipe;
                    or offset given for non-seekable device.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      LKML-Reference: <49D46668.8030806@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      d1e7e02f
  4. 07 4月, 2009 4 次提交
    • N
      Update /debug/tracing/README · bc2b6871
      Nikanth Karthikesan 提交于
      Some of the tracers have been renamed, which was not updated in the in-kernel
      run-time README file. Update it.
      Signed-off-by: NNikanth Karthikesan <knikanth@suse.de>
      LKML-Reference: <200903231158.32151.knikanth@suse.de>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      bc2b6871
    • F
      tracing/ftrace: alloc the started cpumask for the trace file · b0dfa978
      Frederic Weisbecker 提交于
      Impact: fix a crash while cat trace file
      
      Currently we are using a cpumask to remind each cpu where a
      trace occured. It lets us notice the user that a cpu just had
      its first trace.
      
      But on latest -tip we have the following crash once we cat the trace
      file:
      
      IP: [<c0270c4a>] print_trace_fmt+0x45/0xe7
      *pde = 00000000
      Oops: 0000 [#1] PREEMPT SMP
      last sysfs file: /sys/class/net/eth0/carrier
      Pid: 3897, comm: cat Not tainted (2.6.29-tip-02825-g0f22972-dirty #81)
      EIP: 0060:[<c0270c4a>] EFLAGS: 00010297 CPU: 0
      EIP is at print_trace_fmt+0x45/0xe7
      EAX: 00000000 EBX: 00000000 ECX: c12d9e98 EDX: ccdb7010
      ESI: d31f4000 EDI: 00322401 EBP: d31f3f10 ESP: d31f3efc
      DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
      Process cat (pid: 3897, ti=d31f2000 task=d3b3cf20 task.ti=d31f2000)
      Stack:
      d31f4080 ccdb7010 d31f4000 d691fe70 ccdb7010 d31f3f24 c0270e5c d31f4000
      d691fe70 d31f4000 d31f3f34 c02718e8 c12d9e98 d691fe70 d31f3f70 c02bfc33
      00001000 09130000 d3b46e00 d691fe98 00000000 00000079 00000001 00000000
      Call Trace:
      [<c0270e5c>] ? print_trace_line+0x170/0x17c
      [<c02718e8>] ? s_show+0xa7/0xbd
      [<c02bfc33>] ? seq_read+0x24a/0x327
      [<c02bf9e9>] ? seq_read+0x0/0x327
      [<c02ab18b>] ? vfs_read+0x86/0xe1
      [<c02ab289>] ? sys_read+0x40/0x65
      [<c0202d8f>] ? sysenter_do_call+0x12/0x3c
      Code: 00 00 00 89 45 ec f7 c7 00 20 00 00 89 55 f0 74 4e f6 86 98 10 00 00 02 74 45 8b 86 8c 10 00 00 8b 9e a8 10 00 00 e8 52 f3 ff ff <0f> a3 03 19 c0 85 c0 75 2b 8b 86 8c 10 00 00 8b 9e a8 10 00 00
      EIP: [<c0270c4a>] print_trace_fmt+0x45/0xe7 SS:ESP 0068:d31f3efc
      CR2: 0000000000000000
      ---[ end trace aa9cf38e5ebed9dd ]---
      
      This is because we alloc the iter->started cpumask on tracing_pipe_open but
      not on tracing_open.
      
      It hadn't been noticed until now because we need to have ring buffer overruns
      to activate the starting of cpu buffer detection.
      
      Also, we need a check to not print the messagge for the first trace on the file.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1238619188-6109-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b0dfa978
    • F
      tracing/ftrace: fix missing include string.h · 5f0c6c03
      Frederic Weisbecker 提交于
      Building a kernel with tracing can raise the following warning on
      tip/master:
      
      kernel/trace/trace.c:1249: error: implicit declaration of function 'vbin_printf'
      
      We are missing an include to string.h
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <1238160130-7437-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5f0c6c03
    • L
      tracing: fix incorrect return type of ns2usecs() · cf8e3474
      Lai Jiangshan 提交于
      Impact: fix time output bug in 32bits system
      
      ns2usecs() returns 'long', it's incorrect.
      
      (In i386)
      ...
                <idle>-0     [000]   521.442100: _spin_lock <-tick_do_update_jiffies64
                <idle>-0     [000]   521.442101: do_timer <-tick_do_update_jiffies64
                <idle>-0     [000]   521.442102: update_wall_time <-do_timer
                <idle>-0     [000]   521.442102: update_xtime_cache <-update_wall_time
      ....
      (It always print the time less than 2200 seconds besides ...)
      Because 'long' is 32bits in i386. ( (1<<31) useconds is about 2200 seconds)
      
      ...
                <idle>-0     [001] 4154502640.134759: rcu_bh_qsctr_inc <-__do_softirq
                <idle>-0     [001] 4154502640.134760: _local_bh_enable <-__do_softirq
                <idle>-0     [001] 4154502640.134761: idle_cpu <-irq_exit
      ...
      (very large value)
      Because 'long' is a signed type and it is 32bits in i386.
      
      Changes in v2:
      return 'unsigned long long' instead of 'cycle_t'
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      LKML-Reference: <49D05D10.4030009@cn.fujitsu.com>
      Reported-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      cf8e3474
  5. 24 3月, 2009 2 次提交
    • S
      function-graph: add option for include sleep times · be6f164a
      Steven Rostedt 提交于
      Impact: give user a choice to show times spent while sleeping
      
      The user may want to see the time a function spent sleeping.
      This patch adds the trace option "sleep-time" to allow that.
      The "sleep-time" option is default on.
      
       echo sleep-time > /debug/tracing/trace_options
      
      produces:
      
       ------------------------------------------
       2)  avahi-d-3428  =>    <idle>-0
       ------------------------------------------
      
       2)               |      finish_task_switch() {
       2)   0.621 us    |        _spin_unlock_irq();
       2)   2.202 us    |      }
       2) ! 1002.197 us |    }
       2) ! 1003.521 us |  }
      
      where as,
      
       echo nosleep-time > /debug/tracing/trace_options
      
      produces:
      
       0)    <idle>-0    =>  yum-upd-3416
       ------------------------------------------
      
       0)               |              finish_task_switch() {
       0)   0.643 us    |                _spin_unlock_irq();
       0)   2.342 us    |              }
       0) + 41.302 us   |            }
       0) + 42.453 us   |          }
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      be6f164a
    • F
      tracing/function-graph-tracer: fix functions call traces imbalance · 16185369
      Frederic Weisbecker 提交于
      Impact: fix traces output
      
      Sometimes one can observe an imbalance in the traces between function
      calls and function return traces:
      
      func1() {
          }
      }
      
      The curly brace inside func1() is the return of another function nested
      inside func1. The return trace have been inserted in the buffer but not
      the entry.
      We are storing a return address on the function traces stack while we
      haven't inserted its entry on the buffer, hence the imbalance on the
      traces.
      
      This is because the tracers doesn't check all failures that can happen
      on buffer insertion.
      
      This patch reports the tracing recursion failures and the ring buffer
      failures. In such cases, we now restore the original return address for
      the function, giving up its return trace.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237843021-11695-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      16185369
  6. 23 3月, 2009 3 次提交
    • F
      tracing/ftrace: check if debugfs is registered before creating files · 3e1f60b8
      Frederic Weisbecker 提交于
      Impact: fix a crash with ftrace={nop,boot} parameter
      
      If the nop or initcall tracers are launched as boot tracers,
      they will attempt to create their option directory and files.
      But these tracers are registered very early and then assigned
      as "boot tracers" very early if asked to.
      
      Since they do this before debugfs has been registered (core initcall),
      a crash is triggered.
      
      Another early tracers could also come later. So we fix it by
      checking if debugfs is initialized before creating the root
      tracing directory.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237759847-21025-3-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      3e1f60b8
    • F
      tracing/events: don't use wake up for events · 07edf712
      Frederic Weisbecker 提交于
      Impact: fix hard-lockup with sched switch events
      
      Some ftrace events, such as sched wakeup, can be traced
      while the runqueue lock is hold. Since they are using
      trace_current_buffer_unlock_commit(), they call wake_up()
      which can try to grab the runqueue lock too, resulting in
      a deadlock.
      
      Now for all event, we call a new helper:
      trace_nowake_buffer_unlock_commit() which do pretty the same than
      trace_current_buffer_unlock_commit() except than it doesn't call
      trace_wake_up().
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237759847-21025-4-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      07edf712
    • D
      tracing: fix four sparse warnings · b8b94265
      Dmitri Vorobiev 提交于
      Impact: cleanup.
      
      This patch fixes the following sparse warnings:
      
       kernel/trace/trace.c:385:9: warning: symbol 'trace_seq_to_buffer' was
       not declared. Should it be static?
      
       kernel/trace/trace_clock.c:29:13: warning: symbol 'trace_clock_local'
       was not declared. Should it be static?
      
       kernel/trace/trace_clock.c:54:13: warning: symbol 'trace_clock' was not
       declared. Should it be static?
      
       kernel/trace/trace_clock.c:74:13: warning: symbol 'trace_clock_global'
       was not declared. Should it be static?
      Signed-off-by: NDmitri Vorobiev <dmitri.vorobiev@movial.com>
      LKML-Reference: <1237741871-5827-4-git-send-email-dmitri.vorobiev@movial.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b8b94265
  7. 22 3月, 2009 1 次提交
    • F
      tracing/function-graph-tracer: prevent hangs during self-tests · cf586b61
      Frederic Weisbecker 提交于
      Impact: detect tracing related hangs
      
      Sometimes, with some configs, the function graph tracer can make
      the timer interrupt too much slow, hanging the kernel in an endless
      loop of timer interrupts servicing.
      
      As suggested by Ingo, this patch brings a watchdog which stops the
      selftest after a defined number of functions traced, definitely
      disabling this tracer.
      
      For those who want to debug the cause of the function graph trace
      hang, you can pass the ftrace_dump_on_oops kernel parameter to dump
      the traces after this hang detection.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237694675-23509-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      cf586b61
  8. 20 3月, 2009 2 次提交
  9. 18 3月, 2009 7 次提交
  10. 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
  11. 16 3月, 2009 2 次提交
  12. 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
  13. 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
  14. 11 3月, 2009 2 次提交