Re: [PATCH i-g-t] lib/igt_core: Prefer CLOCK_MONOTONIC_RAW

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

 



On Tue, Nov 17, 2015 at 12:24:13PM +0200, Joonas Lahtinen wrote:
> CLOCK_MONOTONIC_RAW is not affected by NTP, so it should be THE clock
> used for timing execution of tests.
> 
> Cc: Thomas Wood <thomas.wood@xxxxxxxxx>
> Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
> ---
>  lib/igt_core.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 04a0ab2..5a5b1a9 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -341,10 +341,15 @@ static void gettime(struct timespec *ts)
>  {
>  	memset(ts, 0, sizeof(*ts));
>  
> +#ifdef CLOCK_MONOTONIC_RAW
> +	if (!clock_gettime(CLOCK_MONOTONIC_RAW, ts))
> +		return;
> +#endif
>  #ifdef CLOCK_MONOTONIC_COARSE
> -	if (clock_gettime(CLOCK_MONOTONIC_COARSE, ts))
> +	if (!clock_gettime(CLOCK_MONOTONIC_COARSE, ts))
> +		return;
>  #endif
> -		clock_gettime(CLOCK_MONOTONIC, ts);
> +	clock_gettime(CLOCK_MONOTONIC, ts);

Would it be worth doing

static clock_t clock = -1;

if (clock_gettime(clock, ts) == 0)
	return;

#ifdef CLOCK_MONOTONIC_RAW
	if (clock_gettime(clock = CLOCK_MONOTONIC_RAW, ts) == 0)
		return;
#endif
...

?

Anyway,
Reviewed-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux