From 83ac6e0a72c4ba6ce44e6b86f0cc32050af6924d Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 22 Aug 2023 18:10:37 +0200 Subject: [PATCH] btrfs-progs: crypto: make the PCL implementation default for crc32c Drop the old native intel implementation and use the PCL one. Remove the artifical CPU flags. Signed-off-by: David Sterba --- common/cpu-utils.c | 2 -- common/cpu-utils.h | 3 --- crypto/crc32c.c | 10 +++++----- crypto/hash-speedtest.c | 2 -- crypto/hash-vectest.c | 7 ------- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/common/cpu-utils.c b/common/cpu-utils.c index 250a5731..3527a3cb 100644 --- a/common/cpu-utils.c +++ b/common/cpu-utils.c @@ -58,7 +58,6 @@ void cpu_print_flags(void) { FLAG(SHA); FLAG(AVX); FLAG(AVX2); - FLAG(CRC32C_PCL); putchar(10); } #undef FLAG @@ -89,7 +88,6 @@ void cpu_detect_flags(void) if (b & (1UL << 29)) __cpu_flags |= CPU_FLAG_SHA; - __cpu_flags |= CPU_FLAG_CRC32C_PCL; __cpu_flags_orig = __cpu_flags; } diff --git a/common/cpu-utils.h b/common/cpu-utils.h index bd2f50b7..e4a8641b 100644 --- a/common/cpu-utils.h +++ b/common/cpu-utils.h @@ -37,9 +37,6 @@ enum cpu_feature { ENUM_CPU_BIT(CPU_FLAG_SHA), ENUM_CPU_BIT(CPU_FLAG_AVX), ENUM_CPU_BIT(CPU_FLAG_AVX2), - - /* Special features */ - ENUM_CPU_BIT(CPU_FLAG_CRC32C_PCL), }; #undef ENUM_CPU_BIT diff --git a/crypto/crc32c.c b/crypto/crc32c.c index c72ddf69..23cbb1a6 100644 --- a/crypto/crc32c.c +++ b/crypto/crc32c.c @@ -13,7 +13,7 @@ #include "crypto/crc32c.h" #include "common/cpu-utils.h" -uint32_t __crc32c_le(uint32_t crc, unsigned char const *data, uint32_t length); +static uint32_t __crc32c_le(uint32_t crc, unsigned char const *data, uint32_t length); static uint32_t (*crc_function)(uint32_t crc, unsigned char const *data, uint32_t length) = __crc32c_le; #ifdef __x86_64__ @@ -96,7 +96,7 @@ void crc32c_init_accel(void) */ if (0) { #ifdef __GLIBC__ - } else if (cpu_has_feature(CPU_FLAG_CRC32C_PCL)) { + } else if (cpu_has_feature(CPU_FLAG_SSE42)) { /* printf("CRC32C: pcl\n"); */ crc_function = crc32c_pcl; #else @@ -196,11 +196,11 @@ static const uint32_t crc32c_table[256] = { }; /* - * Steps through buffer one byte at at time, calculates reflected - * crc using table. + * Steps through buffer one byte at at time, calculates reflected crc using + * table. */ -uint32_t __crc32c_le(uint32_t crc, unsigned char const *data, uint32_t length) +static uint32_t __crc32c_le(uint32_t crc, unsigned char const *data, uint32_t length) { while (length--) crc = diff --git a/crypto/hash-speedtest.c b/crypto/hash-speedtest.c index 8f304cd2..2b02f6ae 100644 --- a/crypto/hash-speedtest.c +++ b/crypto/hash-speedtest.c @@ -191,8 +191,6 @@ int main(int argc, char **argv) { .cpu_flag = CPU_FLAG_NONE }, { .name = "CRC32C-NI", .digest = hash_crc32c, .digest_size = 4, .cpu_flag = CPU_FLAG_SSE42 }, - { .name = "CRC32C-PCL", .digest = hash_crc32c, .digest_size = 4, - .cpu_flag = CPU_FLAG_CRC32C_PCL }, { .name = "XXHASH", .digest = hash_xxhash, .digest_size = 8 }, { .name = "SHA256-ref", .digest = hash_sha256, .digest_size = 32, .cpu_flag = CPU_FLAG_NONE, .backend = CRYPTOPROVIDER_BUILTIN + 1 }, diff --git a/crypto/hash-vectest.c b/crypto/hash-vectest.c index b20d2b9d..498b9a12 100644 --- a/crypto/hash-vectest.c +++ b/crypto/hash-vectest.c @@ -444,13 +444,6 @@ static const struct hash_testspec test_spec[] = { .count = ARRAY_SIZE(crc32c_tv), .cpu_flag = CPU_FLAG_SSE42, .hash = hash_crc32c - }, { - .name = "CRC32C-PCL", - .digest_size = 4, - .testvec = crc32c_tv, - .count = ARRAY_SIZE(crc32c_tv), - .cpu_flag = CPU_FLAG_CRC32C_PCL, - .hash = hash_crc32c }, { .name = "XXHASH", .digest_size = 8,