From patchwork Fri Aug 31 11:03:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seraj Alijan X-Patchwork-Id: 10583613 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 22CAD13AC for ; Fri, 31 Aug 2018 11:04:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 102092B486 for ; Fri, 31 Aug 2018 11:04:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 047F02B55E; Fri, 31 Aug 2018 11:04:30 +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 8F4202B486 for ; Fri, 31 Aug 2018 11:04:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727741AbeHaPLZ (ORCPT ); Fri, 31 Aug 2018 11:11:25 -0400 Received: from mail-eopbgr60067.outbound.protection.outlook.com ([40.107.6.67]:41216 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726990AbeHaPLZ (ORCPT ); Fri, 31 Aug 2018 11:11:25 -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=s6odmDxp7LgTxT9anY07sJ3vGJOKaf7hnYq2OxeXt/w=; b=P1OdJn7ULyxEKF20sgVAuJiPUFM89mFeOQGpOrN3VN9fX+1dojcjcbJc6hjt0weUKx2tO9NekScAhHyBFAmJOdriEYre2Q/ZSnkTLIKpUhzMPPN2yg6AQ9JSJt/rUShIGWQzAxJNy8BCRfECtARt9idcMSZ5kzenfS9n1s4BGHM= 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 AM4P191MB0243.EURP191.PROD.OUTLOOK.COM (2603:10a6:200:67::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.14; Fri, 31 Aug 2018 11:04:24 +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 V2 2/5] dmaengine: dmatest: Use fixed point div to calculate iops Date: Fri, 31 Aug 2018 12:03:41 +0100 Message-Id: <1535713424-11322-3-git-send-email-seraj.alijan@sondrel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535713424-11322-1-git-send-email-seraj.alijan@sondrel.com> References: <1535713424-11322-1-git-send-email-seraj.alijan@sondrel.com> MIME-Version: 1.0 X-Originating-IP: [195.88.9.101] X-ClientProxiedBy: VI1P195CA0048.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::37) To AM4P191MB0243.EURP191.PROD.OUTLOOK.COM (2603:10a6:200:67::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30b7d083-cde3-4ec7-a00a-08d60f31830d X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:AM4P191MB0243; X-Microsoft-Exchange-Diagnostics: 1;AM4P191MB0243;3:OSA5h3OH0vMh9GrDaGy5L4IQtABAl4O/iA55CDSBPmCvAuNfaATCb/JhKd98ul4LtVMUiviExSErcE9ChqQcAMpMVqh7QCp4T0Ha1ug1A9GZslSvebA62+bvC/wyD+E2fwSELHFByoNMBkfM0GKcayV/NvP8n4fVsMZ6wlRkYt+sibrOF/QQvLKxR1dwQ52aRP6iK+mBCe+x56pPdZNBsWfLKF49TbUVgN9HmDmz3wFQ2PBlJ4pYnW9hBkMR2jUH;25:EA97eHNYb9msC4CcW4Osl9cANyTAEqg9CizNTkO6LJcymqSEkaRQS/6hpWqEEJQRB8r8PqLl+waLT4DPA9+wUpBJg5MQt9Wa0DzgQ5D6YcyxijhkPwgawfAQNE0K8ddW2AQasDnhbMoVnuh5HGv6/6O5Y/sEpoS+KtE8VedWyg3KFPfCcm4HyEJUq4tCPN1NDyZ8rx/WCYXBU6YseJyf5Xay0ItyFfkTKHuHeqntjePOvW/wu0vcKqtQ4yx3QzNBq1tMFdD0CvCCSrP6iTUF803Tj5bUd3JyX7jXjMi7/eCH1W2Sx+BK6XvDu0gJj9MiVeqDOsUgNnDpm+rroognGw==;31:h3E+UILeBrtH+FIBFa/FKrAl909vOussPlU4ZDvanpMw7JAe4L+O1nvVz3yCpQywwrc0ANeXrFb6zWc8axIqHx3O1g50+c8JV/jlxsjzw0u/4B3hTnikCTirgfCaqiYFzN5ppPmRHr9cyltyOTVbgpr7TKABBIkWMlAwoFCjQro6mDPFNdRKy6PojAp1vS5mEQZW7U6L52uT/HA/HMFxZo71vXBmrGq3o6z5sMQbJxg= X-MS-TrafficTypeDiagnostic: AM4P191MB0243: X-Microsoft-Exchange-Diagnostics: 1;AM4P191MB0243;20:/QHgnIo1EBjCGWFH3svPO7n3SEkigduUNALRvdwhaH7tfjQI8lx56K9I9hdDoTq7mRkOBs3u3l4an4lBJXz9C3/1b2eDTiazQjuDSUe07NrlMremF9ddbGhvf6p2QbGSEnf3+Ez36G+cktUBaN3OSj81g0BL0NvSgHpzJUXACJMhrkF4QshyyLpuISu0eZTQo4lLEUcgPDofBtiYvbVYu/3uCImyAIDLoyVMLEKYjV1lJyj44FPKU+R/mQWoavq/Qi9sKFfPCVjsyEypebSi3plVaYH0BpDR6TZdaxzeGynBRzyM+IC5kK760GPOeJFk+eb98HM2bEotyQlJl0LSiT7CcdsLcz9fsm+7y91A8dfiJzu0giK7a9rLqwcME/gz+QpDmaPg+PHc0jUkWZRWa/Nb1hffDwwEFhzQbk2I/qG2KflekHGFEjHTBMrQD/MpT7jhB+QWEErFc7R4Jlrcir05qeWw+gLluH2wabIlxFIzbjGl2BZ2iFfS+aqoRZq6;4:QHgcleH9kT0XJrJKOWAc5C8j6SGfzCs5Ml1R/Mn1oeMN6WBgbTFzP0OCmpDX3A9JI3Geljq/hdsSzuMffBDh3a3mxJAQbgI5MXLaHhEiBl2CW9he+q79RE4UTuGW47bxwTtfdUcA70/89JmmjwKv/xsHDwJx8su2dWsobcpofUVUWZjpDrxb7y9TqFfLrJ55Xfvszgqu+9NIQW2oWvk9d3OWgaAeKDMDTQLvftRnaQGwloPeZIkXDKl3BFa/7d4YKm5HWk21LSdnxzJBAyQfp8y4/q7P1+4xBqEDv5aLyZsVwNDODLW70SXCVJmeywFC 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)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201708071742011)(7699016);SRVR:AM4P191MB0243;BCL:0;PCL:0;RULEID:;SRVR:AM4P191MB0243; X-Forefront-PRVS: 07817FCC2D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39840400004)(396003)(346002)(366004)(376002)(136003)(199004)(189003)(6916009)(6486002)(386003)(5660300001)(6666003)(53936002)(478600001)(6506007)(4326008)(16586007)(6512007)(25786009)(97736004)(14444005)(305945005)(107886003)(52116002)(51416003)(48376002)(76176011)(7736002)(50466002)(81166006)(36756003)(81156014)(8936002)(3846002)(16526019)(316002)(66066001)(26005)(2351001)(6116002)(50226002)(2906002)(106356001)(446003)(68736007)(11346002)(186003)(105586002)(2361001)(486006)(47776003)(8676002)(2616005)(956004)(476003)(44832011)(16060500001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4P191MB0243;H:Seraj-pc.hh.imgtec.org;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: sondrel.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;AM4P191MB0243;23:euZ54xmJRnok7tpO4vZvwtWuTUCgOKjVCsfM/ZzskPYDWJTtagSBTFUqAsm/1DeLKGbmjQ2KjdS/Pwz39u27vVH/vP+BhpQw2I7idNUvxUa/oOOXNrkWNEUj9j/vtWBjnJXP7cnHdCzEyrEGHwKEzBPeEADxFIervp70iyC2WqyyFHacqkKNCO84UzJsQTaNy67QAHkb27ov42wrbaa9n3IZGu1BE9bBT65/AIFS+GJydmMDYBVDfu+NfzC8D+G+xJMg2kUHLOILa1+5Qlj77jjuKeNm5e5ghTwhV1DHH91+eo38hlYx5Hv9bWx44Daa7q4vkhnn1FMGNO0LwUA1q8wUoQ1U8i521rrKZckbGuz4UjVU3OVFLBzrR5wvsGJSOC+Y3uCmH7NFGOMEQBrv/D83mjcMdEpctSA5ereqjQmXmawJ6kIY682CHAO/eHvGFUTs9DI9HMilFd9Z3IR9Q8kgqRoMwwbH7lW1T3sK16w0WnKWUaZgHxaDCJkVOMeuMs12wwojn2lXB8ulMVWTVczvNkxvuP7KXECWSePQOVtUtPQWCX6HsEUfNPDJy1YHy1N7+uD20fnMajiZjFQGdzS3LAbX/lcxGWvnRh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4P191MB0243;6:OTiWFWmauL/EJBHTtLeDT8SlVEpPIEMcDfe7A0+qzrWtO3QVza949VYR8H2zgMcq+f0Zr0HdKgS0Ct0YuXS29TqBEL5B89DSS2GaW7LyjNYA4IEtUqNien9iFXtLRw8y8LA/G0m8jwRQVAzyznhDJuTH78GxqZgGTx7gjoDagttC3By4BeCQS9nVrWTw6bjwCwHNcDFJgVrrHzPBGMlwLJHElNgCyOXKeGKLTLCFhqahCA5XucAPYsjaLKvhYzaZRvWwKm+As97HZUHPneSgBCGyEjh1ymPcRIky6TwANrndnnQ0seFWV5rQVQ7O7E9yNx7pbQ/llcWYaKM9B3tdXU/QRAU85nGwt7pY7nVzVA+VbuJwkaoxa+QGvuJQJQyq3EfZ7bqTpkXtceSS6GNJAhv87fifxOYkInTnnMtWwhjBu6vZBGLKvQuhqrunq5eH4gad7kg7jiCUxlwf8UwjGg==;5:8FldDSsyM3sPtUO2FGJbnVSxJtzbjf1WzaRrY2SJA2QrIx2LA00Vy4HmnUi8IMfEuLd4lTo7hTYXmuZ3sm5peirogSOqF0Q557PcB/eEaPhTMb/ZnrtNkEdZTd4dbPEL6lgAwE7mYoYEyyDss+AT/9X2IY9aUgX2eDUte+xPK/w=;7:HK/k0k/Kmf9f+iH+khCZRasumqmK7MjfjpezIliS07Vidw24fwT2tmeLiOXig02d8U/Vwtgz0HEGzYa83O+jWDHJmjcZaL9GpokhVPBztQlPcAeHC2+Aq7Rgp+/xqn/j7x4BXlF9tOQDEgZ/vyxEtUqi5H5zpy5VM8qaE0Vlg9eJD9MW5IiioAW0ZgsRwkz/8REGx70FIXSzfpnlb77BbGULesgjJs782KrDZpbHfxiIAYPGuN6pd4HpmENnWH/m SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sondrel.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2018 11:04:24.1338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30b7d083-cde3-4ec7-a00a-08d60f31830d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4faa3872-698e-4896-80ec-148b916cb1ba X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4P191MB0243 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 8ce3b06..3c55190 100644 --- a/drivers/dma/dmatest.c +++ b/drivers/dma/dmatest.c @@ -170,6 +170,13 @@ MODULE_PARM_DESC(channel, "Bus ID of the channel to test (default: any)"); #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; @@ -446,13 +453,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)); } /* @@ -493,6 +502,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; @@ -833,9 +843,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 */