From patchwork Mon Dec 10 08:52:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seraj Alijan X-Patchwork-Id: 10720839 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 51ECB15A6 for ; Mon, 10 Dec 2018 08:52:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4361329CBB for ; Mon, 10 Dec 2018 08:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3779D29CCD; Mon, 10 Dec 2018 08:52:44 +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 CC66929CBB for ; Mon, 10 Dec 2018 08:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726554AbeLJIwn (ORCPT ); Mon, 10 Dec 2018 03:52:43 -0500 Received: from mail-eopbgr50076.outbound.protection.outlook.com ([40.107.5.76]:52480 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726531AbeLJIwn (ORCPT ); Mon, 10 Dec 2018 03:52:43 -0500 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=qGgiE3VA1yprUoZJznsp0yCd74RsdXqUvQ4qmyj8ySk=; b=NUm+lOv37qhXYjlqbUAVCyaWEaTnrM8aJfYqh95Q8V3gsgTFF0Tf0+23tKi0gWJlOTP9WHto17fh7KHuYpQcVGm8MLDFvceiU4VV4F19e+e+P+E/0Bt62s6/jJ/XUR/qDIlgn3U+E+ucvLQ0dB333Ct0kq1HMLXfNjywxcbdrPg= Received: from VI1P191MB0255.EURP191.PROD.OUTLOOK.COM (10.172.82.20) by VI1P191MB0191.EURP191.PROD.OUTLOOK.COM (10.172.81.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.22; Mon, 10 Dec 2018 08:52:34 +0000 Received: from VI1P191MB0255.EURP191.PROD.OUTLOOK.COM ([fe80::cc1:80a8:5ce5:9674]) by VI1P191MB0255.EURP191.PROD.OUTLOOK.COM ([fe80::cc1:80a8:5ce5:9674%2]) with mapi id 15.20.1404.025; Mon, 10 Dec 2018 08:52:34 +0000 From: Seraj Alijan To: "vkoul@kernel.org" CC: "dmaengine@vger.kernel.org" , "dan.j.williams@intel.com" , James Hartley , Sifan Naeem , Ed Blake , Seraj Mohammed Subject: [PATCH V4 2/5] dmaengine: dmatest: Use fixed point div to calculate iops Thread-Topic: [PATCH V4 2/5] dmaengine: dmatest: Use fixed point div to calculate iops Thread-Index: AQHUkGWxiP72sUQ9SEioj3XlufWc4g== Date: Mon, 10 Dec 2018 08:52:34 +0000 Message-ID: <1544431926-8662-3-git-send-email-seraj.alijan@sondrel.com> References: <1544431926-8662-1-git-send-email-seraj.alijan@sondrel.com> In-Reply-To: <1544431926-8662-1-git-send-email-seraj.alijan@sondrel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LNXP265CA0077.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::17) To VI1P191MB0255.EURP191.PROD.OUTLOOK.COM (2603:10a6:800:a7::20) authentication-results: spf=none (sender IP is ) smtp.mailfrom=seraj.mohammed@sondrel.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [195.88.9.101] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1P191MB0191;6:uEsmwZmNOML63QWskX1UuN3MLD3jpgE99uBC+J4g2QoZhhgowvDQ8PPpRUT/LUZhUMpoD3B45605a38fXXhFJDHokpBS1t+U3c7n5j4JaX+Tw9GKvD2OHl831fWP6ZtAR4RdbZOIrdXjh9HDac9qkOIe3YZJUUTEMGDuKH+AfIi8/3sEo+oAzM+OcYm1ESLM8aSdpERp1c2SJkGlBIBRWgjIBsMCm6T4nUwv8EzS6dNIDw1VfXf84Ty/77MKW0DPRE3882CkIOzln/4zH6L9eWNMksd/REl0dqYxQ1571b1RtfSVzwwRwqfJwmThIpTgYtmRgbn4AFwUh/0/JSm8YRJtAhFRdnh5XrrJdO1Frbw12iH/QAkIu25Sr+lfWE0sima1YelV8hBP4aUgs9iP/dDFQvaLozZuDVy19vXnyj1IGx9gy7jK3QA+BbD9QUpF1OZst5IyLPo9zzq/uKmoFQ==;5:44/eq/VWyGd49U929uRQdyXQyO+4UnFzGh3iZQ49AeyTZvNhACsMXQCsPBzQnN/mssrlhlqAS9Mk3khvahbK0WlZGAdOBXEexl/UFV9DrpUDNDONiIDltFwLM/NdBXNOProx2T8Ur1hbiKeDOX3dhwq0T7e1TG+AIH1rBIeU+ds=;7:VZWAc2Kgblh0xmRJizz7k4166+YOGnBdrzeLnVmPWO1AkZusZXyflz8MYpKax0Wv0lNHP3jSKmGWtHU96pbOQm5SrC+DcZ+MGupe0KF+sP9dH78R+eTBhtWaKSB9/xSRCiM17fXWXNXzRPq5QMuzrQ== x-ms-office365-filtering-correlation-id: b5a2f95b-985c-46c5-d66b-08d65e7cd3c2 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:VI1P191MB0191; x-ms-traffictypediagnostic: VI1P191MB0191: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(3230017)(999002)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231472)(944501520)(52105112)(10201501046)(93006095)(93001095)(148016)(149066)(150057)(6041310)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:VI1P191MB0191;BCL:0;PCL:0;RULEID:;SRVR:VI1P191MB0191; x-forefront-prvs: 08828D20BC x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(346002)(39840400004)(136003)(396003)(376002)(189003)(199004)(5660300001)(5640700003)(6506007)(386003)(6436002)(6512007)(1730700003)(3846002)(8676002)(2906002)(81156014)(81166006)(53936002)(6486002)(76176011)(52116002)(486006)(68736007)(575784001)(107886003)(446003)(11346002)(66066001)(2616005)(4326008)(476003)(99286004)(6116002)(36756003)(2501003)(186003)(26005)(6916009)(478600001)(256004)(25786009)(97736004)(14444005)(2351001)(14454004)(54906003)(8936002)(316002)(71190400001)(71200400001)(102836004)(106356001)(105586002)(7736002)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1P191MB0191;H:VI1P191MB0255.EURP191.PROD.OUTLOOK.COM;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-antispam-message-info: tIjHjtDbPO4NfT0Q9SQbneSPlbH9eqRXzVgf0hEkflmjFUwu/e8E6DN7lCmFAUId1QFVnbDGb4Px3NOw2bJFRjiz5+gUNA0JTJezKNsbE+1LMHobHIi73MA33bv3vK/srQUweIIsYoIw3lt7q1Wl7nCZgfYtz+rWc3zCUgLiDYCnHGEps8El6kwduRpBMmxD7g/lDKPqMYf+kMeG+ECwpX9jpH63kDq10wCQbsVTs47ZKs+MYpaNgTobF9Db9F7tKlVnldh9YYMgUx99xPtDNlCJshLCPlsPhdIUgCdyeTBgmujNQW7ZdLOzW3i9USn9 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: sondrel.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5a2f95b-985c-46c5-d66b-08d65e7cd3c2 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Dec 2018 08:52:34.4033 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4faa3872-698e-4896-80ec-148b916cb1ba X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1P191MB0191 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 d192772..998344b 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; @@ -838,9 +848,10 @@ static int dmatest_func(void *data) err_free_coefs: 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 */