From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37C2D3002DC for ; Mon, 2 Mar 2026 16:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772468805; cv=none; b=Im98DrZ2ifxn5PnmtalA4AOq59Bkr93Vf6qwRnHgSoTJsaGaW+K4ZpYHJZTPlMwYT5ZkryD47hyfuLll1NizaQeb8/EBKQ68P+pfAT8gTX62Kc1Jg4KPHJEhdtKSVO3S15QUyVbFnMvyUDxItMvMjX57Q+AygBcJrsRH96mkGrI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772468805; c=relaxed/simple; bh=kdYmkec+vibcZGizPRkgLEMx84dJqP3cy2bXqQiGjvc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HuAAA5a2TvLHWUOWwBY+6euqnVTYFZMBR0UEAQM7iTQ/kHgQuX14EA/5tliWiKXHz2Uw5iX6ajvZO0enON6Ydz7es5w/siQ+xopepaNWL0Y68+f4KDhHIHdlX3XEzRrLwhTAjbppY6ve3lYZoX52UPgpEwzRKoEFKUCxRto2X9s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kyGGH6hp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kyGGH6hp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6B98C19423; Mon, 2 Mar 2026 16:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772468805; bh=kdYmkec+vibcZGizPRkgLEMx84dJqP3cy2bXqQiGjvc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kyGGH6hpbWifdwqL06YTWOp2jCkLAQLRupwY4AWdy7uM/ORn2LZ68eN3Ej780fkSJ uZYhDiZtyYikwnFmrs2KSA00qp5Bwp4PskpXBZQ5M1MYPHgAz0HsVp4kd7EfX7unax fvjZ8ue6hAWYTzKCbc7bv/LRysF/CdRQgA2GvlxSpfaD1gBIQnfuH/YyGqbIwsjJqm A1HPXSHtHDV1gncgp++jOjBtX5pWU/WCo7wySnb98yKqNU6VQLkNcG60bbGx62eyog e0tEqf4havobIDdFtijMkmsMAs1A0XcJEDYLUmQdsmYxFdvYWFW2Ltq+bRKpBW5zoN WYcEd9PsF8J9A== Date: Tue, 3 Mar 2026 00:08:09 +0800 From: Jisheng Zhang To: Catalin Marinas Cc: Will Deacon , 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 Message-ID: References: <20260225144613.30846-1-jszhang@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Fri, Feb 27, 2026 at 04:34:04PM +0000, Catalin Marinas wrote: > 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? 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. oops, you are right! I missed both: KASAN_SW_TAGS is disabled due to overhead while KASAN_HW_TAGS doesn't work since I don't have the platform. Will take care these two options in the future. > > > 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 > > > > +#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. Usually, the runtime const ptr is set once during boot then read onlly so IMHO we don't need KASAN to catch the ptr related memory bugs. > > 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? Good question. I guess a micro benchmark just measure the 4 instructions vs 3 instructions thus 25% saving can't persuade you to merge it. Let me find or write a userspace program to iterate a deep directory to show the improvement. Any hint is appreciated. Thanks