linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* cyclictest: write tracemark if latency above spike value
@ 2023-03-01 19:55 Marcelo Tosatti
  0 siblings, 0 replies; only message in thread
From: Marcelo Tosatti @ 2023-03-01 19:55 UTC (permalink / raw)
  To: John Kacur, linux-rt-users


It is useful to have the following ranges:

	Value			Behaviour

	> break_lat	   -> write tracemark entry, quit cyclictest.

	[spike, break_lat] -> write tracemark entry, continue execution.

	< spike		   -> no tracemark entry, continue execution.


So one can know which events are causing "close to break value"
(and their causes).

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 82759d1..22eab05 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1698,6 +1698,9 @@ static void trigger_update(struct thread_param *par, int diff, int64_t ts)
 	}
 	spikes++;
 	pthread_mutex_unlock(&trigger_lock);
+	if (trace_marker && diff > trigger) {
+		tracemark_nostop("hit latency trigger (%d > %d)", diff, trigger);
+	}
 }
 
 /* Running status shared memory open */
@@ -1892,7 +1895,7 @@ int main(int argc, char **argv)
 	/* use the /dev/cpu_dma_latency trick if it's there */
 	set_latency_target();
 
-	if (tracelimit && trace_marker)
+	if ((tracelimit && trace_marker) || (trigger && trace_marker))
 		enable_trace_mark();
 
 	if (check_timer())
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index f6b3fed..85a459f 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -32,6 +32,7 @@ int parse_mem_string(char *str, uint64_t *val);
 
 void enable_trace_mark(void);
 void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
+void tracemark_nostop(char *fmt, ...) __attribute__((format(printf, 1, 2)));
 void disable_trace_mark(void);
 
 #define MSEC_PER_SEC		1000
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index 6c0235d..daa8bb8 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -458,7 +458,7 @@ static void debugfs_prepare(void)
 		     "debug fs not mounted");
 }
 
-void tracemark(char *fmt, ...)
+void tracemark_nostop(char *fmt, ...)
 {
 	va_list ap;
 	int len;
@@ -474,6 +474,21 @@ void tracemark(char *fmt, ...)
 
 	/* write the tracemark message */
 	write(tracemark_fd, tracebuf, len);
+}
+
+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 || trace_fd < 0)
+		return;
+
+	va_start(ap, fmt);
+	len = vsnprintf(tracebuf, TRACEBUFSIZ, fmt, ap);
+	va_end(ap);
 
 	/* now stop any trace */
 	write(trace_fd, "0\n", 2);



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-01 20:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01 19:55 cyclictest: write tracemark if latency above spike value Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).