Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1636948

Re: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday.

From Jon Masters <jcm@jonmasters.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday.
Date 2017-05-06 18:30 +0200
Message-ID <tEaKJ-1VB-3@gated-at.bofh.it> (permalink)
References <tzAmt-7Jg-3@gated-at.bofh.it> <tzAmt-7Jg-1@gated-at.bofh.it>
Organization World Organi{s,z}ation of Broken Dreams

Show all headers | View raw


On 04/23/2017 07:47 PM, Andrew Pinski wrote:
> ISB is normally required before mrs CNTVCT if we want the
> mrs to completed after the loads. In this case it is not.
> As we are taking the difference and if that difference
> was going to be negative, we just use the last counter value
> instead.
> 
> Signed-off-by: Andrew Pinski <apinski@cavium.com>

Humor me. Walk me through this?

> ---
>  arch/arm64/kernel/vdso/gettimeofday.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kernel/vdso/gettimeofday.c b/arch/arm64/kernel/vdso/gettimeofday.c
> index a0ab8b1..cf3235a 100644
> --- a/arch/arm64/kernel/vdso/gettimeofday.c
> +++ b/arch/arm64/kernel/vdso/gettimeofday.c
> @@ -117,10 +117,20 @@ static notrace u64 get_clock_shifted_nsec(u64 cycle_last, u64 mult)
>  	u64 res;
>  
>  	/* Read the virtual counter. */
> -	isb();
> +	/*
> +	 * This normally requires an ISB but since we know the
> +	 * read of the last cycle will always be after the
> +	 * read of the values are valid word.
> +	 */
>  	asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
>  
> -	res = res - cycle_last;
> +	/*
> +	 * If the current cycle is greater than the last,
> +	 *  then get the difference.
> +	 */
> +	if (res > cycle_last)
> +		res = res - cycle_last;
> +
>  	/* We can only guarantee 56 bits of precision. */
>  	res &= ~(0xff00ul<<48);
>  	return res * mult;
> 


-- 
Computer Architect

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday. Jon Masters <jcm@jonmasters.org> - 2017-05-06 18:30 +0200
  RE: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday. "Pinski, Andrew" <Andrew.Pinski@cavium.com> - 2017-05-06 19:50 +0200
    Re: [PATCH 2/2] arm64:vdso: Remove ISB from gettimeofday. Jon Masters <jcm@jonmasters.org> - 2017-05-06 21:40 +0200

csiph-web