[PATCH v2 1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE
Jinjie Ruan
ruanjinjie at huawei.com
Mon Jun 8 18:26:20 PDT 2026
On 5/7/2026 1:52 AM, Yury Norov wrote:
> Architectures may have bit reversal instructions, but if the API not
> needed, the corresponding option should not be selected because it may
> lead to generating the unneeded code.
>
> Signed-off-by: Yury Norov <ynorov at nvidia.com>
> ---
> arch/arm/Kconfig | 2 +-
> arch/arm64/Kconfig | 2 +-
> arch/loongarch/Kconfig | 2 +-
> arch/mips/Kconfig | 2 +-
> lib/Kconfig | 1 +
> 5 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 71fc5dd4123f..0e963e54fe06 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -83,7 +83,7 @@ config ARM
> select HARDIRQS_SW_RESEND
> select HAS_IOPORT
> select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
> - select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
> + select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6 && BITREVERSE
I think there is a semantic confusion:
HAVE_ARCH_BITREVERSE indicates that the architecture itself has an
efficient bit‑reverse implementation (e.g., the RBIT instruction on
ARMv7). It is a hardware capability declaration and should not depend on
a higher‑level feature option like BITREVERSE.
> select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU && (!PREEMPT_RT || !SMP)
> select HAVE_ARCH_KFENCE if MMU && !XIP_KERNEL
> select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index fe60738e5943..f5bb62c2ba9c 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -150,7 +150,7 @@ config ARM64
> select HAVE_ACPI_APEI if (ACPI && EFI)
> select HAVE_ALIGNED_STRUCT_PAGE
> select HAVE_ARCH_AUDITSYSCALL
> - select HAVE_ARCH_BITREVERSE
> + select HAVE_ARCH_BITREVERSE if BITREVERSE
[..]
> bool
> default n
> + depends on BITREVERSE
> help
> This option enables the use of hardware bit-reversal instructions on
> architectures which support such operations.
More information about the linux-riscv
mailing list