[PATCH v2 3/8] [ANDROID]: Add a trace point for GPU work period
Rodrigo Vivi
rodrigo.vivi at intel.com
Fri Aug 22 19:57:05 UTC 2025
On Fri, Aug 22, 2025 at 08:59:25AM +0000, Aakash Deep Sarkar wrote:
> The GPU work period event is required to have the following format:
>
> Defines the structure of the kernel tracepoint:
> /sys/kernel/tracing/events/power/gpu_work_period
It is okay to add traces in the driver, but in a xe_ namespace.
For using such a bold name like this we need to add this infrastructure
in the drm level.
Please move this to drm level and include dri-devel in the proposal.
>
> A value that uniquely identifies the GPU within the system.
> uint32_t gpu_id;
>
> The UID of the application (i.e. persistent, unique ID of the Android
> app) that submitted work to the GPU.
> uint32_t uid;
>
> The start time of the period in nanoseconds. The clock must be
> CLOCK_MONOTONIC_RAW, as returned by the ktime_get_raw_ns(void) function.
> uint64_t start_time_ns;
>
> The end time of the period in nanoseconds. The clock must be
> CLOCK_MONOTONIC_RAW, as returned by the ktime_get_raw_ns(void) function.
> uint64_t end_time_ns;
>
> The amount of time the GPU was running GPU work for |uid| during the
> period, in nanoseconds, without double-counting parallel GPU work for the
> same |uid|. For example, this might include the amount of time the GPU
> spent performing shader work (vertex work, fragment work, etc.) for
> |uid|.
> uint64_t total_active_duration_ns;
>
> Signed-off-by: Aakash Deep Sarkar <aakash.deep.sarkar at intel.com>
> ---
> .../drm/xe/xe_power_gpu_work_period_trace.h | 61 +++++++++++++++++++
> 1 file changed, 61 insertions(+)
> create mode 100644 drivers/gpu/drm/xe/xe_power_gpu_work_period_trace.h
>
> diff --git a/drivers/gpu/drm/xe/xe_power_gpu_work_period_trace.h b/drivers/gpu/drm/xe/xe_power_gpu_work_period_trace.h
> new file mode 100644
> index 000000000000..2de05f1b64f3
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_power_gpu_work_period_trace.h
> @@ -0,0 +1,61 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2024 Intel Corporation
> + */
> +
> +#ifndef _TRACE_POWER_GPU_WORK_PERIOD_INTEL
> +#define _TRACE_POWER_GPU_WORK_PERIOD_INTEL
> +#endif
> +
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM power
> +#undef TRACE_INCLUDE_FILE
> +#define TRACE_INCLUDE_FILE xe_power_gpu_work_period_trace
> +#undef TRACE_INCLUDE_PATH
> +#define TRACE_INCLUDE_PATH .
> +
> +#if !defined(_TRACE_POWER_GPU_WORK_PERIOD_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _TRACE_POWER_GPU_WORK_PERIOD_H
> +
> +#include <linux/tracepoint.h>
> +
> +TRACE_EVENT(gpu_work_period,
> +
> + TP_PROTO(
> + u32 gpu_id,
> + u32 uid,
> + u64 start_time_ns,
> + u64 end_time_ns,
> + u64 total_active_duration_ns
> + ),
> +
> + TP_ARGS(gpu_id, uid, start_time_ns, end_time_ns, total_active_duration_ns),
> +
> + TP_STRUCT__entry(
> + __field(u32, gpu_id)
> + __field(u32, uid)
> + __field(u64, start_time_ns)
> + __field(u64, end_time_ns)
> + __field(u64, total_active_duration_ns)
> + ),
> +
> + TP_fast_assign(
> + __entry->gpu_id = gpu_id;
> + __entry->uid = uid;
> + __entry->start_time_ns = start_time_ns;
> + __entry->end_time_ns = end_time_ns;
> + __entry->total_active_duration_ns = total_active_duration_ns;
> + ),
> +
> + TP_printk("gpu_id=%u uid=%u start_time_ns=%llu end_time_ns=%llu total_active_duration_ns=%llu",
> + __entry->gpu_id,
> + __entry->uid,
> + __entry->start_time_ns,
> + __entry->end_time_ns,
> + __entry->total_active_duration_ns)
> +);
> +
> +#endif /* _TRACE_POWER_GPU_WORK_PERIOD_H */
> +
> +/* This part must be outside protection */
> +#include <trace/define_trace.h>
> --
> 2.49.0
>
More information about the Intel-xe
mailing list