linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Printing improvements for tcrypt
@ 2022-10-26 19:16 Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 1/4] crypto: tcrypt - Use pr_cont to print test results Anirudh Venkataramanan
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Anirudh Venkataramanan @ 2022-10-26 19:16 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto; +Cc: Robert Elliott, Anirudh Venkataramanan

The text tcrypt prints to dmesg is a bit inconsistent. This makes it
difficult to process tcrypt results using scripts. This little series
makes the prints more consistent.

Changes v1 -> v2: Rebase to tag v6.1-p2, resolve conflict in patch 2/4

Anirudh Venkataramanan (4):
  crypto: tcrypt - Use pr_cont to print test results
  crypto: tcrypt - Use pr_info/pr_err
  crypto: tcrypt - Drop module name from print string
  crypto: tcrypt - Drop leading newlines from prints

 crypto/tcrypt.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

-- 
2.37.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] crypto: tcrypt - Use pr_cont to print test results
  2022-10-26 19:16 [PATCH v2 0/4] Printing improvements for tcrypt Anirudh Venkataramanan
@ 2022-10-26 19:16 ` Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 2/4] crypto: tcrypt - Use pr_info/pr_err Anirudh Venkataramanan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Anirudh Venkataramanan @ 2022-10-26 19:16 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto; +Cc: Robert Elliott, Anirudh Venkataramanan

For some test cases, a line break gets inserted between the test banner
and the results. For example, with mode=211 this is the output:

[...]
      testing speed of rfc4106(gcm(aes)) (rfc4106-gcm-aesni) encryption
[...] test 0 (160 bit key, 16 byte blocks):
[...] 1 operation in 2373 cycles (16 bytes)

--snip--

[...]
      testing speed of gcm(aes) (generic-gcm-aesni) encryption
[...] test 0 (128 bit key, 16 byte blocks):
[...] 1 operation in 2338 cycles (16 bytes)

Similar behavior is seen in the following cases as well:

  modprobe tcrypt mode=212
  modprobe tcrypt mode=213
  modprobe tcrypt mode=221
  modprobe tcrypt mode=300 sec=1
  modprobe tcrypt mode=400 sec=1

This doesn't happen with mode=215:

[...] tcrypt:
              testing speed of multibuffer rfc4106(gcm(aes)) (rfc4106-gcm-aesni) encryption
[...] tcrypt: test 0 (160 bit key, 16 byte blocks): 1 operation in 2215 cycles (16 bytes)

--snip--

[...] tcrypt:
              testing speed of multibuffer gcm(aes) (generic-gcm-aesni) encryption
[...] tcrypt: test 0 (128 bit key, 16 byte blocks): 1 operation in 2191 cycles (16 bytes)

This print inconsistency is because printk() is used instead of pr_cont()
in a few places. Change these to be pr_cont().

checkpatch warns that pr_cont() shouldn't be used. This can be ignored in
this context as tcrypt already uses pr_cont().

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
---
Changes v1 -> v2: Rebase to tag v6.1-p2
---
 crypto/tcrypt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index a82679b..6aed45c 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -506,8 +506,8 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)
 
 out:
 	if (ret == 0)
-		printk("1 operation in %lu cycles (%d bytes)\n",
-		       (cycles + 4) / 8, blen);
+		pr_cont("1 operation in %lu cycles (%d bytes)\n",
+			(cycles + 4) / 8, blen);
 
 	return ret;
 }
@@ -727,8 +727,8 @@ static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,
 			return ret;
 	}
 
-	printk("%6u opers/sec, %9lu bytes/sec\n",
-	       bcount / secs, ((long)bcount * blen) / secs);
+	pr_cont("%6u opers/sec, %9lu bytes/sec\n",
+		bcount / secs, ((long)bcount * blen) / secs);
 
 	return 0;
 }
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] crypto: tcrypt - Use pr_info/pr_err
  2022-10-26 19:16 [PATCH v2 0/4] Printing improvements for tcrypt Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 1/4] crypto: tcrypt - Use pr_cont to print test results Anirudh Venkataramanan
@ 2022-10-26 19:16 ` Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 3/4] crypto: tcrypt - Drop module name from print string Anirudh Venkataramanan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Anirudh Venkataramanan @ 2022-10-26 19:16 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto; +Cc: Robert Elliott, Anirudh Venkataramanan

Currently, there's mixed use of printk() and pr_info()/pr_err(). The latter
prints the module name (because pr_fmt() is defined so) but the former does
not. As a result there's inconsistency in the printed output. For example:

