Reputation: 31
Want to use the ftrace when we want to trace the kernel function of gs4.
So, I accepted the contents of here.
http://www.linuxforu.com/2010/11/kernel-tracing-with-ftrace-part-1/
mount -t debugfs nodev /sys/kernel/debug
When you enter the command, to come out as follows.
root@android:/sys/kernel/debug/tracing # mount -t debugfs nodev /nodev /sys/kernel/debug
mount: Device or resource busy
Also,
root@android:/sys/kernel/debug/tracing # cat current_tracer
nop
root@android:/sys/kernel/debug/tracing # echo function > current_tracer
root@android:/sys/kernel/debug/tracing # cat current_tracer
nop
To come out like this.
root@android:/sys/kernel/debug/tracing # ls -al current_tracer
-rw-r--r-- root root 0 2013-08-27 20:32 current_tracer
Last update time will change, it is not possible to change the contents of the currnet_tracer.
Of course, come out as follows.
root@android:/sys/kernel/debug/tracing # cat trace
# tracer: nop
#
# entries-in-buffer/entries-written: 0/0 #P:1
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
I can not change the currnet_tracer. tracing_on is capable of change.
root@android:/sys/kernel/debug/tracing # cat tracing_on
0
root@android:/sys/kernel/debug/tracing # echo 1 > tracing_on
root@android:/sys/kernel/debug/tracing # cat tracing_on
1
root@android:/sys/kernel/debug/tracing #
I can use the atrace, I come out information according to the corresponding options as follows, want to trace the call to the kernel function.
root@android:/sys/kernel/debug/tracing # atrace -s -w capturing trace < /test/trace.txt
root@android:/sys/kernel/debug/tracing # cat /test/trace.txt
capturing trace... done
TRACE:
# tracer: nop
#
# entries-in-buffer/entries-written: 532/532 #P:1
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
atrace-22948 [000] ...2 623726.157067: sched_switch: prev_comm=atrace prev_pid=22948 prev_prio=120 prev_state=S ==> next_comm=AsyncTask #2 next_pid=21620 next_prio=130
....
I want to know how to change the current_tracer and how to mount by using the debugfs.
To receive and grateful to help.
Thank!
Upvotes: 3
Views: 7718
Reputation: 1050
You maybe better use trace-cmd to do such things, it's much easier then print those trace in console.
http://www.omappedia.com/wiki/Installing_and_Using_Ftrace#Using_FTrace_with_Trace-cmd
Upvotes: 0
Reputation: 142545
You miss the point of available_tracers option under /sys/kernel/debug/tracing, which shows what are the tracing features available from kernel. To see the list of available tracer do -
cat /sys/kernel/debug/tracing/available_tracers
This will show you all the tracers available. Now, if you found "function" then you'll be able to trace kernel functions otherwise not.
If you have function tracer option available to activate it do the following -
echo function > /sys/kernel/debug/tracing/current_tracer
echo 1 > /sys/kernel/debug/tracing/tracing_on
Now, you'll find the tracing output via /sys/kernel/debug/tracing/trace . To disable the tracing do
echo 0 > /sys/kernel/debug/tracing/tracing_on
echo nop > /sys/kernel/debug/tracing/current_tracer
So, the main requirement of changing the current tracer is, that feature must have to be available, which can be found via current_tracer.
Upvotes: 5