From patchwork Fri Apr 28 12:09:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 98353 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp232035qgf; Fri, 28 Apr 2017 05:12:19 -0700 (PDT) X-Received: by 10.36.250.4 with SMTP id v4mr710716ith.13.1493381539614; Fri, 28 Apr 2017 05:12:19 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i15si5760899ioa.30.2017.04.28.05.12.19; Fri, 28 Apr 2017 05:12:19 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2E5DF62C36; Fri, 28 Apr 2017 12:12:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-4.7 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6357B62B68; Fri, 28 Apr 2017 12:11:37 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 17AE760A79; Fri, 28 Apr 2017 12:11:29 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10127.outbound.protection.outlook.com [40.107.1.127]) by lists.linaro.org (Postfix) with ESMTPS id 1C2A262008 for ; Fri, 28 Apr 2017 12:11:02 +0000 (UTC) Received: from HE1PR0701CA0055.eurprd07.prod.outlook.com (10.168.191.23) by HE1PR0701MB2124.eurprd07.prod.outlook.com (10.168.36.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.1; Fri, 28 Apr 2017 12:10:59 +0000 Received: from DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::209) by HE1PR0701CA0055.outlook.office365.com (2603:10a6:3:9e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.1 via Frontend Transport; Fri, 28 Apr 2017 12:10:59 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.240 as permitted sender) Received: from mailrelay.int.nokia.com (131.228.2.240) by DB5EUR03FT054.mail.protection.outlook.com (10.152.20.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1047.9 via Frontend Transport; Fri, 28 Apr 2017 12:10:58 +0000 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v3SC9wl0001679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Apr 2017 15:09:58 +0300 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v3SC9wn8001645 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 28 Apr 2017 15:09:58 +0300 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Fri, 28 Apr 2017 15:09:57 +0300 Message-ID: <20170428120958.17526-11-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170428120958.17526-1-petri.savolainen@linaro.org> References: <20170428120958.17526-1-petri.savolainen@linaro.org> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.240; IPV:CAL; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(39410400002)(39840400002)(39400400002)(39850400002)(39450400003)(2980300002)(199003)(189002)(9170700003)(305945005)(8676002)(8936002)(81166006)(5660300001)(47776003)(1076002)(53936002)(50226002)(5003940100001)(86362001)(48376002)(50466002)(36756003)(38730400002)(76176999)(105596002)(106466001)(356003)(2906002)(50986999)(22756006)(189998001)(2351001)(33646002)(110136004)(2950100002)(77096006)(6916009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0701MB2124; H:mailrelay.int.nokia.com; FPR:; SPF:SoftFail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB5EUR03FT054; 1:ccG62bLJw/8574td/04Qe+kg14u6a+5SUz5MEAHUWpTBDjmyyxLU/8Wl4bQsNpMVKqoEzZAYmJnNXwet05CZKa7XDVmH3s5We2gw/tD4tUMdwzIiF81XMUQH2I151Pkm32Y54tlEBQYWowy8yfiIDu9RUO3+0eY/7NpHqZ0UYTpR3CnTbmmPz8nbpYO/laWqftw9m8a1zGlkZJNJBHOGOvlMwPeidcAkePlz/8ENI6qDYukfaCK6EQla7DB/XFEHxp6BdGV4xzjC5sHJOIGlPpICEc1GI55SkdRxIwQQnJZ3O1dAZ5507354t6F4D5Q8xKrkXCMzRaud0rR13ZeNZxjfTa9nOlgbInHgqCV48Cebn9QypRUdvlfWTh1Orl50nHuNXzafBZ0pORaLKU6t7gpdw/BqS0OquoADKonV3QHTunozOohuQkOJC9SD5iCqXbHNm061IOMVBsluVuvfobJGgcgz5wY6AtpwA4crxvxoF0HQS+Uukpf+9drA0gljV/Xhm/pbfR1mx2VPHlDvNw== MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 270d8239-b9da-4848-3909-08d48e2fa16d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081); SRVR:HE1PR0701MB2124; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2124; 3:62bcI8JS2C/TG9AhIFzf30VpLsJeTTLV2hkJfFMeMnwTXxsiVzEKXVhycIGrO1Zn104um8UaBDV2TlNI6cmpCHA3O6/kbEOTwte2DhFOnC3tXSop6o0QIToyEFU0FewzyDQyBS06AxXIZ5pwftgDDsNsDxZkoqR4CbGP3/yx28GrEM++dBINkZMkONworCqp9mLffd2t6e+4gmNmOVmcosAeh8R9qhS0eTmyUZ05aX5nJDSaLdVKMyumxh3Co/0XhBOHa4+TTFafc0IMcqfS6zxd4Ve1WlEyNHEvPOgslbHD+x0yAw8e3gXdvVzDhTJqCEEy3HfOOv2nCNd/qApJHNeCQJFJ0LSiImGrxHeUj8R9LZyw5mKfaV67fK2SWu06rAkJoylUErQbPL6ufEDgK7VWAAe6vTqxqjhslgw+lkQt7up0O4r1VXAYz49fIkr+abbP7+vaEdRFa4nTWzQB3A== X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2124; 25:UUB1YfHvJF8Bvj2LzyA+slxQu15FFmSSerymo0F5gY9HMUsFC7eLW2EDdeCFOb4c6yHu56KUGHLCVnBgpFzKGaH0qQaB5M461hfFETd5TWqOWZqSf49Lin3TOm9W14jV6KhbFaZs/CVxsYpX6xQIycjkASRBlskq0uHEFVJZCeJVQ40aeCu49z0LeuUp15WdL857lhAVnxdHcDCvcTt6lZYDSxESGdUgtACJeEGvcfrz7zsLb+uj8nbCQWwg6vbyUkvbY1W0xDXL8TIlKlchUcW9BJbqx+SLRZGGo19TZNVSuT+jKBi9EdbDsZ5DtalBNAm6n2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KDDyG6Ogl4A73m8EVnLxsy4m2Kl37Ik3w1QTO+wP/q1KeEKgw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13021025)(13023025)(5005006)(13013025)(8121501046)(93006095)(93003095)(10201501046)(3002001)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061750153)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(6072148); SRVR:HE1PR0701MB2124; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0701MB2124; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2124; 4:jwpx/zh8vMTi/P6Cp+h+EBoMAWzKzwlvrhOEC8vjLyEqItV10VxOQNIJp1ePuLfbTin6rNFWOTA2dBFl8ldkeRONnClHe/8Z61Gl5oqEqUhWHJ/zHzYotm4gfRn+7QziD8+voU3Pk0dv/JdcrFrEs6x7hUMlZsy7a6msfS1uf1MfaHkVh+LcVn1cm7wWc/yVhHfSfLdyxOg0mhEHU1LJX7keSGg36fdhHHhaIfzXBmyev9seJwm6XJKeZx9vxkcXXIdYZWYt1VrsEFU8zRY1ryItnJhtIIalgHgZNYkNZkm7jO5ONmp7VsxvPyMNCtnUxtpZZHXYIqlAycQlLSbg2w1vsunAHBRbTtmJlJ2i67V4Jx4xpEK40tTP4U1ZryJ+LvJbbDjoek70ZpbLYaYRv4aSGM04X/O8HW5pAeKdw9bcMO3nEV0eB5yC0Q7eqwI69SA87iZU86KgFXXMtz0U5v7STfNS/WCBdZXUZcktMUO+m9RL5Xl3Dw6oP3wNsmnZhZ7swyPZd7+mxiAj+qR4qM6NJBPGmAP8kZjG2s9BTa1OMpKaJUM4iTRXqjygTs46a1mmfmwfQ2z+sbuDf8KfhEdxXN6dVoF3AwlJpZ5I8IsrM4VlYYZd6XVRA/xaO9XmZUbSPCo11tZDd3FLHsZWi8k+q0svE2dYByMaWzh/DK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q/aQpY7g+XdH/UWQJmkc6XJ42fYnDjnk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2124; 7:bngMz0IYC0HkUOQ38/x8gPbVeR3BEcXf9opT5qpTnqK7bOIcNIt7D6kRCWW3j/thzErOA2GTq9f71o2gRmEXX69AV47NBB+fh0urLKGX/PiQAQ6k5TGmlS/+oF65HndzOSNwz7fgwMCdr1PISkBzqVKgyWVmClCXSsLoYcOG0m7HyqdSz7A+4Qz9A4EANS2OtC+ibWrI2qBPPC8RisPJS7VwInIVVn9MnbaVAmhqctXqfAm6nn/gXH3UqEIf+ca7mBM+lh3kNJp47i/DiiiB+M2aGdOZn9yu5N2yYBahRRjb0GqGCxd8ns2kcILr5f+LjEe44efMD00YGP56nGrT5A== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 12:10:58.6948 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.240]; Helo=[mailrelay.int.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0701MB2124 Subject: [lng-odp] [API-NEXT PATCH v3 10/11] linux-gen: time: improve x86 TSC freq measurement accuracy X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add short warm up round and measure over a longer period of time (250ms vs 100ms). Signed-off-by: Petri Savolainen --- platform/linux-generic/arch/x86/odp_cpu_arch.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/arch/x86/odp_cpu_arch.c b/platform/linux-generic/arch/x86/odp_cpu_arch.c index 9ba601a3..b1da428b 100644 --- a/platform/linux-generic/arch/x86/odp_cpu_arch.c +++ b/platform/linux-generic/arch/x86/odp_cpu_arch.c @@ -54,11 +54,16 @@ uint64_t cpu_global_time_freq(void) uint64_t t1, t2, ts_nsec, cycles, hz; int i; uint64_t avg = 0; - int rounds = 4; + int rounds = 3; + int warm_up = 1; for (i = 0; i < rounds; i++) { - sleep.tv_sec = 0; - sleep.tv_nsec = SEC_IN_NS / 10; + sleep.tv_sec = 0; + + if (warm_up) + sleep.tv_nsec = SEC_IN_NS / 1000; + else + sleep.tv_nsec = SEC_IN_NS / 4; if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts1)) { ODP_DBG("clock_gettime failed\n"); @@ -85,8 +90,12 @@ uint64_t cpu_global_time_freq(void) cycles = t2 - t1; hz = (cycles * SEC_IN_NS) / ts_nsec; - avg += hz; + + if (warm_up) + warm_up = 0; + else + avg += hz; } - return avg / rounds; + return avg / (rounds - 1); }