From patchwork Sun Dec 17 08:29:03 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: 122176 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1514790qgn; Sun, 17 Dec 2017 00:30:28 -0800 (PST) X-Google-Smtp-Source: ACJfBos1btZorC2tW7rThGh1q+4VFp3qPZsXTOeEpOAVP3b+tUCTPAHUh2bGhmnEpNxMmSwl8h5a X-Received: by 10.159.195.73 with SMTP id z9mr19134573pln.186.1513499428238; Sun, 17 Dec 2017 00:30:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513499428; cv=none; d=google.com; s=arc-20160816; b=CW4EZL3UNCIRCBQ+TUlDiqtbrG6jtsDrXyKBJyBxBKQxzOa0efeeSHzyDk6yaTr7Av x9agXVPX0TJoE5dT2hIuZJYLbsgbHyJpCV2PtxS842oqR2wuwpTUSO8NlQsyOCaI0Db7 25xtjli7CBmx2pzXeuM2DxpjqA3D7HDoCevUAPdFv1rMepQx6569bYa4g2tS3di7+aJ/ /y/+zUkW63BF80njge7cqaT9S+KI+PKlGyYz9xj32etFGYZdKeOb14KOviRWo7wigHb9 DNc/CSqf8PUN7vlMYIspvhHgyLZD8JshKSYl3dNVxXz6PUng2zggB7uuONTi0F6q41/A 2YFg== 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=ik/8z54EtGKY8BUZ2woTOl2cRlc883m3+aGNiw7cdZA=; b=QW+TczzYBrxYLkxGj9Cy0WDE/m6mB0IFTjZqsQeR4QwYN3kMsjLUN5oaSN0SbgPHRA Y5J/isa6xyFx4jt8RzooEmeeo/3AIN02zERWPdgyCVJn3IZ3WmmN+F3b9VhG65VfAd09 6rr0tUnxEcUXStQK3lsOvhkFw/YSyzT19TSy34CDcMmwM11K6/uONZ1c41Tt/WUP+A8M 7gfA3MN5ypjSzofS95B5RdjUk09qWhyXaIlfpgLFCKib4Sn8VPB8OZg1ITU03zKYm6EF bo4oyEx7WFoJCWDNVROSsWcBIVKJ2Bq4G2iGkY+zgxk1ZPW46SqOu8nvQxucbSnALhmx YSXA== 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 71si1913261pge.254.2017.12.17.00.30.27; Sun, 17 Dec 2017 00:30:28 -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 S1753472AbdLQIaX (ORCPT + 25 others); Sun, 17 Dec 2017 03:30:23 -0500 Received: from foss.arm.com ([217.140.101.70]:40930 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729AbdLQIaS (ORCPT ); Sun, 17 Dec 2017 03:30:18 -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 1951D1435; Sun, 17 Dec 2017 00:30:18 -0800 (PST) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BCB2D3F24A; Sun, 17 Dec 2017 00:30:12 -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 v2 4/6] crypto: tcrypt: add multi buf ahash jiffies test Date: Sun, 17 Dec 2017 08:29:03 +0000 Message-Id: <1513499346-9047-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513499346-9047-1-git-send-email-gilad@benyossef.com> References: <1513499346-9047-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 2604360..e406b00 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -413,13 +413,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; @@ -483,34 +557,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);