From patchwork Thu Nov 30 10:09:29 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: 120093 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp468793qgn; Thu, 30 Nov 2017 02:09:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMZdNkG5oR9Hoer46iH8xrW7JKmrJtShWM1PaBA+x5+V+wKgF2mxpQycw2mtfoGxwBuEAD/F X-Received: by 10.84.128.197 with SMTP id a63mr2060021pla.212.1512036595255; Thu, 30 Nov 2017 02:09:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512036595; cv=none; d=google.com; s=arc-20160816; b=qsVMhpHf2sS+FYCbMl1X0obnnh9giD1xS9Ey8n3+9s6G6geRzTKXayY833XNyl5xsN WGVcWWAxRQmz7h/0ASxDk0Bi59UsP37o0cbJPM+SWl6WMzwtgju++gEwdOYee3hD3HlY mhKeK0CR48/74uDSGmr42c0xaq+mz6LL6Qvwz3BeS6RU0YYHRcfBG0esmitTJ/Df3vj0 CCOr6beJrM4aoOkAmMTcOJAFDTxD266zlHym118NsuwcSrZXOmfRNGCWRs0h/J5iQDpw CeXOfxwQf5vUB6SBxO/2HmtHnS3+SsmejR+ID6Oj9zLRFf1P/IKMBCa6B4GWBnvpVyfc FFKQ== 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=x/3r+HPn94ptP5yEY/bEpGFUUZyC9bMjfeFHGoSLvq8=; b=o49mxyKuNSWLyeQ7CmGZ5H+Iv4+tLux7g9K1tvVXnlUC1tJiyB3Wd4aalU0pG33aD5 8GPiigs8G2XFKjdfau7QQOvqkI1+TF1eVOUvlAQhYsT3wYYM7gaPimSyWu5qNryGFTkX qgztUrM/SADwLCTF+bwKUnauCMnbh+gTC7smis48VofKT4+8nqLfjED+y5ieskS+dP3R eghOsauHlJ/Fhv9AYH1AbMILLN9rDdw9VlO/v1v56tU352EH6G072R+JvnJJOK1YkflC jhaOM6wAlabxG6yg2ivUTNvr92JmnCxK16X1a/UY/PgqevXNf7B37bAB3DwGvpuCd/cX JHdg== 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 r9si3013834pfe.13.2017.11.30.02.09.54; Thu, 30 Nov 2017 02:09:55 -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 S1752320AbdK3KJx (ORCPT + 26 others); Thu, 30 Nov 2017 05:09:53 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50222 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752252AbdK3KJu (ORCPT ); Thu, 30 Nov 2017 05:09:50 -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 E25CA1435; Thu, 30 Nov 2017 02:09:49 -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 802613F246; Thu, 30 Nov 2017 02:09:48 -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 3/6] crypto: tcrypt: allow setting num of bufs Date: Thu, 30 Nov 2017 10:09:29 +0000 Message-Id: <1512036574-26665-4-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 For multiple buffers speed tests, the number of buffers, or requests, used actually sets the level of parallelism a tfm provider may utilize to hide latency. The existing number (of 8) is good for some software based providers but not enough for many HW providers with deep FIFOs. Add a module parameter that allows setting the number of multiple buffers/requests used, leaving the default at 8. Signed-off-by: Gilad Ben-Yossef --- crypto/tcrypt.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 56fb6a6..447b18c 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -67,6 +67,7 @@ static char *alg = NULL; static u32 type; static u32 mask; static int mode; +static u32 num_mb = 8; static char *tvmem[TVMEMSIZE]; static char *check[] = { @@ -411,7 +412,7 @@ struct test_mb_ahash_data { }; static void test_mb_ahash_speed(const char *algo, unsigned int sec, - struct hash_speed *speed) + struct hash_speed *speed, u32 num_mb) { struct test_mb_ahash_data *data; struct crypto_ahash *tfm; @@ -420,7 +421,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, unsigned int i, j, k; int ret; - data = kzalloc(sizeof(*data) * 8, GFP_KERNEL); + data = kcalloc(num_mb, sizeof(*data), GFP_KERNEL); if (!data) return; @@ -431,7 +432,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, goto free_data; } - for (i = 0; i < 8; ++i) { + for (i = 0; i < num_mb; ++i) { if (testmgr_alloc_buf(data[i].xbuf)) goto out; @@ -471,7 +472,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, if (speed[i].klen) crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen); - for (k = 0; k < 8; k++) + for (k = 0; k < num_mb; k++) ahash_request_set_crypt(data[k].req, data[k].sg, data[k].result, speed[i].blen); @@ -482,7 +483,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, start = get_cycles(); - for (k = 0; k < 8; k++) { + for (k = 0; k < num_mb; k++) { ret = crypto_ahash_digest(data[k].req); if (ret == -EINPROGRESS) { ret = 0; @@ -507,7 +508,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, end = get_cycles(); cycles = end - start; pr_cont("%6lu cycles/operation, %4lu cycles/byte\n", - cycles, cycles / (8 * speed[i].blen)); + cycles, cycles / (num_mb * speed[i].blen)); if (ret) { pr_err("At least one hashing failed ret=%d\n", ret); @@ -516,10 +517,10 @@ static void test_mb_ahash_speed(const char *algo, unsigned int sec, } out: - for (k = 0; k < 8; ++k) + for (k = 0; k < num_mb; ++k) ahash_request_free(data[k].req); - for (k = 0; k < 8; ++k) + for (k = 0; k < num_mb; ++k) testmgr_free_buf(data[k].xbuf); crypto_free_ahash(tfm); @@ -1813,19 +1814,23 @@ static int do_test(const char *alg, u32 type, u32 mask, int m) if (mode > 400 && mode < 500) break; /* fall through */ case 422: - test_mb_ahash_speed("sha1", sec, generic_hash_speed_template); + test_mb_ahash_speed("sha1", sec, generic_hash_speed_template, + num_mb); if (mode > 400 && mode < 500) break; /* fall through */ case 423: - test_mb_ahash_speed("sha256", sec, generic_hash_speed_template); + test_mb_ahash_speed("sha256", sec, generic_hash_speed_template, + num_mb); if (mode > 400 && mode < 500) break; /* fall through */ case 424: - test_mb_ahash_speed("sha512", sec, generic_hash_speed_template); + test_mb_ahash_speed("sha512", sec, generic_hash_speed_template, + num_mb); if (mode > 400 && mode < 500) break; /* fall through */ case 425: - test_mb_ahash_speed("sm3", sec, generic_hash_speed_template); + test_mb_ahash_speed("sm3", sec, generic_hash_speed_template, + num_mb); if (mode > 400 && mode < 500) break; /* fall through */ case 499: @@ -2104,6 +2109,8 @@ module_param(mode, int, 0); module_param(sec, uint, 0); MODULE_PARM_DESC(sec, "Length in seconds of speed tests " "(defaults to zero which uses CPU cycles instead)"); +module_param(num_mb, uint, 0000); +MODULE_PARM_DESC(num_mb, "Number of concurrent requests to be used in mb speed tests (defaults to 8)"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Quick & dirty crypto testing module");