linux-kernelembedded-linuxlinux-rt

Which method for finding the reason for latency peaks on embedded Linux?


Best case would be, if I had a (debug)-tool which runs in the background and tells me the name of the process or driver that breaks my latency requirement to my system. Which tool is suitable? Do you have a short example of its usage for the following case?

Test case:


Solution

  • The best real chance is to

    1. switch on tracing in the kernel configuration and build such Linux kernel:
    CONFIG_FTRACE=y
    CONFIG_FUNCTION_TRACER=y
    CONFIG_FUNCTION_GRAPH_TRACER=y
    CONFIG_SCHED_TRACER=y
    CONFIG_FTRACE_SYSCALLS=y
    CONFIG_STACK_TRACER=y
    CONFIG_DYNAMIC_FTRACE=y
    CONFIG_FUNCTION_PROFILER=y
    CONFIG_DEBUG_FS=y
    
    1. then run your application until weird things happen by using a tool trace-cmd
    trace-cmd start -b 10000 -e 'sched_wakeup*' -e sched_switch -e gpio_value -e irq_handler_entry -e irq_handler_exit /tmp/myUserApplication
    

    and get a trace.dat file.

    trace-cmd stop
    trace-cmd extract
    
    1. Load that trace.dat file in KernelShark and analyse the CPUs, threads, interrupts, kworker threads and user space threads. It's great to see which blocks the system.