Skip to content

Commit 9b56075

Browse files
vvfedorenkoAlexei Starovoitov
authored andcommitted
selftests: bpf: crypto: adjust bench to use nullable IV
The bench shows some improvements, around 4% faster on decrypt. Before: Benchmark 'crypto-decrypt' started. Iter 0 (325.719us): hits 5.105M/s ( 5.105M/prod), drops 0.000M/s, total operations 5.105M/s Iter 1 (-17.295us): hits 5.224M/s ( 5.224M/prod), drops 0.000M/s, total operations 5.224M/s Iter 2 ( 5.504us): hits 4.630M/s ( 4.630M/prod), drops 0.000M/s, total operations 4.630M/s Iter 3 ( 9.239us): hits 5.148M/s ( 5.148M/prod), drops 0.000M/s, total operations 5.148M/s Iter 4 ( 37.885us): hits 5.198M/s ( 5.198M/prod), drops 0.000M/s, total operations 5.198M/s Iter 5 (-53.282us): hits 5.167M/s ( 5.167M/prod), drops 0.000M/s, total operations 5.167M/s Iter 6 (-17.809us): hits 5.186M/s ( 5.186M/prod), drops 0.000M/s, total operations 5.186M/s Summary: hits 5.092 ± 0.228M/s ( 5.092M/prod), drops 0.000 ±0.000M/s, total operations 5.092 ± 0.228M/s After: Benchmark 'crypto-decrypt' started. Iter 0 (268.912us): hits 5.312M/s ( 5.312M/prod), drops 0.000M/s, total operations 5.312M/s Iter 1 (124.869us): hits 5.354M/s ( 5.354M/prod), drops 0.000M/s, total operations 5.354M/s Iter 2 (-36.801us): hits 5.334M/s ( 5.334M/prod), drops 0.000M/s, total operations 5.334M/s Iter 3 (254.628us): hits 5.334M/s ( 5.334M/prod), drops 0.000M/s, total operations 5.334M/s Iter 4 (-77.691us): hits 5.275M/s ( 5.275M/prod), drops 0.000M/s, total operations 5.275M/s Iter 5 (-164.510us): hits 5.313M/s ( 5.313M/prod), drops 0.000M/s, total operations 5.313M/s Iter 6 (-81.376us): hits 5.346M/s ( 5.346M/prod), drops 0.000M/s, total operations 5.346M/s Summary: hits 5.326 ± 0.029M/s ( 5.326M/prod), drops 0.000 ±0.000M/s, total operations 5.326 ± 0.029M/s Reviewed-by: Eduard Zingerman <[email protected]> Signed-off-by: Vadim Fedorenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 9363dc8 commit 9b56075

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tools/testing/selftests/bpf/progs/crypto_bench.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int crypto_encrypt(struct __sk_buff *skb)
5757
{
5858
struct __crypto_ctx_value *v;
5959
struct bpf_crypto_ctx *ctx;
60-
struct bpf_dynptr psrc, pdst, iv;
60+
struct bpf_dynptr psrc, pdst;
6161

6262
v = crypto_ctx_value_lookup();
6363
if (!v) {
@@ -73,9 +73,8 @@ int crypto_encrypt(struct __sk_buff *skb)
7373

7474
bpf_dynptr_from_skb(skb, 0, &psrc);
7575
bpf_dynptr_from_mem(dst, len, 0, &pdst);
76-
bpf_dynptr_from_mem(dst, 0, 0, &iv);
7776

78-
status = bpf_crypto_encrypt(ctx, &psrc, &pdst, &iv);
77+
status = bpf_crypto_encrypt(ctx, &psrc, &pdst, NULL);
7978
__sync_add_and_fetch(&hits, 1);
8079

8180
return 0;
@@ -84,7 +83,7 @@ int crypto_encrypt(struct __sk_buff *skb)
8483
SEC("tc")
8584
int crypto_decrypt(struct __sk_buff *skb)
8685
{
87-
struct bpf_dynptr psrc, pdst, iv;
86+
struct bpf_dynptr psrc, pdst;
8887
struct __crypto_ctx_value *v;
8988
struct bpf_crypto_ctx *ctx;
9089

@@ -98,9 +97,8 @@ int crypto_decrypt(struct __sk_buff *skb)
9897

9998
bpf_dynptr_from_skb(skb, 0, &psrc);
10099
bpf_dynptr_from_mem(dst, len, 0, &pdst);
101-
bpf_dynptr_from_mem(dst, 0, 0, &iv);
102100

103-
status = bpf_crypto_decrypt(ctx, &psrc, &pdst, &iv);
101+
status = bpf_crypto_decrypt(ctx, &psrc, &pdst, NULL);
104102
__sync_add_and_fetch(&hits, 1);
105103

106104
return 0;

0 commit comments

Comments
 (0)