|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 2/5] x86/time: Always count s_time from Xen boot
From: Tim Deegan <tim@xxxxxxx>
In the early-boot clock, before the calibration routines kick in,
count time from Xen boot rather than from when the BSP's TSC was 0.
Signed-off-by: Tim Deegan <tim@xxxxxxx>
Stash the timestamp in head.S as a good approximation of when we actually
started, rather than measuing "time since we ran early_time_init()"
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
xen/arch/x86/boot/head.S | 10 ++++++++++
xen/arch/x86/time.c | 4 ++++
2 files changed, 14 insertions(+)
diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index b12eefb..d62eaae 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
@@ -203,6 +209,10 @@ GLOBAL(trampoline_end)
__high_start:
#include "x86_64.S"
+ .section .init.data, "a", @progbits
+GLOBAL(boot_tsc_stamp)
+ .quad 0
+
.section .data.page_aligned, "aw", @progbits
.p2align PAGE_SHIFT
/*
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 883c135..3da4def 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 (initdata) */
+extern u64 boot_tsc_stamp;
+
/*
* 32-bit division of integer dividend and integer divisor yielding
* 32-bit fractional quotient.
@@ -1456,6 +1459,7 @@ void __init early_time_init(void)
u64 tmp = init_pit_and_calibrate_tsc();
set_time_scale(&this_cpu(cpu_time).tsc_scale, tmp);
+ this_cpu(cpu_time).local_tsc_stamp = boot_tsc_stamp;
do_div(tmp, 1000);
cpu_khz = (unsigned long)tmp;
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |