Search code examples
debugginglinux-kernelftrace

ftrace: Is there any way to view my trace with kernelshark without using trace-cmd?


I have been using ftrace to trace and time a boot process on my machine. I don't know of any way to start trace-cmd early enough to catch the things I need to see, whereas with ftrace, I just enable it before I reboot, then disable after I've rebooted. I would like to view this trace with kernelshark for a presentation. Is there any way to perhaps convert my /sys/kernel/debug/tracing/trace into a .dat readable by kernelshark?


Solution

  • 1. Capturing an oops (from startup) to the serial console

    The function calls leading up to a kernel-panic can be captured by passing the following command-line options to the Linux kernel:

    ftrace=function ftrace_dump_on_oops
    

    2. Capturing traces automatically upon boot

    You can use the following kernel command line parameters to automatically generate a trace at boot. This can then be opened using parsers like Kernelshark and pytimechart.

    trace_event=sched:*,timer:*,irq:* trace_buf_size=40M
    

    For more details checkout this Ftrace wiki.