public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: John Kacur <jkacur@redhat.com>, linux-rt-users@vger.kernel.org
Subject: cyclictest: write tracemark if latency above spike value
Date: Wed, 1 Mar 2023 16:55:37 -0300	[thread overview]
Message-ID: <Y/+tuRphtuNBuXEf@tpad> (raw)


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);



                 reply	other threads:[~2023-03-01 20:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=Y/+tuRphtuNBuXEf@tpad \
    --to=mtosatti@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.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