All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Joey Gouly <joey.gouly@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, nd@arm.com,
	andre.przywara@arm.com, catalin.marinas@arm.com,
	vincenzo.frascino@arm.com, will@kernel.org
Subject: Re: [PATCH v1 3/3] arm64: vdso: use SYS_CNTVCTSS_EL0 for gettimeofday
Date: Thu, 25 Aug 2022 14:24:22 +0100	[thread overview]
Message-ID: <Ywd4BsITN4FJvfPO@FVFF77S0Q05N> (raw)
In-Reply-To: <20220825102025.53916-4-joey.gouly@arm.com>

On Thu, Aug 25, 2022 at 11:20:25AM +0100, Joey Gouly wrote:
> If FEAT_ECV is implemented, the self-synchronized counter CNTVCTSS_EL0 can
> be used, removing the need for an ISB.
> 
> Signed-off-by: Joey Gouly <joey.gouly@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Andre Przywara <andre.przywara@arm.com>
> ---
>  arch/arm64/include/asm/vdso/gettimeofday.h | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h
> index 4f7a629df81f..d8aff747019c 100644
> --- a/arch/arm64/include/asm/vdso/gettimeofday.h
> +++ b/arch/arm64/include/asm/vdso/gettimeofday.h
> @@ -9,6 +9,8 @@
>  
>  #include <asm/barrier.h>
>  #include <asm/unistd.h>
> +#include <asm/sysreg.h>
> +#include <asm/alternative.h>

Nit: please sort this alphabetically.

>  
>  #define VDSO_HAS_CLOCK_GETRES		1
>  
> @@ -78,11 +80,15 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
>  		return 0;
>  
>  	/*
> -	 * This isb() is required to prevent that the counter value
> +	 * If FEAT_ECV is available, use the self-synchronizing counter.
> +	 * Otherwise the isb is required to prevent that the counter value
>  	 * is speculated.
> -	 */
> -	isb();
> -	asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
> +	*/
> +	asm volatile(ALTERNATIVE("isb\nmrs %0, cntvct_el0",
> +			"nop\n" __mrs_s("%0", SYS_CNTVCTSS_EL0),
> +			ARM64_HAS_ECV)
> +		     : "=r" (res) :: "memory");
> +

For legibility (and ease of future modification), could we please format this
with the fields all aligned, e.g.

	asm volatile(
	ALTERNATIVE("isb\n"
		    "mrs %0, cntvct_el0",
		    "nop\n"
		    __mrs_s("%0", SYS_CNTVCTSS_EL0),
		    ARM64_HAS_ECV)
	: "=r" (res)
	:
	: "memory");


Regardless:

	Acked-by: Mark Rutland <mark.rutland@arm.com>

Thanks,
Mark.

>  	arch_counter_enforce_ordering(res);
>  
>  	return res;
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2022-08-25 13:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25 10:20 [PATCH v1 0/3] Use CNTVCTSS_EL0 in gettimeofday() Joey Gouly
2022-08-25 10:20 ` [PATCH v1 1/3] arm64: module: move find_section to header Joey Gouly
2022-08-25 13:19   ` Mark Rutland
2022-08-25 10:20 ` [PATCH v1 2/3] arm64: alternative: patch alternatives in the vDSO Joey Gouly
2022-08-25 13:19   ` Mark Rutland
2022-08-25 14:57     ` Joey Gouly
2022-08-25 10:20 ` [PATCH v1 3/3] arm64: vdso: use SYS_CNTVCTSS_EL0 for gettimeofday Joey Gouly
2022-08-25 13:24   ` Mark Rutland [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ywd4BsITN4FJvfPO@FVFF77S0Q05N \
    --to=mark.rutland@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=nd@arm.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.