Skip to content

[DO NOT MERGE] Android: Use perfetto.dev to trace GPU internal metrics

Roman Stratiienko requested to merge roman.stratiienko/mesa:pps-producer into main

Meson within AOSP scripts can't be used to produce executables (they need some extensive rework to do it).

Therefore this patch is not for merging into mainline/mesa. User can cherry-pick it prior to debugging.

How to use (panfrost-specific example):

  1. Add pps-producer into your device.mk:
    PRODUCT_PACKAGES += pps-producer
  1. Build/deploy android.

  2. Enable additional panfrost IOCTLs, run:

    adb root
    adb shell "echo Y > /sys/module/panfrost/parameters/unstable_ioctls"
  1. Run adb root && adb shell pps-producer, check output in terminal.
    [557.448]        pps_driver.cc:88 Driver selected: panfrost
    [557.449]   pps_datasource.cc:139 Waiting for start

Keep this daemon running, use another terminal for remaining stuff.

  1. Ensure data source is registered by pps-producer daemon Run adb shell perfetto --query , check if output contains:
    gpu.counters.panfrost                    pps-producer ()
  1. Open perfetto.dev in the browser. Click record new trace, enable all necessary events. I could not find any option to add custom dataset using perfetto web UI, therefore you have to click "Recording command", copy and paste it into any text editor and add the following section:
    data_sources: {
      config {
        name: "gpu.counters.panfrost"
        gpu_counter_config {
          counter_period_ns: 1000000
        }
      }
    }
  1. Copy modified commands from the editor and paste them into separate terminal. After record complete check pps-producer is still running. It can fail time-to-time, in this case you have to restart it and repeat the procedure.

  2. Pull the trace from the device:

   adb pull /data/misc/perfetto-traces/trace ~/trace
  1. Open the trace using https://perfetto.dev/ web UI

  2. Have a fun with debugging.

Edited by Roman Stratiienko

Merge request reports