Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tursulin@ursulin.net>
To: S Sebinraj <s.sebinraj@intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org
Cc: jeevaka.badrappan@intel.com
Subject: Re: [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level
Date: Wed, 17 Sep 2025 10:17:06 +0100	[thread overview]
Message-ID: <37619915-ff50-4a62-a43e-a0b2fcdb4596@ursulin.net> (raw)
In-Reply-To: <20250917084135.2049550-2-s.sebinraj@intel.com>


On 17/09/2025 09:41, S Sebinraj wrote:
> Add a GPU frequency tracepoint at the DRM subsystem level
> 
> The implementation includes:
> - DRM-level tracepoint exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency/
> - CONFIG_DRM_GPU_FREQUENCY_TRACE Kconfig option (default=n)
> 
> The tracepoint follows kernel tracing and provides kHz frequency
> values with GPU identification for power analysis and
> performance monitoring tools.
> 
> The tracepoint is only active when CONFIG_DRM_GPU_FREQUENCY_TRACE=y
> and can be integrated by GPU drivers for frequency reporting.
> 
> Signed-off-by: S Sebinraj <s.sebinraj@intel.com>
> ---
>   drivers/gpu/drm/Kconfig                   | 11 ++++++
>   drivers/gpu/drm/Makefile                  |  1 +
>   drivers/gpu/drm/drm_gpu_frequency_trace.c | 16 ++++++++
>   drivers/gpu/drm/drm_gpu_frequency_trace.h | 47 +++++++++++++++++++++++
>   4 files changed, 75 insertions(+)
>   create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.c
>   create mode 100644 drivers/gpu/drm/drm_gpu_frequency_trace.h
> 
> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
> index f7ea8e895c0c..975cc7b2581d 100644
> --- a/drivers/gpu/drm/Kconfig
> +++ b/drivers/gpu/drm/Kconfig
> @@ -53,6 +53,17 @@ config DRM_DRAW
>   	bool
>   	depends on DRM
>   
> +config DRM_GPU_FREQUENCY_TRACE
> +	bool "Enable GPU frequency tracepoints"
> +	depends on DRM && TRACEPOINTS
> +	default n
> +	help
> +	  Enable GPU frequency tracepoints in the power trace subsystem.
> +	  This provides kernel tracing support for GPU frequency changes
> +	  that will be exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency/.
> +
> +	  If unsure, say N.
> +
>   config DRM_PANIC
>   	bool "Display a user-friendly message when a kernel panic occurs"
>   	depends on DRM
> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
> index 4dafbdc8f86a..12c81b6a750d 100644
> --- a/drivers/gpu/drm/Makefile
> +++ b/drivers/gpu/drm/Makefile
> @@ -77,6 +77,7 @@ drm-$(CONFIG_DRM_CLIENT) += \
>   	drm_client.o \
>   	drm_client_event.o \
>   	drm_client_modeset.o
> +drm-$(CONFIG_DRM_GPU_FREQUENCY_TRACE) += drm_gpu_frequency_trace.o
>   drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
>   drm-$(CONFIG_COMPAT) += drm_ioc32.o
>   drm-$(CONFIG_DRM_PANEL) += drm_panel.o
> diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.c b/drivers/gpu/drm/drm_gpu_frequency_trace.c
> new file mode 100644
> index 000000000000..b5fa5134226d
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_gpu_frequency_trace.c
> @@ -0,0 +1,16 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * GPU frequency trace points for DRM subsystem
> + *
> + * This provides GPU frequency tracing support that will be exposed at:
> + * /sys/kernel/debug/tracing/events/power/gpu_frequency/
> + */
> +
> +#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> +
> +#define CREATE_TRACE_POINTS
> +#include "drm_gpu_frequency_trace.h"
> +
> +EXPORT_TRACEPOINT_SYMBOL_GPL(gpu_frequency);
> +
> +#endif /* CONFIG_DRM_GPU_FREQUENCY_TRACE */
> diff --git a/drivers/gpu/drm/drm_gpu_frequency_trace.h b/drivers/gpu/drm/drm_gpu_frequency_trace.h
> new file mode 100644
> index 000000000000..cf6337847b3a
> --- /dev/null
> +++ b/drivers/gpu/drm/drm_gpu_frequency_trace.h
> @@ -0,0 +1,47 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#if !defined(_GPU_FREQUENCY_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
> +#define _GPU_FREQUENCY_TRACE_H
> +
> +#include <linux/tracepoint.h>
> +
> +#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> +
> +#undef TRACE_SYSTEM
> +#define TRACE_SYSTEM power

Not sure masquerading as a different subsystem will fly.

> +#define TRACE_INCLUDE_FILE drm_gpu_frequency_trace
> +
> +/*
> + * Tracepoint for GPU frequency changes
> + * This tracepoint is exposed at /sys/kernel/debug/tracing/events/power/gpu_frequency
> + *
> + * location: /sys/kernel/debug/tracing/events/power/gpu_frequency
> + * format: {unsigned int state, unsigned int gpu_id}
> + * where state holds the frequency(in KHz) and the gpu_id holds the GPU clock domain.
> + */
> +TRACE_EVENT(gpu_frequency,
> +	    TP_PROTO(unsigned int state, unsigned int gpu_id),
> +	    TP_ARGS(state, gpu_id),
> +	    TP_STRUCT__entry(
> +		    __field(unsigned int, state)

Why is the frequency field not called frequency?

> +		    __field(unsigned int, gpu_id)

It is required to be able to identify which GPU in muti-GPU systems. See 
how gpu_id is defined in gpu_mem.h.

Regards,

Tvrtko

> +		    ),
> +	    TP_fast_assign(
> +		    __entry->state = state;
> +		    __entry->gpu_id = gpu_id;
> +		    ),
> +	    TP_printk("state=%u gpu_id=%u", __entry->state, __entry->gpu_id)
> +);
> +
> +#else /* !CONFIG_DRM_GPU_FREQUENCY_TRACE */
> +
> +static inline void trace_gpu_frequency(unsigned int state, unsigned int gpu_id) { }
> +
> +#endif /* CONFIG_DRM_GPU_FREQUENCY_TRACE */
> +
> +#endif /* _GPU_FREQUENCY_TRACE_H */
> +
> +#ifdef CONFIG_DRM_GPU_FREQUENCY_TRACE
> +#undef TRACE_INCLUDE_PATH
> +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm
> +#include <trace/define_trace.h>
> +#endif


  reply	other threads:[~2025-09-17  9:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17  8:41 [PATCH v4 0/2] drm: Add GPU frequency tracepoint S Sebinraj
2025-09-17  8:41 ` [PATCH v4 1/2] drm: Add GPU frequency tracepoint at DRM level S Sebinraj
2025-09-17  9:17   ` Tvrtko Ursulin [this message]
2025-09-17  8:41 ` [PATCH v4 2/2] drm/xe: Add DRM GPU frequency tracepoint to Xe S Sebinraj
2025-09-17  9:19   ` Tvrtko Ursulin
2025-09-17  8:56 ` ✗ CI.checkpatch: warning for drm: Add GPU frequency tracepoint (rev3) Patchwork
2025-09-17  8:57 ` ✓ CI.KUnit: success " Patchwork
2025-09-17  9:43 ` ✓ Xe.CI.BAT: " Patchwork
2025-09-17 10:54 ` ✗ Xe.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=37619915-ff50-4a62-a43e-a0b2fcdb4596@ursulin.net \
    --to=tursulin@ursulin.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jeevaka.badrappan@intel.com \
    --cc=s.sebinraj@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox