Linux Kernel call stack

46 views
Skip to first unread message

Mohamed Emara

unread,
Mar 12, 2025, 5:53:44 AMMar 12
to Perfetto Development - www.perfetto.dev
Hi,
I have a soc "imx8" where a mipi-display is attached and qt application is running on the display with touch function. I have some lagging when i click on my display and would like to track the touch event.
So, I wanna produce a call stack starting from for ex. the renderer till the kernel, so if it is hanging somewhere. Any suggestions on how to produce the trace?

I am using this cfg file:
buffers: {
    size_kb: 102400
    fill_policy: DISCARD
}

data_sources: {
    config: {
        name: "linux.ftrace"
        ftrace_config: {
            ftrace_events: "sched/sched_switch"
            ftrace_events: "sched/sched_wakeup"
            ftrace_events: "irq/irq_handler_entry"
            ftrace_events: "irq/irq_handler_exit"
            ftrace_events: "power/cpu_frequency"
            ftrace_events: "power/cpu_idle"
            ftrace_events: "power/gpu_frequency"
            ftrace_events: "power/gpu_work_period"
            ftrace_events: "drm/drm_vblank_event"
            ftrace_events: "drm/drm_vblank_event_queued"
            ftrace_events: "drm/drm_vblank_event_delivered"
        }
    }
}

data_sources: {
    config: {
        name: "linux.sys_stats"
        sys_stats_config: {
            stat_period_ms: 1000
            stat_counters: STAT_CPU_TIMES
            stat_counters: STAT_FORK_COUNT
            stat_counters: STAT_IRQ_COUNTS
            stat_counters: STAT_SOFTIRQ_COUNTS
        }
    }
}

data_sources: {
  config {
    name: "ftrace"
    ftrace_config {
      ftrace_events: "vblank/enable_vblank"
      ftrace_events: "vblank/disable_vblank"
      ftrace_events: "sched/sched_switch"
      ftrace_events: "sched/sched_wakeup"
    }
  }
}

data_sources: {
  config {
    name: "ftrace"
    ftrace_config {
      ftrace_events: "input/input_handle_event"
      ftrace_events: "input/input_event"
      ftrace_events: "input/input_mt_sync"
      ftrace_events: "input/input_mt_report_slot_state"
    }
  }
}

data_sources: {
  config {
    name: "gpu.renderstages"
  }
}

# Capture Touch Input Events
data_sources: {
  config {
    name: "linux.input"
  }
}

data_sources: {
    config: {
        name: "linux.process_stats"
        process_stats_config: {
            proc_stats_poll_ms: 1000
        }
    }
}

duration_ms: 10000

Thanks and best regards,
Mohamed

Primiano Tucci

unread,
Mar 12, 2025, 7:29:58 AMMar 12
to Mohamed Emara, Ryan Savitski, Perfetto Development - www.perfetto.dev
Oh hey Mohamed,

> I have a soc "imx8" 

I used to have a imx8-based UDOO board in my living room, I'm very familiar with that SoC :)

I think here you should go in layers:

1. First of all I'd start looking at sched_switch + sched_waking events, to understand if the nature of the latency is CPU-bound or blocking/contention bound 
2. If it's CPU bound, you can use callstack sampling. You can generate configs via tools/cpu_profile (see docs). However I don't recall what it takes to run it on Linux rather than Android. +Ryan Savitski  here
3. If it's latency bound, you need to follow the sched_waking events (the UI shows arrows) and use the "critical path lite" feature to figure out where it's blocked

It could be too many different things. Could be that you are blocked waiting for  a GPU fence (the GPU on that chipset isn't really great honestly).
You can try a callstack sampling config based on sched_switch, so you get a sample precisely whenever every thread switches in/out, rather than just every xx ms. Ryan can help you with that (Ryan: we should put it in the docs / FAQ, It' the 3rd time this year that I end up discussing this with somebody).

I honestly put most of my bets on the GPU driver ;)

Good luck with your project!

--
You received this message because you are subscribed to the Google Groups "Perfetto Development - www.perfetto.dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to perfetto-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/perfetto-dev/0c70776f-f6bb-4e9d-aabb-3eb5e142f8e4n%40googlegroups.com.


--
Primiano Tucci
Software Engineer
Google UK Limited

Reply all
Reply to author
Forward
0 new messages