From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH 8/8] x86/time: group time stamps into a structure Date: Wed, 15 Jun 2016 04:30:38 -0600 Message-ID: <57614A6E02000078000F53B1@prv-mh.provo.novell.com> References: <576140F302000078000F52FE@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2E18155E.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bD85s-0008UF-KG for xen-devel@lists.xenproject.org; Wed, 15 Jun 2016 10:30:44 +0000 In-Reply-To: <576140F302000078000F52FE@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Andrew Cooper , Dario Faggioli , Joao Martins List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part2E18155E.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline If that had been done from the beginning, mistakes like the one corrected in commit b64438c7c1 ("x86/time: use correct (local) time stamp in constant-TSC calibration fast path") would likely never have happened. Also add a few "const" to make more obvious when things aren't expected to change. Signed-off-by: Jan Beulich --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -47,10 +47,14 @@ unsigned long __read_mostly cpu_khz; /* DEFINE_SPINLOCK(rtc_lock); unsigned long pit0_ticks; =20 +struct cpu_time_stamp { + u64 local_tsc; + s_time_t local_stime; + s_time_t master_stime; +}; + struct cpu_time { - u64 local_tsc_stamp; - s_time_t stime_local_stamp; - s_time_t stime_master_stamp; + struct cpu_time_stamp stamp; struct time_scale tsc_scale; }; =20 @@ -118,7 +122,7 @@ static inline u32 mul_frac(u32 multiplic * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, * yielding a 64-bit result. */ -u64 scale_delta(u64 delta, struct time_scale *scale) +u64 scale_delta(u64 delta, const struct time_scale *scale) { u64 product; =20 @@ -635,11 +639,11 @@ u64 stime2tsc(s_time_t stime) t =3D &this_cpu(cpu_time); sys_to_tsc =3D scale_reciprocal(t->tsc_scale); =20 - stime_delta =3D stime - t->stime_local_stamp; + stime_delta =3D stime - t->stamp.local_stime; if ( stime_delta < 0 ) stime_delta =3D 0; =20 - return t->local_tsc_stamp + scale_delta(stime_delta, &sys_to_tsc); + return t->stamp.local_tsc + scale_delta(stime_delta, &sys_to_tsc); } =20 void cstate_restore_tsc(void) @@ -793,7 +797,7 @@ static unsigned long get_cmos_time(void) =20 s_time_t get_s_time_fixed(u64 at_tsc) { - struct cpu_time *t =3D &this_cpu(cpu_time); + const struct cpu_time *t =3D &this_cpu(cpu_time); u64 tsc, delta; s_time_t now; =20 @@ -801,8 +805,8 @@ s_time_t get_s_time_fixed(u64 at_tsc) tsc =3D at_tsc; else tsc =3D rdtsc_ordered(); - delta =3D tsc - t->local_tsc_stamp; - now =3D t->stime_local_stamp + scale_delta(delta, &t->tsc_scale); + delta =3D tsc - t->stamp.local_tsc; + now =3D t->stamp.local_stime + scale_delta(delta, &t->tsc_scale); =20 return now; } @@ -821,7 +825,7 @@ uint64_t tsc_ticks2ns(uint64_t ticks) =20 static void __update_vcpu_system_time(struct vcpu *v, int force) { - struct cpu_time *t; + const struct cpu_time *t; struct vcpu_time_info *u, _u =3D {}; struct domain *d =3D v->domain; s_time_t tsc_stamp; @@ -834,7 +838,7 @@ static void __update_vcpu_system_time(st =20 if ( d->arch.vtsc ) { - s_time_t stime =3D t->stime_local_stamp; + s_time_t stime =3D t->stamp.local_stime; =20 if ( is_hvm_domain(d) ) { @@ -856,20 +860,20 @@ static void __update_vcpu_system_time(st { if ( has_hvm_container_domain(d) && hvm_tsc_scaling_supported ) { - tsc_stamp =3D hvm_scale_tsc(d, t->local_tsc_stamp);= + tsc_stamp =3D hvm_scale_tsc(d, t->stamp.local_tsc);= _u.tsc_to_system_mul =3D d->arch.vtsc_to_ns.mul_frac; _u.tsc_shift =3D d->arch.vtsc_to_ns.shift; } else { - tsc_stamp =3D t->local_tsc_stamp; + tsc_stamp =3D t->stamp.local_tsc; _u.tsc_to_system_mul =3D t->tsc_scale.mul_frac; _u.tsc_shift =3D t->tsc_scale.shift; } } =20 _u.tsc_timestamp =3D tsc_stamp; - _u.system_time =3D t->stime_local_stamp; + _u.system_time =3D t->stamp.local_stime; =20 if ( is_hvm_domain(d) ) _u.tsc_timestamp +=3D v->arch.hvm_vcpu.cache_tsc_offset; @@ -969,12 +973,12 @@ int cpu_frequency_change(u64 freq) =20 local_irq_disable(); /* Platform time /first/, as we may be delayed by platform_timer_lock.= */ - t->stime_master_stamp =3D read_platform_stime(); - /* TSC-extrapolated time may be bogus after frequency change. */ - /*t->stime_local_stamp =3D get_s_time();*/ - t->stime_local_stamp =3D t->stime_master_stamp; + t->stamp.master_stime =3D read_platform_stime(); curr_tsc =3D rdtsc_ordered(); - t->local_tsc_stamp =3D curr_tsc; + /* TSC-extrapolated time may be bogus after frequency change. */ + /*t->stamp.local_stime =3D get_s_time_fixed(curr_tsc);*/ + t->stamp.local_stime =3D t->stamp.master_stime; + t->stamp.local_tsc =3D curr_tsc; set_time_scale(&t->tsc_scale, freq); local_irq_enable(); =20 @@ -991,28 +995,19 @@ int cpu_frequency_change(u64 freq) } =20 /* Per-CPU communication between rendezvous IRQ and softirq handler. */ -struct cpu_calibration { - u64 local_tsc_stamp; - s_time_t stime_local_stamp; - s_time_t stime_master_stamp; -}; -static DEFINE_PER_CPU(struct cpu_calibration, cpu_calibration); +static DEFINE_PER_CPU(struct cpu_time_stamp, cpu_calibration); =20 /* Softirq handler for per-CPU time calibration. */ static void local_time_calibration(void) { struct cpu_time *t =3D &this_cpu(cpu_time); - struct cpu_calibration *c =3D &this_cpu(cpu_calibration); + const struct cpu_time_stamp *c =3D &this_cpu(cpu_calibration); =20 /* - * System timestamps, extrapolated from local and master oscillators, - * taken during this calibration and the previous calibration. + * System (extrapolated from local and master oscillators) and TSC + * timestamps, taken during this calibration and the previous one. */ - s_time_t prev_local_stime, curr_local_stime; - s_time_t prev_master_stime, curr_master_stime; - - /* TSC timestamps taken during this calibration and prev calibration. = */ - u64 prev_tsc, curr_tsc; + struct cpu_time_stamp prev, curr; =20 /* * System time and TSC ticks elapsed during the previous calibration @@ -1021,9 +1016,6 @@ static void local_time_calibration(void) u64 stime_elapsed64, tsc_elapsed64; u32 stime_elapsed32, tsc_elapsed32; =20 - /* The accumulated error in the local estimate. */ - u64 local_stime_err; - /* Error correction to slow down a fast local clock. */ u32 error_factor =3D 0; =20 @@ -1037,40 +1029,34 @@ static void local_time_calibration(void) { /* Atomically read cpu_calibration struct and write cpu_time = struct. */ local_irq_disable(); - t->local_tsc_stamp =3D c->local_tsc_stamp; - t->stime_local_stamp =3D c->stime_local_stamp; - t->stime_master_stamp =3D c->stime_master_stamp; + t->stamp =3D *c; local_irq_enable(); update_vcpu_system_time(current); goto out; } =20 - prev_tsc =3D t->local_tsc_stamp; - prev_local_stime =3D t->stime_local_stamp; - prev_master_stime =3D t->stime_master_stamp; + prev =3D t->stamp; =20 /* Disabling IRQs ensures we atomically read cpu_calibration struct. = */ local_irq_disable(); - curr_tsc =3D c->local_tsc_stamp; - curr_local_stime =3D c->stime_local_stamp; - curr_master_stime =3D c->stime_master_stamp; + curr =3D *c; local_irq_enable(); =20 #if 0 printk("PRE%d: tsc=3D%"PRIu64" stime=3D%"PRIu64" master=3D%"PRIu64"\n"= , - smp_processor_id(), prev_tsc, prev_local_stime, prev_master_sti= me); + smp_processor_id(), prev.local_tsc, prev.local_stime, = prev.master_stime); printk("CUR%d: tsc=3D%"PRIu64" stime=3D%"PRIu64" master=3D%"PRIu64 " -> %"PRId64"\n", - smp_processor_id(), curr_tsc, curr_local_stime, curr_master_sti= me, - curr_master_stime - curr_local_stime); + smp_processor_id(), curr.local_tsc, curr.local_stime, = curr.master_stime, + curr.master_stime - curr.local_stime); #endif =20 /* Local time warps forward if it lags behind master time. */ - if ( curr_local_stime < curr_master_stime ) - curr_local_stime =3D curr_master_stime; + if ( curr.local_stime < curr.master_stime ) + curr.local_stime =3D curr.master_stime; =20 - stime_elapsed64 =3D curr_master_stime - prev_master_stime; - tsc_elapsed64 =3D curr_tsc - prev_tsc; + stime_elapsed64 =3D curr.master_stime - prev.master_stime; + tsc_elapsed64 =3D curr.local_tsc - prev.local_tsc; =20 /* * Weirdness can happen if we lose sync with the platform timer. @@ -1084,9 +1070,10 @@ static void local_time_calibration(void) * clock (slow clocks are warped forwards). The scale factor is = clamped * to >=3D 0.5. */ - if ( curr_local_stime !=3D curr_master_stime ) + if ( curr.local_stime !=3D curr.master_stime ) { - local_stime_err =3D curr_local_stime - curr_master_stime; + u64 local_stime_err =3D curr.local_stime - curr.master_stime; + if ( local_stime_err > EPOCH ) local_stime_err =3D EPOCH; error_factor =3D div_frac(EPOCH, EPOCH + (u32)local_stime_err); @@ -1139,9 +1126,7 @@ static void local_time_calibration(void) local_irq_disable(); t->tsc_scale.mul_frac =3D calibration_mul_frac; t->tsc_scale.shift =3D tsc_shift; - t->local_tsc_stamp =3D curr_tsc; - t->stime_local_stamp =3D curr_local_stime; - t->stime_master_stamp =3D curr_master_stime; + t->stamp =3D curr; local_irq_enable(); =20 update_vcpu_system_time(current); @@ -1269,11 +1254,11 @@ struct calibration_rendezvous { static void time_calibration_rendezvous_tail(const struct calibration_rendezvous *r) { - struct cpu_calibration *c =3D &this_cpu(cpu_calibration); + struct cpu_time_stamp *c =3D &this_cpu(cpu_calibration); =20 - c->local_tsc_stamp =3D rdtsc_ordered(); - c->stime_local_stamp =3D get_s_time_fixed(c->local_tsc_stamp); - c->stime_master_stamp =3D r->master_stime; + c->local_tsc =3D rdtsc_ordered(); + c->local_stime =3D get_s_time_fixed(c->local_tsc); + c->master_stime =3D r->master_stime; =20 raise_softirq(TIME_CALIBRATE_SOFTIRQ); } @@ -1388,20 +1373,17 @@ void __init clear_tsc_cap(unsigned int f time_calibration_rendezvous_fn =3D rendezvous_fn; } =20 -static struct { - s_time_t local_stime, master_stime; -} ap_bringup_ref; +static struct cpu_time_stamp ap_bringup_ref; =20 void time_latch_stamps(void) { unsigned long flags; - u64 tsc; =20 local_irq_save(flags); ap_bringup_ref.master_stime =3D read_platform_stime(); - tsc =3D rdtsc_ordered(); + ap_bringup_ref.local_tsc =3D rdtsc_ordered(); local_irq_restore(flags); =20 - ap_bringup_ref.local_stime =3D get_s_time_fixed(tsc); + ap_bringup_ref.local_stime =3D get_s_time_fixed(ap_bringup_ref.local_t= sc); } =20 void init_percpu_time(void) @@ -1419,7 +1401,7 @@ void init_percpu_time(void) tsc =3D rdtsc_ordered(); local_irq_restore(flags); =20 - t->stime_master_stamp =3D now; + t->stamp.master_stime =3D now; /* * To avoid a discontinuity (TSC and platform clock can't be expected * to be in perfect sync), initialization here needs to match up with @@ -1432,8 +1414,8 @@ void init_percpu_time(void) else now +=3D ap_bringup_ref.local_stime - ap_bringup_ref.master_st= ime; } - t->local_tsc_stamp =3D tsc; - t->stime_local_stamp =3D now; + t->stamp.local_tsc =3D tsc; + t->stamp.local_stime =3D now; } =20 /* @@ -1557,7 +1539,7 @@ void __init early_time_init(void) tmp =3D init_platform_timer(); =20 set_time_scale(&t->tsc_scale, tmp); - t->local_tsc_stamp =3D boot_tsc_stamp; + t->stamp.local_tsc =3D boot_tsc_stamp; =20 do_div(tmp, 1000); cpu_khz =3D (unsigned long)tmp; --- a/xen/include/asm-x86/time.h +++ b/xen/include/asm-x86/time.h @@ -79,6 +79,6 @@ u64 stime2tsc(s_time_t stime); =20 struct time_scale; void set_time_scale(struct time_scale *ts, u64 ticks_per_sec); -u64 scale_delta(u64 delta, struct time_scale *scale); +u64 scale_delta(u64 delta, const struct time_scale *scale); =20 #endif /* __X86_TIME_H__ */ --=__Part2E18155E.1__= Content-Type: text/plain; name="x86-time-calibration-pack.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-time-calibration-pack.patch" x86/time: group time stamps into a structure=0A=0AIf that had been done = from the beginning, mistakes like the one=0Acorrected in commit b64438c7c1 = ("x86/time: use correct (local) time=0Astamp in constant-TSC calibration = fast path") would likely never have=0Ahappened.=0A=0AAlso add a few = "const" to make more obvious when things aren't expected=0Ato change.=0A=0A= Signed-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/time= .c=0A+++ b/xen/arch/x86/time.c=0A@@ -47,10 +47,14 @@ unsigned long = __read_mostly cpu_khz; /*=0A DEFINE_SPINLOCK(rtc_lock);=0A unsigned long = pit0_ticks;=0A =0A+struct cpu_time_stamp {=0A+ u64 local_tsc;=0A+ = s_time_t local_stime;=0A+ s_time_t master_stime;=0A+};=0A+=0A struct = cpu_time {=0A- u64 local_tsc_stamp;=0A- s_time_t stime_local_stamp;= =0A- s_time_t stime_master_stamp;=0A+ struct cpu_time_stamp = stamp;=0A struct time_scale tsc_scale;=0A };=0A =0A@@ -118,7 +122,7 @@ = static inline u32 mul_frac(u32 multiplic=0A * Scale a 64-bit delta by = scaling and multiplying by a 32-bit fraction,=0A * yielding a 64-bit = result.=0A */=0A-u64 scale_delta(u64 delta, struct time_scale *scale)=0A+u= 64 scale_delta(u64 delta, const struct time_scale *scale)=0A {=0A u64 = product;=0A =0A@@ -635,11 +639,11 @@ u64 stime2tsc(s_time_t stime)=0A = t =3D &this_cpu(cpu_time);=0A sys_to_tsc =3D scale_reciprocal(t->tsc_sc= ale);=0A =0A- stime_delta =3D stime - t->stime_local_stamp;=0A+ = stime_delta =3D stime - t->stamp.local_stime;=0A if ( stime_delta < 0 = )=0A stime_delta =3D 0;=0A =0A- return t->local_tsc_stamp + = scale_delta(stime_delta, &sys_to_tsc);=0A+ return t->stamp.local_tsc + = scale_delta(stime_delta, &sys_to_tsc);=0A }=0A =0A void cstate_restore_tsc(= void)=0A@@ -793,7 +797,7 @@ static unsigned long get_cmos_time(void)=0A = =0A s_time_t get_s_time_fixed(u64 at_tsc)=0A {=0A- struct cpu_time *t = =3D &this_cpu(cpu_time);=0A+ const struct cpu_time *t =3D &this_cpu(cpu_= time);=0A u64 tsc, delta;=0A s_time_t now;=0A =0A@@ -801,8 +805,8 = @@ s_time_t get_s_time_fixed(u64 at_tsc)=0A tsc =3D at_tsc;=0A = else=0A tsc =3D rdtsc_ordered();=0A- delta =3D tsc - t->local_ts= c_stamp;=0A- now =3D t->stime_local_stamp + scale_delta(delta, = &t->tsc_scale);=0A+ delta =3D tsc - t->stamp.local_tsc;=0A+ now =3D = t->stamp.local_stime + scale_delta(delta, &t->tsc_scale);=0A =0A = return now;=0A }=0A@@ -821,7 +825,7 @@ uint64_t tsc_ticks2ns(uint64_t = ticks)=0A =0A static void __update_vcpu_system_time(struct vcpu *v, int = force)=0A {=0A- struct cpu_time *t;=0A+ const struct cpu_time = *t;=0A struct vcpu_time_info *u, _u =3D {};=0A struct domain *d = =3D v->domain;=0A s_time_t tsc_stamp;=0A@@ -834,7 +838,7 @@ static = void __update_vcpu_system_time(st=0A =0A if ( d->arch.vtsc )=0A = {=0A- s_time_t stime =3D t->stime_local_stamp;=0A+ s_time_t = stime =3D t->stamp.local_stime;=0A =0A if ( is_hvm_domain(d) )=0A = {=0A@@ -856,20 +860,20 @@ static void __update_vcpu_system_time(st= =0A {=0A if ( has_hvm_container_domain(d) && hvm_tsc_scaling_su= pported )=0A {=0A- tsc_stamp =3D hvm_scale_ts= c(d, t->local_tsc_stamp);=0A+ tsc_stamp =3D = hvm_scale_tsc(d, t->stamp.local_tsc);=0A _u.tsc_to_system_mul = =3D d->arch.vtsc_to_ns.mul_frac;=0A _u.tsc_shift =3D = d->arch.vtsc_to_ns.shift;=0A }=0A else=0A {=0A- = tsc_stamp =3D t->local_tsc_stamp;=0A+ = tsc_stamp =3D t->stamp.local_tsc;=0A _u.tsc_to_syste= m_mul =3D t->tsc_scale.mul_frac;=0A _u.tsc_shift =3D = t->tsc_scale.shift;=0A }=0A }=0A =0A _u.tsc_timestamp =3D = tsc_stamp;=0A- _u.system_time =3D t->stime_local_stamp;=0A+ = _u.system_time =3D t->stamp.local_stime;=0A =0A if ( is_hvm_domain(d)= )=0A _u.tsc_timestamp +=3D v->arch.hvm_vcpu.cache_tsc_offset;=0A@@= -969,12 +973,12 @@ int cpu_frequency_change(u64 freq)=0A =0A = local_irq_disable();=0A /* Platform time /first/, as we may be delayed = by platform_timer_lock. */=0A- t->stime_master_stamp =3D read_platform_s= time();=0A- /* TSC-extrapolated time may be bogus after frequency = change. */=0A- /*t->stime_local_stamp =3D get_s_time();*/=0A- = t->stime_local_stamp =3D t->stime_master_stamp;=0A+ t->stamp.master_stim= e =3D read_platform_stime();=0A curr_tsc =3D rdtsc_ordered();=0A- = t->local_tsc_stamp =3D curr_tsc;=0A+ /* TSC-extrapolated time may be = bogus after frequency change. */=0A+ /*t->stamp.local_stime =3D = get_s_time_fixed(curr_tsc);*/=0A+ t->stamp.local_stime =3D t->stamp.mast= er_stime;=0A+ t->stamp.local_tsc =3D curr_tsc;=0A set_time_scale(&t-= >tsc_scale, freq);=0A local_irq_enable();=0A =0A@@ -991,28 +995,19 @@ = int cpu_frequency_change(u64 freq)=0A }=0A =0A /* Per-CPU communication = between rendezvous IRQ and softirq handler. */=0A-struct cpu_calibration = {=0A- u64 local_tsc_stamp;=0A- s_time_t stime_local_stamp;=0A- = s_time_t stime_master_stamp;=0A-};=0A-static DEFINE_PER_CPU(struct = cpu_calibration, cpu_calibration);=0A+static DEFINE_PER_CPU(struct = cpu_time_stamp, cpu_calibration);=0A =0A /* Softirq handler for per-CPU = time calibration. */=0A static void local_time_calibration(void)=0A {=0A = struct cpu_time *t =3D &this_cpu(cpu_time);=0A- struct cpu_calibration= *c =3D &this_cpu(cpu_calibration);=0A+ const struct cpu_time_stamp *c = =3D &this_cpu(cpu_calibration);=0A =0A /*=0A- * System timestamps, = extrapolated from local and master oscillators,=0A- * taken during = this calibration and the previous calibration.=0A+ * System (extrapolat= ed from local and master oscillators) and TSC=0A+ * timestamps, taken = during this calibration and the previous one.=0A */=0A- s_time_t = prev_local_stime, curr_local_stime;=0A- s_time_t prev_master_stime, = curr_master_stime;=0A-=0A- /* TSC timestamps taken during this = calibration and prev calibration. */=0A- u64 prev_tsc, curr_tsc;=0A+ = struct cpu_time_stamp prev, curr;=0A =0A /*=0A * System time and = TSC ticks elapsed during the previous calibration=0A@@ -1021,9 +1016,6 @@ = static void local_time_calibration(void)=0A u64 stime_elapsed64, = tsc_elapsed64;=0A u32 stime_elapsed32, tsc_elapsed32;=0A =0A- /* = The accumulated error in the local estimate. */=0A- u64 local_stime_err;= =0A-=0A /* Error correction to slow down a fast local clock. */=0A = u32 error_factor =3D 0;=0A =0A@@ -1037,40 +1029,34 @@ static void = local_time_calibration(void)=0A {=0A /* Atomically read = cpu_calibration struct and write cpu_time struct. */=0A local_irq_d= isable();=0A- t->local_tsc_stamp =3D c->local_tsc_stamp;=0A- = t->stime_local_stamp =3D c->stime_local_stamp;=0A- t->stime_mast= er_stamp =3D c->stime_master_stamp;=0A+ t->stamp =3D *c;=0A = local_irq_enable();=0A update_vcpu_system_time(current);=0A = goto out;=0A }=0A =0A- prev_tsc =3D t->local_tsc_stamp;=0A= - prev_local_stime =3D t->stime_local_stamp;=0A- prev_master_stime = =3D t->stime_master_stamp;=0A+ prev =3D t->stamp;=0A =0A /* = Disabling IRQs ensures we atomically read cpu_calibration struct. */=0A = local_irq_disable();=0A- curr_tsc =3D c->local_tsc_stamp;=0A- = curr_local_stime =3D c->stime_local_stamp;=0A- curr_master_stime = =3D c->stime_master_stamp;=0A+ curr =3D *c;=0A local_irq_enable();= =0A =0A #if 0=0A printk("PRE%d: tsc=3D%"PRIu64" stime=3D%"PRIu64" = master=3D%"PRIu64"\n",=0A- smp_processor_id(), prev_tsc, = prev_local_stime, prev_master_stime);=0A+ smp_processor_id(), = prev.local_tsc, prev.local_stime, prev.master_stime);=0A printk("CUR%d:= tsc=3D%"PRIu64" stime=3D%"PRIu64" master=3D%"PRIu64=0A " -> = %"PRId64"\n",=0A- smp_processor_id(), curr_tsc, curr_local_stime,= curr_master_stime,=0A- curr_master_stime - curr_local_stime);=0A= + smp_processor_id(), curr.local_tsc, curr.local_stime, = curr.master_stime,=0A+ curr.master_stime - curr.local_stime);=0A = #endif=0A =0A /* Local time warps forward if it lags behind master = time. */=0A- if ( curr_local_stime < curr_master_stime )=0A- = curr_local_stime =3D curr_master_stime;=0A+ if ( curr.local_stime < = curr.master_stime )=0A+ curr.local_stime =3D curr.master_stime;=0A = =0A- stime_elapsed64 =3D curr_master_stime - prev_master_stime;=0A- = tsc_elapsed64 =3D curr_tsc - prev_tsc;=0A+ stime_elapsed64 =3D = curr.master_stime - prev.master_stime;=0A+ tsc_elapsed64 =3D = curr.local_tsc - prev.local_tsc;=0A =0A /*=0A * Weirdness can = happen if we lose sync with the platform timer.=0A@@ -1084,9 +1070,10 @@ = static void local_time_calibration(void)=0A * clock (slow clocks are = warped forwards). The scale factor is clamped=0A * to >=3D 0.5.=0A = */=0A- if ( curr_local_stime !=3D curr_master_stime )=0A+ if ( = curr.local_stime !=3D curr.master_stime )=0A {=0A- local_stime_e= rr =3D curr_local_stime - curr_master_stime;=0A+ u64 local_stime_err= =3D curr.local_stime - curr.master_stime;=0A+=0A if ( local_stime_= err > EPOCH )=0A local_stime_err =3D EPOCH;=0A = error_factor =3D div_frac(EPOCH, EPOCH + (u32)local_stime_err);=0A@@ = -1139,9 +1126,7 @@ static void local_time_calibration(void)=0A = local_irq_disable();=0A t->tsc_scale.mul_frac =3D calibration_mul_frac;= =0A t->tsc_scale.shift =3D tsc_shift;=0A- t->local_tsc_stamp = =3D curr_tsc;=0A- t->stime_local_stamp =3D curr_local_stime;=0A- = t->stime_master_stamp =3D curr_master_stime;=0A+ t->stamp = =3D curr;=0A local_irq_enable();=0A =0A update_vcpu_system_time(cur= rent);=0A@@ -1269,11 +1254,11 @@ struct calibration_rendezvous {=0A static = void=0A time_calibration_rendezvous_tail(const struct calibration_rendezvou= s *r)=0A {=0A- struct cpu_calibration *c =3D &this_cpu(cpu_calibration);= =0A+ struct cpu_time_stamp *c =3D &this_cpu(cpu_calibration);=0A =0A- = c->local_tsc_stamp =3D rdtsc_ordered();=0A- c->stime_local_stamp =3D = get_s_time_fixed(c->local_tsc_stamp);=0A- c->stime_master_stamp =3D = r->master_stime;=0A+ c->local_tsc =3D rdtsc_ordered();=0A+ = c->local_stime =3D get_s_time_fixed(c->local_tsc);=0A+ c->master_stime = =3D r->master_stime;=0A =0A raise_softirq(TIME_CALIBRATE_SOFTIRQ);=0A = }=0A@@ -1388,20 +1373,17 @@ void __init clear_tsc_cap(unsigned int f=0A = time_calibration_rendezvous_fn =3D rendezvous_fn;=0A }=0A =0A-static = struct {=0A- s_time_t local_stime, master_stime;=0A-} ap_bringup_ref;=0A= +static struct cpu_time_stamp ap_bringup_ref;=0A =0A void time_latch_stamps= (void) {=0A unsigned long flags;=0A- u64 tsc;=0A =0A local_irq_s= ave(flags);=0A ap_bringup_ref.master_stime =3D read_platform_stime();= =0A- tsc =3D rdtsc_ordered();=0A+ ap_bringup_ref.local_tsc =3D = rdtsc_ordered();=0A local_irq_restore(flags);=0A =0A- ap_bringup_ref= .local_stime =3D get_s_time_fixed(tsc);=0A+ ap_bringup_ref.local_stime = =3D get_s_time_fixed(ap_bringup_ref.local_tsc);=0A }=0A =0A void init_percp= u_time(void)=0A@@ -1419,7 +1401,7 @@ void init_percpu_time(void)=0A = tsc =3D rdtsc_ordered();=0A local_irq_restore(flags);=0A =0A- = t->stime_master_stamp =3D now;=0A+ t->stamp.master_stime =3D now;=0A = /*=0A * To avoid a discontinuity (TSC and platform clock can't be = expected=0A * to be in perfect sync), initialization here needs to = match up with=0A@@ -1432,8 +1414,8 @@ void init_percpu_time(void)=0A = else=0A now +=3D ap_bringup_ref.local_stime - ap_bringup_ref.= master_stime;=0A }=0A- t->local_tsc_stamp =3D tsc;=0A- = t->stime_local_stamp =3D now;=0A+ t->stamp.local_tsc =3D tsc;=0A+ = t->stamp.local_stime =3D now;=0A }=0A =0A /*=0A@@ -1557,7 +1539,7 @@ void = __init early_time_init(void)=0A tmp =3D init_platform_timer();=0A =0A = set_time_scale(&t->tsc_scale, tmp);=0A- t->local_tsc_stamp =3D = boot_tsc_stamp;=0A+ t->stamp.local_tsc =3D boot_tsc_stamp;=0A =0A = do_div(tmp, 1000);=0A cpu_khz =3D (unsigned long)tmp;=0A--- a/xen/inclu= de/asm-x86/time.h=0A+++ b/xen/include/asm-x86/time.h=0A@@ -79,6 +79,6 @@ = u64 stime2tsc(s_time_t stime);=0A =0A struct time_scale;=0A void set_time_s= cale(struct time_scale *ts, u64 ticks_per_sec);=0A-u64 scale_delta(u64 = delta, struct time_scale *scale);=0A+u64 scale_delta(u64 delta, const = struct time_scale *scale);=0A =0A #endif /* __X86_TIME_H__ */=0A --=__Part2E18155E.1__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__Part2E18155E.1__=--