[PW_SID:967868] lib/crc: improve how arch-optimized code is integrated#460
[PW_SID:967868] lib/crc: improve how arch-optimized code is integrated#460linux-riscv-bot wants to merge 14 commits into
Conversation
Stop unnecessarily registering a "crc32-generic" shash_alg when a "crc32-$(ARCH)" shash_alg is registered too. While every algorithm does need to have a generic implementation to ensure uniformity of support across platforms, that doesn't mean that we need to make the generic implementation available through crypto_shash when an optimized implementation is also available. Registering the generic shash_alg did allow users of the crypto_shash or crypto_ahash APIs to request the generic implementation specifically, instead of an optimized one. However, the only known use case for that was the differential fuzz tests in crypto/testmgr.c. Equivalent test coverage is now provided by crc_kunit. Besides simplifying crypto/crc32.c, this change eliminates the need for the library to provide crc32_le_base() as part of its interface. Later patches will make crc32_le_base() be internal to the library. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Stop unnecessarily registering a "crc32c-generic" shash_alg when a "crc32c-$(ARCH)" shash_alg is registered too. While every algorithm does need to have a generic implementation to ensure uniformity of support across platforms, that doesn't mean that we need to make the generic implementation available through crypto_shash when an optimized implementation is also available. Registering the generic shash_alg did allow users of the crypto_shash or crypto_ahash APIs to request the generic implementation specifically, instead of an optimized one. However, the only known use case for that was the differential fuzz tests in crypto/testmgr.c. Equivalent test coverage is now provided by crc_kunit. Besides simplifying crypto/crc32c.c, this change eliminates the need for the library to provide crc32c_base() as part of its interface. Later patches will make crc32c_base() be internal to the library. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move all CRC files in lib/ into a subdirectory lib/crc/ to keep them from cluttering up the main lib/ directory. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Rework how lib/crc/ supports arch-optimized code. First, instead of the arch-optimized code being in arch/$(SRCARCH)/lib/, it will now be in lib/crc/$(SRCARCH)/. Second, the API functions (e.g. crc32c()), arch-optimized functions (e.g. crc32c_arch()), and generic functions (e.g. crc32c_base()) will now be part of a single module for each CRC type, allowing better inlining and dead code elimination. The second change is made possible by the first. As an example, consider CONFIG_CRC32=m on x86. We'll now have just crc32.ko instead of both crc32-x86.ko and crc32.ko. The two modules were already coupled together and always both got loaded together via direct symbol dependency, so the separation provided no benefit. Note: later I'd like to apply the same design to lib/crypto/ too, where often the API functions are out-of-line so this will work even better. In those cases, for each algorithm we currently have 3 modules all coupled together, e.g. libsha256.ko, libsha256-generic.ko, and sha256-x86.ko. We should have just one, inline things properly, and rely on the compiler's dead code elimination to decide the inclusion of the generic code instead of manually setting it via kconfig. Having arch-specific code outside arch/ was somewhat controversial when Zinc proposed it back in 2018. But I don't think the concerns are warranted. It's better from a technical perspective, as it enables the improvements mentioned above. This model is already successfully used in other places in the kernel such as lib/raid6/. The community of each architecture still remains free to work on the code, even if it's not in arch/. At the time there was also a desire to put the library code in the same files as the old-school crypto API, but that was a mistake; now that the library is separate, that's no longer a constraint either. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the arm-optimized CRC code from arch/arm/lib/crc* into its new location in lib/crc/arm/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the arm64-optimized CRC code from arch/arm64/lib/crc* into its new location in lib/crc/arm64/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the loongarch-optimized CRC code from arch/loongarch/lib/crc* into its new location in lib/crc/loongarch/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the mips-optimized CRC code from arch/mips/lib/crc* into its new location in lib/crc/mips/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the powerpc-optimized CRC code from arch/powerpc/lib/crc* into its new location in lib/crc/powerpc/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the riscv-optimized CRC code from arch/riscv/lib/crc* into its new location in lib/crc/riscv/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the s390-optimized CRC code from arch/s390/lib/crc* into its new location in lib/crc/s390/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the sparc-optimized CRC code from arch/sparc/lib/crc* into its new location in lib/crc/sparc/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Move the x86-optimized CRC code from arch/x86/lib/crc* into its new location in lib/crc/x86/, and wire it up in the new way. For a detailed explanation of why this change is being made, see the commit that introduced the new way of integrating arch-specific code into lib/crc/. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 1: "[01/13] crypto/crc32: register only one shash_alg" |
|
Patch 2: "[02/13] crypto/crc32c: register only one shash_alg" |
|
Patch 2: "[02/13] crypto/crc32c: register only one shash_alg" |
|
Patch 2: "[02/13] crypto/crc32c: register only one shash_alg" |
|
Patch 2: "[02/13] crypto/crc32c: register only one shash_alg" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
|
Patch 13: "[13/13] lib/crc/x86: migrate x86-optimized CRC code into lib/crc/" |
83b702b to
b94890f
Compare
PR for series 967868 applied to workflow
Name: lib/crc: improve how arch-optimized code is integrated
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=967868
Version: 1