drm/xe/xe_pmu: Add PMU support for engine activity
authorRiana Tauro <riana.tauro@intel.com>
Mon, 24 Feb 2025 05:39:01 +0000 (11:09 +0530)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 24 Feb 2025 21:23:57 +0000 (13:23 -0800)
commit6978c5f5a64d4bdd6b00214368d5fe59f56e9890
tree0d55b78f429ee4a8aef4a1d3f63617153100f892
parent0e6ffdb2b740f3aab098e3a7857ddf53fe2e0059
drm/xe/xe_pmu: Add PMU support for engine activity

PMU provides two counters (engine-active-ticks, engine-total-ticks)
to calculate engine activity. When querying engine activity,
user must group these 2 counters using the perf_event
group mechanism to ensure both counters are sampled together.

To list the events

./perf list
  xe_0000_03_00.0/engine-active-ticks/ [Kernel PMU event]
  xe_0000_03_00.0/engine-total-ticks/ [Kernel PMU event]

The formats to be used with the above are

engine_instance - config:12-19
engine_class - config:20-27
gt - config:60-63

The events can then be read using perf tool

./perf stat -e xe_0000_03_00.0/engine-active-ticks,gt=0,
       engine_class=0,engine_instance=0/,
       xe_0000_03_00.0/engine-total-ticks,gt=0,
       engine_class=0,engine_instance=0/ -I 1000

Engine activity can then be calculated as below
engine activity % = (engine active ticks/engine total ticks) * 100

v2: validate gt
    rename total-ticks to engine-total-ticks
    add helper to get hwe (Umesh)

v3: fix checkpatch warning
    add details to documentation (Umesh)
    remove ascii formats from documentation (Lucas)

v4: remove unnecessary warn within raw_spinlock (Lucas)

Signed-off-by: Riana Tauro <riana.tauro@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250224053903.2253539-5-riana.tauro@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_guc.c
drivers/gpu/drm/xe/xe_pmu.c
drivers/gpu/drm/xe/xe_uc.c