minor cleanup of code that writes to TSC
PATCH 1/1 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 <[email protected]>
xen/arch/x86/smpboot.c +2 -2
@@ -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 (vrdtscll (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 ();
xen/arch/x86/time.c +5 -7
@@ -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); + new_tsc = t->local_tsc_stamp +scale_delta (stime_delta, &sys_to_tsc); -wrmsrl (MSR_IA32_TSC , t->local_tsc_stamp + tsc_delta); +write_tsc (new_tsc); }/***************************************************************************
@@ -1126,8 +1126,7 @@ static void time_calibration_tsc_rendezvatomic_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_rendezvmb ();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 )
xen/include/asm-x86/msr.h +1 -1
@@ -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" \