Skip to contentSkip to conversation

riscv/crc-t10dif: Optimize crct10dif with zbc extension

PATCH New Eric Biggers 1 participant 1 message Feb 12, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 riscv/crc-t10dif: Optimize crct10dif with zbc extension

From: Zhihang Shao <[email protected]>

The current CRC-T10DIF algorithm on RISC-V platform is based on table-lookup optimization. Given the previous work on optimizing crc32 calculations with zbc extension, it is believed that this will be equally effective for accelerating crc-t10dif.

Therefore this patch adds an implementation of crc-t10dif using zbc extension. It detects whether the current runtime environment supports zbc feature and, if so, uses it to accelerate crc-t10dif calculations.

This patch is updated due to the patchset of updating kernel's CRC-T10DIF library in 6.14, which is finished by Eric Biggers. Also, I used crc_kunit.c to test the performance of crc-t10dif optimized by crc extension.

[EB: fixed 32-bit build, added comments that explain the algorithm used,
and various other cleanups]

---

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

 arch/riscv/Kconfig                |   1 +
 arch/riscv/lib/Makefile           |   1 +
 arch/riscv/lib/crc-t10dif-riscv.c | 131 ++++++++++++++++++++++++++++++
 3 files changed, 133 insertions(+)
 create mode 100644 arch/riscv/lib/crc-t10dif-riscv.c
arch/riscv/Kconfig +1 -0
index 7612c52e9b1e3..db1cf9666dfdd 100644
@@ -23,10 +23,11 @@ config RISCV
 	select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG
 	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
 	select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
 	select ARCH_HAS_BINFMT_FLAT
 	select ARCH_HAS_CRC32 if RISCV_ISA_ZBC
+	select ARCH_HAS_CRC_T10DIF if RISCV_ISA_ZBC
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DEBUG_VIRTUAL if MMU
 	select ARCH_HAS_DEBUG_VM_PGTABLE
 	select ARCH_HAS_DEBUG_WX
 	select ARCH_HAS_FAST_MULTIPLIER
arch/riscv/lib/Makefile +1 -0
index 79368a895feed..d1d1f3d880e32 100644
@@ -14,8 +14,9 @@ lib-$(CONFIG_RISCV_ISA_V)	+= uaccess_vector.o
 endif
 lib-$(CONFIG_MMU)	+= uaccess.o
 lib-$(CONFIG_64BIT)	+= tishift.o
 lib-$(CONFIG_RISCV_ISA_ZICBOZ)	+= clear_page.o
 obj-$(CONFIG_CRC32_ARCH)	+= crc32-riscv.o
+obj-$(CONFIG_CRC_T10DIF_ARCH)	+= crc-t10dif-riscv.o
 obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
 lib-$(CONFIG_RISCV_ISA_V)	+= xor.o
 lib-$(CONFIG_RISCV_ISA_V)	+= riscv_v_helpers.o
arch/riscv/lib/crc-t10dif-riscv.c new file +131 -0

131 lines not on this page · raw message

base-commit: 4ffd50862d41e5aaf2e749efa354afaa1317c309

Signature · 1 line
2.48.1