linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: linux-rt-users@vger.kernel.org
Cc: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Subject: [PATCH rt-tests v2] Fix tracemark output when the latency threshold is hit on ARM
Date: Fri, 31 Jan 2014 20:16:52 +0100	[thread overview]
Message-ID: <1391195812-24833-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <1390945793-28357-1-git-send-email-u.kleine-koenig@pengutronix.de>

On ARM I'm seeing output like:

	cyclicte-623     0....... 19619418us+: tracing_mark_write: hit latency threshold (2000 > 2097)

That's because of a format mismatch in

	tracemark("hit latency threshold (%d > %d)", diff, tracelimit);

diff is a u64 and tracelimit an int. So on ARM the string is passed in r0,
tracelimit in r1 and diff in r2+r3. vsnprintf used in tracemark only
expects two ints passed and so only uses r1 and r2 yielding the permutation
in the output.

This patch also adds a gcc attribute to tracemark that helps catching
similar bugs. In this case just adding the attribute but not touching
the call site, would result in:

	src/cyclictest/cyclictest.c: In function ‘timerthread’:
	src/cyclictest/cyclictest.c:899:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘uint64_t’ [-Wformat]

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello

after some chatting with Clark and John I dropped the c99 stuff and added the
attribute annotation.

Best regards
Uwe

 src/cyclictest/cyclictest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 686a6356659f..638e1ab57634 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -400,6 +400,7 @@ static int trace_file_exists(char *name)
 #define TRACEBUFSIZ 1024
 static __thread char tracebuf[TRACEBUFSIZ];
 
+static void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
 static void tracemark(char *fmt, ...)
 {
 	va_list ap;
@@ -895,7 +896,8 @@ void *timerthread(void *param)
 
 		if (!stopped && tracelimit && (diff > tracelimit)) {
 			stopped++;
-			tracemark("hit latency threshold (%d > %d)", diff, tracelimit);
+			tracemark("hit latency threshold (%llu > %d)",
+				  (unsigned long long)diff, tracelimit);
 			tracing(0);
 			shutdown++;
 			pthread_mutex_lock(&break_thread_id_lock);
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2014-01-31 19:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 21:49 [PATCH rt-tests] Fix tracemark output when the latency threshold is hit on ARM Uwe Kleine-König
2014-01-31 19:16 ` Uwe Kleine-König [this message]

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=1391195812-24833-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).