direct-io.hg

changeset 12350:5a4517468f4f

[HVM] Remove HVM halt timer. It's no longer needed since interrupts
can wake it up now.

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kfraser@localhost.localdomain
date Fri Nov 10 11:01:15 2006 +0000 (2006-11-10)
parents 2d20b5432253
children ac10e3047f36 272cd2dc7cdf
files xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/vcpu.h
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Fri Nov 10 10:31:29 2006 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Fri Nov 10 11:01:15 2006 +0000
     1.3 @@ -176,8 +176,6 @@ int hvm_vcpu_initialise(struct vcpu *v)
     1.4          get_vio(v->domain, v->vcpu_id)->vp_eport =
     1.5              v->arch.hvm_vcpu.xen_port;
     1.6  
     1.7 -    init_timer(&v->arch.hvm_vcpu.hlt_timer, hlt_timer_fn, v, v->processor);
     1.8 -
     1.9      if ( v->vcpu_id != 0 )
    1.10          return 0;
    1.11  
    1.12 @@ -198,7 +196,6 @@ int hvm_vcpu_initialise(struct vcpu *v)
    1.13  
    1.14  void hvm_vcpu_destroy(struct vcpu *v)
    1.15  {
    1.16 -    kill_timer(&v->arch.hvm_vcpu.hlt_timer);
    1.17      vlapic_destroy(v);
    1.18      hvm_funcs.vcpu_destroy(v);
    1.19  
    1.20 @@ -272,10 +269,6 @@ static void hvm_vcpu_down(void)
    1.21  
    1.22  void hvm_hlt(unsigned long rflags)
    1.23  {
    1.24 -    struct vcpu *v = current;
    1.25 -    struct periodic_time *pt = &v->domain->arch.hvm_domain.pl_time.periodic_tm;
    1.26 -    s_time_t next_pt = -1, next_wakeup;
    1.27 -
    1.28      /*
    1.29       * If we halt with interrupts disabled, that's a pretty sure sign that we
    1.30       * want to shut down. In a real processor, NMIs are the only way to break
    1.31 @@ -284,13 +277,6 @@ void hvm_hlt(unsigned long rflags)
    1.32      if ( unlikely(!(rflags & X86_EFLAGS_IF)) )
    1.33          return hvm_vcpu_down();
    1.34  
    1.35 -    if ( !v->vcpu_id )
    1.36 -        next_pt = get_scheduled(v, pt->irq, pt);
    1.37 -    next_wakeup = get_apictime_scheduled(v);
    1.38 -    if ( (next_pt != -1 && next_pt < next_wakeup) || next_wakeup == -1 )
    1.39 -        next_wakeup = next_pt;
    1.40 -    if ( next_wakeup != - 1 ) 
    1.41 -        set_timer(&current->arch.hvm_vcpu.hlt_timer, next_wakeup);
    1.42      do_sched_op_compat(SCHEDOP_block, 0);
    1.43  }
    1.44  
     2.1 --- a/xen/arch/x86/hvm/intercept.c	Fri Nov 10 10:31:29 2006 +0000
     2.2 +++ b/xen/arch/x86/hvm/intercept.c	Fri Nov 10 11:01:15 2006 +0000
     2.3 @@ -268,13 +268,6 @@ int register_io_handler(
     2.4      return 1;
     2.5  }
     2.6  
     2.7 -/* Hook function for the HLT instruction emulation wakeup. */
     2.8 -void hlt_timer_fn(void *data)
     2.9 -{
    2.10 -    struct vcpu *v = data;
    2.11 -    vcpu_kick(v);
    2.12 -}
    2.13 -
    2.14  static __inline__ void missed_ticks(struct periodic_time *pt)
    2.15  {
    2.16      s_time_t missed_ticks;
    2.17 @@ -297,16 +290,19 @@ static __inline__ void missed_ticks(stru
    2.18  void pt_timer_fn(void *data)
    2.19  {
    2.20      struct vcpu *v = data;
    2.21 -    struct periodic_time *pt = &(v->domain->arch.hvm_domain.pl_time.periodic_tm);
    2.22 +    struct periodic_time *pt = &v->domain->arch.hvm_domain.pl_time.periodic_tm;
    2.23  
    2.24      pt->pending_intr_nr++;
    2.25      pt->scheduled += pt->period;
    2.26  
    2.27 -    /* pick up missed timer tick */
    2.28 +    /* Pick up missed timer ticks. */
    2.29      missed_ticks(pt);
    2.30 -    if ( test_bit(_VCPUF_running, &v->vcpu_flags) ) {
    2.31 +
    2.32 +    /* No need to run the timer while a VCPU is descheduled. */
    2.33 +    if ( test_bit(_VCPUF_running, &v->vcpu_flags) )
    2.34          set_timer(&pt->timer, pt->scheduled);
    2.35 -    }
    2.36 +
    2.37 +    vcpu_kick(v);
    2.38  }
    2.39  
    2.40  /* pick up missed timer ticks at deactive time */
     3.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Nov 10 10:31:29 2006 +0000
     3.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Nov 10 11:01:15 2006 +0000
     3.3 @@ -712,11 +712,13 @@ static void arch_svm_do_launch(struct vc
     3.4  static void svm_freeze_time(struct vcpu *v)
     3.5  {
     3.6      struct periodic_time *pt=&v->domain->arch.hvm_domain.pl_time.periodic_tm;
     3.7 -    
     3.8 -    if ( pt->enabled && pt->first_injected && v->vcpu_id == pt->bind_vcpu 
     3.9 +
    3.10 +    if ( pt->enabled && pt->first_injected
    3.11 +            && (v->vcpu_id == pt->bind_vcpu)
    3.12              && !v->arch.hvm_vcpu.guest_time ) {
    3.13          v->arch.hvm_vcpu.guest_time = hvm_get_guest_time(v);
    3.14 -        stop_timer(&(pt->timer));
    3.15 +        if ( test_bit(_VCPUF_blocked, &v->vcpu_flags) )
    3.16 +            stop_timer(&pt->timer);
    3.17      }
    3.18  }
    3.19  
    3.20 @@ -853,7 +855,6 @@ static void svm_migrate_timers(struct vc
    3.21      if ( pt->enabled )
    3.22      {
    3.23          migrate_timer(&pt->timer, v->processor);
    3.24 -        migrate_timer(&v->arch.hvm_vcpu.hlt_timer, v->processor);
    3.25      }
    3.26      migrate_timer(&vcpu_vlapic(v)->vlapic_timer, v->processor);
    3.27      migrate_timer(&vrtc->second_timer, v->processor);
     4.1 --- a/xen/arch/x86/hvm/vlapic.c	Fri Nov 10 10:31:29 2006 +0000
     4.2 +++ b/xen/arch/x86/hvm/vlapic.c	Fri Nov 10 11:01:15 2006 +0000
     4.3 @@ -835,6 +835,8 @@ void vlapic_timer_fn(void *data)
     4.4      else
     4.5          vlapic_set_reg(vlapic, APIC_TMCCT, 0);
     4.6  
     4.7 +    vcpu_kick(vlapic_vcpu(vlapic));
     4.8 +
     4.9      HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER,
    4.10                  "now 0x%016"PRIx64", expire @ 0x%016"PRIx64", "
    4.11                  "timer initial count 0x%x, timer current count 0x%x.",
     5.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Nov 10 10:31:29 2006 +0000
     5.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Nov 10 11:01:15 2006 +0000
     5.3 @@ -368,11 +368,13 @@ static inline void vmx_restore_dr(struct
     5.4  static void vmx_freeze_time(struct vcpu *v)
     5.5  {
     5.6      struct periodic_time *pt=&v->domain->arch.hvm_domain.pl_time.periodic_tm;
     5.7 -    
     5.8 -    if ( pt->enabled && pt->first_injected && v->vcpu_id == pt->bind_vcpu
     5.9 +
    5.10 +    if ( pt->enabled && pt->first_injected
    5.11 +            && (v->vcpu_id == pt->bind_vcpu)
    5.12              && !v->arch.hvm_vcpu.guest_time ) {
    5.13          v->arch.hvm_vcpu.guest_time = hvm_get_guest_time(v);
    5.14 -        stop_timer(&(pt->timer));
    5.15 +        if ( !test_bit(_VCPUF_blocked, &v->vcpu_flags) )
    5.16 +            stop_timer(&pt->timer);
    5.17      }
    5.18  }
    5.19  
    5.20 @@ -407,7 +409,6 @@ void vmx_migrate_timers(struct vcpu *v)
    5.21      if ( pt->enabled )
    5.22      {
    5.23          migrate_timer(&pt->timer, v->processor);
    5.24 -        migrate_timer(&v->arch.hvm_vcpu.hlt_timer, v->processor);
    5.25      }
    5.26      migrate_timer(&vcpu_vlapic(v)->vlapic_timer, v->processor);
    5.27      migrate_timer(&vrtc->second_timer, v->processor);
     6.1 --- a/xen/include/asm-x86/hvm/vcpu.h	Fri Nov 10 10:31:29 2006 +0000
     6.2 +++ b/xen/include/asm-x86/hvm/vcpu.h	Fri Nov 10 11:01:15 2006 +0000
     6.3 @@ -44,9 +44,6 @@ struct hvm_vcpu {
     6.4      /* Flags */
     6.5      int                 flag_dr_dirty;
     6.6  
     6.7 -    /* hlt ins emulation wakeup timer */
     6.8 -    struct timer        hlt_timer;
     6.9 -
    6.10      unsigned long       hvm_trace_values[5];
    6.11  
    6.12      union {