summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorGilad Ben-Yossef <gilad@benyossef.com>2017-12-17 03:29:03 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2017-12-28 01:56:41 -0500
commitb34a0f67ba62027394598e3c47fd3549c5c8e294 (patch)
treee31d535b7dd3dbfa37c3a649bf0ea1c435f9bc29 /crypto
parent8fcdc86856b24d3f76b4d70665f2cbbe5102d8de (diff)
crypto: tcrypt - add multi buf ahash jiffies test
The multi buffer concurrent requests ahash speed test only supported the cycles mode. Add support for the so called jiffies mode that test performance of bytes/sec. We only add support for digest mode at the moment. Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/tcrypt.c112
1 files changed, 82 insertions, 30 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 260436004a76..e406b00db89c 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -413,13 +413,87 @@ struct test_mb_ahash_data {
413 char *xbuf[XBUFSIZE]; 413 char *xbuf[XBUFSIZE];
414}; 414};
415 415
416static void test_mb_ahash_speed(const char *algo, unsigned int sec, 416static inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb)
417{
418 int i, rc[num_mb], err = 0;
419
420 /* Fire up a bunch of concurrent requests */
421 for (i = 0; i < num_mb; i++)
422 rc[i] = crypto_ahash_digest(data[i].req);
423
424 /* Wait for all requests to finish */
425 for (i = 0; i < num_mb; i++) {
426 rc[i] = crypto_wait_req(rc[i], &data[i].wait);
427
428 if (rc[i]) {
429 pr_info("concurrent request %d error %d\n", i, rc[i]);
430 err = rc[i];
431 }
432 }
433
434 return err;
435}
436
437static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen,
438 int secs, u32 num_mb)
439{
440 unsigned long start, end;
441 int bcount;
442 int ret;
443
444 for (start = jiffies, end = start + secs * HZ, bcount = 0;
445 time_before(jiffies, end); bcount++) {
446 ret = do_mult_ahash_op(data, num_mb);
447 if (ret)
448 return ret;
449 }
450
451 pr_cont("%d operations in %d seconds (%ld bytes)\n",
452 bcount * num_mb, secs, (long)bcount * blen * num_mb);
453 return 0;
454}
455
456static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen,
457 u32 num_mb)
458{
459 unsigned long cycles = 0;
460 int ret = 0;
461 int i;
462
463 /* Warm-up run. */
464 for (i = 0; i < 4; i++) {
465 ret = do_mult_ahash_op(data, num_mb);
466 if (ret)
467 goto out;
468 }
469
470 /* The real thing. */
471 for (i = 0; i < 8; i++) {
472 cycles_t start, end;
473
474 start = get_cycles();
475 ret = do_mult_ahash_op(data, num_mb);
476 end = get_cycles();
477
478 if (ret)
479 goto out;
480
481 cycles += end - start;
482 }
483
484out:
485 if (ret == 0)
486 pr_cont("1 operation in %lu cycles (%d bytes)\n",
487 (cycles + 4) / (8 * num_mb), blen);
488
489 return ret;
490}
491
492static void test_mb_ahash_speed(const char *algo, unsigned int secs,
417 struct hash_speed *speed, u32 num_mb) 493 struct hash_speed *speed, u32 num_mb)
418{ 494{
419 struct test_mb_ahash_data *data; 495 struct test_mb_ahash_data *data;
420 struct crypto_ahash *tfm; 496 struct crypto_ahash *tfm;
421 unsigned long start, end;
422 unsigned long cycles;
423 unsigned int i, j, k; 497 unsigned int i, j, k;
424 int ret; 498 int ret;
425 499
@@ -483,34 +557,12 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec,
483 i, speed[i].blen, speed[i].plen, 557 i, speed[i].blen, speed[i].plen,
484 speed[i].blen / speed[i].plen); 558 speed[i].blen / speed[i].plen);
485 559
486 start = get_cycles(); 560 if (secs)
487 561 ret = test_mb_ahash_jiffies(data, speed[i].blen, secs,
488 for (k = 0; k < num_mb; k++) { 562 num_mb);
489 ret = crypto_ahash_digest(data[k].req); 563 else
490 if (ret == -EINPROGRESS) { 564 ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb);
491 ret = 0;
492 continue;
493 }
494
495 if (ret)
496 break;
497
498 crypto_req_done(&data[k].req->base, 0);
499 }
500
501 for (j = 0; j < k; j++) {
502 struct crypto_wait *wait = &data[j].wait;
503 int wait_ret;
504
505 wait_ret = crypto_wait_req(-EINPROGRESS, wait);
506 if (wait_ret)
507 ret = wait_ret;
508 }
509 565
510 end = get_cycles();
511 cycles = end - start;
512 pr_cont("%6lu cycles/operation, %4lu cycles/byte\n",
513 cycles, cycles / (num_mb * speed[i].blen));
514 566
515 if (ret) { 567 if (ret) {
516 pr_err("At least one hashing failed ret=%d\n", ret); 568 pr_err("At least one hashing failed ret=%d\n", ret);