From: Eric Biggers <ebiggers@kernel.org>
To: parker@cronstable.dev
Cc: linux-crypto@vger.kernel.org, ardb@kernel.org
Subject: Re: lib/crc: x86/crc32c: question about the "Future work" note (crc32q + VPCLMULQDQ on Zen)
Date: Fri, 13 Nov 2026 21:23:31 -0800 [thread overview]
Message-ID: <20261114052331.GA1893@sol> (raw)
In-Reply-To: <84998C7E-A862-4483-BB1B-D2C63AB45C7D@cronstable.dev>
Hi Parker,
On Fri, Nov 13, 2026 at 10:27:09PM -0500, parker@cronstable.dev wrote:
> Hi Eric,
>
> There's a comment in crc32c_arch() in lib/crc/x86/crc32.h that says that
> the optimal strategy on Zen 3--5 is to use crc32q and VPCLMULQDQ in
> parallel, but that different numbers of streams and vector lengths are
> optimal on each microarchitecture. I've been experimenting with this on
> Zen 5, and am curious about what you're looking for here.
>
> I've tuned an impl for Zen 5 only: two zmm registers folding with
> VPCLMULQDQ while four crc32q streams run alongside, merged at the end
> using multipliers from a 1 KiB table. Compared with
> crc32_lsb_vpclmul_avx512() at len=4096:
>
> AMD Ryzen 7 9800X3D (Zen 5) +53% (crc_kunit)
> AMD EPYC 9V45 (Zen 5) +57% (userspace)
> AMD EPYC 9V74 (Zen 4) +15%, but slower at len=1024
> Intel Xeon 6975P-C (Granite Rapids) -43%
>
>
> 1. What would you want a solution to look like? A variant per
> microarchitecture, a single variant for whichever one is worth it, or
> nothing until there's an approach that covers several of them?
>
> 2. Would a Zen 5-only variant be acceptable for now?
I don't think a separate CRC-32C implementation for each
microarchitecture is worth it currently. CRC-32C is already incredibly
fast. In particular, crc32_lsb_vpclmul_avx512() (which we have anyway,
to support the IEEE CRC-32) already reaches up to 80 GB/s on CPUs with
good AVX-512 support, so we already have something better than the
traditional 3-way scalar CRC on them.
And "a separate variant for each microarchitecture" is indeed what each
of Zen 3, Zen 4, and Zen 5 would need, which is annoying.
Also, virtually every kernel has CONFIG_CRC32=y enabled, so it would be
nice not to bloat it too much.
If we could generate them all from a template, that could make it more
worthwhile. But it's hard to handle different numbers of streams in
that way, and Zen 3 is extra special since it doesn't support AVX-512.
Generally, when we add CRC or crypto assembly files, each one is useful
on multiple CPU microarchitectures from both Intel and AMD.
I'm kind of waiting for Zen 6 and Nova Lake at this point and hoping
that a single CRC-32C implementation (maybe 2 ZMM + 4 crc32q, as you
implemented) will be close to optimum on all of those and be
meaningfully better than crc32_lsb_vpclmul_avx512() on each. In that
case, it would be more worthwhile to add.
So yes, I think your implementation may be what we want eventually. I'd
just like to be a bit more sure it won't be a one-off for Zen 5.
(And FWIW, Zen 6 having the same 3 scalar CRC units as Zen 5 is likely,
but also not guaranteed. Tech news is reporting that one of the
multiplication units is going away since it was deemed not worthwhile.)
- Eric
prev parent reply other threads:[~2026-11-14 5:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 3:27 lib/crc: x86/crc32c: question about the "Future work" note (crc32q + VPCLMULQDQ on Zen) parker
2026-11-14 5:23 ` 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=20261114052331.GA1893@sol \
--to=ebiggers@kernel.org \
--cc=ardb@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=parker@cronstable.dev \
/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.