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

Re: [Xen-devel] [PATCH v4 4/7] add nspin_sleep function to time manager



On Tue, Apr 10, 2018 at 09:16:58PM +0200, Paul Semel wrote:
> this function spin sleeps for t nanoseconds
> 
> Signed-off-by: Paul Semel <phentex@xxxxxxxxx>
> ---
> 
> Notes:
>     v4:
>     - new patch version
> 
>  common/time.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/common/time.c b/common/time.c
> index 8489f3b..232e134 100644
> --- a/common/time.c
> +++ b/common/time.c
> @@ -139,6 +139,18 @@ int gettimeofday(struct timeval *tp, void *restrict tzp)
>      return 0;
>  }
>  
> +static inline void nspin_sleep(uint64_t t)
> +{
> +    uint64_t curr = since_boot_time();
> +    uint64_t end = curr + t;
> +
> +    if ( end < curr )
> +        panic("end value overflows counter\n");
> +
> +    while ( since_boot_time() < end )
> +        asm volatile ("pause");

You likely want to add a pause helper to arch/x86/include/arch/lib.h
in order to avoid open-coding the asm instruction in common code.

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