public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Wagner <dwagner@suse.de>
To: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, Mike Galbraith <efault@gmx.de>,
	Daniel Wagner <dwagner@suse.de>
Subject: [PATCH rt-tests v1 1/2] rt-utils: Call get_timestmap() in rt_init()
Date: Mon, 28 Jun 2021 22:12:02 +0200	[thread overview]
Message-ID: <20210628201203.30974-2-dwagner@suse.de> (raw)
In-Reply-To: <20210628201203.30974-1-dwagner@suse.de>

Move the get_timestamp() from rt_test_start() to rt_init(). The idea
of rt_test_start() was to get the start timestamp right before the
'main loop' for the test starts. At least for cyclictest the
rt_test_start() was placed wrongly so that the first test cycle could
hit the pagefault when strftime() wrote into the tsbuf.

We don't have an exact semantic description what start test timestamp
means, so the simplest thing to avoid any further problems with it, is
to take the timestamp right at the beginning when the program
starts. Most test programs have a very short setup phase anyway.

Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/lib/rt-utils.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index d264c348ad42..11f386098867 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -490,6 +490,19 @@ void disable_trace_mark(void)
 	close_tracemark_fd();
 }
 
+static void get_timestamp(char *tsbuf)
+{
+	struct timeval tv;
+	struct tm *tm;
+	time_t t;
+
+	gettimeofday(&tv, NULL);
+	t = tv.tv_sec;
+	tm = localtime(&t);
+	/* RFC 2822-compliant date format */
+	strftime(tsbuf, MAX_TS_SIZE, "%a, %d %b %Y %T %z", tm);
+}
+
 void rt_init(int argc, char *argv[])
 {
 	int offset = 0;
@@ -514,24 +527,12 @@ void rt_init(int argc, char *argv[])
 
 		offset += len + 1;
 	}
-}
 
-static void get_timestamp(char *tsbuf)
-{
-	struct timeval tv;
-	struct tm *tm;
-	time_t t;
-
-	gettimeofday(&tv, NULL);
-	t = tv.tv_sec;
-	tm = localtime(&t);
-	/* RFC 2822-compliant date format */
-	strftime(tsbuf, MAX_TS_SIZE, "%a, %d %b %Y %T %z", tm);
+	get_timestamp(ts_start);
 }
 
 void rt_test_start(void)
 {
-	get_timestamp(ts_start);
 }
 
 void rt_write_json(const char *filename, int return_code,
-- 
2.32.0


  reply	other threads:[~2021-06-28 20:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 20:12 [PATCH rt-tests v1 0/2] Fix for start timestamp Daniel Wagner
2021-06-28 20:12 ` Daniel Wagner [this message]
2021-06-29  6:43   ` [PATCH rt-tests v1 1/2] rt-utils: Call get_timestmap() in rt_init() Kurt Kanzenbach
2021-06-30  3:05     ` John Kacur
2021-06-30  3:04   ` John Kacur
2021-06-28 20:12 ` [PATCH rt-tests v1 2/2] rt-utils: Remove empty rt_test_start() Daniel Wagner
2021-06-30  3:05   ` John Kacur

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=20210628201203.30974-2-dwagner@suse.de \
    --to=dwagner@suse.de \
    --cc=efault@gmx.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