Message ID | 20231223155226.4050-2-jszhang@kernel.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | riscv: enable EFFICIENT_UNALIGNED_ACCESS and DCACHE_WORD_ACCESS | expand |
On Sat, Dec 23, 2023 at 11:52:25PM +0800, Jisheng Zhang wrote: > +config RISCV_EFFICIENT_UNALIGNED_ACCESS > + bool "Use unaligned access for some functions" How about: bool "Assume the CPU supports fast unaligned memory accesses" > + depends on NONPORTABLE > + select HAVE_EFFICIENT_UNALIGNED_ACCESS > + default n There's no need to explicitly list "default n", since n is already the default. > + help > + Say Y here if you want the kernel only run on hardware platforms which > + support efficient unaligned access, then unaligned access will be used > + in some functions for optimized performance. How about: Say Y here if you want the kernel to assume that the CPU supports efficient unaligned memory accesses. When enabled, this option improves the performance of the kernel on such CPUs. However, the kernel will run much more slowly, or will not be able to run at all, on CPUs that do not support efficient unaligned memory accesses. - Eric
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 24c1799e2ec4..b91094ea53b7 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -651,6 +651,18 @@ config RISCV_MISALIGNED load/store for both kernel and userspace. When disable, misaligned accesses will generate SIGBUS in userspace and panic in kernel. +config RISCV_EFFICIENT_UNALIGNED_ACCESS + bool "Use unaligned access for some functions" + depends on NONPORTABLE + select HAVE_EFFICIENT_UNALIGNED_ACCESS + default n + help + Say Y here if you want the kernel only run on hardware platforms which + support efficient unaligned access, then unaligned access will be used + in some functions for optimized performance. + + If unsure what to do here, say N. + endmenu # "Platform type" menu "Kernel features" diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index a74be78678eb..ebbe02628a27 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -108,7 +108,9 @@ KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax) # unaligned accesses. While unaligned accesses are explicitly allowed in the # RISC-V ISA, they're emulated by machine mode traps on all extant # architectures. It's faster to have GCC emit only aligned accesses. +ifneq ($(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS),y) KBUILD_CFLAGS += $(call cc-option,-mstrict-align) +endif ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y) prepare: stack_protector_prepare