From: Robert Elliott <elliott@hpe.com>
To: herbert@gondor.apana.org.au, davem@davemloft.net,
paulmck@kernel.org, frederic@kernel.org,
quic_neeraju@quicinc.com, josh@joshtriplett.org
Cc: linux-crypto@vger.kernel.org, rcu@vger.kernel.org,
linux-kernel@vger.kernel.org, Robert Elliott <elliott@hpe.com>
Subject: [PATCH 3/3] crypto: tcrypt - suppress RCU stall warnings during speed tests
Date: Mon, 19 Dec 2022 14:29:10 -0600 [thread overview]
Message-ID: <20221219202910.3063036-4-elliott@hpe.com> (raw)
In-Reply-To: <20221219202910.3063036-1-elliott@hpe.com>
Suppress RCU CPU stall warnings while running speed tests.
The tcrypt module is intended only for developer usage, so
RCU stalls induced by those tests are not necessarily representative
of real problems.
Speed tests need to disable interrupts or preemption to get results
that are not distorted by such interruptions. This triggers more
RCU stalls than normal invocations of the crypto functions.
If an RCU stall is triggered and reported, the time to print to the
console distorts the speed results.
Signed-off-by: Robert Elliott <elliott@hpe.com>
---
crypto/tcrypt.c | 113 ++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 94 insertions(+), 19 deletions(-)
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 8645e72a7099..3e9e4adeef02 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -27,6 +27,7 @@
#include <linux/init.h>
#include <linux/gfp.h>
#include <linux/module.h>
+#include <linux/rcupdate.h>
#include <linux/scatterlist.h>
#include <linux/string.h>
#include <linux/moduleparam.h>
@@ -191,12 +192,16 @@ static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc,
if (!rc)
return -ENOMEM;
+ rcu_suppress_start();
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
ret = do_mult_aead_op(data, enc, num_mb, rc, prefix);
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
pr_info("%s %8d operations in %d seconds (%12llu bytes)\n",
prefix, bcount * num_mb, secs, (u64)bcount * blen * num_mb);
@@ -218,19 +223,25 @@ static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
return -ENOMEM;
/* Warm-up run. */
+ rcu_suppress_start();
for (i = 0; i < 4; i++) {
ret = do_mult_aead_op(data, enc, num_mb, rc, prefix);
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
+ rcu_suppress_start();
start = get_cycles();
ret = do_mult_aead_op(data, enc, num_mb, rc, prefix);
end = get_cycles();
+ rcu_suppress_end();
if (ret)
goto out;
@@ -470,6 +481,7 @@ static int test_aead_jiffies(struct aead_request *req, int enc,
int bcount;
int ret;
+ rcu_suppress_start();
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
if (enc)
@@ -477,9 +489,12 @@ static int test_aead_jiffies(struct aead_request *req, int enc,
else
ret = do_one_aead_op(req, crypto_aead_decrypt(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
return ret;
+ }
}
+ rcu_suppress_end();
pr_info("%s %8d operations in %d seconds (%12llu bytes)\n",
prefix, bcount, secs, (u64)bcount * blen);
@@ -494,26 +509,32 @@ static int test_aead_cycles(struct aead_request *req, int enc,
int i;
/* Warm-up run. */
+ rcu_suppress_start();
for (i = 0; i < 4; i++) {
if (enc)
ret = do_one_aead_op(req, crypto_aead_encrypt(req));
else
ret = do_one_aead_op(req, crypto_aead_decrypt(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
+ rcu_suppress_start();
start = get_cycles();
if (enc)
ret = do_one_aead_op(req, crypto_aead_encrypt(req));
else
ret = do_one_aead_op(req, crypto_aead_decrypt(req));
end = get_cycles();
+ rcu_suppress_end();
if (ret)
goto out;
@@ -746,12 +767,16 @@ static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
int bcount;
int ret;
+ rcu_suppress_start();
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
ret = do_one_ahash_op(req, crypto_ahash_digest(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
return ret;
+ }
}
+ rcu_suppress_end();
pr_info("%s %6u opers/sec, %9lu bytes/sec\n",
prefix, bcount / secs, ((long)bcount * blen) / secs);
@@ -769,21 +794,29 @@ static int test_ahash_jiffies(struct ahash_request *req, int blen,
if (plen == blen)
return test_ahash_jiffies_digest(req, blen, secs, prefix);
+ rcu_suppress_start();
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
ret = do_one_ahash_op(req, crypto_ahash_init(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
return ret;
+ }
for (pcount = 0; pcount < blen; pcount += plen) {
ret = do_one_ahash_op(req, crypto_ahash_update(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
return ret;
+ }
}
ret = do_one_ahash_op(req, crypto_ahash_final(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
return ret;
+ }
}
+ rcu_suppress_end();
pr_info("%s %6u opers/sec, %9lu bytes/sec\n",
prefix, bcount / secs, ((long)bcount * blen) / secs);
@@ -798,23 +831,31 @@ static int test_ahash_cycles_digest(struct ahash_request *req, int blen,
int ret, i;
/* Warm-up run. */
+ rcu_suppress_start();
for (i = 0; i < 4; i++) {
ret = do_one_ahash_op(req, crypto_ahash_digest(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
+ rcu_suppress_start();
start = get_cycles();
ret = do_one_ahash_op(req, crypto_ahash_digest(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
end = get_cycles();
+ rcu_suppress_end();
cycles += end - start;
}
@@ -839,24 +880,33 @@ static int test_ahash_cycles(struct ahash_request *req, int blen,
return test_ahash_cycles_digest(req, blen, prefix);
/* Warm-up run. */
+ rcu_suppress_start();
for (i = 0; i < 4; i++) {
ret = do_one_ahash_op(req, crypto_ahash_init(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
for (pcount = 0; pcount < blen; pcount += plen) {
ret = do_one_ahash_op(req, crypto_ahash_update(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
ret = do_one_ahash_op(req, crypto_ahash_final(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
+ rcu_suppress_start();
start = get_cycles();
ret = do_one_ahash_op(req, crypto_ahash_init(req));
@@ -864,14 +914,19 @@ static int test_ahash_cycles(struct ahash_request *req, int blen,
goto out;
for (pcount = 0; pcount < blen; pcount += plen) {
ret = do_one_ahash_op(req, crypto_ahash_update(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
ret = do_one_ahash_op(req, crypto_ahash_final(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
end = get_cycles();
+ rcu_suppress_end();
cycles += end - start;
}
@@ -1039,12 +1094,16 @@ static int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc,
if (!rc)
return -ENOMEM;
+ rcu_suppress_start();
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
ret = do_mult_acipher_op(data, enc, num_mb, rc, prefix);
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
pr_info("%s %8d operations in %d seconds (%12llu bytes)\n",
prefix, bcount * num_mb, secs, (u64)bcount * blen * num_mb);
@@ -1066,19 +1125,25 @@ static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc,
return -ENOMEM;
/* Warm-up run. */
+ rcu_suppress_start();
for (i = 0; i < 4; i++) {
ret = do_mult_acipher_op(data, enc, num_mb, rc, prefix);
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
+ rcu_suppress_start();
start = get_cycles();
ret = do_mult_acipher_op(data, enc, num_mb, rc, prefix);
end = get_cycles();
+ rcu_suppress_end();
if (ret)
goto out;
@@ -1270,6 +1335,7 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc,
int bcount;
int ret;
+ rcu_suppress_start();
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
if (enc)
@@ -1279,9 +1345,12 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc,
ret = do_one_acipher_op(req,
crypto_skcipher_decrypt(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
return ret;
+ }
}
+ rcu_suppress_end();
pr_info("%s %8d operations in %d seconds (%12llu bytes)\n",
prefix, bcount, secs, (u64)bcount * blen);
@@ -1296,6 +1365,7 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc,
int i;
/* Warm-up run. */
+ rcu_suppress_start();
for (i = 0; i < 4; i++) {
if (enc)
ret = do_one_acipher_op(req,
@@ -1304,14 +1374,18 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc,
ret = do_one_acipher_op(req,
crypto_skcipher_decrypt(req));
- if (ret)
+ if (ret) {
+ rcu_suppress_end();
goto out;
+ }
}
+ rcu_suppress_end();
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
+ rcu_suppress_start();
start = get_cycles();
if (enc)
ret = do_one_acipher_op(req,
@@ -1320,6 +1394,7 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc,
ret = do_one_acipher_op(req,
crypto_skcipher_decrypt(req));
end = get_cycles();
+ rcu_suppress_end();
if (ret)
goto out;
--
2.38.1
next prev parent reply other threads:[~2022-12-19 20:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 20:29 [PATCH 0/3] crypto/rcu: suppress unnecessary CPU stall warnings Robert Elliott
2022-12-19 20:29 ` [PATCH 1/3] rcu: genericize RCU stall suppression functions Robert Elliott
2022-12-21 18:56 ` Paul E. McKenney
2023-01-10 6:07 ` Joel Fernandes
2023-01-10 6:12 ` Joel Fernandes
2022-12-19 20:29 ` [PATCH 2/3] rcu: print first CPU on expedited stall line Robert Elliott
2022-12-21 19:02 ` Paul E. McKenney
2022-12-19 20:29 ` Robert Elliott [this message]
2022-12-30 8:39 ` [PATCH 3/3] crypto: tcrypt - suppress RCU stall warnings during speed tests Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221219202910.3063036-4-elliott@hpe.com \
--to=elliott@hpe.com \
--cc=davem@davemloft.net \
--cc=frederic@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=josh@joshtriplett.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®