modprobe mode=211:

[...] test 0 (160 bit key, 16 byte blocks): 1 operation in 2320 cycles (16 bytes)
[...] test 1 (160 bit key, 64 byte blocks): 1 operation in 2336 cycles (64 bytes)

modprobe mode=215:

[...] tcrypt: test 0 (160 bit key, 16 byte blocks): 1 operation in 2173 cycles (16 bytes)
[...] tcrypt: test 1 (160 bit key, 64 byte blocks): 1 operation in 2241 cycles (64 bytes)

Replace all instances of printk() with pr_info()/pr_err() so that the
module name is printed consistently.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
---
Changes v1 -> v2: Rebase to tag v6.1-p2, resolve conflicts
---
 crypto/tcrypt.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 6aed45c..d380ff8 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -575,8 +575,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 	}
 
 	crypto_init_wait(&wait);
-	printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo,
-			get_driver_name(crypto_aead, tfm), e);
+	pr_info("\ntesting speed of %s (%s) %s\n", algo,
+		get_driver_name(crypto_aead, tfm), e);
 
 	req = aead_request_alloc(tfm, GFP_KERNEL);
 	if (!req) {
@@ -624,8 +624,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 				memset(iv, 0xff, iv_len);
 
 			crypto_aead_clear_flags(tfm, ~0);
-			printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ",
-					i, *keysize * 8, bs);
+			pr_info("test %u (%d bit key, %d byte blocks): ",
+				i, *keysize * 8, bs);
 
 			memset(tvmem[0], 0xff, PAGE_SIZE);
 
@@ -877,8 +877,8 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 		return;
 	}
 
-	printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo,
-			get_driver_name(crypto_ahash, tfm));
+	pr_info("\ntesting speed of async %s (%s)\n", algo,
+		get_driver_name(crypto_ahash, tfm));
 
 	if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
 		pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
@@ -2885,7 +2885,7 @@ static int __init tcrypt_mod_init(void)
 	err = do_test(alg, type, mask, mode, num_mb);
 
 	if (err) {
-		printk(KERN_ERR "tcrypt: one or more tests failed!\n");
+		pr_err("one or more tests failed!\n");
 		goto err_free_tv;
 	} else {
 		pr_debug("all tests passed\n");
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] crypto: tcrypt - Drop module name from print string
  2022-10-26 19:16 [PATCH v2 0/4] Printing improvements for tcrypt Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 1/4] crypto: tcrypt - Use pr_cont to print test results Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 2/4] crypto: tcrypt - Use pr_info/pr_err Anirudh Venkataramanan
