From patchwork Mon Dec 28 16:59:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joao Martins X-Patchwork-Id: 7926811 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D80489F350 for ; Mon, 28 Dec 2015 17:03:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3CAF20253 for ; Mon, 28 Dec 2015 17:03:02 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F407B2024D for ; Mon, 28 Dec 2015 17:03:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aDb9h-0008ET-Iy; Mon, 28 Dec 2015 17:00:21 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aDb9f-0008Dt-Ff for xen-devel@lists.xen.org; Mon, 28 Dec 2015 17:00:19 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 62/2A-13905-2AA61865; Mon, 28 Dec 2015 17:00:18 +0000 X-Env-Sender: joao.m.martins@oracle.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1451322014!13015905!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: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35027 invoked from network); 28 Dec 2015 17:00:16 -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; 28 Dec 2015 17:00:16 -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 tBSH0CEq020923 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 28 Dec 2015 17:00:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id tBSH0C2k019360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 28 Dec 2015 17:00:12 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id tBSH0CFn000479; Mon, 28 Dec 2015 17:00:12 GMT Received: from paddy.lan (/85.245.89.156) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 28 Dec 2015 09:00:12 -0800 From: Joao Martins To: xen-devel@lists.xen.org Date: Mon, 28 Dec 2015 16:59:42 +0000 Message-Id: <1451321985-13728-4-git-send-email-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1451321985-13728-1-git-send-email-joao.m.martins@oracle.com> References: <1451321985-13728-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: Andrew Cooper , Joao Martins , Keir Fraser , Jan Beulich Subject: [Xen-devel] [PATCH RFC 3/6] x86/time: streamline platform time init on plt_init() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 --- xen/arch/x86/time.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index c9e5c14..df42d31 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -518,17 +518,31 @@ static s_time_t __read_platform_stime(u64 platform_time) return (stime_platform_stamp + scale_delta(diff, &plt_scale)); } +static void __plt_init(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_init(void) +{ + spin_lock_irq(&platform_timer_lock); + __plt_init(); + 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_init(); now = NOW(); plt_wrap = __read_platform_stime(plt_stamp64); @@ -635,11 +649,22 @@ static void __init init_platform_timer(void) set_time_scale(&plt_scale, pts->frequency); - plt_overflow_period = scale_delta( - 1ull << (pts->counter_bits-1), &plt_scale); - init_timer(&plt_overflow_timer, plt_overflow, NULL, 0); plt_src = *pts; - plt_overflow(NULL); + + if ( clocksource_is_tsc ) + { + plt_init(); + } + else + { + plt_overflow_period = scale_delta( + 1ull << (pts->counter_bits-1), &plt_scale); + init_timer(&plt_overflow_timer, plt_overflow, NULL, 0); + plt_overflow(NULL); + + printk("Platform timer overflow period is %lu secs\n", + plt_overflow_period/1000000000); + } platform_timer_stamp = plt_stamp64; stime_platform_stamp = NOW();