Skip to content

arm64: Speed up CRC-32 using PMULL instructions

Ard Biesheuvel linux-arm-kernel linux-crypto lkml 4 versions – Applied

Status from this message: Applied to arm64 (for-next/crc32), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 3 repliesApplied
  2. v32 patches 3 repliesSuperseded
  3. v22 patches 3 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches3 repliesSuperseded

Changes in v4 from the cover letter

- fix broken crc32be version
- add patch to tidy up existing code for reuse
- add 4-way code to existing .S file

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/3arm64/lib: Handle CRC-32 alternative in C codearch/arm64/lib/Makefile arch/arm64/lib/crc32-glue.c arch/arm64/lib/crc32.S+41 -170 replies
2/3arm64/crc32: Reorganize bit/byte ordering macrosarch/arm64/lib/crc32.S+39 -521 reply
3/3arm64/crc32: Implement 4-way interleave using PMULLarch/arm64/lib/crc32-glue.c arch/arm64/lib/crc32.S+276 -31 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchEric Biggers
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/3] arm64: Speed up CRC-32 using PMULL instructions

From: Ard Biesheuvel <[email protected]>

The CRC-32 code is library code, and is not part of the crypto subsystem. This means that callers may not generally be aware of the kind of implementation that backs it, and so we've refrained from using FP/SIMD code in the past, as it disables preemption, and this may incur scheduling latencies that the caller did not anticipate.

This was solved a while ago, and on arm64, kernel mode FP/SIMD no longer disables preemption.

This means we can happily use PMULL instructions in the CRC-32 library code, which permits an optimization to be implemented that results in a speedup of 2 - 2.8x for inputs >1k in size (on Apple M2)

Patch #1 implements some prepwork to handle the scalar CRC-32 alternatives patching in C code.

Changes since v3:
- fix broken crc32be version
- add patch to tidy up existing code for reuse
- add 4-way code to existing .S file

Changes since v2:
- drop alternatives.h #include (#1)
- drop unneeded branch (#2)
- fix comment max -> min (#2)
- add Eric's Rb

Changes since v1:
- rename crc32-pmull.S to crc32-4way.S and avoid pmull in the function names to avoid confusion about the nature of the implementation;
- polish the asm a bit, and add some comments
- don't return via the scalar code if len dropped to 0 after calling the 4-way code.

Cc Eric Biggers <[email protected]>
Cc Kees Cook <[email protected]>

Ard Biesheuvel (3):
arm64/lib: Handle CRC-32 alternative in C code arm64/crc32: Reorganize bit/byte ordering macros arm64/crc32: Implement 4-way interleave using PMULL

 arch/arm64/lib/Makefile     |   2 +-
 arch/arm64/lib/crc32-glue.c |  82 +++++
 arch/arm64/lib/crc32.S      | 344 ++++++++++++++++----
 3 files changed, 356 insertions(+), 72 deletions(-)
 create mode 100644 arch/arm64/lib/crc32-glue.c
Signature · 1 line
2.47.0.rc1.288.g06298d1525-goog