diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-10-27 03:51:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-27 03:51:21 -0400 |
commit | a5a613a4291a8107008e4c40108a385cda71b08d (patch) | |
tree | 80b125bd9418fe202f652a533f986adc1b50d275 /crypto/tcrypt.c | |
parent | ceaa79c434044e40031585a65a4e45dc09322e8f (diff) |
[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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r-- | crypto/tcrypt.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index c457bdb2a42b..24141fb6f5cb 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, | |||
572 | int bcount; | 572 | int bcount; |
573 | int ret; | 573 | int ret; |
574 | 574 | ||
575 | sg_init_table(sg, 1); | ||
576 | |||
575 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 577 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
576 | time_before(jiffies, end); bcount++) { | 578 | time_before(jiffies, end); bcount++) { |
577 | sg_init_one(sg, p, blen); | 579 | sg_set_buf(sg, p, blen); |
578 | ret = crypto_hash_digest(desc, sg, blen, out); | 580 | ret = crypto_hash_digest(desc, sg, blen, out); |
579 | if (ret) | 581 | if (ret) |
580 | return ret; | 582 | return ret; |
@@ -597,13 +599,15 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen, | |||
597 | if (plen == blen) | 599 | if (plen == blen) |
598 | return test_hash_jiffies_digest(desc, p, blen, out, sec); | 600 | return test_hash_jiffies_digest(desc, p, blen, out, sec); |
599 | 601 | ||
602 | sg_init_table(sg, 1); | ||
603 | |||
600 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 604 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
601 | time_before(jiffies, end); bcount++) { | 605 | time_before(jiffies, end); bcount++) { |
602 | ret = crypto_hash_init(desc); | 606 | ret = crypto_hash_init(desc); |
603 | if (ret) | 607 | if (ret) |
604 | return ret; | 608 | return ret; |
605 | for (pcount = 0; pcount < blen; pcount += plen) { | 609 | for (pcount = 0; pcount < blen; pcount += plen) { |
606 | sg_init_one(sg, p + pcount, plen); | 610 | sg_set_buf(sg, p + pcount, plen); |
607 | ret = crypto_hash_update(desc, sg, plen); | 611 | ret = crypto_hash_update(desc, sg, plen); |
608 | if (ret) | 612 | if (ret) |
609 | return ret; | 613 | return ret; |
@@ -628,12 +632,14 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, | |||
628 | int i; | 632 | int i; |
629 | int ret; | 633 | int ret; |
630 | 634 | ||
635 | sg_init_table(sg, 1); | ||
636 | |||
631 | local_bh_disable(); | 637 | local_bh_disable(); |
632 | local_irq_disable(); | 638 | local_irq_disable(); |
633 | 639 | ||
634 | /* Warm-up run. */ | 640 | /* Warm-up run. */ |
635 | for (i = 0; i < 4; i++) { | 641 | for (i = 0; i < 4; i++) { |
636 | sg_init_one(sg, p, blen); | 642 | sg_set_buf(sg, p, blen); |
637 | ret = crypto_hash_digest(desc, sg, blen, out); | 643 | ret = crypto_hash_digest(desc, sg, blen, out); |
638 | if (ret) | 644 | if (ret) |
639 | goto out; | 645 | goto out; |
@@ -645,7 +651,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, | |||
645 | 651 | ||
646 | start = get_cycles(); | 652 | start = get_cycles(); |
647 | 653 | ||
648 | sg_init_one(sg, p, blen); | 654 | sg_set_buf(sg, p, blen); |
649 | ret = crypto_hash_digest(desc, sg, blen, out); | 655 | ret = crypto_hash_digest(desc, sg, blen, out); |
650 | if (ret) | 656 | if (ret) |
651 | goto out; | 657 | goto out; |
@@ -679,6 +685,8 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, | |||
679 | if (plen == blen) | 685 | if (plen == blen) |
680 | return test_hash_cycles_digest(desc, p, blen, out); | 686 | return test_hash_cycles_digest(desc, p, blen, out); |
681 | 687 | ||
688 | sg_init_table(sg, 1); | ||
689 | |||
682 | local_bh_disable(); | 690 | local_bh_disable(); |
683 | local_irq_disable(); | 691 | local_irq_disable(); |
684 | 692 | ||
@@ -688,7 +696,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, | |||
688 | if (ret) | 696 | if (ret) |
689 | goto out; | 697 | goto out; |
690 | for (pcount = 0; pcount < blen; pcount += plen) { | 698 | for (pcount = 0; pcount < blen; pcount += plen) { |
691 | sg_init_one(sg, p + pcount, plen); | 699 | sg_set_buf(sg, p + pcount, plen); |
692 | ret = crypto_hash_update(desc, sg, plen); | 700 | ret = crypto_hash_update(desc, sg, plen); |
693 | if (ret) | 701 | if (ret) |
694 | goto out; | 702 | goto out; |
@@ -708,7 +716,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, | |||
708 | if (ret) | 716 | if (ret) |
709 | goto out; | 717 | goto out; |
710 | for (pcount = 0; pcount < blen; pcount += plen) { | 718 | for (pcount = 0; pcount < blen; pcount += plen) { |
711 | sg_init_one(sg, p + pcount, plen); | 719 | sg_set_buf(sg, p + pcount, plen); |
712 | ret = crypto_hash_update(desc, sg, plen); | 720 | ret = crypto_hash_update(desc, sg, plen); |
713 | if (ret) | 721 | if (ret) |
714 | goto out; | 722 | goto out; |