Debugging Linux kernel using ftrace Part18 - set_ftrace_filter

ftrace by default will trace all the kernel functions. The information generated is huge and very difficult to get hold by any human. ftrace provides a way to limit the amount of information generated using set_ftrace_filter.

If we add any functions in the set_ftrace_filter, ftrace will skip tracing all the other functions and only will trace the functions listed in the set_ftrace_filter file.



In the above screenshot, you can see
1. First we set the current tracer to "nop"
2. We cleared the trace ring buffer
3. Then we told the ftrace to only trace "i8042_interrupt" which is keyboard/mouse interrupt handler by echoing on set_ftrace_filter
4. Then we enable "function_graph" tracer
5. Now reading the "trace" file, you will observe only i8042_interrupt function is displayed. You can see it takes on average of 100 us for each key press by i8042 interrupt handler.

If you want to trace multiple functions, you can use the append operator (>>).

For example, if we want to add "ksys_read" which is called in the kernel space when user calls read in user space.

echo "ksys_read" >> set_ftrace_filter

To remove all the functions, just echo a blank line in the set_ftrace_filter file.

echo > set_ftrace_filter

Comments

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto