From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2] lib: Add igt_trace()
Date: Mon, 14 Oct 2019 21:50:37 +0300 [thread overview]
Message-ID: <20191014185037.24291-1-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20191014150817.18549-1-ville.syrjala@linux.intel.com>
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.
v2: Use igt_debugfs_mount() (Chris)
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ville Syrjälä <ville.syrjala@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
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-10-14 18:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 15:08 [igt-dev] [PATCH i-g-t] lib: Add igt_trace() Ville Syrjala
2019-10-14 15:22 ` Chris Wilson
2019-10-14 16:10 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-10-14 18:50 ` Ville Syrjala [this message]
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=20191014185037.24291-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