[igt-dev] [PATCH i-g-t] lib: Add igt_trace()

Chris Wilson chris at chris-wilson.co.uk
Mon Oct 14 15:22:25 UTC 2019


Quoting Ville Syrjala (2019-10-14 16:08:17)
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Add igt_trace() which can be used to inject messages into the
> kernel ftrace buffer via the trace_marker file. Quite useful when
> trying to correlate test case activity with kernel tracepoints.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  lib/igt_core.c | 16 ++++++++++++++++
>  lib/igt_core.h |  9 +++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 940913c185ee..6a9c036393ac 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -421,6 +421,22 @@ void igt_kmsg(const char *format, ...)
>         fclose(file);
>  }
>  
> +void igt_trace(const char *format, ...)
> +{
> +       va_list ap;
> +       FILE *file;

We could do

base = igt_debugfs_mount();
snprintf(buf, sizeof(buf), "%s/tracing/trace_marker", base);

to be paranoid.

> +
> +       file = fopen("/sys/kernel/debug/tracing/trace_marker", "w");
> +       if (file == NULL)
> +               return;
> +
> +       va_start(ap, format);
> +       vfprintf(file, format, ap);
> +       va_end(ap);

Writes to trace_marker are copied verbatim (with a trailing '\n' if
lacking).

> +
> +       fclose(file);
> +}

Mechanically looks fine,
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list