summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2012-08-30 15:53:35 -0500
committerClark Williams <williams@redhat.com>2012-08-30 15:54:02 -0500
commit7667ff6946931558ff1c148c067faf34eba2bb5d (patch)
tree4cafb4d6936c6090a9b4d82e6e955b187c72b5ab
parent857cdd5320ce1f293f5dbcbec79cc8fe22b0bebf (diff)
downloadrt-tests-7667ff6946931558ff1c148c067faf34eba2bb5d.tar.gz
add setup and call of tracemark function for breaktrace
Add back call to the tracemark function but only if we're using the breaktrace option and only when we actually hit the breaktrace threshold. Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 11b6cea..523c70e 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -245,6 +245,7 @@ static char functiontracer[MAX_PATH];
static char traceroptions[MAX_PATH];
static int trace_fd = -1;
+static int tracemark_fd = -1;
static int kernvar(int mode, const char *name, char *value, size_t sizeofvalue)
{
@@ -374,6 +375,27 @@ static int trace_file_exists(char *name)
return stat(path, &sbuf) ? 0 : 1;
}
+#define TRACEBUFSIZ 1024
+static __thread char tracebuf[TRACEBUFSIZ];
+
+static void tracemark(char *fmt, ...)
+{
+ va_list ap;
+ int len;
+
+ /* bail out if we're not tracing */
+ /* or if the kernel doesn't support trace_mark */
+ if (tracemark_fd < 0)
+ return;
+
+ va_start(ap, fmt);
+ len = vsnprintf(tracebuf, TRACEBUFSIZ, fmt, ap);
+ va_end(ap);
+ write(tracemark_fd, tracebuf, len);
+}
+
+
+
void tracing(int on)
{
if (on) {
@@ -536,6 +558,14 @@ static void setup_tracer(void)
fatal("unable to open %s for tracing", path);
}
+ /* open the tracemark file descriptor */
+ if (tracemark_fd == -1) {
+ char path[MAX_PATH];
+ strcat(strcpy(path, fileprefix), "trace_marker");
+ if ((tracemark_fd = open(path, O_WRONLY)) == -1)
+ warn("unable to open trace_marker file: %s\n", path);
+ }
+
} else {
setkernvar("trace_all_cpus", "1");
setkernvar("trace_freerunning", "1");
@@ -835,6 +865,7 @@ void *timerthread(void *param)
if (!stopped && tracelimit && (diff > tracelimit)) {
stopped++;
+ tracemark("hit latency threshold (%d > %d)", diff, tracelimit);
tracing(0);
shutdown++;
pthread_mutex_lock(&break_thread_id_lock);
@@ -1700,6 +1731,8 @@ int main(int argc, char **argv)
/* close any tracer file descriptors */
+ if (tracemark_fd >= 0)
+ close(tracemark_fd);
if (trace_fd >= 0)
close(trace_fd);