public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Jisheng Zhang <jszhang@kernel.org>
Cc: Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: runtime-const: save one instruction when ARM64_VA_BITS <= 48
Date: Fri, 27 Feb 2026 16:34:04 +0000	[thread overview]
Message-ID: <aaHHfCL4hdV4z9Uo@arm.com> (raw)
In-Reply-To: <20260225144613.30846-1-jszhang@kernel.org>

On Wed, Feb 25, 2026 at 10:46:13PM +0800, Jisheng Zhang wrote:
> Currently, the runtime_const_ptr() uses 4 instructions to move a long
> imm to GP, but when ARM64_VA_BITS <= 48(which is true for android and
> armbian), the top 8bits of runtime cont ptr is all '1', so we can make
                    ^^^^^
                    8 or 16?

> use of the movn instruction to construct the imm's top 8bits and lower
> 16bits at the same time, thus save one instruction.

This works as long as KASAN_{SW,HW}_TAGS is disabled, otherwise the top
byte of a pointer is not guaranteed to be 0xff. I think both
filename_init() and dcache_init() can pass tagged pointers.

> diff --git a/arch/arm64/include/asm/runtime-const.h b/arch/arm64/include/asm/runtime-const.h
> index be5915669d23..6797dd37d690 100644
> --- a/arch/arm64/include/asm/runtime-const.h
> +++ b/arch/arm64/include/asm/runtime-const.h
> @@ -7,6 +7,8 @@
>  /* Sigh. You can still run arm64 in BE mode */
>  #include <asm/byteorder.h>
>  
> +#if CONFIG_ARM64_VA_BITS > 48

You could use VA_BITS, it's shorter, though if you add the KASAN checks
it's a pretty long #if to copy all over the place. We could untag the
pointer but it kind of defeats the purpose of enabling KASAN in the
first place.

Given that Android enables KASAN_HW_TAGS by default, not sure we should
bother with this change. Do you have any perf data to show that it's
worth it?

-- 
Catalin

  reply	other threads:[~2026-02-27 16:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 14:46 [PATCH] arm64: runtime-const: save one instruction when ARM64_VA_BITS <= 48 Jisheng Zhang
2026-02-27 16:34 ` Catalin Marinas [this message]
2026-03-02 16:08   ` Jisheng Zhang

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=aaHHfCL4hdV4z9Uo@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=jszhang@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox