Re: [PATCH v2] lib/crc: arm64: Add NEON PMULL+EOR3 crc64_nvme implementation
From: Shreesh Adiga
Date: Tue Nov 17 2026 - 09:54:28 EST
On Tue, Nov 17, 2026 at 12:41 PM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
>
> On Tue, Nov 17, 2026 at 12:20:08PM +0530, Shreesh Adiga wrote:
> > Hi Eric,
> >
> > On Tue, Nov 17, 2026 at 5:31 AM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
> > > Was crc_kunit run? It already has a benchmark in it.
> > No, I have access to only one aarch64 device that is Android Mediatek
> > Dimensity 9400 SoC without root access.
> > Therefore I can't run crc_kunit on that, instead I have done userspace
> > comparisons for the same kernel with libbenchmark.
> > This is based on my earlier work for FFmpeg:
> > https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21651
> > I also have Corporate MacOS M5 and did check inside Ubuntu VM but that
> > is not accurate due to virtualization.
>
> Well, this is a kernel patch. Contributors are expected to test their
> kernel patches. It can at least be done with QEMU.
Okay have run and will be running the below commands for future arm patches:
./tools/testing/kunit/kunit.py run --arch=arm
--cross_compile=arm-linux-gnueabihf-
--kunitconfig=/tmp/a32.kunitconfig --qemu_args='-cpu max'
--build_dir=.kunit-arm 'crc.*'
./tools/testing/kunit/kunit.py run --arch=arm64
--cross_compile=aarch64-linux-gnu- --kunitconfig=lib/crc
--build_dir=.kunit-arm64 'crc.*'
These were suggestions by LLM tools though and I can see they're green.
As mentioned I don't have a measurable benchmark device so I can't
include them via kunit.
For testing correctness I am having a libfuzzer userspace differential
fuzzer test that measures exactness between the earlier single fold
case with generic scalar tail with the newer 4x folding with partial
block handling.
>
> > > Note that this is missing several optimizations compared to the x86
> > > version (lib/crc/x86/crc-pclmul-template.S), including using
> > > fold_consts_2x for a tail of 'len & 32', efficiently handling lengths
> > > that aren't a multiple of 16 bytes, and reducing to the final CRC in two
> > > carryless multiplication instructions rather than three.
> > I was looking at the crc-pclmul-template.S code and I have a few queries.
> > In this aarch64 version we only dispatch to this SIMD routine only
> > when len>=128.
> > Since we have 128 bytes available, do we have to add the tail of `len
> > & 32` handling?
>
> It's still useful, since the length mod 64 might be >= 32.
Okay this makes sense, the len mod 64 >=32 I wasn't aware of before.
One follow-up query regarding the efficient handling of lengths not
multiple of 16 bytes, I have the implementation similar to DPDK's code
https://github.com/DPDK/dpdk/blob/main/lib/net/net_crc_neon.c#L222
However it seems like vqtbl1q_u8/vcgezq_s8 is not available on
AArch32. Instead some kernel code like crypto/aegis128-neon-inner.c
have their own emulation of that intrinsic using vtbl2_u8.
Can I have this partial block logic only for AArch64, or should I
include the emulation logic and enable it for both since it is shared
code? For now I'm assuming AArch64 is sufficient and I won't change
the dispatch logic for AArch32 so that it can pass multiple of 16 and
process the tail using scalar loop.
Thanks,
Shreesh