Skip to contentSkip to conversation

lib/crypto: tests: Add some additional lengths to the ChaCha benchmark

PATCH Applied Eric Biggers 2 participants 4 messages Nov 4 – Nov 7

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crypto: tests: Add some additional lengths to the ChaCha benchmark

All the benchmarked lengths below 1420 are multiples of the ChaCha block size, and all except 64 are a multiple of 4 blocks. Add some additional lengths to cover a wider variety of situations.

---
 lib/crypto/tests/chacha_kunit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/crypto/tests/chacha_kunit.c +2 -1
index bbf73dcbafee..2e002e46976e 100644
@@ -217,7 +217,8 @@ static void test_chacha_rfc7539(struct kunit *test)
 static void benchmark_chacha(struct kunit *test)
 {
 	static const size_t lens_to_test[] = {
-		64, 256, 512, 1024, 1420, 2048, 4096, 8920, 16384,
+		64,   128,  200,  256,	511,  512,   513,
+		1024, 1420, 2048, 4096, 8920, 16384,
 	};
 	const size_t max_len = 16384;
 	u8 *data = alloc_buf(test, max_len);

base-commit: 9fbbbaefd5f95551da18426c200cf41e1b4255a1

Signature · 1 line
2.56.0
Tested-by on v1 1/1
#1 lore raw

Tested on Zen 5 (Ryzen 9 9950X) in a KVM guest, on top of base 9fbbbaefd5f9. KUnit chacha suite passes and the benchmark reports all 13 lengths on every x86 code path:

  path                 CPU setup              KUnit  benchmark
  -------------------  ---------------------  -----  ------------
  AVX-512, zmm         native                 pass   13/13 lengths
  AVX-512VL, ymm only  spoofed SKX (6/0x55)   pass   13/13 lengths
  AVX2                 clearcpuid=avx512f     pass   13/13 lengths
  SSSE3                clearcpuid=avx2        pass   13/13 lengths

Nit: there's a tab between "256," and "511," while the rest of the array is aligned with spaces.

Signature · 5 lines
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl
https://www.mandelbit.com
author maintainer
#2 lore raw
Quoted 2 lines · Antonio Quartulli

Nit: there's a tab between "256," and "511," while the rest of the array is aligned with spaces.

If it's removed, 'git clang-format' puts it back in. It just happens to be the only place where it does so here, due to the spacing. We do still override 'git clang-format' with manual formatting fairly often, but I don't think it's worth it here.

- Eric

author maintainer Applied
#3 lore raw
In reply to Eric Biggers
Quoted 8 lines · Eric Biggers

All the benchmarked lengths below 1420 are multiples of the ChaCha block size, and all except 64 are a multiple of 4 blocks. Add some additional lengths to cover a wider variety of situations.

---
 lib/crypto/tests/chacha_kunit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric