xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Joao Martins <joao.m.martins@oracle.com>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Joao Martins <joao.m.martins@oracle.com>,
	Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH RFC 3/6] x86/time: streamline platform time init on plt_init()
Date: Mon, 28 Dec 2015 16:59:42 +0000	[thread overview]
Message-ID: <1451321985-13728-4-git-send-email-joao.m.martins@oracle.com> (raw)
In-Reply-To: <1451321985-13728-1-git-send-email-joao.m.martins@oracle.com>

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 <joao.m.martins@oracle.com>
---
 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();
-- 
2.1.4

  parent reply	other threads:[~2015-12-28 16:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-28 16:59 [PATCH RFC 0/6] x86/time: PVCLOCK_TSC_STABLE_BIT support Joao Martins
2015-12-28 16:59 ` [PATCH RFC 1/6] public/xen.h: add flags field to vcpu_time_info Joao Martins
2016-01-25 20:11   ` Konrad Rzeszutek Wilk
2016-01-26 10:31     ` Joao Martins
2015-12-28 16:59 ` [PATCH RFC 2/6] x86/time: implement tsc as clocksource Joao Martins
2015-12-29 15:11   ` Andrew Cooper
2015-12-29 17:37     ` Joao Martins
2015-12-28 16:59 ` Joao Martins [this message]
2016-01-25 20:26   ` [PATCH RFC 3/6] x86/time: streamline platform time init on plt_init() Konrad Rzeszutek Wilk
2016-01-26 10:31     ` Joao Martins
2015-12-28 16:59 ` [PATCH RFC 4/6] x86/time: refactor read_platform_stime() Joao Martins
2015-12-28 16:59 ` [PATCH RFC 5/6] x86/time: implement PVCLOCK_TSC_STABLE_BIT Joao Martins
2015-12-28 16:59 ` [PATCH RFC 6/6] x86/time: convert counter to tsc for non-tsc clocksource Joao Martins
2015-12-29 14:58 ` [PATCH RFC 0/6] x86/time: PVCLOCK_TSC_STABLE_BIT support Andrew Cooper
2015-12-29 17:37   ` Joao Martins
2016-02-22 21:14     ` Joao Martins
2016-02-23  8:09       ` Jan Beulich
2016-02-23 12:13         ` Joao Martins
2015-12-30  3:47   ` Haozhong Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1451321985-13728-4-git-send-email-joao.m.martins@oracle.com \
    --to=joao.m.martins@oracle.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).