1. 26 Mar, 2009 2 commits
    • Steven Rostedt's avatar
      tracing: add average time in function to function profiler · 34886c8b
      Steven Rostedt authored
      Show the average time in the function (Time / Hit)
      
        Function                               Hit    Time            Avg
        --------                               ---    ----            ---
        mwait_idle                              51    140326.6 us     2751.503 us
        smp_apic_timer_interrupt                47    3517.735 us     74.845 us
        schedule                                10    2738.754 us     273.875 us
        __schedule                              10    2732.857 us     273.285 us
        hrtimer_interrupt                       47    1896.104 us     40.342 us
        irq_exit                                56    1711.833 us     30.568 us
        __run_hrtimer                           47    1315.589 us     27.991 us
        tick_sched_timer                        47    1138.690 us     24.227 us
        do_softirq                              56    1116.829 us     19.943 us
        __do_softirq                            56    1066.932 us     19.052 us
        do_IRQ                                   9    926.153 us      102.905 us
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      34886c8b
    • Steven Rostedt's avatar
      tracing: remove on the fly allocator from function profiler · 318e0a73
      Steven Rostedt authored
      Impact: safer code
      
      The on the fly allocator for the function profiler was to save
      memory. But at the expense of stability. Although it survived several
      tests, allocating from the function tracer is just too risky, just
      to save space.
      
      This patch removes the allocator and simply allocates enough entries
      at start up.
      
      Each function gets a profiling structure of 40 bytes. With an average
      of 20K functions, and this is for each CPU, we have 800K per online
      CPU. This is not too bad, at least for non-embedded.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      318e0a73
  2. 25 Mar, 2009 7 commits
    • Steven Rostedt's avatar
      tracing: clean up tracing profiler · fb9fb015
      Steven Rostedt authored
      Ingo Molnar suggested clean ups for the profiling code. This patch
      makes those updates.
      Reported-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      fb9fb015
    • Steven Rostedt's avatar
      function-graph: add option to calculate graph time or not · a2a16d6a
      Steven Rostedt authored
      graph time is the time that a function is executing another function.
      Thus if function A calls B, if graph-time is set, then the time for
      A includes B. This is the default behavior. But if graph-time is off,
      then the time spent executing B is subtracted from A.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      a2a16d6a
    • Steven Rostedt's avatar
      tracing: make the function profiler per cpu · cafb168a
      Steven Rostedt authored
      Impact: speed enhancement
      
      By making the function profiler record in per cpu data we not only
      get better readings, avoid races, we also do not have to take any
      locks.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      cafb168a
    • Steven Rostedt's avatar
      tracing: adding function timings to function profiler · 0706f1c4
      Steven Rostedt authored
      If the function graph trace is enabled, the function profiler will
      use it to take the timing of the functions.
      
       cat /debug/tracing/trace_stat/functions
      
        Function                               Hit    Time
        --------                               ---    ----
        mwait_idle                             127    183028.4 us
        schedule                                26    151997.7 us
        __schedule                              31    151975.1 us
        sys_wait4                                2    74080.53 us
        do_wait                                  2    74077.80 us
        sys_newlstat                           138    39929.16 us
        do_path_lookup                         179    39845.79 us
        vfs_lstat_fd                           138    39761.97 us
        user_path_at                           153    39469.58 us
        path_walk                              179    39435.76 us
        __link_path_walk                       189    39143.73 us
      [...]
      
      Note the times are skewed due to the function graph tracer not taking
      into account schedules.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      0706f1c4
    • Steven Rostedt's avatar
      tracing: move function profiler data out of function struct · 493762fc
      Steven Rostedt authored
      Impact: reduce size of memory in function profiler
      
      The function profiler originally introduces its counters into the
      function records itself. There is 20 thousand different functions on
      a normal system, and that is adding 20 thousand counters for profiling
      event when not needed.
      
      A normal run of the profiler yields only a couple of thousand functions
      executed, depending on what is being profiled. This means we have around
      18 thousand useless counters.
      
      This patch rectifies this by moving the data out of the function
      records used by dynamic ftrace. Data is preallocated to hold the functions
      when the profiling begins. Checks are made during profiling to see if
      more recorcds should be allocated, and they are allocated if it is safe
      to do so.
      
      This also removes the dependency from using dynamic ftrace, and also
      removes the overhead by having it enabled.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      493762fc
    • Steven Rostedt's avatar
      tracing: add function profiler · bac429f0
      Steven Rostedt authored
      Impact: new profiling feature
      
      This patch adds a function profiler. In debugfs/tracing/ two new
      files are created.
      
        function_profile_enabled  - to enable or disable profiling
      
        trace_stat/functions   - the profiled functions.
      
      For example:
      
        echo 1 > /debugfs/tracing/function_profile_enabled
        ./hackbench 50
        echo 0 > /debugfs/tracing/function_profile_enabled
      
      yields:
      
        cat /debugfs/tracing/trace_stat/functions
      
        Function                               Hit
        --------                               ---
        _spin_lock                        10106442
        _spin_unlock                      10097492
        kfree                              6013704
        _spin_unlock_irqrestore            4423941
        _spin_lock_irqsave                 4406825
        __phys_addr                        4181686
        __slab_free                        4038222
        dput                               4030130
        path_put                           4023387
        unroll_tree_refs                   4019532
      [...]
      
      The most hit functions are listed first. Functions that are not
      hit are not listed.
      
      This feature depends on and uses dynamic function tracing. When the
      function profiling is disabled, no overhead occurs. But it still
      takes up around 300KB to hold the data, thus it is not recomended
      to keep it enabled for systems low on memory.
      
      When a '1' is echoed into the function_profile_enabled file, the
      counters for is function is reset back to zero. Thus you can see what
      functions are hit most by different programs.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      bac429f0
    • Steven Rostedt's avatar
      tracing: add handler to trace_stat · 42548008
      Steven Rostedt authored
      Currently, if a trace_stat user wants a handle to some private data,
      the trace_stat infrastructure does not supply a way to do that.
      
      This patch passes the trace_stat structure to the start function of
      the trace_stat code.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      42548008
  3. 24 Mar, 2009 7 commits
    • Lai Jiangshan's avatar
      tracing: use union for multi-usages field · ee000b7f
      Lai Jiangshan authored
      Impact: cleanup
      
      struct dyn_ftrace::ip has different usages in his lifecycle,
      we use union for it. And also for struct dyn_ftrace::flags.
      Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <49C871BE.3080405@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      ee000b7f
    • Lai Jiangshan's avatar
      ftrace: show virtual PID · cc59c9e8
      Lai Jiangshan authored
      Impact: fix PID output under namespaces
      
      When current namespace is not the global namespace,
      pid read from set_ftrace_pid is no correct.
      
       # ~/newpid_namespace_run bash
       # echo $$
       1
       # echo 1 > set_ftrace_pid
       # cat set_ftrace_pid
       3756
      
      Since we write virtual PID to set_ftrace_pid, we need get
      virtual PID when we read it.
      Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      LKML-Reference: <49C84D65.9050606@cn.fujitsu.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      cc59c9e8
    • Steven Rostedt's avatar
      function-graph: add option for include sleep times · be6f164a
      Steven Rostedt authored
      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: default avatarSteven Rostedt <srostedt@redhat.com>
      be6f164a
    • Steven Rostedt's avatar
      function-graph: ignore times across schedule · 8aef2d28
      Steven Rostedt authored
      Impact: more accurate timings
      
      The current method of function graph tracing does not take into
      account the time spent when a task is not running. This shows functions
      that call schedule have increased costs:
      
       3) + 18.664 us   |      }
       ------------------------------------------
       3)    <idle>-0    =>  kblockd-123
       ------------------------------------------
      
       3)               |      finish_task_switch() {
       3)   1.441 us    |        _spin_unlock_irq();
       3)   3.966 us    |      }
       3) ! 2959.433 us |    }
       3) ! 2961.465 us |  }
      
      This patch uses the tracepoint in the scheduling context switch to
      account for time that has elapsed while a task is scheduled out.
      Now we see:
      
       ------------------------------------------
       3)    <idle>-0    =>  edac-po-1067
       ------------------------------------------
      
       3)               |      finish_task_switch() {
       3)   0.685 us    |        _spin_unlock_irq();
       3)   2.331 us    |      }
       3) + 41.439 us   |    }
       3) + 42.663 us   |  }
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      8aef2d28
    • Steven Rostedt's avatar
      function-graph: prevent more than one tracer registering · 05ce5818
      Steven Rostedt authored
      Impact: prevent crash due to multiple function graph tracers
      
      The function graph tracer can currently only handle a single tracer
      being registered. If another tracer registers with the function
      graph tracer it can crash the system.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      05ce5818
    • Steven Rostedt's avatar
      function-graph: moved the timestamp from arch to generic code · 5d1a03dc
      Steven Rostedt authored
      This patch move the timestamp from happening in the arch specific
      code into the general code. This allows for better control by the tracer
      to time manipulation.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      5d1a03dc
    • Steven Rostedt's avatar
      tracing: fix memory leak in trace_stat · 09833521
      Steven Rostedt authored
      If the function profiler does not have any items recorded and one were
      to cat the function stat file, the kernel would take a BUG with a NULL
      pointer dereference.
      
      Looking further into this, I found that returning NULL from stat_start
      did not stop the stat logic, and would later call stat_next. This breaks
      from the way seq_file works, so I looked into fixing the stat code.
      
      This is where I noticed that the last next_entry is never freed.
      It is allocated, and if the stat_next returns NULL, the code breaks out
      of the loop, unlocks the mutex and exits. We never link the next_entry
      nor do we free it. Thus it is a real memory leak.
      
      This patch rearranges the code a bit to not only fix the memory leak,
      but also to act more like seq_file where nothing is printed if there
      is nothing to print. That is, stat_start returns NULL.
      Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
      09833521
  4. 23 Mar, 2009 3 commits
    • Anton Vorontsov's avatar
      tracing: Fix TRACING_SUPPORT dependency for PPC32 · 45b95608
      Anton Vorontsov authored
      commit 40ada30f ("tracing: clean up menu"),
      despite the "clean up" in its purpose, introduced a behavioural
      change for Kconfig symbols: we no longer able to select tracing
      support on PPC32 (because IRQFLAGS_SUPPORT isn't yet implemented).
      
      The IRQFLAGS_SUPPORT is not mandatory for most tracers, tracing core
      has a special case for platforms w/o irqflags (which, by the way, has
      become useless as of the commit above).
      
      Though according to Ingo Molnar, there was periodic build failures on
      weird, unmaintained architectures that had no irqflags-tracing support
      and hence didn't know the raw_irqs_save/restore primitives. Thus we'd
      better not enable irqflags-less tracing for all architectures.
      
      This patch restores the old behaviour for PPC32, and thus brings the
      tracing back. Other architectures can either add themselves to the
      exception list or (better) implement TRACE_IRQFLAGS_SUPPORT.
      Signed-off-by: default avatarAnton Vorontsov <avorontsov@ru.mvista.com>
      Acked-b: Steven Rostedt <rostedt@goodmis.org>
      Cc: linuxppc-dev@ozlabs.org
      LKML-Reference: <20090323220724.GA9851@oksana.dev.rtsoft.ru>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      45b95608
    • Frederic Weisbecker's avatar
      tracing/ftrace: check if debugfs is registered before creating files · 3e1f60b8
      Frederic Weisbecker authored
      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: default avatarFrederic 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: default avatarIngo Molnar <mingo@elte.hu>
      3e1f60b8
    • Frederic Weisbecker's avatar
      debugfs: function to know if debugfs is initialized · c0f92ba9
      Frederic Weisbecker authored
      Impact: add new debugfs API
      
      With ftrace, some tracers are registered in early initcalls
      and attempt to create files on the debugfs filesystem.
      Depending on when they are activated, they can try to create their
      file at any time. Some checks can be done on the tracing area
      but providing a helper to know if debugfs is registered make it
      really more easy.
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237759847-21025-2-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      c0f92ba9
  5. 22 Mar, 2009 4 commits
    • Dmitri Vorobiev's avatar
      tracing: fix four sparse warnings · b8b94265
      Dmitri Vorobiev authored
      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: default avatarDmitri Vorobiev <dmitri.vorobiev@movial.com>
      LKML-Reference: <1237741871-5827-4-git-send-email-dmitri.vorobiev@movial.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      b8b94265
    • Ingo Molnar's avatar
      Merge branches 'tracing/ftrace', 'tracing/hw-breakpoints',... · a524446f
      Ingo Molnar authored
      Merge branches 'tracing/ftrace', 'tracing/hw-breakpoints', 'tracing/ring-buffer', 'tracing/textedit' and 'linus' into tracing/core
      a524446f
    • Frederic Weisbecker's avatar
      tracing: keep the tracing buffer after self-test failure · 0cf53ff6
      Frederic Weisbecker authored
      Instead of using ftrace_dump_on_oops, it's far more convenient
      to have the trace leading up to a self-test failure available
      in /debug/tracing/trace.
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237694675-23509-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      0cf53ff6
    • Frederic Weisbecker's avatar
      tracing/function-graph-tracer: prevent hangs during self-tests · cf586b61
      Frederic Weisbecker authored
      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: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237694675-23509-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      cf586b61
  6. 21 Mar, 2009 1 commit
    • Frederic Weisbecker's avatar
      tracing/ring-buffer: don't annotate rb_cpu_notify with __cpuinit · 09c9e84d
      Frederic Weisbecker authored
      Impact: remove a section warning
      
      CONFIG_DEBUG_SECTION_MISMATCH raises the following warning on -tip:
      
        WARNING: kernel/trace/built-in.o(.text+0x5bc5): Section mismatch in
        reference from the function ring_buffer_alloc() to the function
        .cpuinit.text:rb_cpu_notify()
        The function ring_buffer_alloc() references
        the function __cpuinit rb_cpu_notify().
      
      This is actually harmless. The code in the ring buffer don't build
      rb_cpu_notify and other cpu hotplug stuffs when !CONFIG_HOTPLUG_CPU
      so we have no risk to reference freed memory here (it would even
      be harmless if we unconditionally build it because register_cpu_notifier
      would do nothing when !CONFIG_HOTPLUG_CPU.
      
      But since ring_buffer_alloc() can be called everytime, we don't want it
      to be annotated with __cpuinit so we drop the __cpuinit from
      rb_cpu_notify.
      
      This is not a waste of memory because it is only defined and used on
      CONFIG_HOTPLUG_CPU.
      Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      LKML-Reference: <1237606416-22268-1-git-send-email-fweisbec@gmail.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      09c9e84d
  7. 20 Mar, 2009 6 commits
  8. 19 Mar, 2009 10 commits