diff mbox series

[3/3] crypto: tcrypt - suppress RCU stall warnings during speed tests

Message ID 20221219202910.3063036-4-elliott@hpe.com (mailing list archive)
State New, archived
Headers show
Series crypto/rcu: suppress unnecessary CPU stall warnings | expand

Commit Message

Elliott, Robert (Servers) Dec. 19, 2022, 8:29 p.m. UTC
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(-)

Comments

Herbert Xu Dec. 30, 2022, 8:39 a.m. UTC | #1
On Mon, Dec 19, 2022 at 02:29:10PM -0600, Robert Elliott wrote:
> 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.

Where do we disable interrupts? That would seem to break the
use of jiffies since it won't get updated anymore.

Which particular test is still triggering the RCU warnings after
fixing the hash problems that you've already identified?

Cheers,
diff mbox series

Patch

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;