From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH v3 2/5] x86/time: Always count s_time from Xen boot
Date: Thu, 6 Mar 2014 19:28:02 +0000 [thread overview]
Message-ID: <1394134085-22952-3-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1394134085-22952-1-git-send-email-andrew.cooper3@citrix.com>
From: Tim Deegan <tim@xen.org>
Timestamped printks() can call NOW() before init_xen_time().
Set a baseline TSC as soon as we've calibrated the TSC rate,
so that NOW() consistently counts from boot time.
Signed-off-by: Tim Deegan <tim@xen.org>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
---
v2: use TSC from __start() rather than from early_time_init().
v3: remove later reset of TSC baseline from init_xen_time().
v4: shuffle boot_tsc_stamp definition and use of 'this_cpu()'.
---
xen/arch/x86/boot/head.S | 6 ++++++
xen/arch/x86/time.c | 10 ++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index b12eefb..1777c17 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -136,6 +136,12 @@ __start:
/* Check for availability of long mode. */
bt $29,%edx
jnc bad_cpu
+
+ /* Stash TSC to calculate a good approximation of time-since-boot */
+ rdtsc
+ mov %eax,sym_phys(boot_tsc_stamp)
+ mov %edx,sym_phys(boot_tsc_stamp+4)
+
/* Initialise L2 boot-map page table entries (16MB). */
mov $sym_phys(l2_bootmap),%edx
mov $PAGE_HYPERVISOR|_PAGE_PSE,%eax
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 000191b..4f4de22 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -84,6 +84,9 @@ static u16 pit_stamp16;
static u32 pit_stamp32;
static bool_t __read_mostly using_pit;
+/* Boot timestamp, filled in head.S */
+u64 __initdata boot_tsc_stamp;
+
/*
* 32-bit division of integer dividend and integer divisor yielding
* 32-bit fractional quotient.
@@ -1433,9 +1436,6 @@ int __init init_xen_time(void)
open_softirq(TIME_CALIBRATE_SOFTIRQ, local_time_calibration);
- /* System time (get_s_time()) starts ticking from now. */
- rdtscll(this_cpu(cpu_time).local_tsc_stamp);
-
/* NB. get_cmos_time() can take over one second to execute. */
do_settime(get_cmos_time(), 0, NOW());
@@ -1453,9 +1453,11 @@ int __init init_xen_time(void)
/* Early init function. */
void __init early_time_init(void)
{
+ struct cpu_time *t = &this_cpu(cpu_time);
u64 tmp = init_pit_and_calibrate_tsc();
- set_time_scale(&this_cpu(cpu_time).tsc_scale, tmp);
+ set_time_scale(&t->tsc_scale, tmp);
+ t->local_tsc_stamp = boot_tsc_stamp;
do_div(tmp, 1000);
cpu_khz = (unsigned long)tmp;
--
1.7.10.4
next prev parent reply other threads:[~2014-03-06 19:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 19:28 [PATCH v3 0/5] Improvements to console timestamps Andrew Cooper
2014-03-06 19:28 ` [PATCH v3 1/5] xen/time: Move wallclock_time() declaration into common code Andrew Cooper
2014-03-06 19:28 ` Andrew Cooper [this message]
2014-03-06 19:28 ` [PATCH v3 3/5] x86/time: Initialise time earlier during start_secondary() Andrew Cooper
2014-03-06 19:28 ` [PATCH v3 4/5] xen/console: Provide timestamps as an offset since boot Andrew Cooper
2014-03-07 9:47 ` Jan Beulich
2014-03-07 10:27 ` Andrew Cooper
2014-03-06 19:28 ` [PATCH v3 5/5] xen/console: Traditional console timestamps including milliseconds Andrew Cooper
2014-03-06 23:54 ` Don Slutz
2014-03-07 0:41 ` Andrew Cooper
2014-03-07 23:33 ` Don Slutz
2014-03-11 10:43 ` Ian Campbell
2014-03-11 11:32 ` Andrew Cooper
2014-03-11 11:39 ` Tim Deegan
2014-03-11 12:47 ` Jan Beulich
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=1394134085-22952-3-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@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).