[igt-dev] [PATCH i-g-t v2] lib: Add igt_trace()
Ville Syrjala
ville.syrjala at linux.intel.com
Mon Oct 14 18:50:37 UTC 2019
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.
v2: Use igt_debugfs_mount() (Chris)
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/igt_core.c | 20 ++++++++++++++++++++
lib/igt_core.h | 9 +++++++++
2 files changed, 29 insertions(+)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 940913c185ee..7bd5afa5dada 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -421,6 +421,26 @@ void igt_kmsg(const char *format, ...)
fclose(file);
}
+void igt_trace(const char *format, ...)
+{
+ char path[128];
+ va_list ap;
+ FILE *file;
+
+ snprintf(path, sizeof(path), "%s/tracing/trace_marker",
+ igt_debugfs_mount());
+
+ file = fopen(path, "w");
+ if (file == NULL)
+ return;
+
+ va_start(ap, format);
+ vfprintf(file, format, ap);
+ va_end(ap);
+
+ fclose(file);
+}
+
#define time_valid(ts) ((ts)->tv_sec || (ts)->tv_nsec)
double igt_time_elapsed(struct timespec *then,
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 521cda10f6fa..e8b61128680d 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -1190,6 +1190,15 @@ int igt_system_quiet(const char *command);
free(buf); \
} while (0)
+/**
+ * igt_trace:
+ * @format: printf-style format string with optional args
+ *
+ * Writes a message into the kernel trace log.
+ */
+__attribute__((format(printf, 1, 2)))
+void igt_trace(const char *format, ...);
+
/**
* igt_kmsg:
* @format: printf-style format string with optional args
--
2.21.0
More information about the igt-dev
mailing list