1. 21 4月, 2009 8 次提交
    • S
      ring-buffer: only warn on wrap if buffer is bigger than two pages · 3554228d
      Steven Rostedt 提交于
      On boot up, to save memory, ftrace allocates the minimum buffer
      which is two pages. Ftrace also goes through a series of tests
      (when configured) on boot up. These tests can fill up a page within
      a single interrupt.
      
      The ring buffer also has a WARN_ON when it detects that the buffer was
      completely filled within a single commit (other commits are allowed to
      be nested).
      
      Combine the small buffer on start up, with the tests that can fill more
      than a single page within an interrupt, this can trigger the WARN_ON.
      
      This patch makes the WARN_ON only happen when the ring buffer consists
      of more than two pages.
      
      [ Impact: prevent false WARN_ON in ftrace startup tests ]
      Reported-by: NIngo Molnar <mingo@elte.hu>
      LKML-Reference: <20090421094616.GA14561@elte.hu>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      3554228d
    • L
      tracing/filters: allow user-input to be integer-like string · f66578a7
      Li Zefan 提交于
      Suppose we would like to trace all tasks named '123', but this
      will fail:
      
       # echo 'parent_comm == 123' > events/sched/sched_process_fork/filter
       bash: echo: write error: Invalid argument
      
      Don't guess the type of the filter pred in filter_parse(), but instead
      we check it in __filter_add_pred().
      
      [ Impact: extend allowed filter field string values ]
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <49ED8DEB.6000700@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      f66578a7
    • L
      tracing/filters: don't remove old filters when failed to write subsys->filter · e8082f3f
      Li Zefan 提交于
      If writing subsys->filter returns EINVAL or ENOSPC, the original
      filters in subsys/ and subsys/events/ will be removed. This is
      definitely wrong.
      
      [ Impact: fix filter setting semantics on error condition ]
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <49ED8DD2.2070700@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      e8082f3f
    • S
      tracing: use nowakeup version of commit for function event trace tests · cb4764a6
      Steven Rostedt 提交于
      The startup tests for the event tracer also runs with the function
      tracer enabled. The "wakeup" version of the trace commit was used
      which can grab spinlocks. If a task was preempted by an NMI
      that called a function being traced, it could deadlock due to the
      function tracer trying to grab the same lock.
      
      Thanks to Frederic Weisbecker for pointing out where the bug was.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Reported-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      cb4764a6
    • S
      tracing: use recursive counter over irq level · aa18efb2
      Steven Rostedt 提交于
      Althought using the irq level (hardirq_count, softirq_count and in_nmi)
      was nice to detect bad recursion right away, but since the counters are
      not atomically updated with respect to the interrupts, the function tracer
      might trigger the test from an interrupt handler before the hardirq_count
      is updated. This will trigger a false warning.
      
      This patch converts the recursive detection to a simple counter.
      If the depth is greater than 16 then the recursive detection will trigger.
      16 is more than enough for any nested interrupts.
      
      [ Impact: fix false positive trace recursion detection ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      aa18efb2
    • S
      tracing: remove recursive test from ring_buffer_event_discard · e395898e
      Steven Rostedt 提交于
      The ring_buffer_event_discard is not tied to ring_buffer_lock_reserve.
      It can be called inside or outside the reserve/commit. Even if it
      is called inside the reserve/commit the commit part must also be called.
      
      Only ring_buffer_discard_commit can be used as a replacement for
      ring_buffer_unlock_commit.
      
      This patch removes the trace_recursive_unlock from ring_buffer_event_discard
      since it would be the wrong place to do so.
      
      [Impact: prevent breakage in trace recursive testing ]
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      e395898e
    • S
      tracing: fix recursive test level calculation · 17487bfe
      Steven Rostedt 提交于
      The recursive tests to detect same level recursion in the ring buffers
      did not account for the hard/softirq_counts to be shifted. Thus the
      numbers could be larger than then mask to be tested.
      
      This patch includes the shift for the calculation of the irq depth.
      
      [ Impact: stop false positives in trace recursion detection ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      17487bfe
    • S
      tracing/events: call the correct event trace selftest init function · 28d20e2d
      Steven Rostedt 提交于
      The late_initcall calls a helper function instead of the proper
      init event selftest function.
      
      This update may have been lost due to conflicting merges.
      
      [ Impact: fix compiler warning and call extended event trace self tests ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      28d20e2d
  2. 20 4月, 2009 5 次提交
    • S
      tracing: rename EVENT_TRACER config to ENABLE_EVENT_TRACING · a7abe97f
      Steven Rostedt 提交于
      Currently we have two configs: EVENT_TRACING and EVENT_TRACER.
      All tracers enable EVENT_TRACING. The EVENT_TRACER is only a
      convenience to enable the EVENT_TRACING when no other tracers
      are enabled.
      
      The names EVENT_TRACER and EVENT_TRACING are too similar and confusing.
      This patch renames EVENT_TRACER to ENABLE_EVENT_TRACING to be more
      appropriate to what it actually does, as well as add a comment in
      the help menu to explain the option's purpose.
      
      [ Impact: rename config option to reduce confusion ]
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      a7abe97f
    • S
      tracing: create menuconfig for tracing infrastructure · 4ed9f071
      Steven Rostedt 提交于
      During testing we often use randconfig to test various kernels.
      The current configuration set up does not give an easy way to disable
      all tracing with a single config. The case where randconfig would
      test all tracing disabled is very unlikely.
      
      This patch adds a config option to enable or disable all tracing.
      It is hooked into the tracing menu just like other submenus are done.
      
      [ Impact: allow randconfig to easily produce all traces disabled ]
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      4ed9f071
    • S
      tracing: change branch profiling to a choice selection · 9ae5b879
      Steven Rostedt 提交于
      This patch makes the branch profiling into a choice selection:
      
        None               - no branch profiling
        likely/unlikely    - only profile likely/unlikely branches
        all                - profile all branches
      
      The all profiler will also enable the likely/unlikely branches.
      
      This does not change the way the profiler works or the dependencies
      between the profilers.
      
      What this patch does, is keep the branch profiling from being selected
      by an allyesconfig make. The branch profiler is very intrusive and
      it is known to break various architecture builds when selected as an
      allyesconfig.
      
      [ Impact: prevent branch profiler from being selected in allyesconfig ]
      Reported-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Reported-by: NAl Viro <viro@zeniv.linux.org.uk>
      Reported-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Reported-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      9ae5b879
    • F
      tracing/ring-buffer: Add unlock recursion protection on discard · f3b9aae1
      Frederic Weisbecker 提交于
      The pair of helpers trace_recursive_lock() and trace_recursive_unlock()
      have been introduced recently to provide generic tracing recursion
      protection.
      
      They are used in a symetric way:
      
       - trace_recursive_lock() on buffer reserve
       - trace_recursive_unlock() on buffer commit
      
      However sometimes, we don't commit but discard on entry
      to the buffer, ie: in case of filter checking.
      
      Then we must also unlock the recursion protection on discard time,
      otherwise the tracing gets definitely deactivated and a warning
      is raised spuriously, such as:
      
      111.119821] ------------[ cut here ]------------
      [  111.119829] WARNING: at kernel/trace/ring_buffer.c:1498 ring_buffer_lock_reserve+0x1b7/0x1d0()
      [  111.119835] Hardware name: AMILO Li 2727
      [  111.119839] Modules linked in:
      [  111.119846] Pid: 5731, comm: Xorg Tainted: G        W  2.6.30-rc1 #69
      [  111.119851] Call Trace:
      [  111.119863]  [<ffffffff8025ce68>] warn_slowpath+0xd8/0x130
      [  111.119873]  [<ffffffff8028a30f>] ? __lock_acquire+0x19f/0x1ae0
      [  111.119882]  [<ffffffff8028a30f>] ? __lock_acquire+0x19f/0x1ae0
      [  111.119891]  [<ffffffff802199b0>] ? native_sched_clock+0x20/0x70
      [  111.119899]  [<ffffffff80286dee>] ? put_lock_stats+0xe/0x30
      [  111.119906]  [<ffffffff80286eb8>] ? lock_release_holdtime+0xa8/0x150
      [  111.119913]  [<ffffffff802c8ae7>] ring_buffer_lock_reserve+0x1b7/0x1d0
      [  111.119921]  [<ffffffff802cd110>] trace_buffer_lock_reserve+0x30/0x70
      [  111.119930]  [<ffffffff802ce000>] trace_current_buffer_lock_reserve+0x20/0x30
      [  111.119939]  [<ffffffff802474e8>] ftrace_raw_event_sched_switch+0x58/0x100
      [  111.119948]  [<ffffffff808103b7>] __schedule+0x3a7/0x4cd
      [  111.119957]  [<ffffffff80211b56>] ? ftrace_call+0x5/0x2b
      [  111.119964]  [<ffffffff80211b56>] ? ftrace_call+0x5/0x2b
      [  111.119971]  [<ffffffff80810c08>] schedule+0x18/0x40
      [  111.119977]  [<ffffffff80810e09>] preempt_schedule+0x39/0x60
      [  111.119985]  [<ffffffff80813bd3>] _read_unlock+0x53/0x60
      [  111.119993]  [<ffffffff807259d2>] sock_def_readable+0x72/0x80
      [  111.120002]  [<ffffffff807ad5ed>] unix_stream_sendmsg+0x24d/0x3d0
      [  111.120011]  [<ffffffff807219a3>] sock_aio_write+0x143/0x160
      [  111.120019]  [<ffffffff80211b56>] ? ftrace_call+0x5/0x2b
      [  111.120026]  [<ffffffff80721860>] ? sock_aio_write+0x0/0x160
      [  111.120033]  [<ffffffff80721860>] ? sock_aio_write+0x0/0x160
      [  111.120042]  [<ffffffff8031c283>] do_sync_readv_writev+0xf3/0x140
      [  111.120049]  [<ffffffff80211b56>] ? ftrace_call+0x5/0x2b
      [  111.120057]  [<ffffffff80276ff0>] ? autoremove_wake_function+0x0/0x40
      [  111.120067]  [<ffffffff8045d489>] ? cap_file_permission+0x9/0x10
      [  111.120074]  [<ffffffff8045c1e6>] ? security_file_permission+0x16/0x20
      [  111.120082]  [<ffffffff8031cab4>] do_readv_writev+0xd4/0x1f0
      [  111.120089]  [<ffffffff80211b56>] ? ftrace_call+0x5/0x2b
      [  111.120097]  [<ffffffff80211b56>] ? ftrace_call+0x5/0x2b
      [  111.120105]  [<ffffffff8031cc18>] vfs_writev+0x48/0x70
      [  111.120111]  [<ffffffff8031cd65>] sys_writev+0x55/0xc0
      [  111.120119]  [<ffffffff80211e32>] system_call_fastpath+0x16/0x1b
      [  111.120125] ---[ end trace 15605f4e98d5ccb5 ]---
      
      [ Impact: fix spurious warning triggering tracing shutdown ]
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      f3b9aae1
    • F
      tracing/core: Add current context on tracing recursion warning · e057a5e5
      Frederic Weisbecker 提交于
      In case of tracing recursion detection, we only get the stacktrace.
      But the current context may be very useful to debug the issue.
      
      This patch adds the softirq/hardirq/nmi context with the warning
      using lockdep context display to have a familiar output.
      
      v2: Use printk_once()
      v3: drop {hardirq,softirq}_context which depend on lockdep,
          only keep what is part of current->trace_recursion,
          sufficient to debug the warning source.
      
      [ Impact: print context necessary to debug recursion ]
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      e057a5e5
  3. 18 4月, 2009 5 次提交
    • S
      tracing: protect trace_printk from recursion · 3189cdb3
      Steven Rostedt 提交于
      trace_printk can be called from any context, including NMIs.
      If this happens, then we must test for for recursion before
      grabbing any spinlocks.
      
      This patch prevents trace_printk from being called recursively.
      
      [ Impact: prevent hard lockup in lockdep event tracer ]
      
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      3189cdb3
    • S
      tracing: add same level recursion detection · 261842b7
      Steven Rostedt 提交于
      The tracing infrastructure allows for recursion. That is, an interrupt
      may interrupt the act of tracing an event, and that interrupt may very well
      perform its own trace. This is a recursive trace, and is fine to do.
      
      The problem arises when there is a bug, and the utility doing the trace
      calls something that recurses back into the tracer. This recursion is not
      caused by an external event like an interrupt, but by code that is not
      expected to recurse. The result could be a lockup.
      
      This patch adds a bitmask to the task structure that keeps track
      of the trace recursion. To find the interrupt depth, the following
      algorithm is used:
      
        level = hardirq_count() + softirq_count() + in_nmi;
      
      Here, level will be the depth of interrutps and softirqs, and even handles
      the nmi. Then the corresponding bit is set in the recursion bitmask.
      If the bit was already set, we know we had a recursion at the same level
      and we warn about it and fail the writing to the buffer.
      
      After the data has been committed to the buffer, we clear the bit.
      No atomics are needed. The only races are with interrupts and they reset
      the bitmask before returning anywy.
      
      [ Impact: detect same irq level trace recursion ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      261842b7
    • S
      tracing: add EXPORT_SYMBOL_GPL for trace commits · 12acd473
      Steven Rostedt 提交于
      Not all the necessary symbols were exported to allow for tracing
      by modules. This patch adds them in.
      
      [ Impact: allow modules to commit data to the ring buffer ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      12acd473
    • T
      tracing/filters: add filter_mutex to protect filter predicates · ac1adc55
      Tom Zanussi 提交于
      This patch adds a filter_mutex to prevent the filter predicates from
      being accessed concurrently by various external functions.
      
      It's based on a previous patch by Li Zefan:
              "[PATCH 7/7] tracing/filters: make filter preds RCU safe"
      
      v2 changes:
      
      - fixed wrong value returned in a add_subsystem_pred() failure case
        noticed by Li Zefan.
      
      [ Impact: fix trace filter corruption/crashes on parallel access ]
      Signed-off-by: NTom Zanussi <tzanussi@gmail.com>
      Reviewed-by: NLi Zefan <lizf@cn.fujitsu.com>
      Tested-by: NLi Zefan <lizf@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: paulmck@linux.vnet.ibm.com
      LKML-Reference: <1239946028.6639.13.camel@tropicana>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ac1adc55
    • L
      tracing: fix file mode of trace and README · 339ae5d3
      Li Zefan 提交于
      trace is read-write and README is read-only.
      
      [ Impact: fix /debug/tracing/ file permissions. ]
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <49E7EAB6.4070605@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      339ae5d3
  4. 17 4月, 2009 5 次提交
    • S
      tracing/events: perform function tracing in event selftests · 9ea21c1e
      Steven Rostedt 提交于
      We can find some bugs in the trace events if we stress the writes as well.
      The function tracer is a good way to stress the events.
      
      [ Impact: extend scope of event tracer self-tests ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <20090416161746.604786131@goodmis.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      9ea21c1e
    • A
      tracing: add saved_cmdlines file to show cached task comms · 69abe6a5
      Avadh Patel 提交于
      Export the cached task comms to userspace. This allows user apps to translate
      the pids from a trace into their respective task command lines.
      
      [ Impact: let userspace apps reading binary buffer know comm's of pids ]
      Signed-off-by: NAvadh Patel <avadh4all@gmail.com>
      [ added error checking and use of buf pointer to index file_buf ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      69abe6a5
    • S
      tracing/events/ring-buffer: expose format of ring buffer headers to users · d1b182a8
      Steven Rostedt 提交于
      Currently, every thing needed to read the binary output from the
      ring buffers is available, with the exception of the way the ring
      buffers handles itself internally.
      
      This patch creates two special files in the debugfs/tracing/events
      directory:
      
       # cat /debug/tracing/events/header_page
              field: u64 timestamp;   offset:0;       size:8;
              field: local_t commit;  offset:8;       size:8;
              field: char data;       offset:16;      size:4080;
      
       # cat /debug/tracing/events/header_event
              type        :    2 bits
              len         :    3 bits
              time_delta  :   27 bits
              array       :   32 bits
      
              padding     : type == 0
              time_extend : type == 1
              data        : type == 3
      
      This is to allow a userspace app to see if the ring buffer format changes
      or not.
      
      [ Impact: allow userspace apps to know of ringbuffer format changes ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      d1b182a8
    • S
      tracing/events: add startup tests for events · e6187007
      Steven Rostedt 提交于
      As events start to become popular, and the new way to add tracing
      infrastructure into ftrace, it is important to catch any problems
      that might happen with a mistake in the TRACE_EVENT macro.
      
      This patch introduces a startup self test on the registered trace
      events. Note, it can only do a generic test, any type of testing that
      needs more involement is needed to be implemented by the tracepoint
      creators.
      
      The test goes down one by one enabling a trace point and running
      some random tasks (random in the sense that I just made them up).
      Those tasks are creating threads, grabbing mutexes and spinlocks
      and using workqueues.
      
      After testing each event individually, it does the same test after
      enabling each system of trace points. Like sched, irq, lockdep.
      
      Then finally it enables all tracepoints and performs the tasks again.
      The output to the console on bootup will look like this when everything
      works:
      
      Running tests on trace events:
      Testing event kfree_skb: OK
      Testing event kmalloc: OK
      Testing event kmem_cache_alloc: OK
      Testing event kmalloc_node: OK
      Testing event kmem_cache_alloc_node: OK
      Testing event kfree: OK
      Testing event kmem_cache_free: OK
      Testing event irq_handler_exit: OK
      Testing event irq_handler_entry: OK
      Testing event softirq_entry: OK
      Testing event softirq_exit: OK
      Testing event lock_acquire: OK
      Testing event lock_release: OK
      Testing event sched_kthread_stop: OK
      Testing event sched_kthread_stop_ret: OK
      Testing event sched_wait_task: OK
      Testing event sched_wakeup: OK
      Testing event sched_wakeup_new: OK
      Testing event sched_switch: OK
      Testing event sched_migrate_task: OK
      Testing event sched_process_free: OK
      Testing event sched_process_exit: OK
      Testing event sched_process_wait: OK
      Testing event sched_process_fork: OK
      Testing event sched_signal_send: OK
      Running tests on trace event systems:
      Testing event system skb: OK
      Testing event system kmem: OK
      Testing event system irq: OK
      Testing event system lockdep: OK
      Testing event system sched: OK
      Running tests on all trace events:
      Testing all events: OK
      
      [ folded in:
      
        tracing: add #include <linux/delay.h> to fix build failure in test_work()
      
        This build failure occured on a few rare configs:
      
         kernel/trace/trace_events.c: In function ‘test_work’:
         kernel/trace/trace_events.c:975: error: implicit declaration of function ‘udelay’
         kernel/trace/trace_events.c:980: error: implicit declaration of function ‘msleep’
      
        delay.h is included in way too many other headers, hiding cases
        where new usage is added without header inclusion.
      
        [ Impact: build fix ]
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ]
      
      [ Impact: add event tracer self-tests ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      e6187007
    • S
      ftrace: use module notifier for function tracer · 93eb677d
      Steven Rostedt 提交于
      The hooks in the module code for the function tracer must be called
      before any of that module code runs. The function tracer hooks
      modify the module (replacing calls to mcount to nops). If the code
      is executed while the change occurs, then the CPU can take a GPF.
      
      To handle the above with a bit of paranoia, I originally implemented
      the hooks as calls directly from the module code.
      
      After examining the notifier calls, it looks as though the start up
      notify is called before any of the module's code is executed. This makes
      the use of the notify safe with ftrace.
      
      Only the startup notify is required to be "safe". The shutdown simply
      removes the entries from the ftrace function list, and does not modify
      any code.
      
      This change has another benefit. It removes a issue with a reverse dependency
      in the mutexes of ftrace_lock and module_mutex.
      
      [ Impact: fix lock dependency bug, cleanup ]
      
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      93eb677d
  5. 16 4月, 2009 4 次提交
    • L
      blktrace: fix context-info when mixed-using blk tracer and trace events · f3948f88
      Li Zefan 提交于
      When current tracer is set to blk tracer, TRACE_ITER_CONTEXT_INFO is
      unset, but actually context-info is printed:
      
          pdflush-431   [000]   821.181576:   8,0    P   N [pdflush]
      
      And then if we enable TRACE_ITER_CONTEXT_INFO:
      
          # echo context-info > trace_options
      
      We'll see context-info printed twice. What's worse, when we use blk
      tracer and trace events at the same time, we'll see no context-info
      for trace events at all:
      
          jbd2_commit_logging: dev dm-0:8 transaction 333227
          jbd2_end_commit: dev dm-0:8 transaction 333227 head 332814
            rm-25433 [001]  9578.307485:   8,18   m   N cfq25433 slice expired t=0
            rm-25433 [001]  9578.307486:   8,18   m   N cfq25433 put_queue
      
      This patch adds blk_tracer->set_flags(), and context-info flag is unset
      only when we set the output to classic mode.
      
      Note after this patch, one should unset context-info explicitly if he
      wants to get binary output that can be parsed by blkparse:
      
          # echo nocontext-info > trace_options
          # echo bin > trace_options
          # echo blk > current_tracer
          # cat trace_pipe | blkparse -i -
      Reported-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <49E54E60.50408@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      f3948f88
    • L
      blktrace: add trace/ to /sys/block/sda · 1d54ad6d
      Li Zefan 提交于
      Impact: allow ftrace-plugin blktrace to trace device-mapper devices
      
      To trace a single partition:
        # echo 1 > /sys/block/sda/sda1/enable
      
      To trace the whole sda instead:
        # echo 1 > /sys/block/sda/enable
      
      Thus we also fix an issue reported by Ted, that ftrace-plugin blktrace
      can't be used to trace device-mapper devices.
      
      Now:
      
        # echo 1 > /sys/block/dm-0/trace/enable
        echo: write error: No such device or address
        # mount -t ext4 /dev/dm-0 /mnt
        # echo 1 > /sys/block/dm-0/trace/enable
        # echo blk > /debug/tracing/current_tracer
      Reported-by: NTheodore Tso <tytso@mit.edu>
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Shawn Du <duyuyang@gmail.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      LKML-Reference: <49E42665.6020506@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1d54ad6d
    • L
      blktrace: support per-partition tracing for ftrace plugin · 9908c309
      Li Zefan 提交于
      The previous patch adds support to trace a single partition for
      relay+ioctl blktrace, and this patch is for ftrace plugin blktrace:
      
        # echo 1 > /sys/block/sda/sda7/enable
        # cat start_lba
        102398373
        # cat end_lba
        102703545
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Shawn Du <duyuyang@gmail.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      LKML-Reference: <49E42646.4060608@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      9908c309
    • S
      blktrace: support per-partition tracing · d0deef5b
      Shawn Du 提交于
      Though one can specify '-d /dev/sda1' when using blktrace, it still
      traces the whole sda.
      
      To support per-partition tracing, when we start tracing, we initialize
      bt->start_lba and bt->end_lba to the start and end sector of that
      partition.
      
      Note some actions are per device, thus we don't filter 0-sector events.
      
      The original patch and discussion can be found here:
      	http://marc.info/?l=linux-btrace&m=122949374214540&w=2Signed-off-by: NShawn Du <duyuyang@gmail.com>
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Acked-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      LKML-Reference: <49E42620.4050701@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      d0deef5b
  6. 15 4月, 2009 8 次提交
    • S
      tracing/events: move trace point headers into include/trace/events · ad8d75ff
      Steven Rostedt 提交于
      Impact: clean up
      
      Create a sub directory in include/trace called events to keep the
      trace point headers in their own separate directory. Only headers that
      declare trace points should be defined in this directory.
      
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: Zhao Lei <zhaolei@cn.fujitsu.com>
      Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
      Cc: Pekka Enberg <penberg@cs.helsinki.fi>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      ad8d75ff
    • S
      tracing/events: fix compile for modules disabled · 61f919a1
      Steven Rostedt 提交于
      Impact: compile fix
      
      The addition of TRACE_EVENT for modules breaks the build for when
      modules are disabled. This code fixes that.
      Reported-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      61f919a1
    • S
      tracing/events: add support for modules to TRACE_EVENT · 6d723736
      Steven Rostedt 提交于
      Impact: allow modules to add TRACE_EVENTS on load
      
      This patch adds the final hooks to allow modules to use the TRACE_EVENT
      macro. A notifier and a data structure are used to link the TRACE_EVENTs
      defined in the module to connect them with the ftrace event tracing system.
      
      It also adds the necessary automated clean ups to the trace events when a
      module is removed.
      
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      6d723736
    • S
      tracing/events: add export symbols for trace events in modules · 17c873ec
      Steven Rostedt 提交于
      Impact: let modules add trace events
      
      The trace event code requires some functions to be exported to allow
      modules to use TRACE_EVENT. This patch adds EXPORT_SYMBOL_GPL to the
      necessary functions.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      17c873ec
    • S
      tracing/events: convert event call sites to use a link list · a59fd602
      Steven Rostedt 提交于
      Impact: makes it possible to define events in modules
      
      The events are created by reading down the section that they are linked
      in by the macros. But this is not scalable to modules. This patch converts
      the manipulations to use a global link list, and on boot up it adds
      the items in the section to the list.
      
      This change will allow modules to add their tracing events to the list as
      well.
      
      Note, this change alone does not permit modules to use the TRACE_EVENT macros,
      but the change is needed for them to eventually do so.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      a59fd602
    • S
      tracing/events: move the ftrace event tracing code to core · f42c85e7
      Steven Rostedt 提交于
      This patch moves the ftrace creation into include/trace/ftrace.h and
      simplifies the work of developers in adding new tracepoints.
      Just the act of creating the trace points in include/trace and including
      define_trace.h will create the events in the debugfs/tracing/events
      directory.
      
      This patch removes the need of include/trace/trace_events.h
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      f42c85e7
    • S
      tracing/events: move declarations from trace directory to core include · 97f20251
      Steven Rostedt 提交于
      In preparation to allowing trace events to happen in modules, we need
      to move some of the local declarations in the kernel/trace directory
      into include/linux.
      
      This patch simply moves the declarations and performs no context changes.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      97f20251
    • S
      tracing: make trace_seq operations available for core kernel · 9504504c
      Steven Rostedt 提交于
      In the process to make TRACE_EVENT macro work for modules, the trace_seq
      operations must be available for core kernel code.
      
      These operations are quite useful and can be used for other implementations.
      
      The main idea is that we create a trace_seq handle that acts very much
      like the seq_file handle.
      
      	struct trace_seq *s = kmalloc(sizeof(*s, GFP_KERNEL);
      
      	trace_seq_init(s);
      	trace_seq_printf(s, "some data %d\n", variable);
      
      	printk("%s", s->buffer);
      
      The main use is to allow a top level function call several other functions
      that may store printf like data into the buffer. Then at the end, the top
      level function can process all the data with any method it would like to.
      It could be passed to userspace, output via printk or even use seq_file:
      
      	trace_seq_to_user(s, ubuf, cnt);
      	seq_puts(m, s->buffer);
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      9504504c
  7. 14 4月, 2009 5 次提交
    • S
      tracing: consolidate trace and trace_event headers · ea20d929
      Steven Rostedt 提交于
      Impact: clean up
      
      Neil Horman (et. al.) criticized the way the trace events were broken up
      into two files. The reason for that was that ftrace needed to separate out
      the declarations from where the #include <linux/tracepoint.h> was used.
      It then dawned on me that the tracepoint.h header only needs to define the
      TRACE_EVENT macro if it is not already defined.
      
      The solution is simply to test if TRACE_EVENT is defined, and if it is not
      then the linux/tracepoint.h header can define it. This change consolidates
      all the <traces>.h and <traces>_event_types.h into the <traces>.h file.
      Reported-by: NNeil Horman <nhorman@tuxdriver.com>
      Reported-by: NTheodore Tso <tytso@mit.edu>
      Reported-by: NJiaying Zhang <jiayingz@google.com>
      Cc: Zhaolei <zhaolei@cn.fujitsu.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Jason Baron <jbaron@redhat.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      ea20d929
    • T
      tracing/filters: allow on-the-fly filter switching · 0a19e53c
      Tom Zanussi 提交于
      This patch allows event filters to be safely removed or switched
      on-the-fly while avoiding the use of rcu or the suspension of tracing of
      previous versions.
      
      It does it by adding a new filter_pred_none() predicate function which
      does nothing and by never deallocating either the predicates or any of
      the filter_pred members used in matching; the predicate lists are
      allocated and initialized during ftrace_event_calls initialization.
      
      Whenever a filter is removed or replaced, the filter_pred_* functions
      currently in use by the affected ftrace_event_call are immediately
      switched over to to the filter_pred_none() function, while the rest of
      the filter_pred members are left intact, allowing any currently
      executing filter_pred_* functions to finish up, using the values they're
      currently using.
      
      In the case of filter replacement, the new predicate values are copied
      into the old predicates after the above step, and the filter_pred_none()
      functions are replaced by the filter_pred_* functions for the new
      filter.  In this case, it is possible though very unlikely that a
      previous filter_pred_* is still running even after the
      filter_pred_none() switch and the switch to the new filter_pred_*.  In
      that case, however, because nothing has been deallocated in the
      filter_pred, the worst that can happen is that the old filter_pred_*
      function sees the new values and as a result produces either a false
      positive or a false negative, depending on the values it finds.
      
      So one downside to this method is that rarely, it can produce a bad
      match during the filter switch, but it should be possible to live with
      that, IMHO.
      
      The other downside is that at least in this patch the predicate lists
      are always pre-allocated, taking up memory from the start.  They could
      probably be allocated on first-use, and de-allocated when tracing is
      completely stopped - if this patch makes sense, I could create another
      one to do that later on.
      
      Oh, and it also places a restriction on the size of __arrays in events,
      currently set to 128, since they can't be larger than the now embedded
      str_val arrays in the filter_pred struct.
      Signed-off-by: NTom Zanussi <tzanussi@gmail.com>
      Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: paulmck@linux.vnet.ibm.com
      LKML-Reference: <1239610670.6660.49.camel@tropicana>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0a19e53c
    • T
      tracing/filters: use ring_buffer_discard_commit() in filter_check_discard() · eb02ce01
      Tom Zanussi 提交于
      This patch changes filter_check_discard() to make use of the new
      ring_buffer_discard_commit() function and modifies the current users to
      call the old commit function in the non-discard case.
      
      It also introduces a version of filter_check_discard() that uses the
      global trace buffer (filter_current_check_discard()) for those cases.
      
      v2 changes:
      
      - fix compile error noticed by Ingo Molnar
      Signed-off-by: NTom Zanussi <tzanussi@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: fweisbec@gmail.com
      LKML-Reference: <1239178554.10295.36.camel@tropicana>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      eb02ce01
    • T
      tracing/infrastructure: separate event tracer from event support · 5f77a88b
      Tom Zanussi 提交于
      Add a new config option, CONFIG_EVENT_TRACING that gets selected
      when CONFIG_TRACING is selected and adds everything needed by the stuff
      in trace_export - basically all the event tracing support needed by e.g.
      bprint, minus the actual events, which are only included if
      CONFIG_EVENT_TRACER is selected.
      
      So CONFIG_EVENT_TRACER can be used to turn on or off the generated events
      (what I think of as the 'event tracer'), while CONFIG_EVENT_TRACING turns
      on or off the base event tracing support used by both the event tracer and
      the other things such as bprint that can't be configured out.
      Signed-off-by: NTom Zanussi <tzanussi@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: fweisbec@gmail.com
      LKML-Reference: <1239178441.10295.34.camel@tropicana>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5f77a88b
    • S
      tracing/filters: use ring_buffer_discard_commit for discarded events · 77d9f465
      Steven Rostedt 提交于
      The ring_buffer_discard_commit makes better usage of the ring_buffer
      when an event has been discarded. It tries to remove it completely if
      possible.
      
      This patch converts the trace event filtering to use
      ring_buffer_discard_commit instead of the ring_buffer_event_discard.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      77d9f465