1. 21 4月, 2017 10 次提交
    • S
      tracing/ftrace: Allow for instances to trigger their own stacktrace probes · dcc19d28
      Steven Rostedt (VMware) 提交于
      Have the stacktrace function trigger probe trigger stack traces within the
      instance that they were added to in the set_ftrace_filter.
      
       ># cd /sys/kernel/debug/tracing
       ># mkdir instances/foo
       ># cd instances/foo
       ># echo schedule:stacktrace:1 > set_ftrace_filter
       ># cat trace
       # tracer: nop
       #
       # entries-in-buffer/entries-written: 1/1   #P:4
       #
       #                              _-----=> irqs-off
       #                             / _----=> need-resched
       #                            | / _---=> hardirq/softirq
       #                            || / _--=> preempt-depth
       #                            ||| /     delay
       #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
       #              | |       |   ||||       |         |
                 <idle>-0     [001] .N.2   202.585010: <stack trace>
        =>
        => schedule
        => schedule_preempt_disabled
        => do_idle
        => cpu_startup_entry
        => start_secondary
        => verify_cpu
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      dcc19d28
    • S
      tracing/ftrace: Allow for the traceonoff probe be unique to instances · 2290f2c5
      Steven Rostedt (VMware) 提交于
      Have the traceon/off function probe triggers affect only the instance they
      are set in. This required making the trace_on/off accessible for other files
      in the tracing directory.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      2290f2c5
    • S
      tracing/ftrace: Add a better way to pass data via the probe functions · 6e444319
      Steven Rostedt (VMware) 提交于
      With the redesign of the registration and execution of the function probes
      (triggers), data can now be passed from the setup of the probe to the probe
      callers that are specific to the trace_array it is on. Although, all probes
      still only affect the toplevel trace array, this change will allow for
      instances to have their own probes separated from other instances and the
      top array.
      
      That is, something like the stacktrace probe can be set to trace only in an
      instance and not the toplevel trace array. This isn't implement yet, but
      this change sets the ground work for the change.
      
      When a probe callback is triggered (someone writes the probe format into
      set_ftrace_filter), it calls register_ftrace_function_probe() passing in
      init_data that will be used to initialize the probe. Then for every matching
      function, register_ftrace_function_probe() will call the probe_ops->init()
      function with the init data that was passed to it, as well as an address to
      a place holder that is associated with the probe and the instance. The first
      occurrence will have a NULL in the pointer. The init() function will then
      initialize it. If other probes are added, or more functions are part of the
      probe, the place holder will be passed to the init() function with the place
      holder data that it was initialized to the last time.
      
      Then this place_holder is passed to each of the other probe_ops functions,
      where it can be used in the function callback. When the probe_ops free()
      function is called, it can be called either with the rip of the function
      that is being removed from the probe, or zero, indicating that there are no
      more functions attached to the probe, and the place holder is about to be
      freed. This gives the probe_ops a way to free the data it assigned to the
      place holder if it was allocade during the first init call.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      6e444319
    • S
      ftrace: Dynamically create the probe ftrace_ops for the trace_array · 7b60f3d8
      Steven Rostedt (VMware) 提交于
      In order to eventually have each trace_array instance have its own unique
      set of function probes (triggers), the trace array needs to hold the ops and
      the filters for the probes.
      
      This is the first step to accomplish this. Instead of having the private
      data of the probe ops point to the trace_array, create a separate list that
      the trace_array holds. There's only one private_data for a probe, we need
      one per trace_array. The probe ftrace_ops will be dynamically created for
      each instance, instead of being static.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      7b60f3d8
    • S
      tracing: Pass the trace_array into ftrace_probe_ops functions · b5f081b5
      Steven Rostedt (VMware) 提交于
      Pass the trace_array associated to a ftrace_probe_ops into the probe_ops
      func(), init() and free() functions. The trace_array is the descriptor that
      describes a tracing instance. This will help create the infrastructure that
      will allow having function probes unique to tracing instances.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      b5f081b5
    • S
      tracing: Have the trace_array hold the list of registered func probes · 04ec7bb6
      Steven Rostedt (VMware) 提交于
      Add a link list to the trace_array to hold func probes that are registered.
      Currently, all function probes are the same for all instances as it was
      before, that is, only the top level trace_array holds the function probes.
      But this lays the ground work to have function probes be attached to
      individual instances, and having the event trigger only affect events in the
      given instance. But that work is still to be done.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      04ec7bb6
    • S
      ftrace: Have unregister_ftrace_function_probe_func() return a value · d3d532d7
      Steven Rostedt (VMware) 提交于
      Currently unregister_ftrace_function_probe_func() is a void function. It
      does not give any feedback if an error occurred or no item was found to
      remove and nothing was done.
      
      Change it to return status and success if it removed something. Also update
      the callers to return that feedback to the user.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      d3d532d7
    • S
      ftrace: Remove data field from ftrace_func_probe structure · 1a48df00
      Steven Rostedt (VMware) 提交于
      No users of the function probes uses the data field anymore. Remove it, and
      change the init function to take a void *data parameter instead of a
      void **data, because the init will just get the data that the registering
      function was received, and there's no state after it is called.
      
      The other functions for ftrace_probe_ops still take the data parameter, but
      it will currently only be passed NULL. It will stay as a parameter for
      future data to be passed to these functions.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      1a48df00
    • S
      ftrace: Convert the rest of the function trigger over to the mapping functions · fe014e24
      Steven Rostedt (VMware) 提交于
      As the data pointer for individual ips will soon be removed and no longer
      passed to the callback function probe handlers, convert the rest of the function
      trigger counters over to the new ftrace_func_mapper helper functions.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      fe014e24
    • S
      ftrace: Pass probe ops to probe function · bca6c8d0
      Steven Rostedt (VMware) 提交于
      In preparation to cleaning up the probe function registration code, the
      "data" parameter will eventually be removed from the probe->func() call.
      Instead it will receive its own "ops" function, in which it can set up its
      own data that it needs to map.
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      bca6c8d0
  2. 25 3月, 2017 1 次提交
  3. 20 6月, 2016 1 次提交
  4. 09 3月, 2016 1 次提交
    • C
      tracing: Make tracer_flags use the right set_flag callback · d39cdd20
      Chunyu Hu 提交于
      When I was updating the ftrace_stress test of ltp. I encountered
      a strange phenomemon, excute following steps:
      
      echo nop > /sys/kernel/debug/tracing/current_tracer
      echo 0 > /sys/kernel/debug/tracing/options/funcgraph-cpu
      bash: echo: write error: Invalid argument
      
      check dmesg:
      [ 1024.903855] nop_test_refuse flag set to 0: we refuse.Now cat trace_options to see the result
      
      The reason is that the trace option test will randomly setup trace
      option under tracing/options no matter what the current_tracer is.
      but the set_tracer_option is always using the set_flag callback
      from the current_tracer. This patch adds a pointer to tracer_flags
      and make it point to the tracer it belongs to. When the option is
      setup, the set_flag of the right tracer will be used no matter
      what the the current_tracer is.
      
      And the old dummy_tracer_flags is used for all the tracers which
      doesn't have a tracer_flags, having issue to use it to save the
      pointer of a tracer. So remove it and use dynamic dummy tracer_flags
      for tracers needing a dummy tracer_flags, as a result, there are no
      tracers sharing tracer_flags, so remove the check code.
      
      And save the current tracer to trace_option_dentry seems not good as
      it may waste mem space when mount the debug/trace fs more than one time.
      
      Link: http://lkml.kernel.org/r/1457444222-8654-1-git-send-email-chuhu@redhat.comSigned-off-by: NChunyu Hu <chuhu@redhat.com>
      [ Fixed up function tracer options to work with the change ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      d39cdd20
  5. 20 11月, 2014 1 次提交
  6. 19 11月, 2014 1 次提交
    • S
      tracing: Fix race of function probes counting · a9ce7c36
      Steven Rostedt (Red Hat) 提交于
      The function probe counting for traceon and traceoff suffered a race
      condition where if the probe was executing on two or more CPUs at the
      same time, it could decrement the counter by more than one when
      disabling (or enabling) the tracer only once.
      
      The way the traceon and traceoff probes are suppose to work is that
      they disable (or enable) tracing once per count. If a user were to
      echo 'schedule:traceoff:3' into set_ftrace_filter, then when the
      schedule function was called, it would disable tracing. But the count
      should only be decremented once (to 2). Then if the user enabled tracing
      again (via tracing_on file), the next call to schedule would disable
      tracing again and the count would be decremented to 1.
      
      But if multiple CPUS called schedule at the same time, it is possible
      that the count would be decremented more than once because of the
      simple "count--" used.
      
      By reading the count into a local variable and using memory barriers
      we can guarantee that the count would only be decremented once per
      disable (or enable).
      
      The stack trace probe had a similar race, but here the stack trace will
      decrement for each time it is called. But this had the read-modify-
      write race, where it could stack trace more than the number of times
      that was specified. This case we use a cmpxchg to stack trace only the
      number of times specified.
      
      The dump probes can still use the old "update_count()" function as
      they only run once, and that is controlled by the dump logic
      itself.
      
      Link: http://lkml.kernel.org/r/20141118134643.4b550ee4@gandalf.local.homeSigned-off-by: NSteven Rostedt <rostedt@goodmis.org>
      a9ce7c36
  7. 14 11月, 2014 1 次提交
  8. 30 4月, 2014 1 次提交
  9. 22 4月, 2014 1 次提交
    • S
      ftrace: Remove global function list and call function directly · 4104d326
      Steven Rostedt (Red Hat) 提交于
      Instead of having a list of global functions that are called,
      as only one global function is allow to be enabled at a time, there's
      no reason to have a list.
      
      Instead, simply have all the users of the global ops, use the global ops
      directly, instead of registering their own ftrace_ops. Just switch what
      function is used before enabling the function tracer.
      
      This removes a lot of code as well as the complexity involved with it.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      4104d326
  10. 17 4月, 2014 1 次提交
    • S
      tracing: Do not try to recreated toplevel set_ftrace_* files · 5d6c97c5
      Steven Rostedt (Red Hat) 提交于
      With the restructing of the function tracer working with instances, the
      "top level" buffer is a bit special, as the function tracing is mapped
      to the same set of filters. This is done by using a "global_ops" descriptor
      and having the "set_ftrace_filter" and "set_ftrace_notrace" map to it.
      
      When an instance is created, it creates the same files but its for the
      local instance and not the global_ops.
      
      The issues is that the local instance creation shares some code with
      the global instance one and we end up trying to create th top level
      "set_ftrace_*" files twice, and on boot up, we get an error like this:
      
       Could not create debugfs 'set_ftrace_filter' entry
       Could not create debugfs 'set_ftrace_notrace' entry
      
      The reason they failed to be created was because they were created
      twice, and the second time gives this error as you can not create the
      same file twice.
      Reported-by: NBorislav Petkov <bp@alien8.de>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      5d6c97c5
  11. 21 2月, 2014 3 次提交
  12. 19 7月, 2013 1 次提交
  13. 12 6月, 2013 2 次提交
    • S
      tracing: Add function probe to trigger a ftrace dump of current CPU trace · 90e3c03c
      Steven Rostedt (Red Hat) 提交于
      Add the "cpudump" command to have the current CPU ftrace buffer dumped
      to console if a function is hit. This is useful when debugging a
      tripple fault, where you have an idea of a function that is called
      just before the tripple fault occurs, and can tell ftrace to dump its
      content out to the console before it continues.
      
      This differs from the "dump" command as it only dumps the content of
      the ring buffer for the currently executing CPU, and does not show
      the contents of the other CPUs.
      
      Format is:
      
        <function>:cpudump
      
      echo 'bad_address:cpudump' > /debug/tracing/set_ftrace_filter
      
      To remove this:
      
      echo '!bad_address:cpudump' > /debug/tracing/set_ftrace_filter
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      90e3c03c
    • S
      tracing: Add function probe to trigger a ftrace dump to console · ad71d889
      Steven Rostedt (Red Hat) 提交于
      Add the "dump" command to have the ftrace buffer dumped to console if
      a function is hit. This is useful when debugging a tripple fault,
      where you have an idea of a function that is called just before the
      tripple fault occurs, and can tell ftrace to dump its content out
      to the console before it continues.
      
      Format is:
      
        <function>:dump
      
      echo 'bad_address:dump' > /debug/tracing/set_ftrace_filter
      
      To remove this:
      
      echo '!bad_address:dump' > /debug/tracing/set_ftrace_filter
      Requested-by: NLuis Claudio R. Goncalves <lclaudio@uudg.org>
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      ad71d889
  14. 15 3月, 2013 6 次提交
    • S
      tracing: Add function probe to trigger stack traces · dd42cd3e
      Steven Rostedt (Red Hat) 提交于
      Add a function probe that will cause a stack trace to be traced in
      the ring buffer when the given function(s) are called.
      
      format is:
      
       <function>:stacktrace[:<count>]
      
       echo 'schedule:stacktrace' > /debug/tracing/set_ftrace_filter
       cat /debug/tracing/trace_pipe
           kworker/2:0-4329  [002] ...2  2933.558007: <stack trace>
       => kthread
       => ret_from_fork
                <idle>-0     [000] .N.2  2933.558019: <stack trace>
       => rest_init
       => start_kernel
       => x86_64_start_reservations
       => x86_64_start_kernel
           kworker/2:0-4329  [002] ...2  2933.558109: <stack trace>
       => kthread
       => ret_from_fork
      [...]
      
      This can be set to only trace a specific amount of times:
      
       echo 'schedule:stacktrace:3' > /debug/tracing/set_ftrace_filter
       cat /debug/tracing/trace_pipe
                 <...>-58    [003] ...2   841.801694: <stack trace>
       => kthread
       => ret_from_fork
                <idle>-0     [001] .N.2   841.801697: <stack trace>
       => start_secondary
                 <...>-2059  [001] ...2   841.801736: <stack trace>
       => wait_for_common
       => wait_for_completion
       => flush_work
       => tty_flush_to_ldisc
       => input_available_p
       => n_tty_poll
       => tty_poll
       => do_select
       => core_sys_select
       => sys_select
       => system_call_fastpath
      
      To remove these:
      
       echo '!schedule:stacktrace' > /debug/tracing/set_ftrace_filter
       echo '!schedule:stacktrace:0' > /debug/tracing/set_ftrace_filter
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      dd42cd3e
    • S
      ftrace: Separate unlimited probes from count limited probes · 8380d248
      Steven Rostedt (Red Hat) 提交于
      The function tracing probes that trigger traceon or traceoff can be
      set to unlimited, or given a count of # of times to execute.
      
      By separating these two types of probes, we can then use the dynamic
      ftrace function filtering directly, and remove the brute force
      "check if this function called is my probe" routines in ftrace.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      8380d248
    • S
      tracing: Consolidate ftrace_trace_onoff_unreg() into callback · 8b8fa62c
      Steven Rostedt (Red Hat) 提交于
      The only thing ftrace_trace_onoff_unreg() does is to do a strcmp()
      against the cmd parameter to determine what op to unregister. But
      this compare is also done after the location that this function is
      called (and returns). By moving the check for '!' to unregister after
      the strcmp(), the callback function itself can just do the unregister
      and we can get rid of the helper function.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      8b8fa62c
    • S
      tracing: Consolidate updating of count for traceon/off · 1c317143
      Steven Rostedt (Red Hat) 提交于
      Remove some duplicate code and replace it with a helper function.
      This makes the code a it cleaner.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      1c317143
    • S
      tracing: Consolidate max_tr into main trace_array structure · 12883efb
      Steven Rostedt (Red Hat) 提交于
      Currently, the way the latency tracers and snapshot feature works
      is to have a separate trace_array called "max_tr" that holds the
      snapshot buffer. For latency tracers, this snapshot buffer is used
      to swap the running buffer with this buffer to save the current max
      latency.
      
      The only items needed for the max_tr is really just a copy of the buffer
      itself, the per_cpu data pointers, the time_start timestamp that states
      when the max latency was triggered, and the cpu that the max latency
      was triggered on. All other fields in trace_array are unused by the
      max_tr, making the max_tr mostly bloat.
      
      This change removes the max_tr completely, and adds a new structure
      called trace_buffer, that holds the buffer pointer, the per_cpu data
      pointers, the time_start timestamp, and the cpu where the latency occurred.
      
      The trace_array, now has two trace_buffers, one for the normal trace and
      one for the max trace or snapshot. By doing this, not only do we remove
      the bloat from the max_trace but the instances of traces can now use
      their own snapshot feature and not have just the top level global_trace have
      the snapshot feature and latency tracers for itself.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      12883efb
    • S
      tracing: Replace the static global per_cpu arrays with allocated per_cpu · a7603ff4
      Steven Rostedt 提交于
      The global and max-tr currently use static per_cpu arrays for the CPU data
      descriptors. But in order to get new allocated trace_arrays, they need to
      be allocated per_cpu arrays. Instead of using the static arrays, switch
      the global and max-tr to use allocated data.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      a7603ff4
  15. 24 1月, 2013 1 次提交
  16. 23 1月, 2013 1 次提交
    • S
      ftrace: Use only the preempt version of function tracing · 897f68a4
      Steven Rostedt 提交于
      The function tracer had two different versions of function tracing.
      
      The disabling of irqs version and the preempt disable version.
      
      As function tracing in very intrusive and can cause nasty recursion
      issues, it has its own recursion protection. But the old method to
      do this was a flat layer. If it detected that a recursion was happening
      then it would just return without recording.
      
      This made the preempt version (much faster than the irq disabling one)
      not very useful, because if an interrupt were to occur after the
      recursion flag was set, the interrupt would not be traced at all,
      because every function that was traced would think it recursed on
      itself (due to the context it preempted setting the recursive flag).
      
      Now that we have a recursion flag for every context level, we
      no longer need to worry about that. We can disable preemption,
      set the current context recursion check bit, and go on. If an
      interrupt were to come along, it would check its own context bit
      and happily continue to trace.
      
      As the preempt version is faster than the irq disable version,
      there's no more reason to keep the preempt version around.
      And the irq disable version still had an issue with missing
      out on tracing NMI code.
      
      Remove the irq disable function tracer version and have the
      preempt disable version be the default (and only version).
      
      Before this patch we had from running:
      
       # echo function > /debug/tracing/current_tracer
       # for i in `seq 10`; do ./hackbench 50; done
      Time: 12.028
      Time: 11.945
      Time: 11.925
      Time: 11.964
      Time: 12.002
      Time: 11.910
      Time: 11.944
      Time: 11.929
      Time: 11.941
      Time: 11.924
      
      (average: 11.9512)
      
      Now we have:
      
       # echo function > /debug/tracing/current_tracer
       # for i in `seq 10`; do ./hackbench 50; done
      Time: 10.285
      Time: 10.407
      Time: 10.243
      Time: 10.372
      Time: 10.380
      Time: 10.198
      Time: 10.272
      Time: 10.354
      Time: 10.248
      Time: 10.253
      
      (average: 10.3012)
      
       a 13.8% savings!
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      897f68a4
  17. 06 12月, 2012 1 次提交
  18. 01 11月, 2012 2 次提交
  19. 07 9月, 2012 1 次提交
    • A
      pstore/ftrace: Convert to its own enable/disable debugfs knob · 65f8c95e
      Anton Vorontsov 提交于
      With this patch we no longer reuse function tracer infrastructure, now
      we register our own tracer back-end via a debugfs knob.
      
      It's a bit more code, but that is the only downside. On the bright side we
      have:
      
      - Ability to make persistent_ram module removable (when needed, we can
        move ftrace_ops struct into a module). Note that persistent_ram is still
        not removable for other reasons, but with this patch it's just one
        thing less to worry about;
      
      - Pstore part is more isolated from the generic function tracer. We tried
        it already by registering our own tracer in available_tracers, but that
        way we're loosing ability to see the traces while we record them to
        pstore. This solution is somewhere in the middle: we only register
        "internal ftracer" back-end, but not the "front-end";
      
      - When there is only pstore tracing enabled, the kernel will only write
        to the pstore buffer, omitting function tracer buffer (which, of course,
        still can be enabled via 'echo function > current_tracer').
      Suggested-by: NSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NAnton Vorontsov <anton.vorontsov@linaro.org>
      65f8c95e
  20. 31 7月, 2012 1 次提交
    • S
      ftrace: Add default recursion protection for function tracing · 4740974a
      Steven Rostedt 提交于
      As more users of the function tracer utility are being added, they do
      not always add the necessary recursion protection. To protect from
      function recursion due to tracing, if the callback ftrace_ops does not
      specifically specify that it protects against recursion (by setting
      the FTRACE_OPS_FL_RECURSION_SAFE flag), the list operation will be
      called by the mcount trampoline which adds recursion protection.
      
      If the flag is set, then the function will be called directly with no
      extra protection.
      
      Note, the list operation is called if more than one function callback
      is registered, or if the arch does not support all of the function
      tracer features.
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      4740974a
  21. 20 7月, 2012 2 次提交