[PATCH v4 5/8] drm/xe/guc: Add PMU counter for total active ticks
Aravind Iddamsetty
aravind.iddamsetty at linux.intel.com
Wed Jan 3 06:54:04 UTC 2024
On 12/22/23 13:15, Riana Tauro wrote:
> GuC provides engine busyness ticks as a 64 bit counter which count
> as clock ticks. These counters are maintained in a
> shared memory buffer and internally updated on a continuous basis.
>
> GuC also provides a periodically total active ticks that GT has been
> active for (GuC loaded and running).
> This counter is exposed to the user such that busyness can
> be calculated as a percentage using
>
> busyness % = (engine active ticks/total active ticks) * 100.
>
> This patch provides a pmu counter for total active ticks.
>
> This is listed by perf tool as
>
> sudo ./perf list
> xe_0000_03_00.0/total-active-ticks-gt0/ [Kernel PMU event]
>
> and can be read using
>
> sudo ./perf stat -e xe_0000_03_00.0/total-active-ticks-gt0/ -I 1000
> time counts unit events
> 1.001332764 58942964 xe_0000_03_00.0/total-active-ticks-gt0/
> 2.011421147 21191869 xe_0000_03_00.0/total-active-ticks-gt0/
> 3.013223865 19269012 xe_0000_03_00.0/total-active-ticks-gt0/
>
> v2: change commit message and comment for
> total active ticks (Umesh, Tvrtko)
>
> Co-developed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
> Signed-off-by: Riana Tauro <riana.tauro at intel.com>
> ---
> drivers/gpu/drm/xe/xe_gt.c | 11 +++
> drivers/gpu/drm/xe/xe_gt.h | 2 +-
> drivers/gpu/drm/xe/xe_guc_engine_busyness.c | 72 ++++++++++++++++----
> drivers/gpu/drm/xe/xe_guc_engine_busyness.h | 1 +
> drivers/gpu/drm/xe/xe_pmu.c | 74 +++++++++++++++++++--
> include/uapi/drm/xe_drm.h | 23 ++++++-
> 6 files changed, 162 insertions(+), 21 deletions(-)
>
<snip>
> diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
> index f8456cda5cda..3134930b0160 100644
> --- a/include/uapi/drm/xe_drm.h
> +++ b/include/uapi/drm/xe_drm.h
> @@ -1341,12 +1341,29 @@ struct drm_xe_wait_user_fence {
> };
>
> /**
> - * DOC: XE PMU event config IDs
> + * DOC: XE PMU Event Config ID's
> *
> - * Check 'man perf_event_open' to use the ID's DRM_XE_PMU_XXXX listed in xe_drm.h
the reason for mentioning xe_drm.h is the defines will not be included in the documentation
> + * Check 'man perf_event_open' to use the ID's DRM_XE_PMU_XXXX listed here
> * in 'struct perf_event_attr' as part of perf_event_open syscall to read a
> * particular event.
> *
> + * For example to open the DRM_XE_PMU_TOTAL_ACTIVE_TICKS(0):
> + *
> + * .. code-block:: C
> + *
> + * struct perf_event_attr attr;
> + * long long count;
> + * int cpu = 0;
> + * int fd;
> + *
> + * memset(&attr, 0, sizeof(struct perf_event_attr));
> + * attr.type = type; // eg: /sys/bus/event_source/devices/xe_0000_03_00.0/type
> + * attr.read_format = PERF_FORMAT_TOTAL_TIME_ENABLED;
> + * attr.use_clockid = 1;
> + * attr.clockid = CLOCK_MONOTONIC;
> + * attr.config = DRM_XE_PMU_TOTAL_ACTIVE_TICKS(0);
> + *
> + * fd = syscall(__NR_perf_event_open, &attr, -1, cpu, -1, 0);
> */
>
> /**
> @@ -1381,6 +1398,8 @@ enum drm_xe_pmu_engine_sample {
> __DRM_XE_PMU_GT_EVENT(gt, __DRM_XE_PMU_ENGINE(class, instance, \
> DRM_XE_PMU_SAMPLE_BUSY_TICKS))
>
> +#define DRM_XE_PMU_TOTAL_ACTIVE_TICKS(gt) __DRM_XE_PMU_OTHER(gt, 0)
> +
> #if defined(__cplusplus)
> }
> #endif
Thanks,
Aravind.
More information about the Intel-xe
mailing list