ftrace
- Ftrace 官方是首字母大写 Ftrace;
- Ftrace 的 Kernel 文档: https://www.kernel.org/doc/html/latest/trace/ftrace.html
- Ftrace 不是一个简单的工具/命令, 而是一个观测内核的框架. 它可以用来 debug/分析延迟/profiling 内核;
- 它的延迟分析能够分析在 interrupt 关闭/打开, 抢占关闭/打开的情况下的延迟;
- 内核提供了上百个事件(event)的观测, 通过配置 tracefs, 可以通过 Ftrace 看到这些 event 的情况;
- Ftrace 使用 tracefs 配置和产生输出;
kernel 支持的 tracer 以及配置 tracer
pi@raspberrypi:~/tmp $ sudo cat /sys/kernel/tracing/available_tracers blk function_graph wakeup_dl wakeup_rt wakeup irqsoff function nop sudo echo function_graph > /sys/kernel/tracing/current_tracer
以下都是材料, 还没整理:
- 这应该是比较早的关于 ftrace 的邮件: https://lwn.net/Articles/264029/
- 关于 ftrace 的一个配置的说明: https://cateee.net/lkddb/web-lkddb/FTRACE.html
Enable the kernel to trace every kernel function. This is done by
using a compiler feature to insert a small, 5-byte No-Operation
instruction to the beginning of every kernel function, which NOP
sequence is then dynamically patched into a tracer call when tracing
is enabled by the administrator. If it's runtime disabled (the bootup
default), then the overhead of the instructions is very small and not
measurable even in micro-benchmarks.
3.https://alex.dzyoba.com/blog/ftrace/#:~:text=Ftrace%20is%20a%20framework%20for,Tracepoints%20support
关于 ftrace 的一些关键字:
框架, NOP, -pg, gcc, gprof, trace-cmd, kernelShark, tracefs, 文件接口, mcount, 所有 kernel 函数, function, function_graph.