From patchwork Thu Nov 30 10:09:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 120096 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp469427qgn; Thu, 30 Nov 2017 02:10:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMa6KcwqzKkH8pvTo3BEauIXWbrZ3H+CggDM6OSoQRm1irNrKdr/Cfdgub5R55dZUYFnjtHX X-Received: by 10.101.101.216 with SMTP id y24mr1979754pgv.236.1512036634946; Thu, 30 Nov 2017 02:10:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512036634; cv=none; d=google.com; s=arc-20160816; b=ZpHjpwxWZKOyyigQ4vvyFqcWD6DkbeZY9+CvbmfoI8bYsK08MICfvs6JpiIGz4CWCY OD95C1R0ej/wCry84t4n6b8OqDVCqGIV0J6cD9pfw64WuFU0FWVbSJtsPMx2zmSK/7y5 LVEu5MUaIqql0RF3oSrceZrZL+BCmeZaR/IYTCI2Nq+n/L+jT+4h5j/aDgKFJ6ba4JTL 9FAAxkdvv4Mvdt2zStio8QSKuYWj6VdJ15dI5iSDKlECwlrW1a9t2cG6WoPF1ECTylQe VTZd8l04gZnWi5Ls8QASZ/Hyegcw0WWLzKiwX4RVfIHc0MCvFHVZNAFcrZz4WThDuQEc mtGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+tPPtzBEHcDH0W4r3tbquzKYRRBLPCxPo3HXy0T4oaI=; b=p2Z00YhMFisgKOYU5PkCU9PgeR9hvU9WWfhCGZJWv9MhtIkE/K0aRkzn2uWxHqKFZ1 ISCOZnRY1bQQ484tJ+Z8xcZe7LaeXk1zpMTR6aRdyEhiPRhy1vW31Jpuqn7kUK6nvRSR 0azhGv0Tn9ghFLtmpHi6c9p5beRtbRHWy3m51yY87oMofZs0wlphtGbt1sriHbVxQWQE 0ActqTK9LqmtEaS1t5JM+N4n5azFStxkj2ES3bU7jU3iNGealsRIPgLegnNmfLIaaeK4 Q7ZUroNpmrHnXdwqT67wmUMKFlOCnxbTuUapsUqCd61XhLry0XZwrSQUcLe6gvCfesne jbtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si2925661plk.551.2017.11.30.02.10.34; Thu, 30 Nov 2017 02:10:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752540AbdK3KKd (ORCPT + 26 others); Thu, 30 Nov 2017 05:10:33 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50230 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752270AbdK3KJw (ORCPT ); Thu, 30 Nov 2017 05:09:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A37B81435; Thu, 30 Nov 2017 02:09:52 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.154]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 45F413F246; Thu, 30 Nov 2017 02:09:51 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] crypto: tcrypt: add multi buf ahash jiffies test Date: Thu, 30 Nov 2017 10:09:30 +0000 Message-Id: <1512036574-26665-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512036574-26665-1-git-send-email-gilad@benyossef.com> References: <1512036574-26665-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- crypto/tcrypt.c | 112 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 30 deletions(-) -- 2.7.4 diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 447b18c..cf9b44f 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -411,13 +411,87 @@ struct test_mb_ahash_data { char *xbuf[XBUFSIZE]; }; -static void test_mb_ahash_speed(const char *algo, unsigned int sec, +static inline int do_mult_ahash_op(struct test_mb_ahash_data *data, u32 num_mb) +{ + int i, rc[num_mb], err = 0; + + /* Fire up a bunch of concurrent requests */ + for (i = 0; i < num_mb; i++) + rc[i] = crypto_ahash_digest(data[i].req); + + /* Wait for all requests to finish */ + for (i = 0; i < num_mb; i++) { + rc[i] = crypto_wait_req(rc[i], &data[i].wait); + + if (rc[i]) { + pr_info("concurrent request %d error %d\n", i, rc[i]); + err = rc[i]; + } + } + + return err; +} + +static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen, + int secs, u32 num_mb) +{ + unsigned long start, end; + int bcount; + int ret; + + for (start = jiffies, end = start + secs * HZ, bcount = 0; + time_before(jiffies, end); bcount++) { + ret = do_mult_ahash_op(data, num_mb); + if (ret) + return ret; + } + + pr_cont("%d operations in %d seconds (%ld bytes)\n", + bcount * num_mb, secs, (long)bcount * blen * num_mb); + return 0; +} + +static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen, + u32 num_mb) +{ + unsigned long cycles = 0; + int ret = 0; + int i; + + /* Warm-up run. */ + for (i = 0; i < 4; i++) { + ret = do_mult_ahash_op(data, num_mb); + if (ret) + goto out; + } + + /* The real thing. */ + for (i = 0; i < 8; i++) { + cycles_t start, end; + + start = get_cycles(); + ret = do_mult_ahash_op(data, num_mb); + end = get_cycles(); + + if (ret) + goto out; + + cycles += end - start; + } + +out: + if (ret == 0) + pr_cont("1 operation in %lu cycles (%d bytes)\n", + (cycles + 4) / (8 * num_mb), blen); + + return ret; +} + +static void test_mb_ahash_speed(const char *algo, unsigned int secs, struct hash_speed *speed, u32 num_mb) { struct test_mb_ahash_data *data; struct crypto_ahash *tfm; - unsigned long start, end; - unsigned long cycles; unsigned int i, j, k; int ret; @@ -481,34 +555,12 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen); - start = get_cycles(); - - for (k = 0; k < num_mb; k++) { - ret = crypto_ahash_digest(data[k].req); - if (ret == -EINPROGRESS) { - ret = 0; - continue; - } - - if (ret) - break; - - crypto_req_done(&data[k].req->base, 0); - } - - for (j = 0; j < k; j++) { - struct crypto_wait *wait = &data[j].wait; - int wait_ret; - - wait_ret = crypto_wait_req(-EINPROGRESS, wait); - if (wait_ret) - ret = wait_ret; - } + if (secs) + ret = test_mb_ahash_jiffies(data, speed[i].blen, secs, + num_mb); + else + ret = test_mb_ahash_cycles(data, speed[i].blen, num_mb); - end = get_cycles(); - cycles = end - start; - pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", - cycles, cycles / (num_mb * speed[i].blen)); if (ret) { pr_err("At least one hashing failed ret=%d\n", ret);