Skip to content

Perfetto support in radeonsi driver

Saroj Kumar requested to merge sarojk/mesa:perfetto_support into main

What does this MR do and why?

Add support for perfetto tracing in radeonsi driver. Use -Dperfetto=true in meson build command to build radeonsi with perfetto support.

Changes:

  • Add si_perfetto.h and si_perfetto.cpp files which contains data structures to keep intermediate state of tracing data source and also contains tracing events callbacks.

    • struct si_ds_device keeps the intermediate state of trace, struct si_ds_stage contains data for each render stages and struct si_ds_queue keeps all the render stages for a command stream.
    • si_ds_begin_##event_name and si_ds_end_##event_name are trace callbacks, it is called from u_trace once the timestamps from the GPU has been collected.
  • Add si_utrace.h and si_utrace.c which contains initialization code for u_trace APIs and callbacks required in u_trace to emit timestamps in cmdstream and read back timestamps.

  • Add si_ds_device, u_trace and si_ds_queue in si_context and initialize u_trace when creating context. u_trace contains trace event chunks with timestamp and payload, which is flushed to a queue in u_trace_context when driver flush the command stream to kernel code. u_trace_context processes the queue later in pctx->flush().

  • Add si_tracepoints.py to create trace point functions in generated code si_tracepoints.h and si_tracepoints.c

  • Add amd.cfg and modify system.cfg to provide data source configurations.

Collecting traces

  1. Build Perfetto from sources available at subprojects/perfetto following this guide.
  2. Go to the subprojects/perfetto directory and run a convenience script CONFIG=../../src/tool/pps/cfg/system.cfg OUT=out/linux/ ./tools/tmux -n
  3. Start perfetto under the tmux session initiated in step 2
  4. Once tracing has finished, you can detach from tmux with Ctrl+b, d, and the convenience script should automatically copy the trace files into tmp directory.
  5. Go to ui.perfetto.dev and upload trace file by clicking on Open trace file
Edited by Saroj Kumar

Merge request reports