Yang, Xiaowei
2006-Jul-10 06:54 UTC
[Xen-devel] Fix "Many lost ticks" warning in ia32e guest
Keir, This patch fixes "Many lost ticks" warning in ia32e guest. New i8254.c code in HV has some problem calculating PIT counter. So when guest kernel reads it and uses it to adjust last_tsc when PIT is generated, it may think there are more than two ticks of time passed between 2 continuous PIT, which ended up with "Warning: Many lost ticks". Thanks, Xiaowei _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Minor comment inline. -- Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/ On Mon, 10 Jul 2006 14:54:21 +0800, Yang, Xiaowei wrote:> [-- text/plain, encoding quoted-printable, charset: us-ascii, 11 lines --] > > Keir, > This patch fixes "Many lost ticks" warning in ia32e guest. > New i8254.c code in HV has some problem calculating PIT counter. So when > guest kernel reads it and uses it to adjust last_tsc when PIT is > generated, it may think there are more than two ticks of time passed > between 2 continuous PIT, which ended up with "Warning: Many lost > ticks". > > Thanks, > Xiaowei > > > Fix "Many lost ticks" warning in ia32e guest > > Signed-off-by: Eddie Dong <eddie.dong@intel.com> > Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com> > > diff -r fd6d12935b56 xen/arch/x86/hvm/i8254.c > --- a/xen/arch/x86/hvm/i8254.c Mon Jul 3 15:07:20 2006 > +++ b/xen/arch/x86/hvm/i8254.c Mon Jul 10 11:23:14 2006 > @@ -188,6 +188,12 @@ > return s->gate; > } > > +void pit_time_fired(struct vcpu *v, void *priv) > +{ > + PITChannelState *s = priv; > + s->count_load_time = hvm_get_clock(v); > +} > + > static inline void pit_load_count(PITChannelState *s, int val) > { > u32 period; > @@ -209,11 +215,11 @@ > switch (s->mode) { > case 2: > /* create periodic time */ > - s->pt = create_periodic_time (s->vcpu, period, 0, 0); > + s->pt = create_periodic_time (s, period, 0, 0); > break; > case 1: > /* create one shot time */ > - s->pt = create_periodic_time (s->vcpu, period, 0, 1); > + s->pt = create_periodic_time (s, period, 0, 1); > #ifdef DEBUG_PIT > printk("HVM_PIT: create one shot time.\n"); > #endif > diff -r fd6d12935b56 xen/arch/x86/hvm/intercept.c > --- a/xen/arch/x86/hvm/intercept.c Mon Jul 3 15:07:20 2006 > +++ b/xen/arch/x86/hvm/intercept.c Mon Jul 10 11:23:14 2006 > @@ -261,11 +261,12 @@ > * period: fire frequency in ns. > */ > struct periodic_time * create_periodic_time( > - struct vcpu *v, > + PITChannelState *s, > u32 period, > char irq, > char one_shot) > { > + struct vcpu *v = s->vcpu; > struct periodic_time *pt = &(v->domain->arch.hvm_domain.pl_time.periodic_tm); > if ( pt->enabled ) { > if ( v->vcpu_id != 0 ) { > @@ -290,6 +291,7 @@ > pt->scheduled = NOW() + period; > set_timer (&pt->timer,pt->scheduled); > pt->enabled = 1; > + pt->priv = s; > return pt; > } > > diff -r fd6d12935b56 xen/arch/x86/hvm/vmx/io.c > --- a/xen/arch/x86/hvm/vmx/io.c Mon Jul 3 15:07:20 2006 > +++ b/xen/arch/x86/hvm/vmx/io.c Mon Jul 10 11:23:14 2006 > @@ -75,6 +75,7 @@ > pt->pending_intr_nr--; > pt->last_plt_gtime += pt->period_cycles; > set_guest_time(v, pt->last_plt_gtime); > + pit_time_fired(v, pt->priv); > } > } > > diff -r fd6d12935b56 xen/include/asm-x86/hvm/vpit.h > --- a/xen/include/asm-x86/hvm/vpit.h Mon Jul 3 15:07:20 2006 > +++ b/xen/include/asm-x86/hvm/vpit.h Mon Jul 10 11:23:14 2006 > @@ -64,6 +64,7 @@ > s_time_t scheduled; /* scheduled timer interrupt */ > u64 last_plt_gtime; /* platform time when last IRQ is injected */ > struct timer timer; /* ac_timer */ > + void *priv; /* ponit back to platform time source */ > }; > > typedef struct PITState { > @@ -93,9 +94,10 @@ > extern void hvm_hooks_assist(struct vcpu *v); > extern void pickup_deactive_ticks(struct periodic_time *vpit); > extern u64 hvm_get_guest_time(struct vcpu *v); > -extern struct periodic_time *create_periodic_time(struct vcpu *v, u32 period, char irq, char one_shot); > +extern struct periodic_time *create_periodic_time(PITChannelState *v, u32 period, char irq, char one_shot);Could this line be <=80 characters wide?> extern void destroy_periodic_time(struct periodic_time *pt); > void pit_init(struct vcpu *v, unsigned long cpu_khz); > void pt_timer_fn(void *data); > +void pit_time_fired(struct vcpu *v, void *priv); > > #endif /* __ASM_X86_HVM_VPIT_H__ */_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel