ia64/xen-unstable

changeset 14581:ba9d3fd4ee4b

Fix time reporting to guest.

The recent change to guest time handling dropped a call to
update_vcpu_system_time(), leading to time-went-backwards messages and
guest hangs (the latter were observed only in 2.6.21-rc4 and only when
no serial console was in use).

Debugging the issue also revealed that some commented out debug
printk-s in x86's time handling code didn't compile under x86-64.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Mar 27 11:47:20 2007 +0100 (2007-03-27)
parents 2c1556c893e7
children c9dc33338ccc
files xen/arch/x86/time.c xen/common/domain.c xen/common/schedule.c
line diff
     1.1 --- a/xen/arch/x86/time.c	Tue Mar 27 11:31:25 2007 +0100
     1.2 +++ b/xen/arch/x86/time.c	Tue Mar 27 11:47:20 2007 +0100
     1.3 @@ -670,14 +670,20 @@ static inline void version_update_end(u3
     1.4      (*version)++;
     1.5  }
     1.6  
     1.7 -static inline void __update_vcpu_system_time(struct vcpu *v)
     1.8 +void update_vcpu_system_time(struct vcpu *v)
     1.9  {
    1.10      struct cpu_time       *t;
    1.11      struct vcpu_time_info *u;
    1.12  
    1.13 +    if ( v->vcpu_info == NULL )
    1.14 +        return;
    1.15 +
    1.16      t = &this_cpu(cpu_time);
    1.17      u = &vcpu_info(v, time);
    1.18  
    1.19 +    if ( u->tsc_timestamp == t->local_tsc_stamp )
    1.20 +        return;
    1.21 +
    1.22      version_update_begin(&u->version);
    1.23  
    1.24      u->tsc_timestamp     = t->local_tsc_stamp;
    1.25 @@ -688,13 +694,6 @@ static inline void __update_vcpu_system_
    1.26      version_update_end(&u->version);
    1.27  }
    1.28  
    1.29 -void update_vcpu_system_time(struct vcpu *v)
    1.30 -{
    1.31 -    if ( vcpu_info(v, time.tsc_timestamp) !=
    1.32 -         this_cpu(cpu_time).local_tsc_stamp )
    1.33 -        __update_vcpu_system_time(v);
    1.34 -}
    1.35 -
    1.36  void update_domain_wallclock_time(struct domain *d)
    1.37  {
    1.38      spin_lock(&wc_lock);
    1.39 @@ -771,9 +770,10 @@ static void local_time_calibration(void 
    1.40      local_irq_enable();
    1.41  
    1.42  #if 0
    1.43 -    printk("PRE%d: tsc=%lld stime=%lld master=%lld\n",
    1.44 +    printk("PRE%d: tsc=%"PRIu64" stime=%"PRIu64" master=%"PRIu64"\n",
    1.45             smp_processor_id(), prev_tsc, prev_local_stime, prev_master_stime);
    1.46 -    printk("CUR%d: tsc=%lld stime=%lld master=%lld -> %lld\n",
    1.47 +    printk("CUR%d: tsc=%"PRIu64" stime=%"PRIu64" master=%"PRIu64
    1.48 +           " -> %"PRId64"\n",
    1.49             smp_processor_id(), curr_tsc, curr_local_stime, curr_master_stime,
    1.50             curr_master_stime - curr_local_stime);
    1.51  #endif
    1.52 @@ -855,6 +855,8 @@ static void local_time_calibration(void 
    1.53      t->stime_local_stamp  = curr_local_stime;
    1.54      t->stime_master_stamp = curr_master_stime;
    1.55  
    1.56 +    update_vcpu_system_time(current);
    1.57 +
    1.58   out:
    1.59      set_timer(&t->calibration_timer, NOW() + EPOCH);
    1.60  
     2.1 --- a/xen/common/domain.c	Tue Mar 27 11:31:25 2007 +0100
     2.2 +++ b/xen/common/domain.c	Tue Mar 27 11:47:20 2007 +0100
     2.3 @@ -96,14 +96,16 @@ struct vcpu *alloc_vcpu(
     2.4  
     2.5      v->domain = d;
     2.6      v->vcpu_id = vcpu_id;
     2.7 -    v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]);
     2.8      spin_lock_init(&v->pause_lock);
     2.9  
    2.10      v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
    2.11      v->runstate.state_entry_time = NOW();
    2.12  
    2.13      if ( !is_idle_domain(d) )
    2.14 +    {
    2.15          set_bit(_VCPUF_down, &v->vcpu_flags);
    2.16 +        v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]);
    2.17 +    }
    2.18  
    2.19      if ( sched_init_vcpu(v, cpu_id) != 0 )
    2.20      {
     3.1 --- a/xen/common/schedule.c	Tue Mar 27 11:31:25 2007 +0100
     3.2 +++ b/xen/common/schedule.c	Tue Mar 27 11:47:20 2007 +0100
     3.3 @@ -659,11 +659,8 @@ static void schedule(void)
     3.4      stop_timer(&prev->periodic_timer);
     3.5  
     3.6      /* Ensure that the domain has an up-to-date time base. */
     3.7 -    if ( !is_idle_vcpu(next) )
     3.8 -    {
     3.9 -        update_vcpu_system_time(next);
    3.10 -        vcpu_periodic_timer_work(next);
    3.11 -    }
    3.12 +    update_vcpu_system_time(next);
    3.13 +    vcpu_periodic_timer_work(next);
    3.14  
    3.15      TRACE_4D(TRC_SCHED_SWITCH,
    3.16               prev->domain->domain_id, prev->vcpu_id,