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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxx>
> Signed-off-by: Daniel Wagner <dwagner@xxxxxxx>
> ---
>  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@xxxxxxxxxx>




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux