From: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH 1/2] [CRYPTO] tcrypt: Move sg_init_table out of timing loops
Date: Fri, 26 Oct 2007 23:00:04 +0800 [thread overview]
Message-ID: <E1IlQfM-0003cO-00@gondolin.me.apana.org.au> (raw)
In-Reply-To: 20071026145905.GA13850@gondor.apana.org.au
[CRYPTO] tcrypt: Move sg_init_table out of timing loops
This patch moves the sg_init_table out of the timing loops for hash
algorithms so that it doesn't impact on the speed test results.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
---
crypto/tcrypt.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index c457bdb..24141fb 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -572,9 +572,11 @@ static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen,
int bcount;
int ret;
+ sg_init_table(sg, 1);
+
for (start = jiffies, end = start + sec * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
- sg_init_one(sg, p, blen);
+ sg_set_buf(sg, p, blen);
ret = crypto_hash_digest(desc, sg, blen, out);
if (ret)
return ret;
@@ -597,13 +599,15 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen,
if (plen == blen)
return test_hash_jiffies_digest(desc, p, blen, out, sec);
+ sg_init_table(sg, 1);
+
for (start = jiffies, end = start + sec * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
ret = crypto_hash_init(desc);
if (ret)
return ret;
for (pcount = 0; pcount < blen; pcount += plen) {
- sg_init_one(sg, p + pcount, plen);
+ sg_set_buf(sg, p + pcount, plen);
ret = crypto_hash_update(desc, sg, plen);
if (ret)
return ret;
@@ -628,12 +632,14 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
int i;
int ret;
+ sg_init_table(sg, 1);
+
local_bh_disable();
local_irq_disable();
/* Warm-up run. */
for (i = 0; i < 4; i++) {
- sg_init_one(sg, p, blen);
+ sg_set_buf(sg, p, blen);
ret = crypto_hash_digest(desc, sg, blen, out);
if (ret)
goto out;
@@ -645,7 +651,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
start = get_cycles();
- sg_init_one(sg, p, blen);
+ sg_set_buf(sg, p, blen);
ret = crypto_hash_digest(desc, sg, blen, out);
if (ret)
goto out;
@@ -679,6 +685,8 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
if (plen == blen)
return test_hash_cycles_digest(desc, p, blen, out);
+ sg_init_table(sg, 1);
+
local_bh_disable();
local_irq_disable();
@@ -688,7 +696,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
if (ret)
goto out;
for (pcount = 0; pcount < blen; pcount += plen) {
- sg_init_one(sg, p + pcount, plen);
+ sg_set_buf(sg, p + pcount, plen);
ret = crypto_hash_update(desc, sg, plen);
if (ret)
goto out;
@@ -708,7 +716,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
if (ret)
goto out;
for (pcount = 0; pcount < blen; pcount += plen) {
- sg_init_one(sg, p + pcount, plen);
+ sg_set_buf(sg, p + pcount, plen);
ret = crypto_hash_update(desc, sg, plen);
if (ret)
goto out;
next prev parent reply other threads:[~2007-10-26 15:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 14:59 [0/2] [CRYPTO] users: Fix up remaining sg issues Herbert Xu
2007-10-26 15:00 ` Herbert Xu [this message]
2007-10-27 7:51 ` [PATCH 1/2] [CRYPTO] tcrypt: Move sg_init_table out of timing loops David Miller
2007-10-29 20:16 ` Jens Axboe
2007-10-30 0:08 ` Herbert Xu
2007-10-30 5:50 ` Jens Axboe
2007-10-30 14:18 ` Herbert Xu
2007-10-30 14:17 ` Jens Axboe
2007-10-30 9:31 ` Boaz Harrosh
2007-10-30 9:32 ` Jens Axboe
2007-10-26 15:00 ` [PATCH 2/2] [CRYPTO] users: Fix up scatterlist conversion errors Herbert Xu
2007-10-26 15:44 ` Vlad Yasevich
2007-10-27 7:52 ` David Miller
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=E1IlQfM-0003cO-00@gondolin.me.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).