mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jianmin Lv <lvjianmin@loongson.cn>
To: David Laight <David.Laight@ACULAB.COM>,
	'Huacai Chen' <chenhuacai@kernel.org>
Cc: Huacai Chen <chenhuacai@loongson.cn>,
	Arnd Bergmann <arnd@arndb.de>,
	"loongarch@lists.linux.dev" <loongarch@lists.linux.dev>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>,
	Xuerui Wang <kernel@xen0n.name>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] LoongArch: Make -mstrict-align be configurable
Date: Mon, 6 Feb 2023 18:28:28 +0800	[thread overview]
Message-ID: <560d73a8-2f2a-4844-44ff-afffad9c8694@loongson.cn> (raw)
In-Reply-To: <9936da8f577842b8b5edafcdc69dc2d1@AcuMS.aculab.com>



On 2023/2/3 下午4:46, David Laight wrote:
> From: Huacai Chen
>> Sent: 03 February 2023 02:01
>>
>> Hi, David,
>>
>> On Thu, Feb 2, 2023 at 5:01 PM David Laight <David.Laight@aculab.com> wrote:
>>>
>>> From: Huacai Chen
>>>> Sent: 02 February 2023 08:43
>>>>
>>>> Introduce Kconfig option ARCH_STRICT_ALIGN to make -mstrict-align be
>>>> configurable.
>>>>
>>>> Not all LoongArch cores support h/w unaligned access, we can use the
>>>> -mstrict-align build parameter to prevent unaligned accesses.
>>>>
>>>> This option is disabled by default to optimise for performance, but you
>>>> can enabled it manually if you want to run kernel on systems without h/w
>>>> unaligned access support.
>>>
>>> Should there be an associated run-time check during kernel initialisation
>>> that a kernel compiled without -mstrict-align isn't being run on hardware
>>> that doesn't support unaligned accesses.
>>>
>>> It can be quite a while before you get a compiler-generated misaligned accesses.
>>
>> If we don't use -mstrict-align, the kernel cannot be run on hardware
>> that doesn't support unaligned accesses, so I think the run-time check
>> is useless, and it has no chance to run the checking.
> 
> If you don't add the check and someone boots the wrong type of kernel
> then they'll probably get a panic well after booting.
> You really do want a check in the bot code.
> 
Agree, maybe it's reasonable to check it at the beginning of cpu probe 
stuff.

> There is also the question of how userspace is compiled.
> You pretty much don't want to be taking traps to fixup misaligned accesses.
> So the default compiler options better include -mstrict-align.
> 
> You should look at -mno-strict-align being a performance option when
> running on known hardware, not a default.
> 
> 	David
> 
I think the key point of the patch is providing users with a high 
performance kernel for existed and future unaligned-access-supported 
Loongson CPUs (mainly for destop and server system, also called *big* 
CPU), which are dominant compared with unaligned-access-unsupported CPUs 
(mainly for customized embedded system, also called *small* CPU). By 
this way, we just want to provide *the vast majority of big CPU users* 
(desktop and server OS) with convenience to directly use high 
performance kernel without any extra compile option. Instead, for 
customized embedded system, we have to support them with an extra 
compile option. So, it seems that we have to reconcile default compile 
option between small CPU and big CPU, and sacrifice the convenience of 
small CPU.

For some specific diffirences with and without -mstrict-align, see:
https://lore.kernel.org/all/5303aeda-5c66-ede6-b3ac-7d8ebd73ec70@loongson.cn/

Thanks!
Jianmin


> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
> 


  reply	other threads:[~2023-02-06 10:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02  8:42 Huacai Chen
2023-02-02  9:01 ` David Laight
2023-02-03  2:00   ` Huacai Chen
2023-02-03  8:46     ` David Laight
2023-02-06 10:28       ` Jianmin Lv [this message]
2023-02-07  5:24         ` WANG Xuerui
2023-02-07 10:32           ` Arnd Bergmann
2023-02-07 13:28             ` Jianmin Lv
2023-02-07 14:10               ` Arnd Bergmann
2023-02-08 11:17                 ` Huacai Chen
2023-02-02  9:46 ` Arnd Bergmann
2023-02-03  2:08   ` Huacai Chen
2023-02-06 10:33     ` Arnd Bergmann
2023-02-02 10:30 ` WANG Xuerui
2023-02-06 10:24   ` Jianmin Lv
2023-02-06 11:18     ` Xi Ruoyao
2023-02-06 13:13       ` Jianmin Lv
2023-02-06 13:22         ` Arnd Bergmann
2023-02-07  1:13           ` Jianmin Lv
2023-02-06 13:30         ` Xi Ruoyao
2023-02-07  1:27           ` Jianmin Lv

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=560d73a8-2f2a-4844-44ff-afffad9c8694@loongson.cn \
    --to=lvjianmin@loongson.cn \
    --cc=David.Laight@ACULAB.COM \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=guoren@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=loongarch@lists.linux.dev \
    /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®