All of lore.kernel.org
 help / color / mirror / Atom feed
From: WANG Xuerui <kernel@xen0n.name>
To: Huacai Chen <chenhuacai@loongson.cn>,
	Arnd Bergmann <arnd@arndb.de>,
	Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org,
	Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] LoongArch: Make -mstrict-align be configurable
Date: Thu, 2 Feb 2023 18:30:46 +0800	[thread overview]
Message-ID: <5fc85453-1e2c-1f00-7879-1b5fa318c78a@xen0n.name> (raw)
In-Reply-To: <20230202084238.2408516-1-chenhuacai@loongson.cn>

On 2023/2/2 16:42, Huacai Chen wrote:
> 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.

It's customary to accompany "performance-related" changes like this with 
some benchmark numbers and concrete use cases where this would be 
profitable. Especially given that arch/loongarch developer and user base 
is relatively small, we probably don't want to allow customization of 
such a low-level characteristic. In general kernel performance does not 
vary much with compiler flags like this, so I'd really hope to see some 
numbers here to convince people that this is *really* providing gains.

Also, defaulting to emitting unaligned accesses would mean those future, 
likely embedded models (and AFAIK some existing models that haven't 
reached GA yet) would lose support with the defconfig. Which means 
downstream packagers that care about those use cases would have one more 
non-default, non-generic option to carry within their Kconfig. We 
probably don't want to repeat the history of other architectures (think 
arch/arm or arch/mips) where there wasn't really generic builds and 
board-specific tweaks proliferated.

> 
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>   arch/loongarch/Kconfig  | 10 ++++++++++
>   arch/loongarch/Makefile |  2 ++
>   2 files changed, 12 insertions(+)
> 
> diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
> index 9cc8b84f7eb0..7470dcfb32f0 100644
> --- a/arch/loongarch/Kconfig
> +++ b/arch/loongarch/Kconfig
> @@ -441,6 +441,16 @@ config ARCH_IOREMAP
>   	  protection support. However, you can enable LoongArch DMW-based
>   	  ioremap() for better performance.
>   
> +config ARCH_STRICT_ALIGN
> +	bool "Enable -mstrict-align to prevent unaligned accesses"
> +	help
> +	  Not all LoongArch cores support h/w unaligned access, we can use
> +	  -mstrict-align build parameter to prevent unaligned accesses.
> +
> +	  This is disabled by default to optimise for performance, you can
> +	  enabled it manually if you want to run kernel on systems without
> +	  h/w unaligned access support.
> +
>   config KEXEC
>   	bool "Kexec system call"
>   	select KEXEC_CORE
> diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile
> index 4402387d2755..ccfb52700237 100644
> --- a/arch/loongarch/Makefile
> +++ b/arch/loongarch/Makefile
> @@ -91,10 +91,12 @@ KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
>   # instead of .eh_frame so we don't discard them.
>   KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
>   
> +ifdef CONFIG_ARCH_STRICT_ALIGN
>   # 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)
> +endif >
>   KBUILD_CFLAGS += -isystem $(shell $(CC) -print-file-name=include)
>   

-- 
WANG "xen0n" Xuerui

Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/


  parent reply	other threads:[~2023-02-02 10:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02  8:42 [PATCH] LoongArch: Make -mstrict-align be configurable 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
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 [this message]
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=5fc85453-1e2c-1f00-7879-1b5fa318c78a@xen0n.name \
    --to=kernel@xen0n.name \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=guoren@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.