All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Peter Collingbourne <pcc@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Will Deacon <will@kernel.org>,
	Evgenii Stepanov <eugenis@google.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: mte: avoid TFSR related operations unless in async mode
Date: Thu, 1 Jul 2021 18:37:39 +0100	[thread overview]
Message-ID: <20210701173738.GI12484@arm.com> (raw)
In-Reply-To: <20210701031448.2173-1-pcc@google.com>

On Wed, Jun 30, 2021 at 08:14:48PM -0700, Peter Collingbourne wrote:
> There is no reason to touch TFSR nor issue a DSB unless our task is
> in asynchronous mode. Since these operations (especially the DSB)
> may be expensive on certain microarchitectures, only perform them
> if necessary.

Have you noticed any performance degradation in practice?

> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Link: https://linux-review.googlesource.com/id/Ib353a63e3d0abc2b0b008e96aa2d9692cfc1b815
> ---
>  arch/arm64/kernel/entry.S | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
> index 863d44f73028..c2338414c558 100644
> --- a/arch/arm64/kernel/entry.S
> +++ b/arch/arm64/kernel/entry.S
> @@ -133,12 +133,18 @@ alternative_cb_end
>  	.endm
>  
>  	/* Check for MTE asynchronous tag check faults */
> -	.macro check_mte_async_tcf, tmp, ti_flags
> +	.macro check_mte_async_tcf, tmp, ti_flags, thread_sctlr
>  #ifdef CONFIG_ARM64_MTE
>  	.arch_extension lse
>  alternative_if_not ARM64_MTE
>  	b	1f
>  alternative_else_nop_endif
> +	/*
> +	 * Asynchronous tag check faults are only possible in ASYNC (2) or
> +	 * ASYM (3) modes. In each of these modes bit 1 of SCTLR_EL1.TCF0 is
> +	 * set, so skip the check if it is unset.
> +	 */
> +	tbz	\thread_sctlr, #(SCTLR_EL1_TCF0_SHIFT + 1), 1f
>  	mrs_s	\tmp, SYS_TFSRE0_EL1
>  	tbz	\tmp, #SYS_TFSR_EL1_TF0_SHIFT, 1f

I don't think this one is that expensive.

>  	/* Asynchronous TCF occurred for TTBR0 access, set the TI flag */
> @@ -151,11 +157,14 @@ alternative_else_nop_endif
>  	.endm
>  
>  	/* Clear the MTE asynchronous tag check faults */
> -	.macro clear_mte_async_tcf
> +	.macro clear_mte_async_tcf thread_sctlr
>  #ifdef CONFIG_ARM64_MTE
>  alternative_if ARM64_MTE
> +	/* See comment in check_mte_async_tcf above. */
> +	tbz	\thread_sctlr, #(SCTLR_EL1_TCF0_SHIFT + 1), 1f
>  	dsb	ish
>  	msr_s	SYS_TFSRE0_EL1, xzr
> +1:

Here, maybe, as we have a DSB.

-- 
Catalin

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

  reply	other threads:[~2021-07-01 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01  3:14 [PATCH] arm64: mte: avoid TFSR related operations unless in async mode Peter Collingbourne
2021-07-01 17:37 ` Catalin Marinas [this message]
2021-07-01 18:11   ` Peter Collingbourne
2021-07-02 17:37     ` Catalin Marinas
2021-07-03  2:46       ` Peter Collingbourne

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=20210701173738.GI12484@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=eugenis@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pcc@google.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.