[lttng-dev] [PATCH lttng-modules] Add new tracepoints for drm_scheduler

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Fri Sep 23 11:53:34 EDT 2022


On 2022-09-08 04:25, Rouven Czerwinski via lttng-dev wrote:
> 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 +++++++++++++++++++

[...]

> 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>
> +

This patch is missing an important piece here, see similar situation for regmap:

/*
  * Create the tracepoint static inlines from the kernel to validate that our
  * trace event macros match the kernel we run on.
  */
#include <../../drivers/base/regmap/trace.h>

and its associated checks in Kbuild:

ifneq ($(CONFIG_REGMAP),)
   regmap_dep_4_1 = $(srctree)/drivers/base/regmap/trace.h
   ifneq ($(wildcard $(regmap_dep_4_1)),)
     obj-$(CONFIG_LTTNG) += lttng-probe-regmap.o
   else
     $(warning File $(regmap_dep_4_1) not found. Probe "regmap" is disabled. Need Linux 4.1+ kernel source tree to enable it.)
   endif # $(wildcard $(regmap_dep_4_1)),
endif # CONFIG_REGMAP

This is required to validate that the tracepoint signature we build
against indeed matches the types expected by the tracepoint probe
callbacks.

Unfortunately, the drm-sched instrumentation is located in
drivers/gpu/drm/scheduler/gpu_scheduler_trace.h which is not
available with installed kernel headers. So we really need
access to the kernel sources to validate this signature.

If we don't validate this at compile-time, this can generate
kernel modules that will crash the kernel at runtime if the
tracepoint signature changes in future kernels. This is something
that is not acceptable.

Thanks,

Mathieu


> +/*
> + * 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);


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


More information about the lttng-dev mailing list