lttng-dev Archive mirror
 help / color / mirror / Atom feed
From: Rouven Czerwinski via lttng-dev <lttng-dev@lists.lttng.org>
To: lttng-dev@lists.lttng.org
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Subject: [lttng-dev] [PATCH lttng-modules] Add new tracepoints for drm_scheduler
Date: Thu,  8 Sep 2022 10:25:23 +0200	[thread overview]
Message-ID: <20220908082523.906444-1-r.czerwinski@pengutronix.de> (raw)

Allows usage of the drm_gpu_scheduler tracepoints within lttng.

Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
---
 .../events/drm_gpu_scheduler.h                | 63 +++++++++++++++++++
 src/probes/Kbuild                             |  7 +++
 src/probes/lttng-probe-drm-sched.c            | 26 ++++++++
 3 files changed, 96 insertions(+)
 create mode 100644 include/instrumentation/events/drm_gpu_scheduler.h
 create mode 100644 src/probes/lttng-probe-drm-sched.c

diff --git a/include/instrumentation/events/drm_gpu_scheduler.h b/include/instrumentation/events/drm_gpu_scheduler.h
new file mode 100644
index 00000000..d217fcb2
--- /dev/null
+++ b/include/instrumentation/events/drm_gpu_scheduler.h
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM drm_sched
+
+#if !defined(LTTNG_TRACE_DRM_GPU_SCHEDULER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define LTTNG_TRACE_DRM_GPU_SCHEDULER_H
+
+#include <lttng/tracepoint-event.h>
+
+LTTNG_TRACEPOINT_EVENT_CLASS(drm_sched_class,
+
+	TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
+
+	TP_ARGS(sched_job, entity),
+
+	TP_FIELDS(
+		ctf_integer_hex(struct drm_sched_entity *, entity, entity)
+		ctf_integer_hex(struct dma_fence *, fence, &sched_job->s_fence->finished)
+		ctf_string(name, sched_job->sched->name)
+		ctf_integer(uint64_t, id, sched_job->id)
+		ctf_integer(u32, job_count, spsc_queue_count(&entity->job_queue))
+		ctf_integer(int, hw_job_count, atomic_read(&sched_job->sched->hw_rq_count))
+	)
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE(drm_sched_class,
+	drm_sched_job,
+	TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
+	TP_ARGS(sched_job, entity)
+)
+
+LTTNG_TRACEPOINT_EVENT_INSTANCE(drm_sched_class,
+	drm_run_job,
+	TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
+	TP_ARGS(sched_job, entity)
+)
+
+LTTNG_TRACEPOINT_EVENT(drm_sched_process_job,
+	TP_PROTO(struct drm_sched_fence *fence),
+	TP_ARGS(fence),
+
+	TP_FIELDS(
+		ctf_integer_hex(struct dma_fence *, fence, &fence->finished)
+	)
+)
+
+LTTNG_TRACEPOINT_EVENT(drm_sched_job_wait_dep,
+	TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
+	TP_ARGS(sched_job, fence),
+
+	TP_FIELDS(
+		ctf_string(name, sched_job->sched->name)
+		ctf_integer(uint64_t, id, sched_job->id)
+		ctf_integer_hex(struct dma_fence *, fence, fence)
+		ctf_integer(uint64_t, ctx, fence->context)
+		ctf_integer(unsigned, seqno, fence->seqno)
+	)
+)
+
+#endif /*  LTTNG_TRACE_DRM_SCHED_H */
+
+/* This part must be outside protection */
+#include <lttng/define_trace.h>
diff --git a/src/probes/Kbuild b/src/probes/Kbuild
index 7597389b..2846b0c7 100644
--- a/src/probes/Kbuild
+++ b/src/probes/Kbuild
@@ -104,6 +104,13 @@ ifneq ($(CONFIG_DMA_SHARED_BUFFER),)
       echo "lttng-probe-dma-fence.o" ; fi;)
 endif # CONFIG_DMA_SHARED_BUFFER
 
+ifneq ($(CONFIG_DRM_SCHED),)
+  obj-$(CONFIG_LTTNG) += $(shell \
+    if [ $(VERSION) -ge 5 \
+       -o \( $VERSION -eq 4 -a $(PATCHLEVEL) -ge 16 \) ] ; then \
+      echo "lttng-probe-drm-sched.o" ; fi;)
+endif # CONFIG_DRM_SCHED
+
 ifneq ($(CONFIG_BLOCK),)
   # need blk_cmd_buf_len
   ifneq ($(CONFIG_EVENT_TRACING),)
diff --git a/src/probes/lttng-probe-drm-sched.c b/src/probes/lttng-probe-drm-sched.c
new file mode 100644
index 00000000..fe8f9cb2
--- /dev/null
+++ b/src/probes/lttng-probe-drm-sched.c
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+ *
+ * probes/lttng-probe-drm-sched.c
+ *
+ * LTTng drm-sched probes.
+ *
+ * Copyright (C) 2022 Pengutronix, Rouven Czerwinski <entwicklung@pengutronix.de>
+ */
+#include <drm/gpu_scheduler.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH instrumentation/events
+
+#include <instrumentation/events/drm_gpu_scheduler.h>
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Rouven Czerwinski <r.czerwinski@pengutronix.de>");
+MODULE_DESCRIPTION("LTTng drm-gpu-scheduler probes");
+MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
+	__stringify(LTTNG_MODULES_MINOR_VERSION) "."
+	__stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
+	LTTNG_MODULES_EXTRAVERSION);
-- 
2.37.2

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

             reply	other threads:[~2022-09-08 14:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  8:25 Rouven Czerwinski via lttng-dev [this message]
2022-09-23 15:53 ` [lttng-dev] [PATCH lttng-modules] Add new tracepoints for drm_scheduler Mathieu Desnoyers via lttng-dev

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=20220908082523.906444-1-r.czerwinski@pengutronix.de \
    --to=lttng-dev@lists.lttng.org \
    --cc=r.czerwinski@pengutronix.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).