All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Shreesh Adiga <16567adigashreesh@gmail.com>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Demian Shulhan <demyansh@gmail.com>,
	linux-crypto@vger.kernel.org
Subject: Re: [PATCH v3] lib/crc: Add 4-way folding in NEON crc64_nvme implementation
Date: Tue, 24 Nov 2026 16:09:29 -0800	[thread overview]
Message-ID: <20261125000929.GG2001@quark> (raw)
In-Reply-To: <20261124060006.862167-1-16567adigashreesh@gmail.com>

On Tue, Nov 24, 2026 at 11:29:51AM +0530, Shreesh Adiga wrote:
> Use 4-way folding in the shared NEON crc64_nvme for AArch64
> as well as AArch32. This improves performance by about 2x for 512 byte
> data size on Cortex-X925, as measured with a userspace benchmark.
> 
> Add similar optimizations from x86 implementation like reducing
> the 4x to 2x and doing a tail (len >= 32) 2x fold as well as partial
> block handling to process lengths which are not multiple of 16 bytes.
> 
> The partial block handling uses vqtbl1q_u8(), which AArch32 does not
> provide, so implement it for AArch32 using two vtbl2_u8() lookups, the
> same emulation used by lib/raid/raid6/arm/recov_neon_inner.c.
> 
> crc64_nvme_neon() therefore accepts any len >= 128 on both
> architectures. The AArch64 dispatch code now passes the full length, and
> the AArch32 dispatch code no longer rounds chunks down to a multiple of
> 16 bytes: each chunk is 4 KiB, or the whole remaining length if less
> than 4 KiB + 128 bytes remains, so no tail is left for the generic
> implementation.
> 
> On AArch64, check for PMULL with a static key, and implement the PMULL
> helpers with inline asm. With the vmull_p64() intrinsics, compilers
> build the fold constants in general purpose registers with mov/movk and
> transfer them with fmov/dup, up to 10 instructions per constant pair,
> instead of loading them from memory.
> 
> Tested for correctness with the CRC KUnit tests under QEMU on both
> AArch64 and AArch32.
> 
> Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
> ---
> Changes in v3:
> - Make the partial_block logic more readable as per suggestion by Ard.
>   Mark the helper functions __always_inline inside the crc64-neon.c
>   file.
> 
> Changes in v2:
> - Squash in the follow-up requested by Eric: AArch32 partial block
>   support, AArch32 chunking without rounding to 16 bytes, and comments
>   explaining the inline asm and partial block handling.
> - Use uint64_t for fold_consts_4x_val and fold_consts_2x_val, fixing the
>   build failure reported.
> - Rebase onto v7.4-rc4
> 
> v1: https://lore.kernel.org/all/20261118160110.1662470-1-16567adigashreesh@gmail.com/
> 
>  lib/crc/arm/crc64-neon.h   |  16 ++++++
>  lib/crc/arm/crc64.h        |   4 +-
>  lib/crc/arm64/crc64-neon.h |  27 +++++++---
>  lib/crc/arm64/crc64.h      |  18 ++++---
>  lib/crc/crc64-neon.c       | 106 ++++++++++++++++++++++++++++++++++---
>  5 files changed, 150 insertions(+), 21 deletions(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=crc-next

- Eric

      parent reply	other threads:[~2026-11-25  0:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  5:59 [PATCH v3] lib/crc: Add 4-way folding in NEON crc64_nvme implementation Shreesh Adiga
2026-11-24 10:58 ` Ard Biesheuvel
2026-11-25  0:09 ` Eric Biggers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125000929.GG2001@quark \
    --to=ebiggers@kernel.org \
    --cc=16567adigashreesh@gmail.com \
    --cc=ardb@kernel.org \
    --cc=demyansh@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.