[lttng-dev] [PATCH lttng-modules] Add new tracepoints for drm_scheduler
Rouven Czerwinski
r.czerwinski at pengutronix.de
Thu Sep 8 04:25:23 EDT 2022
Allows usage of the drm_gpu_scheduler tracepoints within lttng.
Signed-off-by: Rouven Czerwinski <r.czerwinski at 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 at 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 at 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
More information about the lttng-dev
mailing list