[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85fb9d71-b956-3d3e-f279-1310eec8e5c9@loongson.cn>
Date: Tue, 7 Feb 2023 09:27:25 +0800
From: Jianmin Lv <lvjianmin@...ngson.cn>
To: Xi Ruoyao <xry111@...111.site>, WANG Xuerui <kernel@...0n.name>,
Huacai Chen <chenhuacai@...ngson.cn>,
Arnd Bergmann <arnd@...db.de>,
Huacai Chen <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev, linux-arch@...r.kernel.org,
Xuefeng Li <lixuefeng@...ngson.cn>,
Guo Ren <guoren@...nel.org>,
Jiaxun Yang <jiaxun.yang@...goat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] LoongArch: Make -mstrict-align be configurable
On 2023/2/6 下午9:30, Xi Ruoyao wrote:
> On Mon, 2023-02-06 at 21:13 +0800, Jianmin Lv wrote:
>>> (1) Is the difference contributed by a bad code generation of GCC? If
>>> true, it's better to improve GCC before someone starts to build a distro
>>> for LA264 as it would benefit the user space as well.
>>>
>> AFAIK, GCC builds to produce unaligned-access-enabled target binary by
>> default (without -mstrict-align) for improving user space performance
>> (small size and runtime high performance), which is also based the fact
>> that the vast majority of LoongArch CPUs support unaligned-access.
>
> I mean: if someone starts to build a distro for a less-capable LoongArch
> processor, (s)he will need an entire user space compiled with -mstrict-
> align. So it would be better to start preparation now.
>
> And it's likely (s)he will either submit a GCC patch to make GCC
> enable/disable -mstrict-align based on the -march= (--with-arch at
> configure time) value, or hack GCC to enable -mstrict-align by default
> for the distro. So I think we'll also need:
>
>> +ifdef CONFIG_ARCH_STRICT_ALIGN may enable strict align by default.
>> # Don't emit unaligned accesses.
>> # Not all LoongArch cores support unaligned access, and as kernel we can't
>> # rely on others to provide emulation for these accesses.
>> KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
> +else
> +# Distros designed for running on both kind of processors may disable
> +# strict align by default, but the user may want a no-strict-align
> +# kernel for his/her specific hardware.
> KBUILD_CFLAGS += $(call cc-option,-mno-strict-align)
>> +endif
>
Thanks, Ruoyao, I think it's good suggestion. After talking about it
with GCC colleague, it's very likely make GCC enable/disable
-mstrict-align based on the -march= in future, just as you said.
Powered by blists - more mailing lists