From patchwork Wed Sep 19 19:52:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seraj Alijan X-Patchwork-Id: 10606429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B35AC15A6 for ; Wed, 19 Sep 2018 19:53:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2F0C2B8D5 for ; Wed, 19 Sep 2018 19:53:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96C5C2BA2A; Wed, 19 Sep 2018 19:53:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D2B62B8D5 for ; Wed, 19 Sep 2018 19:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731914AbeITBc5 (ORCPT ); Wed, 19 Sep 2018 21:32:57 -0400 Received: from mail-eopbgr00060.outbound.protection.outlook.com ([40.107.0.60]:27849 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726718AbeITBc5 (ORCPT ); Wed, 19 Sep 2018 21:32:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sondrel.onmicrosoft.com; s=selector1-sondrel-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f+bp77MumYvrTQ9byzeUmydiHMcraI2bZ4uVGYg7zJI=; b=c1fbUj5vU+qOEfw48bTJS/GFk00BpQfMpp2FG9rCq2sI3hqFcozPjqVaUYNh6QdMpEfEBY85Vky1GJWDeO6qrZyzsIotUdQKVe4sE16sW33CC5QAPqRlF0+HUzL8fZhZxWJbRm/g+DGxQPAEKQ7oy28bgqq7v1Uhw1gQY6LVDkI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=seraj.mohammed@sondrel.com; Received: from Seraj-pc.hh.imgtec.org (195.88.9.101) by DB6P191MB0245.EURP191.PROD.OUTLOOK.COM (2603:10a6:4:8e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Wed, 19 Sep 2018 19:53:22 +0000 From: Seraj Alijan To: vkoul@kernel.org Cc: dmaengine@vger.kernel.org, dan.j.williams@intel.com, james.hartley@sondrel.com, sifan.naeem@sondrel.com, ed.blake@sondrel.com, Seraj Alijan Subject: [PATCH V3 2/5] dmaengine: dmatest: Use fixed point div to calculate iops Date: Wed, 19 Sep 2018 20:52:51 +0100 Message-Id: <1537386774-20749-3-git-send-email-seraj.alijan@sondrel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537386774-20749-1-git-send-email-seraj.alijan@sondrel.com> References: <1537386774-20749-1-git-send-email-seraj.alijan@sondrel.com> MIME-Version: 1.0 X-Originating-IP: [195.88.9.101] X-ClientProxiedBy: CWLP265CA0040.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:11::28) To DB6P191MB0245.EURP191.PROD.OUTLOOK.COM (2603:10a6:4:8e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ea4fc69-eabd-4880-4769-08d61e698e84 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020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mRTFHRODWkYyp+SyUn/MvVbupG/T66qR6CCkxoWxEffts7YPJR1pn677EUVanPIIX13693+mN+DT1rdQHDOKZi+spWc2BAxJpHHgw55jWTdc5X1ykdmQlFaSb0VKZWt1ChCbYtiGxqycjZ6JCWA5Fi5f+Hd0dla7uYOpDCgXi3NBM42caw6hW2Jt4j7ZJqqj10I2mQibDXSnhGUboNfciFoM4x0SjfsvDOm7adJp+Z4o4BOFC7Q/5rpShkWuEARoSBGJpVpxwjvw+cNnH2YyLGOE8SwIQKSespatA2rqDDppmJzZoDt7aBVeags/7tCAyxhTJ1Dp9uAFazgeHTUIYJRZ+ylCmH6XVI7ZQIYZ7wamoEsRwsP1ajasFp5CZYO6tQwjSy8uBLLKAqpVm9yd;4:Nm7bmuyZMU/gXggeZbby6wWk/myHlO/E9rmFln1+G1/6yQKpogZLZ3fjOWQqHaAIGHG0hyiyifUgbgbL+2LqStnKn2ocXajwHtkxOUsk30+U9WDyqrSVTvLxTaDTN1I22elQnaXRVRJgsNKENeAVgLk+8rDqi5akZoxynPNSE7wQiLa6gavrjcP6XFS3i7zQ9YazSKBBN4A0DYMb+IqZ5hjJP1XkcHeAv+1/4nE4oYSS0dk8BeERwqyb45WxymN09Cv3tvpMe2tml00Zf9S7IKhkEjHVsR2m0lrPd6yXeKLlSNtPe53aOXp87oQzKa+V X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(211171220733660); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231355)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699051);SRVR:DB6P191MB0245;BCL:0;PCL:0;RULEID:;SRVR:DB6P191MB0245; X-Forefront-PRVS: 0800C0C167 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39840400004)(366004)(396003)(136003)(376002)(346002)(189003)(199004)(316002)(16586007)(53936002)(25786009)(5660300001)(2351001)(76176011)(81166006)(50466002)(52116002)(51416003)(2906002)(36756003)(6916009)(6116002)(3846002)(14444005)(575784001)(48376002)(8936002)(386003)(478600001)(81156014)(6506007)(66066001)(97736004)(486006)(107886003)(2361001)(105586002)(106356001)(6666003)(6486002)(7736002)(6512007)(4326008)(47776003)(50226002)(956004)(16526019)(11346002)(476003)(186003)(2616005)(26005)(44832011)(446003)(68736007)(305945005)(8676002)(16060500001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6P191MB0245;H:Seraj-pc.hh.imgtec.org;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: sondrel.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;DB6P191MB0245;23:029UXt9MYKxSdwEKN1EcpT1Ar5m5HuKXNiNgZ4a5Pd90MybWa2yBGe3lW/uln2meU9XQlLLSWzNe2sYQ/mjW/8O/r3I/2OJ7FPq+3ffo5Yn0mH0FfzvrzMhyIXYEZT4VnEe4y06e8YJXVKE9qLwE87OY88i3yZJnkNGdgzmki8U3Y7hiQHR9vKCYd3+YKr6GJ2pFDIsk29QHvm/HfcZcKnpC79a+XUFP2Rs0Z4BTWsB2oSUuGcFvAq94s5urT5cv1l5RxWMwpi0G2AdRj1NH7BvFIr9/Tv+y9D+Y98OyMlbip/ln+uh8e/A03NDNMA3lUVqTqDYX+GqW+dxH5cWoF65KyIL0CdLm3vVkC1W4CfqdhDGVuJf8vLUujfYD6qSK6CZiZ44Bx4nT/HACX/IupM+j5ym1vrWtMD5wyiKvs84XIb4SFig6+9+JV66vUV8uHqR6IiEHNdTr3hdkGyQm4UstvNeTowIyOlTmsfNqZquUDQofmrnCUr4LsygfawEwzl8548GXOf+HcJ7L0WxEHfUUUZhSxjVeTRl+UJUK1WCxZGCvMXSNGJTwqRN3J5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Nbtayc0f3I2w3gs4RTBwNdc514Mjk3xLc40= X-Microsoft-Exchange-Diagnostics: 1;DB6P191MB0245;6:1XJL3XTt3t1BumVhMKSBvJC3OEJU31JMQtPmYwk9gbCTViz+b712gQO4TSRL3itNiRC13nF4S2YV0OQ8GFoqB3Tc82ops655+nuH7Vx6ohSxQfIA5h9ckp9y5cWnn+bAqp6AhRfldDoT5sOUlNGnNv5UGrN5kOI4p7eWUraglJciZ6NkE6rKiA5deVOfOe6/UlUL3B32Nbhzwa0wMoHCcZsCMAiVFeDJdqH6y7AWOvt9o/jrbpfrZ0Bc7PuLWRuEZ15fTz6aeZV+MeOwR0++CpePft08QW0AA6/blQjGd7MvOsgPnhq1DVNxXtcF78mMaCNuDQ59N+q+Ow9T3bOSHMpcaKZaeZDM+XJUDrrN8zem/8rev+JTZVJGjmMLCirvmTucKfKtvNptluA3ObiOzCxKNzTwUk1OAuujoJBIFv/LB+sEUSGsaN0CYNT4dWMg6TVk/w2zV/prbAgdTsxF7w==;5:Sjk7uIjl2EleZOB64R/hFjhcu7+2TUcfIN2lVj/sPtwvwP30B/8H4pYDcU07mnGQcKTESxk6kx+skb1J50ZebXW67N98zoBW2vG45Pu/MhqUOk0uVKZrsg2L9cVO3En/si4EP6Z/z1753cRDkxpZe3Rn3kyDc8ngT01pGNRMDp0=;7:Zln0szyROXfDz4nkHO3RVwlsfI3CT20bbVI50EsSv89xjBxBZOLBVN+8D4TfNEPf8sZ+FFnDUcstHTYR9N8eU9bUgYAcxU8HTLB8u3LnRfj8i+8w/x2HNTNiuACjDwvErJhBQymGeR1A4t+QjnxQ0QcGuwFzQ9H+Ja3CYvB9c/5bW+CwwUauvUXng4Stzr9WzXHUg16NERdVr4lIbwqh8ePc+784ocOUn1zT/v160elwIcUTGSdJM4413kbmXxiX SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sondrel.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2018 19:53:22.8574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea4fc69-eabd-4880-4769-08d61e698e84 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4faa3872-698e-4896-80ec-148b916cb1ba X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6P191MB0245 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use fixed point division to calculate iops to prevent reporting 0 iops when operations last for longer than a second. Signed-off-by: Seraj Alijan --- drivers/dma/dmatest.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c index ea69033..22f0e4eb 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -177,6 +177,13 @@ MODULE_PARM_DESC(test_list, "Print current test list"); #define PATTERN_COUNT_MASK 0x1f #define PATTERN_MEMSET_IDX 0x01 +/* Fixed point arithmetic ops */ +#define FIXPT_SHIFT 8 +#define FIXPNT_MASK 0xFF +#define FIXPT_TO_INT(a) ((a) >> FIXPT_SHIFT) +#define INT_TO_FIXPT(a) ((a) << FIXPT_SHIFT) +#define FIXPT_GET_FRAC(a) ((((a) & FIXPNT_MASK) * 100) >> FIXPT_SHIFT) + /* poor man's completion - we want to use wait_event_freezable() on it */ struct dmatest_done { bool done; @@ -453,13 +460,15 @@ static unsigned long long dmatest_persec(s64 runtime, unsigned int val) } per_sec *= val; + per_sec = INT_TO_FIXPT(per_sec); do_div(per_sec, runtime); + return per_sec; } static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len) { - return dmatest_persec(runtime, len >> 10); + return FIXPT_TO_INT(dmatest_persec(runtime, len >> 10)); } /* @@ -500,6 +509,7 @@ static int dmatest_func(void *data) ktime_t comparetime = 0; s64 runtime = 0; unsigned long long total_len = 0; + unsigned long long iops = 0; u8 align = 0; bool is_memset = false; dma_addr_t *srcs; @@ -840,9 +850,10 @@ static int dmatest_func(void *data) err_srcs: kfree(pq_coefs); err_thread_type: - pr_info("%s: summary %u tests, %u failures %llu iops %llu KB/s (%d)\n", + iops = dmatest_persec(runtime, total_tests); + pr_info("%s: summary %u tests, %u failures %llu.%02llu iops %llu KB/s (%d)\n", current->comm, total_tests, failed_tests, - dmatest_persec(runtime, total_tests), + FIXPT_TO_INT(iops), FIXPT_GET_FRAC(iops), dmatest_KBs(runtime, total_len), ret); /* terminate all transfers on specified channels */