Fix for start timestamp
cover Fix for start timestamp
As Mike reported, the rt_test_start() was not placed cleverly. Let's move the code to rt_init() and avoid any further problems with it.
Daniel Wagner (2):
rt-utils: Call get_timestmap() in rt_init()
rt-utils: Remove empty rt_test_start()
src/cyclictest/cyclictest.c | 1 - src/include/rt-utils.h | 2 -- src/lib/rt-utils.c | 29 ++++++++++++--------------- src/oslat/oslat.c | 1 - src/pi_tests/pi_stress.c | 1 - src/pmqtest/pmqtest.c | 1 - src/ptsematest/ptsematest.c | 1 - src/rt-migrate-test/rt-migrate-test.c | 1 - src/sched_deadline/cyclicdeadline.c | 1 - src/signaltest/signaltest.c | 1 - src/sigwaittest/sigwaittest.c | 1 - src/ssdd/ssdd.c | 1 - src/svsematest/svsematest.c | 1 - 13 files changed, 13 insertions(+), 29 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/2 rt-utils: Call get_timestmap() in rt_init()
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.
--- src/lib/rt-utils.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
src/lib/rt-utils.c +14 -13
@@ -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,
Signature · 1 line
2.32.0
Re: [PATCH rt-tests v1 1/2] rt-utils: Call get_timestmap() in rt_init()
Hi Daniel,
Quoted 6 lines · Daniel Wagner
Move the
get_timestamp()fromrt_test_start()tort_init(). The idea ofrt_test_start()was to get the start timestamp right before the 'main loop' for the test starts. At least for cyclictest thert_test_start()was placed wrongly so that the first test cycle could hit the pagefault whenstrftime()wrote into the tsbuf.
Quoted 7 lines
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 <[email protected]>Signed-off-by Daniel Wagner <[email protected]>
This fixes the issue for me:
Thanks,
Kurt
Re: [PATCH rt-tests v1 1/2] rt-utils: Call get_timestmap() in rt_init()
Quoted 17 lines · Kurt Kanzenbach
Hi Daniel,
Quoted 6 lines · Daniel Wagner
Move the
get_timestamp()fromrt_test_start()tort_init(). The idea ofrt_test_start()was to get the start timestamp right before the 'main loop' for the test starts. At least for cyclictest thert_test_start()was placed wrongly so that the first test cycle could hit the pagefault whenstrftime()wrote into the tsbuf.Quoted 7 lines
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 <[email protected]>Signed-off-by Daniel Wagner <[email protected]>
Quoted 7 lines
This fixes the issue for me:
Tested-by Kurt Kanzenbach <[email protected]>Thanks,
Kurt
thanks, added
Re: [PATCH rt-tests v1 1/2] rt-utils: Call get_timestmap() in rt_init()
In reply to Daniel WagnerQuoted 71 lines · Daniel Wagner
Move the
get_timestamp()fromrt_test_start()tort_init(). The idea ofrt_test_start()was to get the start timestamp right before the 'main loop' for the test starts. At least for cyclictest thert_test_start()was placed wrongly so that the first test cycle could hit the pagefault whenstrftime()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 <[email protected]>Signed-off-by Daniel Wagner <[email protected]>--- src/lib/rt-utils.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)src/lib/rt-utils.c +14
-13@@ -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,Signature · 1 line
2.32.0
PATCH 2/2 rt-utils: Remove empty rt_test_start()
In reply to Daniel Wagnerrt_test_start() is unused, remove it.
--- src/cyclictest/cyclictest.c | 1 - src/include/rt-utils.h | 2 -- src/lib/rt-utils.c | 4 ---- src/oslat/oslat.c | 1 - src/pi_tests/pi_stress.c | 1 - src/pmqtest/pmqtest.c | 1 - src/ptsematest/ptsematest.c | 1 - src/rt-migrate-test/rt-migrate-test.c | 1 - src/sched_deadline/cyclicdeadline.c | 1 - src/signaltest/signaltest.c | 1 - src/sigwaittest/sigwaittest.c | 1 - src/ssdd/ssdd.c | 1 - src/svsematest/svsematest.c | 1 - 13 files changed, 17 deletions(-)
src/cyclictest/cyclictest.c +0 -1
@@ -615,7 +615,6 @@ static void *timerthread(void *param)setitimer (ITIMER_REAL , &itimer,NULL ); } -rt_test_start (); stat->threadstarted++;while (!shutdown) {
src/include/rt-utils.h +0 -2
@@ -82,8 +82,6 @@ static inline int64_t calctime(struct timespec t)void rt_init (int argc,char *argv[]); -void rt_test_start (void ); -void rt_write_json (const char *filename,int return_code,void (*cb)(FILE *,void *),void *data);
src/lib/rt-utils.c +0 -4
@@ -531,10 +531,6 @@ void rt_init(int argc, char *argv[])get_timestamp (ts_start); } -void rt_test_start (void ) -{ -} -void rt_write_json (const char *filename,int return_code,void (*cb)(FILE *,void *),void *data)
src/oslat/oslat.c +0 -1
@@ -854,7 +854,6 @@ int main(int argc, char *argv[])printf ("Test starts...\n" );/* Reset n_threads to always run on all the cores */ g.n_threads = g.n_threads_total; -rt_test_start ();run_expt (threads, g.runtime);if (!g.quiet)
src/pi_tests/pi_stress.c +0 -1
@@ -304,7 +304,6 @@ int main(int argc, char **argv) }/* report */ banner (); -rt_test_start (); start =time (NULL );/* turn loose the threads */
src/pmqtest/pmqtest.c +0 -1
@@ -582,7 +582,6 @@ int main(int argc, char *argv[])sigemptyset (&sigset);pthread_sigmask (SIG_SETMASK , &sigset,NULL ); -rt_test_start (); do { int newsamples = 0, newtimeoutcount = 0; int minsamples = INT_MAX;
src/ptsematest/ptsematest.c +0 -1
@@ -468,7 +468,6 @@ int main(int argc, char *argv[]) maindelay.tv_sec =0 ; maindelay.tv_nsec =50000000 ;/* 50 ms */ -rt_test_start ();while (!shutdown) {for (i =0 ; i < num_threads; i++) shutdown |= receiver[i].shutdown | sender[i].shutdown;
src/rt-migrate-test/rt-migrate-test.c +0 -1
@@ -621,7 +621,6 @@ int main (int argc, char **argv)setup_ftrace_marker (); -rt_test_start ();for (loop=0 ; loop < nr_runs; loop++) {unsigned long long end;
src/sched_deadline/cyclicdeadline.c +0 -1
@@ -1213,7 +1213,6 @@ int main(int argc, char **argv)if (duration)alarm (duration); -rt_test_start ();loop (sched_data, nr_threads);for (i =0 ; i < nr_threads; i++) {
src/signaltest/signaltest.c +0 -1
@@ -500,7 +500,6 @@ int main(int argc, char **argv) strerror(status)); } -rt_test_start ();while (!shutdown) {int allstarted =1 ;
src/sigwaittest/sigwaittest.c +0 -1
@@ -652,7 +652,6 @@ int main(int argc, char *argv[]) &sender[i]); } -rt_test_start ();while (!mustshutdown) {for (i =0 ; i < num_threads; i++) mustshutdown |= receiver[i].shutdown |
src/ssdd/ssdd.c +0 -1
@@ -357,7 +357,6 @@ int main(int argc, char **argv)forktests (i); } -rt_test_start ();for (i =0 ; i < nforks; i++) { status =do_wait (&wait_pid, &ret_sig);if (status !=STATE_EXITED ) {
src/svsematest/svsematest.c +0 -1
@@ -724,7 +724,6 @@ int main(int argc, char *argv[]) &sender[i]); } -rt_test_start ();while (!mustshutdown) {for (i =0 ; i < num_threads; i++) mustshutdown |= receiver[i].shutdown |
Signature · 1 line
2.32.0
Re: [PATCH rt-tests v1 2/2] rt-utils: Remove empty rt_test_start()
Quoted 183 lines · Daniel Wagner
rt_test_start()is unused, remove it.Signed-off-by Daniel Wagner <[email protected]>--- src/cyclictest/cyclictest.c | 1 - src/include/rt-utils.h | 2 -- src/lib/rt-utils.c | 4 ---- src/oslat/oslat.c | 1 - src/pi_tests/pi_stress.c | 1 - src/pmqtest/pmqtest.c | 1 - src/ptsematest/ptsematest.c | 1 - src/rt-migrate-test/rt-migrate-test.c | 1 - src/sched_deadline/cyclicdeadline.c | 1 - src/signaltest/signaltest.c | 1 - src/sigwaittest/sigwaittest.c | 1 - src/ssdd/ssdd.c | 1 - src/svsematest/svsematest.c | 1 - 13 files changed, 17 deletions(-)src/cyclictest/cyclictest.c +0
-1@@ -615,7 +615,6 @@ static void *timerthread(void *param)setitimer (ITIMER_REAL , &itimer,NULL ); } -rt_test_start (); stat->threadstarted++;while (!shutdown) {src/include/rt-utils.h +0
-2@@ -82,8 +82,6 @@ static inline int64_t calctime(struct timespec t)void rt_init (int argc,char *argv[]); -void rt_test_start (void ); -void rt_write_json (const char *filename,int return_code,void (*cb)(FILE *,void *),void *data);src/lib/rt-utils.c +0
-4@@ -531,10 +531,6 @@ void rt_init(int argc, char *argv[])get_timestamp (ts_start); } -void rt_test_start (void ) -{ -} -void rt_write_json (const char *filename,int return_code,void (*cb)(FILE *,void *),void *data)src/oslat/oslat.c +0
-1@@ -854,7 +854,6 @@ int main(int argc, char *argv[])printf ("Test starts...\n" );/* Reset n_threads to always run on all the cores */ g.n_threads = g.n_threads_total; -rt_test_start ();run_expt (threads, g.runtime);if (!g.quiet)src/pi_tests/pi_stress.c +0
-1@@ -304,7 +304,6 @@ int main(int argc, char **argv) }/* report */ banner (); -rt_test_start (); start =time (NULL );/* turn loose the threads */ src/pmqtest/pmqtest.c +0
-1@@ -582,7 +582,6 @@ int main(int argc, char *argv[])sigemptyset (&sigset);pthread_sigmask (SIG_SETMASK , &sigset,NULL ); -rt_test_start (); do { int newsamples = 0, newtimeoutcount = 0; int minsamples = INT_MAX;src/ptsematest/ptsematest.c +0
-1@@ -468,7 +468,6 @@ int main(int argc, char *argv[]) maindelay.tv_sec =0 ; maindelay.tv_nsec =50000000 ;/* 50 ms */ -rt_test_start ();while (!shutdown) {for (i =0 ; i < num_threads; i++) shutdown |= receiver[i].shutdown | sender[i].shutdown;src/rt-migrate-test/rt-migrate-test.c +0
-1@@ -621,7 +621,6 @@ int main (int argc, char **argv)setup_ftrace_marker (); -rt_test_start ();for (loop=0 ; loop < nr_runs; loop++) {unsigned long long end;src/sched_deadline/cyclicdeadline.c +0
-1@@ -1213,7 +1213,6 @@ int main(int argc, char **argv)if (duration)alarm (duration); -rt_test_start ();loop (sched_data, nr_threads);for (i =0 ; i < nr_threads; i++) {src/signaltest/signaltest.c +0
-1@@ -500,7 +500,6 @@ int main(int argc, char **argv) strerror(status)); } -rt_test_start ();while (!shutdown) {int allstarted =1 ;src/sigwaittest/sigwaittest.c +0
-1@@ -652,7 +652,6 @@ int main(int argc, char *argv[]) &sender[i]); } -rt_test_start ();while (!mustshutdown) {for (i =0 ; i < num_threads; i++) mustshutdown |= receiver[i].shutdown |src/ssdd/ssdd.c +0
-1@@ -357,7 +357,6 @@ int main(int argc, char **argv)forktests (i); } -rt_test_start ();for (i =0 ; i < nforks; i++) { status =do_wait (&wait_pid, &ret_sig);if (status !=STATE_EXITED ) {src/svsematest/svsematest.c +0
-1@@ -724,7 +724,6 @@ int main(int argc, char *argv[]) &sender[i]); } -rt_test_start ();while (!mustshutdown) {for (i =0 ; i < num_threads; i++) mustshutdown |= receiver[i].shutdown |Signature · 1 line
2.32.0