From patchwork Wed Aug 24 12:43:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 9297617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF1DD60757 for ; Wed, 24 Aug 2016 12:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE6B3266F3 for ; Wed, 24 Aug 2016 12:44:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1CCD2858E; Wed, 24 Aug 2016 12:44:54 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2B8AA283F6 for ; Wed, 24 Aug 2016 12:44:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcXW7-00009P-95; Wed, 24 Aug 2016 12:42:51 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcXW6-00009B-2p for xen-devel@lists.xenproject.org; Wed, 24 Aug 2016 12:42:50 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id B1/F0-12614-9469DB75; Wed, 24 Aug 2016 12:42:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsUyZ7p8oK7HtL3 hBuveWFp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkN97rYC5YLVnRs7GJpYPzI28XIxSEkMJlJ 4sez5cwQzm9GibfHLrFDOBsZJc7PvwHlNDJKLGqZz9bFyMnBJqAn0Xr+MzOILSKgJHFv1WQmE JtZwE+iadcBVhBbWMBf4tPpXrB6FgFViXVzTrOD2LwCnhK7Vp8E65UQkJM4f/wnmM0p4CVx68 g3FhBbCKhm2ZoNrBA1xhLtby+yTWDkW8DIsIpRvTi1qCy1SNdIL6koMz2jJDcxM0fX0MBULze 1uDgxPTUnMalYLzk/dxMjMFQYgGAH4/c/TocYJTmYlER5w5v2hgvxJeWnVGYkFmfEF5XmpBYf YpTh4FCS4N0+FSgnWJSanlqRlpkDDFqYtAQHj5IIby1Imre4IDG3ODMdInWKUVFKnLcCJCEAk sgozYNrg0XKJUZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnz/p8CNIUnM68EbvoroMVMQItb7u 8GWVySiJCSamBcto5T1V4wxfxb+X5twatx5zlecqhO0L/q2HRby97w38cZ+t8810w+dqzue3T O0mtMOnkvTpetf1j4OXuHr1bvJ58k9l8C2jbz9X5vVXdkb1S62ZfXtW62hV1LUOl74ZqUbY+d jc9tP8/S0cEYUve+sCpyDnPUp3sN27XbLoR+36m+a0vCsvNKLMUZiYZazEXFiQA54wsVjwIAA A== X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1472042567!54401623!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56900 invoked from network); 24 Aug 2016 12:42:48 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-5.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Aug 2016 12:42:48 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u7OCgh8a026519 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2016 12:42:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id u7OCghnb023230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 24 Aug 2016 12:42:43 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u7OCggUH029863; Wed, 24 Aug 2016 12:42:43 GMT Received: from paddy.lan (/89.114.92.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 24 Aug 2016 05:42:42 -0700 From: Joao Martins To: xen-devel@lists.xenproject.org Date: Wed, 24 Aug 2016 13:43:49 +0100 Message-Id: <1472042632-12883-4-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1472042632-12883-1-git-send-email-joao.m.martins@oracle.com> References: <1472042632-12883-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH v3 3/6] x86/time: streamline platform time init on plt_update() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP And use to initialize platform time solely for clocksource=tsc, as opposed to initializing platform overflow timer, which would only fire in ~180 years (on 2.2 Ghz Broadwell processor). Signed-off-by: Joao Martins --- Cc: Jan Beulich Cc: Andrew Cooper Changes since v2: - Remove pointless intializer and replace it with the platform_time init return. - s/plt_init/plt_update/g --- xen/arch/x86/time.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index b2a11a8..a03127e 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -526,17 +526,31 @@ static s_time_t __read_platform_stime(u64 platform_time) return (stime_platform_stamp + scale_delta(diff, &plt_scale)); } +static void __plt_update(void) +{ + u64 count; + + ASSERT(spin_is_locked(&platform_timer_lock)); + count = plt_src.read_counter(); + plt_stamp64 += (count - plt_stamp) & plt_mask; + plt_stamp = count; +} + +static void plt_update(void) +{ + spin_lock_irq(&platform_timer_lock); + __plt_update(); + spin_unlock_irq(&platform_timer_lock); +} + static void plt_overflow(void *unused) { int i; - u64 count; s_time_t now, plt_now, plt_wrap; spin_lock_irq(&platform_timer_lock); - count = plt_src.read_counter(); - plt_stamp64 += (count - plt_stamp) & plt_mask; - plt_stamp = count; + __plt_update(); now = NOW(); plt_wrap = __read_platform_stime(plt_stamp64); @@ -630,10 +644,21 @@ static s64 __init try_platform_timer(struct platform_timesource *pts) set_time_scale(&plt_scale, pts->frequency); - plt_overflow_period = scale_delta( - 1ull << (pts->counter_bits - 1), &plt_scale); plt_src = *pts; + if ( pts == &plt_tsc ) + { + plt_update(); + } + else + { + plt_overflow_period = scale_delta( + 1ull << (pts->counter_bits - 1), &plt_scale); + + printk(XENLOG_INFO "Platform timer overflow period is %lu msecs\n", + plt_overflow_period / MILLISECS(1)); + } + return rc; }