From: Xi Ruoyao <xry111@xry111.site>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] LoongArch: Enable HAVE_EFFICIENT_UNALIGNED_ACCESS by default
Date: Sun, 06 Dec 2026 14:52:01 +0800 [thread overview]
Message-ID: <ebfb59235c3d8ceea0e09617d582039fcd655677.camel@xry111.site> (raw)
In-Reply-To: <20261205100121.3605-1-yangtiezhu@loongson.cn>
On Sat, 2026-12-05 at 18:01 +0800, Tiezhu Yang wrote:
> Currently, CONFIG_ARCH_STRICT_ALIGN is enabled by default in Kconfig
> to prevent unaligned memory accesses on certain LoongArch processors
> without hardware support (such as Loongson-2K0300/2K0500/2K1000).
>
> However, all Loongson-3 series processors and some newer Loongson-2K
> processors (Loongson-2K2000/2K3000) natively support unaligned access
> in hardware. Thus, keeping -mstrict-align enabled by default degrades
> performance and increases code size on mainstream hardware.
>
> Moreover, when ARCH_STRICT_ALIGN is disabled, unaligned.o is not built
> and software emulation is compiled out. As a result, a single generic
> kernel image built without ARCH_STRICT_ALIGN cannot run on processors
> without hardware unaligned access support.
>
> Enable HAVE_EFFICIENT_UNALIGNED_ACCESS by default through disabling
> CONFIG_ARCH_STRICT_ALIGN by default so that modern LoongArch systems
> can fully benefit from hardware unaligned access, allowing subsystems
> such as networking, bpf, and cryptography to perform direct word-size
> unaligned loads/stores instead of falling back to slow byte-by-byte
> accesses or extra alignment padding.
>
> To preserve compatibility so that a single generic kernel image can
> still run on certain processors without hardware UAL support, keep
> software unaligned access emulation always available as a fallback
> (while hot paths like memcpy/memset/copy_user already dynamically
> switch via ALTERNATIVE based on CPU_FEATURE_UAL).
IMO it's easier to just move CONFIG_ARCH_STRICT_ALIGN out of
CONFIG_EXPERT and let the distro maintainer to decide (based on if they
are building a desktop/server distro or a embedded distro).
The desktop/server distros already cannot run on the embedded processors
like 2K0300/2K0500 because the uses of LSX and there's no way to salvage
it. So it does not make sense to be so idealistic and attempt to use
one kernel image for both desktop/server and embedded.
--
Xi Ruoyao <xry111@xry111.site>
prev parent reply other threads:[~2026-12-06 6:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 10:01 Tiezhu Yang
2026-12-06 6:52 ` Xi Ruoyao [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=ebfb59235c3d8ceea0e09617d582039fcd655677.camel@xry111.site \
--to=xry111@xry111.site \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=yangtiezhu@loongson.cn \
/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
all inboxes | Powered by JetHome®