Thread (7 messages) 7 messages, 3 authors, 2021-06-30

Re: [PATCH rt-tests v1 1/2] rt-utils: Call get_timestmap() in rt_init()

From: John Kacur <jkacur@redhat.com>
Date: 2021-06-30 03:04:53


On Mon, 28 Jun 2021, Daniel Wagner wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
Signed-off-by: Daniel Wagner <redacted>
---
 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
Signed-off-by: John Kacur <jkacur@redhat.com>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help