@ 2022-10-26 19:16 ` Anirudh Venkataramanan
  2022-10-26 19:16 ` [PATCH v2 4/4] crypto: tcrypt - Drop leading newlines from prints Anirudh Venkataramanan
  2022-11-04  9:38 ` [PATCH v2 0/4] Printing improvements for tcrypt Herbert Xu
  4 siblings, 0 replies; 6+ messages in thread
From: Anirudh Venkataramanan @ 2022-10-26 19:16 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto; +Cc: Robert Elliott, Anirudh Venkataramanan

The pr_fmt() define includes KBUILD_MODNAME, and so there's no need
for pr_err() to also print it. Drop module name from the print string.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
---
Changes v1 -> v2: Rebase to tag v6.1-p2
---
 crypto/tcrypt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index d380ff8..2878d0e 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -1329,8 +1329,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 
 	req = skcipher_request_alloc(tfm, GFP_KERNEL);
 	if (!req) {
-		pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
-		       algo);
+		pr_err("skcipher: Failed to allocate request for %s\n", algo);
 		goto out;
 	}
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] crypto: tcrypt - Drop leading newlines from prints
  2022-10-26 19:16 [PATCH v2 0/4] Printing improvements for tcrypt Anirudh Venkataramanan
                   ` (2 preceding siblings ...)
  2022-10-26 19:16 ` [PATCH v2 3/4] crypto: tcrypt - Drop module name from print string Anirudh Venkataramanan
@ 2022-10-26 19:16 ` Anirudh Venkataramanan
  2022-11-04  9:38 ` [PATCH v2 0/4] Printing improvements for tcrypt Herbert Xu
  4 siblings, 0 replies; 6+ messages in thread
From: Anirudh Venkataramanan @ 2022-10-26 19:16 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto; +Cc: Robert Elliott, Anirudh Venkataramanan

The top level print banners have a leading newline. It's not entirely
clear why this exists, but it makes it harder to parse tcrypt test output
using a script. Drop said newlines.

tcrypt output before this patch:

[...]
      testing speed of rfc4106(gcm(aes)) (rfc4106-gcm-aesni) encryption
[...] test 0 (160 bit key, 16 byte blocks): 1 operation in 2320 cycles (16 bytes)

tcrypt output with this patch:

[...] testing speed of rfc4106(gcm(aes)) (rfc4106-gcm-aesni) encryption
[...] test 0 (160 bit key, 16 byte blocks): 1 operation in 2320 cycles (16 bytes)

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
---
Changes v1 -> v2: Rebase to tag v6.1-p2
---
 crypto/tcrypt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 2878d0e..af3ea95 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -324,7 +324,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 					  crypto_req_done, &data[i].wait);
 	}
 
-	pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo,
+	pr_info("testing speed of multibuffer %s (%s) %s\n", algo,
 		get_driver_name(crypto_aead, tfm), e);
 
 	i = 0;
@@ -575,7 +575,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 	}
 
 	crypto_init_wait(&wait);
-	pr_info("\ntesting speed of %s (%s) %s\n", algo,
+	pr_info("testing speed of %s (%s) %s\n", algo,
 		get_driver_name(crypto_aead, tfm), e);
 
 	req = aead_request_alloc(tfm, GFP_KERNEL);
@@ -877,7 +877,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 		return;
 	}
 
-	pr_info("\ntesting speed of async %s (%s)\n", algo,
+	pr_info("testing speed of async %s (%s)\n", algo,
 		get_driver_name(crypto_ahash, tfm));
 
 	if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
@@ -1117,7 +1117,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
 		crypto_init_wait(&data[i].wait);
 	}
 
-	pr_info("\ntesting speed of multibuffer %s (%s) %s\n", algo,
+	pr_info("testing speed of multibuffer %s (%s) %s\n", algo,
 		get_driver_name(crypto_skcipher, tfm), e);
 
 	i = 0;
@@ -1324,7 +1324,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 		return;
 	}
 
-	pr_info("\ntesting speed of %s %s (%s) %s\n", async ? "async" : "sync",
+	pr_info("testing speed of %s %s (%s) %s\n", async ? "async" : "sync",
 		algo, get_driver_name(crypto_skcipher, tfm), e);
 
 	req = skcipher_request_alloc(tfm, GFP_KERNEL);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] Printing improvements for tcrypt
  2022-10-26 19:16 [PATCH v2 0/4] Printing improvements for tcrypt Anirudh Venkataramanan
                   ` (3 preceding siblings ...)
  2022-10-26 19:16 ` [PATCH v2 4/4] crypto: tcrypt - Drop leading newlines from prints Anirudh Venkataramanan
@ 2022-11-04  9:38 ` Herbert Xu
  4 siblings, 0 replies; 6+ messages in thread
From: Herbert Xu @ 2022-11-04  9:38 UTC (permalink / raw)
  To: Anirudh Venkataramanan; +Cc: linux-crypto, Robert Elliott

On Wed, Oct 26, 2022 at 12:16:12PM -0700, Anirudh Venkataramanan wrote:
> The text tcrypt prints to dmesg is a bit inconsistent. This makes it
> difficult to process tcrypt results using scripts. This little series
> makes the prints more consistent.
> 
> Changes v1 -> v2: Rebase to tag v6.1-p2, resolve conflict in patch 2/4
> 
> Anirudh Venkataramanan (4):
>   crypto: tcrypt - Use pr_cont to print test results
>   crypto: tcrypt - Use pr_info/pr_err
>   crypto: tcrypt - Drop module name from print string
>   crypto: tcrypt - Drop leading newlines from prints
> 
>  crypto/tcrypt.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> -- 
> 2.37.2

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-04  9:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 19:16 [PATCH v2 0/4] Printing improvements for tcrypt Anirudh Venkataramanan
2022-10-26 19:16 ` [PATCH v2 1/4] crypto: tcrypt - Use pr_cont to print test results Anirudh Venkataramanan
2022-10-26 19:16 ` [PATCH v2 2/4] crypto: tcrypt - Use pr_info/pr_err Anirudh Venkataramanan
2022-10-26 19:16 ` [PATCH v2 3/4] crypto: tcrypt - Drop module name from print string Anirudh Venkataramanan
2022-10-26 19:16 ` [PATCH v2 4/4] crypto: tcrypt - Drop leading newlines from prints Anirudh Venkataramanan
2022-11-04  9:38 ` [PATCH v2 0/4] Printing improvements for tcrypt Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).