* [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
@ 2026-12-01 13:02 Shreesh Adiga
2026-12-01 13:22 ` Ard Biesheuvel
0 siblings, 1 reply; 8+ messages in thread
From: Shreesh Adiga @ 2026-12-01 13:02 UTC (permalink / raw)
To: Eric Biggers, Ard Biesheuvel, Demian Shulhan; +Cc: linux-crypto
Add a crc64_nvme implementation which benefits ARMv8.2 and
later processors with the SHA3 extension.
Usage of EOR3 from SHA3 extension improves performance by 20% compared
to the regular PMULL without EOR3 on Cortex-X925 measured in userspace
benchmark for 512 byte input size.
Move the existing PMULL implementation into a __always_inline function
and instantiate it twice with a boolean parameter which controls when
EOR3 is used. This is only enabled for AArch64 since the SHA3 extension
is not available in AArch32.
Use static_branch mechanism for dispatch in arm64 and enable the EOR3
variant when the CPU is determined to be not slower due to EOR3 and
PMULL sharing pipeline stage. Currently Neoverse N2 is placed on the
list to disable EOR3 based on Software Optimization Guide mentioning the
pipeline V0 being used by both PMULL and EOR3 and V used by EOR.
Tested on KUnit for correctness on both AArch32 and AArch64.
Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
---
Changes in v4:
Fixed build failure with 2.40 and earlier binutils by specifying the
ARM64_ASM_PREAMBLE and .arch_extension crypto for the EOR3 asm block.
Changes in v3:
Avoid running EOR3 routine on Neoverse N2.
Reuses code from PMULL implementation which was extended to support
various optimizations like 4x unrolling and partial_block handling.
Use inline assembly for EOR3 rather than veor3q_u64() intrinsic for GCC
8.1 support.
Changes in v2:
Added 2x reduction based on fold_consts_v2, use static key for PMULL
and EOR3 instead of regular branch.
Link to v1: https://lore.kernel.org/linux-crypto/20261114115749.1061233-1-16567adigashreesh@gmail.com/
Note:
This patch depends on mainline
ff049836f05f5e46f702858a7cb949998e85a310
lib/crc: Don't include <linux/types.h> in NEON intrinsics code
It also builds on top of crc-next submitted patch
lib/crc: Add 4-way folding in NEON crc64_nvme implementation
lib/crc/arm64/crc64-neon.h | 22 +++++++++++++
lib/crc/arm64/crc64.h | 28 ++++++++++++++--
lib/crc/crc64-neon.c | 66 ++++++++++++++++++++++++++++----------
3 files changed, 96 insertions(+), 20 deletions(-)
diff --git a/lib/crc/arm64/crc64-neon.h b/lib/crc/arm64/crc64-neon.h
index d872f4d4e2e7..eeb96d47b488 100644
--- a/lib/crc/arm64/crc64-neon.h
+++ b/lib/crc/arm64/crc64-neon.h
@@ -32,3 +32,25 @@ static inline uint64x2_t pmull64_hi_lo(uint64x2_t a, uint64x2_t b)
{
return pmull64(vextq_u64(a, a, 1), b);
}
+
+/*
+ * Use inline asm instead of veor3q_u64() intrinsic: GCC 8.1 doesn't provide
+ * that, and the target("+sha3") attribute it needs prevents some GCC versions
+ * from inlining the PMULL helpers. This follows lib/raid/xor/arm64/xor-eor3.c.
+ *
+ * Use ARM64_ASM_PREAMBLE since binutils 2.40 and earlier accept EOR3 only
+ * with an Armv8.2-A or later base architecture.
+ * .arch directive resets the enabled extensions for the rest of the file
+ * with GNU as, so re-enable crypto for the PMULL instructions that follow.
+ */
+static inline uint64x2_t eor3(uint64x2_t p, uint64x2_t q, uint64x2_t r)
+{
+ uint64x2_t res;
+
+ asm(ARM64_ASM_PREAMBLE
+ ".arch_extension crypto\n"
+ ".arch_extension sha3\n"
+ "eor3 %0.16b, %1.16b, %2.16b, %3.16b"
+ : "=w"(res) : "w"(p), "w"(q), "w"(r));
+ return res;
+}
diff --git a/lib/crc/arm64/crc64.h b/lib/crc/arm64/crc64.h
index 06dd08a21dd6..0cf79b9da578 100644
--- a/lib/crc/arm64/crc64.h
+++ b/lib/crc/arm64/crc64.h
@@ -4,13 +4,16 @@
*/
#include <linux/cpufeature.h>
+#include <asm/cputype.h>
#include <asm/simd.h>
#include <linux/minmax.h>
#include <linux/sizes.h>
u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
+u64 crc64_nvme_neon_pmull_eor3(u64 crc, const u8 *p, size_t len);
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_pmull);
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_eor3);
#define crc64_be_arch crc64_be_generic
@@ -18,8 +21,12 @@ static inline u64 crc64_nvme_arch(u64 crc, const u8 *p, size_t len)
{
if (static_branch_likely(&have_pmull) && len >= 128 &&
likely(may_use_simd())) {
- scoped_ksimd()
- crc = crc64_nvme_neon(crc, p, len);
+ scoped_ksimd() {
+ if (static_branch_likely(&have_eor3))
+ crc = crc64_nvme_neon_pmull_eor3(crc, p, len);
+ else
+ crc = crc64_nvme_neon(crc, p, len);
+ }
return crc;
}
@@ -29,6 +36,21 @@ static inline u64 crc64_nvme_arch(u64 crc, const u8 *p, size_t len)
#define crc64_mod_init_arch crc64_mod_init_arch
static void crc64_mod_init_arch(void)
{
- if (cpu_have_named_feature(PMULL))
+ /*
+ * On Neoverse N2, EOR3 can only issue on V0 pipeline, which PMULL
+ * also uses, so the EOR3 variant has lower throughput than plain EOR
+ * as per documentation in Arm Neoverse N2 Software Optimization Guide.
+ */
+ static const struct midr_range eor3_slow_cpus[] = {
+ MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
+ {}
+ };
+
+ if (cpu_have_named_feature(PMULL)) {
static_branch_enable(&have_pmull);
+
+ if (cpu_have_named_feature(SHA3) &&
+ !is_midr_in_range_list(eor3_slow_cpus))
+ static_branch_enable(&have_eor3);
+ }
}
diff --git a/lib/crc/crc64-neon.c b/lib/crc/crc64-neon.c
index 18eb17d5462b..faa681bebfec 100644
--- a/lib/crc/crc64-neon.c
+++ b/lib/crc/crc64-neon.c
@@ -3,12 +3,16 @@
* Accelerated CRC64 (NVMe) using ARM NEON C intrinsics
*/
+#include <stdbool.h>
#include <stddef.h>
#include <asm/neon-intrinsics.h>
#include "crc64-neon.h"
u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
+#ifdef CONFIG_ARM64
+u64 crc64_nvme_neon_pmull_eor3(u64 crc, const u8 *p, size_t len);
+#endif
/* x^575 mod G, x^511 mod G */
static const uint64_t fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
@@ -23,14 +27,27 @@ static const uint64_t fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
static const uint64_t bconsts_val[2] = { 0x27ecfa329aef9f77ULL,
0x34d926535897936aULL };
+static __always_inline uint64x2_t xor3(uint64x2_t t1,
+ uint64x2_t t2,
+ uint64x2_t t3,
+ __maybe_unused bool use_eor3)
+{
+#ifdef CONFIG_ARM64
+ if (use_eor3)
+ return eor3(t1, t2, t3);
+#endif
+ return t1 ^ t2 ^ t3;
+}
+
static __always_inline uint64x2_t fold_single_round(uint64x2_t fold,
uint64x2_t temp,
- uint64x2_t consts)
+ uint64x2_t consts,
+ bool use_eor3)
{
uint64x2_t temp1 = pmull64(consts, fold);
uint64x2_t temp2 = pmull64_high(consts, fold);
- return temp ^ temp1 ^ temp2;
+ return xor3(temp, temp1, temp2, use_eor3);
}
/*
@@ -45,7 +62,8 @@ static __always_inline uint64x2_t fold_single_round(uint64x2_t fold,
static __always_inline uint64x2_t fold_partial_block(uint64x2_t fold,
uint64x2_t consts,
const u8 *p,
- size_t len)
+ size_t len,
+ bool use_eor3)
{
static const u8 crc_neon_shift_tab[32] = {
0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
@@ -68,10 +86,11 @@ static __always_inline uint64x2_t fold_partial_block(uint64x2_t fold,
return fold_single_round(vreinterpretq_u64_u8(a),
vreinterpretq_u64_u8(b),
- consts);
+ consts, use_eor3);
}
-u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len)
+static __always_inline u64 crc64_nvme_neon_body(u64 crc, const u8 *p,
+ size_t len, bool use_eor3)
{
/* Assumes len >= 128. */
uint64x2_t fold_consts = vld1q_u64(fold_consts_val);
@@ -94,39 +113,39 @@ u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len)
uint64x2_t t2 = vreinterpretq_u64_u8(vld1q_u8(p + 32));
uint64x2_t t3 = vreinterpretq_u64_u8(vld1q_u8(p + 48));
- v0 = fold_single_round(v0, t0, fold_consts_4x);
- v1 = fold_single_round(v1, t1, fold_consts_4x);
- v2 = fold_single_round(v2, t2, fold_consts_4x);
- v3 = fold_single_round(v3, t3, fold_consts_4x);
+ v0 = fold_single_round(v0, t0, fold_consts_4x, use_eor3);
+ v1 = fold_single_round(v1, t1, fold_consts_4x, use_eor3);
+ v2 = fold_single_round(v2, t2, fold_consts_4x, use_eor3);
+ v3 = fold_single_round(v3, t3, fold_consts_4x, use_eor3);
p += 64;
len -= 64;
} while (len >= 64);
- v0 = fold_single_round(v0, v2, fold_consts_2x);
- v1 = fold_single_round(v1, v3, fold_consts_2x);
+ v0 = fold_single_round(v0, v2, fold_consts_2x, use_eor3);
+ v1 = fold_single_round(v1, v3, fold_consts_2x, use_eor3);
if (len >= 32) {
uint64x2_t t0 = vreinterpretq_u64_u8(vld1q_u8(p + 0));
uint64x2_t t1 = vreinterpretq_u64_u8(vld1q_u8(p + 16));
- v0 = fold_single_round(v0, t0, fold_consts_2x);
- v1 = fold_single_round(v1, t1, fold_consts_2x);
+ v0 = fold_single_round(v0, t0, fold_consts_2x, use_eor3);
+ v1 = fold_single_round(v1, t1, fold_consts_2x, use_eor3);
p += 32;
len -= 32;
}
- v0 = fold_single_round(v0, v1, fold_consts);
+ v0 = fold_single_round(v0, v1, fold_consts, use_eor3);
if (len >= 16) {
uint64x2_t t0 = vreinterpretq_u64_u8(vld1q_u8(p));
- v0 = fold_single_round(v0, t0, fold_consts);
+ v0 = fold_single_round(v0, t0, fold_consts, use_eor3);
p += 16;
len -= 16;
}
if (len)
- v0 = fold_partial_block(v0, fold_consts, p, len);
+ v0 = fold_partial_block(v0, fold_consts, p, len, use_eor3);
/* Multiply the 128-bit value by x^64 and reduce it back to 128 bits. */
v0 = vextq_u64(v0, zero, 1) ^ pmull64_hi_lo(fold_consts, v0);
@@ -135,7 +154,20 @@ u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len)
uint64x2_t bconsts = vld1q_u64(bconsts_val);
uint64x2_t final = pmull64(bconsts, v0);
- v0 ^= vextq_u64(zero, final, 1) ^ pmull64_hi_lo(bconsts, final);
+ v0 = xor3(v0, vextq_u64(zero, final, 1),
+ pmull64_hi_lo(bconsts, final), use_eor3);
return vgetq_lane_u64(v0, 1);
}
+
+u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len)
+{
+ return crc64_nvme_neon_body(crc, p, len, false);
+}
+
+#ifdef CONFIG_ARM64
+u64 crc64_nvme_neon_pmull_eor3(u64 crc, const u8 *p, size_t len)
+{
+ return crc64_nvme_neon_body(crc, p, len, true);
+}
+#endif
--
2.56.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 13:02 [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation Shreesh Adiga
@ 2026-12-01 13:22 ` Ard Biesheuvel
2026-12-01 14:38 ` Shreesh Adiga
0 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2026-12-01 13:22 UTC (permalink / raw)
To: Shreesh Adiga, Eric Biggers, Demian Shulhan; +Cc: linux-crypto
On Tue, 1 Dec 2026, at 14:02, Shreesh Adiga wrote:
> Add a crc64_nvme implementation which benefits ARMv8.2 and
> later processors with the SHA3 extension.
>
> Usage of EOR3 from SHA3 extension improves performance by 20% compared
> to the regular PMULL without EOR3 on Cortex-X925 measured in userspace
> benchmark for 512 byte input size.
>
> Move the existing PMULL implementation into a __always_inline function
> and instantiate it twice with a boolean parameter which controls when
> EOR3 is used. This is only enabled for AArch64 since the SHA3 extension
> is not available in AArch32.
>
> Use static_branch mechanism for dispatch in arm64 and enable the EOR3
> variant when the CPU is determined to be not slower due to EOR3 and
> PMULL sharing pipeline stage. Currently Neoverse N2 is placed on the
> list to disable EOR3 based on Software Optimization Guide mentioning the
> pipeline V0 being used by both PMULL and EOR3 and V used by EOR.
>
How much slower does the Neoverse-N2 version of this code run on X925?
If the marginal gain is minimal, we should just avoid EOR3 entirely.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 13:22 ` Ard Biesheuvel
@ 2026-12-01 14:38 ` Shreesh Adiga
2026-12-01 14:56 ` Ard Biesheuvel
0 siblings, 1 reply; 8+ messages in thread
From: Shreesh Adiga @ 2026-12-01 14:38 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: Eric Biggers, Demian Shulhan, linux-crypto
Hi Ard,
On Tue, Dec 1, 2026 at 6:52 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
>
> On Tue, 1 Dec 2026, at 14:02, Shreesh Adiga wrote:
> > Add a crc64_nvme implementation which benefits ARMv8.2 and
> > later processors with the SHA3 extension.
> >
> > Usage of EOR3 from SHA3 extension improves performance by 20% compared
> > to the regular PMULL without EOR3 on Cortex-X925 measured in userspace
> > benchmark for 512 byte input size.
> >
> > Move the existing PMULL implementation into a __always_inline function
> > and instantiate it twice with a boolean parameter which controls when
> > EOR3 is used. This is only enabled for AArch64 since the SHA3 extension
> > is not available in AArch32.
> >
> > Use static_branch mechanism for dispatch in arm64 and enable the EOR3
> > variant when the CPU is determined to be not slower due to EOR3 and
> > PMULL sharing pipeline stage. Currently Neoverse N2 is placed on the
> > list to disable EOR3 based on Software Optimization Guide mentioning the
> > pipeline V0 being used by both PMULL and EOR3 and V used by EOR.
> >
>
> How much slower does the Neoverse-N2 version of this code run on X925?
> If the marginal gain is minimal, we should just avoid EOR3 entirely.
>
If you're asking about the speedup over the existing PMULL version
with the 4x unrolling changes then from my libbenchmark test for EOR3
neon kernel reports about 20-30%:
For 512 byte input size:
taskset 0x80 ./main
------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------
BM_crc_pmull_4x 18.2 ns 16.4 ns 42910400
BM_crc_pmull_eor3 13.8 ns 12.4 ns 56780209
For 4096 input size:
taskset 0x80 ./main
------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------
BM_crc_pmull_4x 186 ns 168 ns 4408797
BM_crc_pmull_eor3 138 ns 126 ns 5618737
It also has similar speedup for Cortex X4 about 20-30% and slightly
lesser speedup for A720 where it is about 5-10%. I only have access to
Mediatek Dimensity 9400 SoC phone without root access though so can't
run the KUNIT benchmark over there.
This is based on my earlier work for FFmpeg on submitting optimized
kernel for CRC calculation:
https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21651
I'm assuming that even 10% speedup is considered valuable and hence
have worked on this submission.
Thanks,
Shreesh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 14:38 ` Shreesh Adiga
@ 2026-12-01 14:56 ` Ard Biesheuvel
2026-12-01 15:53 ` Shreesh Adiga
0 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2026-12-01 14:56 UTC (permalink / raw)
To: Shreesh Adiga; +Cc: Eric Biggers, Demian Shulhan, linux-crypto
On Tue, 1 Dec 2026, at 15:38, Shreesh Adiga wrote:
> Hi Ard,
>
> On Tue, Dec 1, 2026 at 6:52 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>>
>>
>> On Tue, 1 Dec 2026, at 14:02, Shreesh Adiga wrote:
>> > Add a crc64_nvme implementation which benefits ARMv8.2 and
>> > later processors with the SHA3 extension.
>> >
>> > Usage of EOR3 from SHA3 extension improves performance by 20% compared
>> > to the regular PMULL without EOR3 on Cortex-X925 measured in userspace
>> > benchmark for 512 byte input size.
>> >
>> > Move the existing PMULL implementation into a __always_inline function
>> > and instantiate it twice with a boolean parameter which controls when
>> > EOR3 is used. This is only enabled for AArch64 since the SHA3 extension
>> > is not available in AArch32.
>> >
>> > Use static_branch mechanism for dispatch in arm64 and enable the EOR3
>> > variant when the CPU is determined to be not slower due to EOR3 and
>> > PMULL sharing pipeline stage. Currently Neoverse N2 is placed on the
>> > list to disable EOR3 based on Software Optimization Guide mentioning the
>> > pipeline V0 being used by both PMULL and EOR3 and V used by EOR.
>> >
>>
>> How much slower does the Neoverse-N2 version of this code run on X925?
>> If the marginal gain is minimal, we should just avoid EOR3 entirely.
>>
> If you're asking about the speedup over the existing PMULL version
> with the 4x unrolling changes then from my libbenchmark test for EOR3
> neon kernel reports about 20-30%:
>
> For 512 byte input size:
> taskset 0x80 ./main
> ------------------------------------------------------------
> Benchmark Time CPU Iterations
> ------------------------------------------------------------
> BM_crc_pmull_4x 18.2 ns 16.4 ns 42910400
> BM_crc_pmull_eor3 13.8 ns 12.4 ns 56780209
>
> For 4096 input size:
>
> taskset 0x80 ./main
> ------------------------------------------------------------
> Benchmark Time CPU Iterations
> ------------------------------------------------------------
> BM_crc_pmull_4x 186 ns 168 ns 4408797
> BM_crc_pmull_eor3 138 ns 126 ns 5618737
>
Not sure I follow, but this seems to suggest that adding EOR3
support to the 4xPMULL code is 25% faster right?
> I'm assuming that even 10% speedup is considered valuable and hence
> have worked on this submission.
>
Your contribution is appreciated, of course, and 10% is a worthy
improvement.
However, Neoverse-N2 is similar to Cortex-A710, and the latter is
widely used in big/little configurations, where the MIDR based
logic does not work.
I'd prefer to just drop that logic for now, and enable this code
for all microarchitectures (assuming the 4-way version with EOR3
does outperform the original code on those cores)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 14:56 ` Ard Biesheuvel
@ 2026-12-01 15:53 ` Shreesh Adiga
2026-12-01 16:00 ` Ard Biesheuvel
0 siblings, 1 reply; 8+ messages in thread
From: Shreesh Adiga @ 2026-12-01 15:53 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: Eric Biggers, Demian Shulhan, linux-crypto
On Tue, Dec 1, 2026 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
>
> On Tue, 1 Dec 2026, at 15:38, Shreesh Adiga wrote:
> > Hi Ard,
> >
> > On Tue, Dec 1, 2026 at 6:52 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >>
> >>
> >> On Tue, 1 Dec 2026, at 14:02, Shreesh Adiga wrote:
> >> > Add a crc64_nvme implementation which benefits ARMv8.2 and
> >> > later processors with the SHA3 extension.
> >> >
> >> > Usage of EOR3 from SHA3 extension improves performance by 20% compared
> >> > to the regular PMULL without EOR3 on Cortex-X925 measured in userspace
> >> > benchmark for 512 byte input size.
> >> >
> >> > Move the existing PMULL implementation into a __always_inline function
> >> > and instantiate it twice with a boolean parameter which controls when
> >> > EOR3 is used. This is only enabled for AArch64 since the SHA3 extension
> >> > is not available in AArch32.
> >> >
> >> > Use static_branch mechanism for dispatch in arm64 and enable the EOR3
> >> > variant when the CPU is determined to be not slower due to EOR3 and
> >> > PMULL sharing pipeline stage. Currently Neoverse N2 is placed on the
> >> > list to disable EOR3 based on Software Optimization Guide mentioning the
> >> > pipeline V0 being used by both PMULL and EOR3 and V used by EOR.
> >> >
> >>
> >> How much slower does the Neoverse-N2 version of this code run on X925?
> >> If the marginal gain is minimal, we should just avoid EOR3 entirely.
> >>
> > If you're asking about the speedup over the existing PMULL version
> > with the 4x unrolling changes then from my libbenchmark test for EOR3
> > neon kernel reports about 20-30%:
> >
> > For 512 byte input size:
> > taskset 0x80 ./main
> > ------------------------------------------------------------
> > Benchmark Time CPU Iterations
> > ------------------------------------------------------------
> > BM_crc_pmull_4x 18.2 ns 16.4 ns 42910400
> > BM_crc_pmull_eor3 13.8 ns 12.4 ns 56780209
> >
> > For 4096 input size:
> >
> > taskset 0x80 ./main
> > ------------------------------------------------------------
> > Benchmark Time CPU Iterations
> > ------------------------------------------------------------
> > BM_crc_pmull_4x 186 ns 168 ns 4408797
> > BM_crc_pmull_eor3 138 ns 126 ns 5618737
> >
>
> Not sure I follow, but this seems to suggest that adding EOR3
> support to the 4xPMULL code is 25% faster right?
Yes on Cortex-X925 it can range from 20-30% for medium sized and large inputs.
> > I'm assuming that even 10% speedup is considered valuable and hence
> > have worked on this submission.
> >
>
> Your contribution is appreciated, of course, and 10% is a worthy
> improvement.
>
> However, Neoverse-N2 is similar to Cortex-A710, and the latter is
> widely used in big/little configurations, where the MIDR based
> logic does not work.
Correct, A710/A715 have similar pipeline as N2. My reasoning here was
that this nvme crc calculation is more relevant for server side
datacenter cores which appears to be homogeneous rather than
big.little systems where MIDR based logic will be accurate.
> I'd prefer to just drop that logic for now, and enable this code
> for all microarchitectures (assuming the 4-way version with EOR3
> does outperform the original code on those cores)
Based on theoretical llvm-mca analysis comparison, the clock cycles
required for EOR3 loop body was more than the 4-way version with EOR
though (about 12 cycles for EOR3 vs 8 for EOR). Therefore I am not
sure if EOR3 will be better on those cores and I'd guess it would be
20% slower. It would be great if someone with access to the hardware
could confirm the behavior. Dropping the MIDR logic is an easy task
and I can do that but just wanted confirmation if the potential
performance regression is not a problem.
Thanks,
Shreesh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 15:53 ` Shreesh Adiga
@ 2026-12-01 16:00 ` Ard Biesheuvel
2026-12-01 16:13 ` Ard Biesheuvel
2026-12-01 16:14 ` Shreesh Adiga
0 siblings, 2 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2026-12-01 16:00 UTC (permalink / raw)
To: Shreesh Adiga; +Cc: Eric Biggers, Demian Shulhan, linux-crypto
On Tue, 1 Dec 2026, at 16:53, Shreesh Adiga wrote:
> On Tue, Dec 1, 2026 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>>
...
>> However, Neoverse-N2 is similar to Cortex-A710, and the latter is
>> widely used in big/little configurations, where the MIDR based
>> logic does not work.
> Correct, A710/A715 have similar pipeline as N2. My reasoning here was
> that this nvme crc calculation is more relevant for server side
> datacenter cores which appears to be homogeneous rather than
> big.little systems where MIDR based logic will be accurate.
>
>> I'd prefer to just drop that logic for now, and enable this code
>> for all microarchitectures (assuming the 4-way version with EOR3
>> does outperform the original code on those cores)
> Based on theoretical llvm-mca analysis comparison, the clock cycles
> required for EOR3 loop body was more than the 4-way version with EOR
> though (about 12 cycles for EOR3 vs 8 for EOR). Therefore I am not
> sure if EOR3 will be better on those cores and I'd guess it would be
> 20% slower.
20% slower than what?
> It would be great if someone with access to the hardware
> could confirm the behavior. Dropping the MIDR logic is an easy task
> and I can do that but just wanted confirmation if the potential
> performance regression is not a problem.
>
Are you saying 4x+EOR3 is slower on those cores than the 1x version
you are replacing?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 16:00 ` Ard Biesheuvel
@ 2026-12-01 16:13 ` Ard Biesheuvel
2026-12-01 16:14 ` Shreesh Adiga
1 sibling, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2026-12-01 16:13 UTC (permalink / raw)
To: Shreesh Adiga; +Cc: Eric Biggers, Demian Shulhan, linux-crypto
On Tue, 1 Dec 2026, at 17:00, Ard Biesheuvel wrote:
> On Tue, 1 Dec 2026, at 16:53, Shreesh Adiga wrote:
>> On Tue, Dec 1, 2026 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>>>
> ...
>>> However, Neoverse-N2 is similar to Cortex-A710, and the latter is
>>> widely used in big/little configurations, where the MIDR based
>>> logic does not work.
>> Correct, A710/A715 have similar pipeline as N2. My reasoning here was
>> that this nvme crc calculation is more relevant for server side
>> datacenter cores which appears to be homogeneous rather than
>> big.little systems where MIDR based logic will be accurate.
>>
>>> I'd prefer to just drop that logic for now, and enable this code
>>> for all microarchitectures (assuming the 4-way version with EOR3
>>> does outperform the original code on those cores)
>> Based on theoretical llvm-mca analysis comparison, the clock cycles
>> required for EOR3 loop body was more than the 4-way version with EOR
>> though (about 12 cycles for EOR3 vs 8 for EOR). Therefore I am not
>> sure if EOR3 will be better on those cores and I'd guess it would be
>> 20% slower.
>
> 20% slower than what?
>
>> It would be great if someone with access to the hardware
>> could confirm the behavior. Dropping the MIDR logic is an easy task
>> and I can do that but just wanted confirmation if the potential
>> performance regression is not a problem.
>>
>
> Are you saying 4x+EOR3 is slower on those cores than the 1x version
> you are replacing?
Never mind - I got this mixed up with your other patch.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
2026-12-01 16:00 ` Ard Biesheuvel
2026-12-01 16:13 ` Ard Biesheuvel
@ 2026-12-01 16:14 ` Shreesh Adiga
1 sibling, 0 replies; 8+ messages in thread
From: Shreesh Adiga @ 2026-12-01 16:14 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: Eric Biggers, Demian Shulhan, linux-crypto
On Tue, Dec 1, 2026 at 9:31 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
>
>
> On Tue, 1 Dec 2026, at 16:53, Shreesh Adiga wrote:
> > On Tue, Dec 1, 2026 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >>
> ...
> >> However, Neoverse-N2 is similar to Cortex-A710, and the latter is
> >> widely used in big/little configurations, where the MIDR based
> >> logic does not work.
> > Correct, A710/A715 have similar pipeline as N2. My reasoning here was
> > that this nvme crc calculation is more relevant for server side
> > datacenter cores which appears to be homogeneous rather than
> > big.little systems where MIDR based logic will be accurate.
> >
> >> I'd prefer to just drop that logic for now, and enable this code
> >> for all microarchitectures (assuming the 4-way version with EOR3
> >> does outperform the original code on those cores)
> > Based on theoretical llvm-mca analysis comparison, the clock cycles
> > required for EOR3 loop body was more than the 4-way version with EOR
> > though (about 12 cycles for EOR3 vs 8 for EOR). Therefore I am not
> > sure if EOR3 will be better on those cores and I'd guess it would be
> > 20% slower.
>
> 20% slower than what?
The current 4-way PMULL version.
> > It would be great if someone with access to the hardware
> > could confirm the behavior. Dropping the MIDR logic is an easy task
> > and I can do that but just wanted confirmation if the potential
> > performance regression is not a problem.
> >
>
> Are you saying 4x+EOR3 is slower on those cores than the 1x version
> you are replacing?
Probably not if compared with the 1x version. 4-way version is better
on all but low power A510/A520 cores. However this patch is not
replacing 1x version though and is measuring against the existing 4x
PMULL version which is already reviewed and part of crc-next.
Thanks,
Shreesh
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-01 16:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 13:02 [PATCH v4] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation Shreesh Adiga
2026-12-01 13:22 ` Ard Biesheuvel
2026-12-01 14:38 ` Shreesh Adiga
2026-12-01 14:56 ` Ard Biesheuvel
2026-12-01 15:53 ` Shreesh Adiga
2026-12-01 16:00 ` Ard Biesheuvel
2026-12-01 16:13 ` Ard Biesheuvel
2026-12-01 16:14 ` Shreesh Adiga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox