public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib: Add igt_trace()
Date: Mon, 14 Oct 2019 18:08:17 +0300	[thread overview]
Message-ID: <20191014150817.18549-1-ville.syrjala@linux.intel.com> (raw)

From: Ville Syrjälä <ville.syrjala@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@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;
+
+	file = fopen("/sys/kernel/debug/tracing/trace_marker", "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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2019-10-14 15:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 15:08 Ville Syrjala [this message]
2019-10-14 15:22 ` [igt-dev] [PATCH i-g-t] lib: Add igt_trace() Chris Wilson
2019-10-14 16:10 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-10-14 18:50 ` [igt-dev] [PATCH i-g-t v2] " Ville Syrjala
2019-10-14 19:59 ` [igt-dev] ✓ Fi.CI.BAT: success for lib: Add igt_trace() (rev2) Patchwork
2019-10-14 23:56 ` [igt-dev] ✗ Fi.CI.IGT: failure for lib: Add igt_trace() Patchwork
2019-10-15  6:52 ` [igt-dev] ✗ Fi.CI.IGT: failure for lib: Add igt_trace() (rev2) Patchwork

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=20191014150817.18549-1-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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