Tuesday, May 20, 2014

ftrace - The kernel function tracer - 1



1. Introduction
  • Ftrace is a tracing utility built directly into the Linux kernel.
  • Designed to help out developers and designers of systems to find what is going on inside the kernel.
  • Below mentioned output is executed in ubuntu 12.04 virtual machine.
2. Build kernel with the following configuration(Ubuntu already Configured)
CONFIG_FUNCTION_GRAPH_TRACER
CONFIG_STACK_TRACER
CONFIG_DYNAMIC_FTRACE
CONFIG_FUNCTION_TRACER
3. Mount the debugfs
#mount -t debugfs nodev /sys/kernel/debug
#mount |grep debugfs
5:none on /sys/kernel/debug type debugfs (rw)
4. Enter in to root shell
$ sudo  -i 
You will be asked for your password, then be given a root shell. In that shell, you can cd to /sys/kernel/debug.
5. Sample Execution

# pwd
/sys/kernel/debug/tracing

# cat available_tracers 
blk function_graph mmiotrace wakeup_rt wakeup function nop

# echo function_graph > current_tracer

# cat current_tracer 
function_graph

# cat trace | head -20
# tracer: function_graph
#
# CPU  DURATION                  FUNCTION CALLS
# |     |   |                     |   |   |   |
 0) ! 164785.8 us |      } /* native_safe_halt */
 0) ! 164786.9 us |    } /* default_idle.part.4 */
 0) ! 164787.6 us |  } /* default_idle */
 0)   0.062 us    |  local_touch_nmi();
 0)               |  cpuidle_idle_call() {
 0)   0.094 us    |    cpuidle_get_driver();
 0)   0.690 us    |  }
 0)               |  default_idle() {
 0)               |    default_idle.part.4() {
 0)               |      native_safe_halt() {
 0)   ==========> |
 0)               |        do_IRQ() {
 0)               |          irq_enter() {
 0)               |            rcu_irq_enter() {
 0)   0.231 us    |              rcu_exit_nohz();
 0)   0.995 us    |            }

No comments:

Post a Comment