mbox series

[rt-tests,v1,0/2] Fix for start timestamp

Message ID 20210628201203.30974-1-dwagner@suse.de
Headers show
Series Fix for start timestamp | expand

Message

Daniel Wagner June 28, 2021, 8:12 p.m. UTC
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(-)

Comments

Kurt Kanzenbach June 29, 2021, 6:43 a.m. UTC | #1
Hi Daniel,

On Mon Jun 28 2021, Daniel Wagner wrote:
> 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>


This fixes the issue for me:

Tested-by: Kurt Kanzenbach <kurt@linutronix.de>


Thanks,
Kurt
John Kacur June 30, 2021, 3:04 a.m. UTC | #2
On Mon, 28 Jun 2021, Daniel Wagner wrote:

> 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

> 

> 

Signed-off-by: John Kacur <jkacur@redhat.com>
John Kacur June 30, 2021, 3:05 a.m. UTC | #3
On Tue, 29 Jun 2021, Kurt Kanzenbach wrote:

> Hi Daniel,

> 

> On Mon Jun 28 2021, Daniel Wagner wrote:

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

> 

> This fixes the issue for me:

> 

> Tested-by: Kurt Kanzenbach <kurt@linutronix.de>

> 

> Thanks,

> Kurt

> 


thanks, added