The V3D core has a single set of performance counters. So that a perfmon
only counts the jobs it is attached to, a job carrying a non-global
perfmon waits for every job still in flight, and while it is in flight
every later job waits for it. Knowing what is in flight requires every
job to merge its finished fence into a per-queue accumulator.

That accumulator is maintained unconditionally, so a client pays a fence
merge on every job even when no dependency can ever be built out of it.
This series turns the bookkeeping off in the two cases where that holds:

  1. No perfmon is alive on the device, which is the common case since
     perfmons only exist while userspace runs a performance query;

  2. A global perfmon is set and the job carries no perfmon of its own.
     A global perfmon counts concurrent activity from every job, so
     nothing has to wait. Jobs carrying their own perfmon stay tracked,
     since the global perfmon may be cleared before they run and only
     one of them can be programmed in the HW at a time.

Both share the same trade-off: a job that goes unrecorded never carries a
perfmon, so the only cost is that the first job measured after tracking
resumes may overlap it. Considering the use cases of performance monitors
and that it will only affect the first job, it's a reasonable compromise
to make for the average case.

Best regards,
- Maíra

---
Changes in v2:

- [1/2, 2/2] Add Iago's R-b to both patches.
- [1/2, 2/2] Add a comment to the last_hw_fence field expliciting that
             tracking is only done while nperfmons > 0 and no global
             perform is set (Iago Toral).
- Link to v1: 
https://lore.kernel.org/r/20260921-v3d-quick-exit-perfmon-serialize-v1-0-e58aea107...@igalia.com

---
Maíra Canal (2):
      drm/v3d: Skip perfmon serialization while the device has no perfmon
      drm/v3d: Skip perfmon serialization while a global perfmon is set

 drivers/gpu/drm/v3d/v3d_drv.h     | 14 ++++++++++++--
 drivers/gpu/drm/v3d/v3d_perfmon.c |  8 ++++++--
 drivers/gpu/drm/v3d/v3d_submit.c  | 19 ++++++++++++-------
 3 files changed, 30 insertions(+), 11 deletions(-)
---
base-commit: 8ef59ee794076e2b58cff357b12de2ba5d441271
change-id: 20260921-v3d-quick-exit-perfmon-serialize-9e9e8ceac587

Reply via email to