tracing: add function profiler
authorSteven Rostedt <srostedt@redhat.com>
Fri, 20 Mar 2009 16:50:56 +0000 (12:50 -0400)
committerSteven Rostedt <srostedt@redhat.com>
Wed, 25 Mar 2009 03:40:00 +0000 (23:40 -0400)
commitbac429f037f1a51a74d62bad6d1518c3be065df3
tree40c3dbdd0f6c097c3c9a1087d219dd8632bd7b74
parent425480081e936d8725f0d44b8829d699bf088c6b
tracing: add function profiler

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: Steven Rostedt <srostedt@redhat.com>
include/linux/ftrace.h
kernel/trace/Kconfig
kernel/trace/ftrace.c