[PATCH 2/2] raid6: arm64: use the EOR3 instruction where available
Eric Biggers
ebiggers at kernel.org
Thu Nov 19 14:35:13 PST 2026
On Wed, Nov 18, 2026 at 07:33:38PM +0100, Ard Biesheuvel wrote:
> Build the EOR3 versions from the same neon.uc source, with
> RAID6_NEON_EOR3 defined and the SHA3 extension enabled, and use them
> instead of the plain NEON versions on CPUs that implement SHA3. Use
> -march=armv8.2-a+sha3 for this: SHA3 is an optional extension of
> ARMv8.2, so any CPU that implements it implements ARMv8.2 as well. This
> is also what older toolchains (e.g., GCC 8.5 with binutils 2.36) need to
> accept EOR3.
gcc 8.1 supports the sha3 feature itself, but the veor3q_u8() intrinsic
wasn't added until gcc 9.1 and gcc 8.5. Since the minimum gcc version
to build the kernel is 8.1, we probably need a gcc version check.
> - struct raid6_calls const raid6_neonx ## _n = { \
> - .gen_syndrome = raid6_neon ## _n ## _gen_syndrome, \
> - .xor_syndrome = raid6_neon ## _n ## _xor_syndrome, \
> - .name = "neonx" #_n, \
> + struct raid6_calls const raid6_ ## _name = { \
> + .gen_syndrome = _pfx ## _n ## _gen_syndrome, \
> + .xor_syndrome = _pfx ## _n ## _xor_syndrome, \
> + .name = #_name, \
> }
Nit: 'const' should go before 'struct'
> @@ -129,7 +145,7 @@ static inline void STEP4(unative_t *wp, unative_t *wq, const uint8_t *s3,
> unative_t d1 = vld1q_u8(s1);
> unative_t d0 = vld1q_u8(s0);
>
> - *wp ^= d3 ^ d2 ^ d1 ^ d0;
> + *wp = XOR3(XOR3(*wp, d3, d2), d1, d0);
> *wq = HORNER4(*wq, d3, d2, d1, d0, x1d);
> }
The following might be better, since it cuts down the length of the
loop-carried dependency chain on *wp.
*wp = XOR3(*wp, XOR3(d3, d2, d1), d0);
> diff --git a/lib/raid/raid6/arm64/pq_arch.h b/lib/raid/raid6/arm64/pq_arch.h
> index 27ff564d7594..4e397aa36480 100644
> --- a/lib/raid/raid6/arm64/pq_arch.h
> +++ b/lib/raid/raid6/arm64/pq_arch.h
> @@ -1 +1,33 @@
> -#include "arm/pq_arch.h"
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#include <linux/cpufeature.h>
> +#include <asm/neon.h>
> +
> +extern const struct raid6_calls raid6_neonx1;
> +extern const struct raid6_calls raid6_neonx2;
> +extern const struct raid6_calls raid6_neonx4;
> +extern const struct raid6_calls raid6_neonx8;
> +extern const struct raid6_calls raid6_eor3x1;
> +extern const struct raid6_calls raid6_eor3x2;
> +extern const struct raid6_calls raid6_eor3x4;
> +extern const struct raid6_calls raid6_eor3x8;
> +extern const struct raid6_recov_calls raid6_recov_neon;
These declarations are duplicated in 2 places, but they're still not
in-scope in the .c files that actually define them. Maybe they should
go in lib/raid/raid6/arm/neon.h, and lib/raid/raid6/arm/pq_arch.h and
lib/raid/raid6/arm64/pq_arch.h should include that?
- Eric
More information about the linux-arm-kernel
mailing list