# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1253726370 -3600
# Node ID 0f8376078dc145b465a1929af10e7f576375d8a5
# Parent 401dc67572a2ebc2d048fdeb4358d5cf36b434b5
x86: minor cleanup of code that writes to TSC
While working on TSC-handling code, I missed an important
piece of code that writes to TSC because it does it
differently than other pieces of code. Fix that,
and also cleanup a bit to avoid hardcoded constants
and use wrmsrl instead of wrmsr plus handwritten 64-bit
dismembering code.
Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
---
xen/arch/x86/smpboot.c | 4 ++--
xen/arch/x86/time.c | 14 ++++++--------
xen/include/asm-x86/msr.h | 2 +-
3 files changed, 9 insertions(+), 11 deletions(-)
diff -r 401dc67572a2 -r 0f8376078dc1 xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c Wed Sep 23 18:18:29 2009 +0100
+++ b/xen/arch/x86/smpboot.c Wed Sep 23 18:19:30 2009 +0100
@@ -223,7 +223,7 @@ static void __init synchronize_tsc_bp (v
* We clear the TSC in the last loop:
*/
if (i == NR_LOOPS-1)
- write_tsc(0, 0);
+ write_tsc(0L);
/*
* Wait for all APs to leave the synchronization point:
@@ -293,7 +293,7 @@ static void __init synchronize_tsc_ap (v
rdtscll(tsc_values[smp_processor_id()]);
if (i == NR_LOOPS-1)
- write_tsc(0, 0);
+ write_tsc(0L);
atomic_inc(&tsc_count_stop);
while (atomic_read(&tsc_count_stop) != num_booting_cpus()) mb();
diff -r 401dc67572a2 -r 0f8376078dc1 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c Wed Sep 23 18:18:29 2009 +0100
+++ b/xen/arch/x86/time.c Wed Sep 23 18:19:30 2009 +0100
@@ -699,7 +699,7 @@ void cstate_restore_tsc(void)
struct cpu_time *t = &this_cpu(cpu_time);
struct time_scale sys_to_tsc = scale_reciprocal(t->tsc_scale);
s_time_t stime_delta;
- u64 tsc_delta;
+ u64 new_tsc;
if ( boot_cpu_has(X86_FEATURE_NOSTOP_TSC) )
return;
@@ -708,9 +708,9 @@ void cstate_restore_tsc(void)
if ( stime_delta < 0 )
stime_delta = 0;
- tsc_delta = scale_delta(stime_delta, &sys_to_tsc);
-
- wrmsrl(MSR_IA32_TSC, t->local_tsc_stamp + tsc_delta);
+ new_tsc = t->local_tsc_stamp + scale_delta(stime_delta, &sys_to_tsc);
+
+ write_tsc(new_tsc);
}
/***************************************************************************
@@ -1126,8 +1126,7 @@ static void time_calibration_tsc_rendezv
atomic_inc(&r->semaphore);
if ( i == 0 )
- write_tsc((u32)r->master_tsc_stamp,
- (u32)(r->master_tsc_stamp >> 32));
+ write_tsc(r->master_tsc_stamp);
while ( atomic_read(&r->semaphore) != (2*total_cpus - 1) )
mb();
@@ -1140,8 +1139,7 @@ static void time_calibration_tsc_rendezv
mb();
if ( i == 0 )
- write_tsc((u32)r->master_tsc_stamp,
- (u32)(r->master_tsc_stamp >> 32));
+ write_tsc(r->master_tsc_stamp);
atomic_inc(&r->semaphore);
while ( atomic_read(&r->semaphore) > total_cpus )
diff -r 401dc67572a2 -r 0f8376078dc1 xen/include/asm-x86/msr.h
--- a/xen/include/asm-x86/msr.h Wed Sep 23 18:18:29 2009 +0100
+++ b/xen/include/asm-x86/msr.h Wed Sep 23 18:19:30 2009 +0100
@@ -82,7 +82,7 @@ static inline void wrmsrl(unsigned int m
} while(0)
#endif
-#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
+#define write_tsc(val) wrmsrl(MSR_IA32_TSC, val)
#define rdpmc(counter,low,high) \
__asm__ __volatile__("rdpmc" \
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|