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

Re: [Xen-devel] [PATCH 2/7] add current_time function to time manager



On Wed, Apr 04, 2018 at 03:50:49PM +0000, Pawel Wieczorkiewicz wrote:
> From: Paul Semel <phentex@xxxxxxxxx>
> 
> this function returns the "epoch" time
> 
> Signed-off-by: Paul Semel <phentex@xxxxxxxxx>
> 
> cr https://code.amazon.com/reviews/CR-786224
> ---
>  common/time.c      | 16 ++++++++++++++++
>  include/xtf/time.h |  4 ++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/common/time.c b/common/time.c
> index 11ac168..37a9faf 100644
> --- a/common/time.c
> +++ b/common/time.c
> @@ -76,6 +76,22 @@ uint64_t since_boot_time(void)
>      return system_time;
>  }
>  
> +/* This function return the epoch time (number of seconds elapsed
> + * since Juanary 1, 1970) */
> +#if defined(__i386__)
> +uint32_t current_time(void)
> +#else
> +uint64_t current_time(void)
> +#endif
> +{
> +#if defined(__i386__)
> +    uint32_t seconds = shared_info.wc_sec;
> +#else
> +    uint64_t seconds = ((uint64_t)shared_info.wc_sec_hi << 32) | 
> shared_info.wc_sec;
> +#endif
> +    return seconds + (since_boot_time() / 1000000000);

You need barriers and checking wc_version, see:

https://github.com/freebsd/freebsd/blob/master/sys/x86/x86/pvclock.c#L156

And as commented in patch 1, I think you should return a 64bit value
regardless of the bitness of the binary.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.