Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Herbert Xu and committed by
David S. Miller
a5a613a4 ceaa79c4

+14 -6
+14 -6
crypto/tcrypt.c
··· 572 572 int bcount; 573 573 int ret; 574 574 575 + sg_init_table(sg, 1); 576 + 575 577 for (start = jiffies, end = start + sec * HZ, bcount = 0; 576 578 time_before(jiffies, end); bcount++) { 577 - sg_init_one(sg, p, blen); 579 + sg_set_buf(sg, p, blen); 578 580 ret = crypto_hash_digest(desc, sg, blen, out); 579 581 if (ret) 580 582 return ret; ··· 599 597 if (plen == blen) 600 598 return test_hash_jiffies_digest(desc, p, blen, out, sec); 601 599 600 + sg_init_table(sg, 1); 601 + 602 602 for (start = jiffies, end = start + sec * HZ, bcount = 0; 603 603 time_before(jiffies, end); bcount++) { 604 604 ret = crypto_hash_init(desc); 605 605 if (ret) 606 606 return ret; 607 607 for (pcount = 0; pcount < blen; pcount += plen) { 608 - sg_init_one(sg, p + pcount, plen); 608 + sg_set_buf(sg, p + pcount, plen); 609 609 ret = crypto_hash_update(desc, sg, plen); 610 610 if (ret) 611 611 return ret; ··· 632 628 int i; 633 629 int ret; 634 630 631 + sg_init_table(sg, 1); 632 + 635 633 local_bh_disable(); 636 634 local_irq_disable(); 637 635 638 636 /* Warm-up run. */ 639 637 for (i = 0; i < 4; i++) { 640 - sg_init_one(sg, p, blen); 638 + sg_set_buf(sg, p, blen); 641 639 ret = crypto_hash_digest(desc, sg, blen, out); 642 640 if (ret) 643 641 goto out; ··· 651 645 652 646 start = get_cycles(); 653 647 654 - sg_init_one(sg, p, blen); 648 + sg_set_buf(sg, p, blen); 655 649 ret = crypto_hash_digest(desc, sg, blen, out); 656 650 if (ret) 657 651 goto out; ··· 685 679 if (plen == blen) 686 680 return test_hash_cycles_digest(desc, p, blen, out); 687 681 682 + sg_init_table(sg, 1); 683 + 688 684 local_bh_disable(); 689 685 local_irq_disable(); 690 686 ··· 696 688 if (ret) 697 689 goto out; 698 690 for (pcount = 0; pcount < blen; pcount += plen) { 699 - sg_init_one(sg, p + pcount, plen); 691 + sg_set_buf(sg, p + pcount, plen); 700 692 ret = crypto_hash_update(desc, sg, plen); 701 693 if (ret) 702 694 goto out; ··· 716 708 if (ret) 717 709 goto out; 718 710 for (pcount = 0; pcount < blen; pcount += plen) { 719 - sg_init_one(sg, p + pcount, plen); 711 + sg_set_buf(sg, p + pcount, plen); 720 712 ret = crypto_hash_update(desc, sg, plen); 721 713 if (ret) 722 714 goto out;