All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Seidel <fseidel@suse.de>
To: linux kernel <linux-kernel@vger.kernel.org>
Cc: linux-crypto@vger.kernel.org, Frank Seidel <frank@f-seidel.de>,
	Frank Seidel <fseidel@suse.de>,
	akpm@linux-foundation.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	nhorman@tuxdriver.com, lho@amcc.com, kaber@trash.net,
	darrenrjenkins@gmail.com
Subject: [PATCH][trivial] crypto: tcrypt - reduce stack size
Date: Wed, 25 Feb 2009 14:48:19 +0100	[thread overview]
Message-ID: <49A54C23.8090209@suse.de> (raw)

From: Frank Seidel <frank@f-seidel.de>

Applying kernel janitors todos (printk calls need KERN_*
constants on linebeginnings, reduce stack footprint where
possible) to tcrypts test_hash_speed (where stacks
memory footprint was very high (on i386 1184 bytes to
292 now).

Signed-off-by: Frank Seidel <frank@f-seidel.de>
---
 crypto/tcrypt.c |   29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -396,26 +396,34 @@ static void test_hash_speed(const char *
 	struct scatterlist sg[TVMEMSIZE];
 	struct crypto_hash *tfm;
 	struct hash_desc desc;
-	char output[1024];
+	char *output;
+	size_t output_size = 1024;
 	int i;
 	int ret;
 
-	printk("\ntesting speed of %s\n", algo);
+	printk(KERN_INFO "\ntesting speed of %s\n", algo);
+
+	output = kmalloc(output_size * sizeof(*output), GFP_KERNEL);
+	if (!output) {
+		printk(KERN_ERR "tcrypt: failed to allocate outputbuffer\n");
+		return;
+	}
 
 	tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
 
 	if (IS_ERR(tfm)) {
-		printk("failed to load transform for %s: %ld\n", algo,
+		printk(KERN_ERR "failed to load transform for %s: %ld\n", algo,
 		       PTR_ERR(tfm));
+		kfree(output);
 		return;
 	}
 
 	desc.tfm = tfm;
 	desc.flags = 0;
 
-	if (crypto_hash_digestsize(tfm) > sizeof(output)) {
-		printk("digestsize(%u) > outputbuffer(%zu)\n",
-		       crypto_hash_digestsize(tfm), sizeof(output));
+	if (crypto_hash_digestsize(tfm) > output_size) {
+		printk(KERN_ERR "digestsize(%u) > outputbuffer(%zu)\n",
+		       crypto_hash_digestsize(tfm), output_size);
 		goto out;
 	}
 
@@ -427,12 +435,14 @@ static void test_hash_speed(const char *
 
 	for (i = 0; speed[i].blen != 0; i++) {
 		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
-			printk("template (%u) too big for tvmem (%lu)\n",
+			printk(KERN_ERR
+			       "template (%u) too big for tvmem (%lu)\n",
 			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
 			goto out;
 		}
 
-		printk("test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ",
+		printk(KERN_INFO "test%3u "
+		       "(%5u byte blocks,%5u bytes per update,%4u updates): ",
 		       i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
 
 		if (sec)
@@ -443,13 +453,14 @@ static void test_hash_speed(const char *
 					       speed[i].plen, output);
 
 		if (ret) {
-			printk("hashing failed ret=%d\n", ret);
+			printk(KERN_ERR "hashing failed ret=%d\n", ret);
 			break;
 		}
 	}
 
 out:
 	crypto_free_hash(tfm);
+	kfree(output);
 }
 
 static void test_available(void)

             reply	other threads:[~2009-02-25 13:48 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-25 13:48 Frank Seidel [this message]
2009-02-25 14:06 ` [PATCH][trivial] crypto: tcrypt - reduce stack size Thiago Galesi
2009-02-25 14:06   ` Thiago Galesi
2009-02-25 14:06 ` Neil Horman
2009-02-25 14:20 ` Herbert Xu
2009-02-25 14:24   ` Frank Seidel
2009-02-25 14:27     ` Herbert Xu
2009-02-25 14:31       ` Geert Uytterhoeven
2009-02-25 14:31         ` Geert Uytterhoeven
2009-02-25 14:36         ` Frank Seidel
2009-02-25 14:44           ` Geert Uytterhoeven
2009-02-25 14:44             ` Geert Uytterhoeven
2009-02-25 14:54             ` Frank Seidel
2009-02-25 14:29     ` Thiago Galesi
2009-02-25 14:29       ` Thiago Galesi
2009-02-25 14:34       ` Frank Seidel
2009-02-25 19:40         ` Greg KH
2009-02-25 14:24 ` [PATCHv2][trivial] " Frank Seidel
2009-02-25 14:53   ` [PATCHv3][trivial] " Frank Seidel
2009-02-25 15:32     ` Neil Horman
2009-03-29  7:19       ` Herbert Xu
2009-02-25 15:54     ` Geert Uytterhoeven
2009-02-25 15:54       ` Geert Uytterhoeven
2009-02-25 15:56       ` Frank Seidel
2009-02-25 15:58         ` Geert Uytterhoeven
2009-02-25 15:58           ` Geert Uytterhoeven
2009-02-25 16:01           ` Frank Seidel
2009-02-25 16:08           ` Geert Uytterhoeven
2009-02-25 16:08             ` Geert Uytterhoeven

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=49A54C23.8090209@suse.de \
    --to=fseidel@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=darrenrjenkins@gmail.com \
    --cc=davem@davemloft.net \
    --cc=frank@f-seidel.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=kaber@trash.net \
    --cc=lho@amcc.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.