ia64/xen-unstable

changeset 4007:db2716522d86

bitkeeper revision 1.1236.12.4 (422d7a50g-lmMcSI2gKt0v9vRXTjYQ)

Clean up timer upcalls to guest kernel. Only send an upcall when
timestamp info actually changes.
Signed-off-by: Keir Fraser <keir.fraser@cl.cam.ac.uk>
author kaf24@firebug.cl.cam.ac.uk
date Tue Mar 08 10:11:28 2005 +0000 (2005-03-08)
parents fe0d8973e352
children 96b17bd6c85d
files xen/arch/ia64/domain.c xen/arch/ia64/patch/linux-2.6.7/time.c xen/arch/x86/domain_build.c xen/arch/x86/time.c xen/common/domain.c xen/common/schedule.c xen/include/xen/time.h
line diff
     1.1 --- a/xen/arch/ia64/domain.c	Tue Mar 08 09:58:53 2005 +0000
     1.2 +++ b/xen/arch/ia64/domain.c	Tue Mar 08 10:11:28 2005 +0000
     1.3 @@ -555,9 +555,6 @@ int construct_dom0(struct domain *d,
     1.4  #if 0
     1.5      strcpy(d->name,"Domain0");
     1.6  #endif
     1.7 -    /* Set up shared-info area. */
     1.8 -    update_dom_time(d);
     1.9 -    d->shared_info->domain_time = 0;
    1.10  
    1.11  	// prepare domain0 pagetable (maps METAphysical to physical)
    1.12  	// following is roughly mm_init() in linux/kernel/fork.c
     2.1 --- a/xen/arch/ia64/patch/linux-2.6.7/time.c	Tue Mar 08 09:58:53 2005 +0000
     2.2 +++ b/xen/arch/ia64/patch/linux-2.6.7/time.c	Tue Mar 08 10:11:28 2005 +0000
     2.3 @@ -71,7 +71,7 @@
     2.4  +    return now; 
     2.5  +}
     2.6  +
     2.7 -+void update_dom_time(struct domain *d)
     2.8 ++void update_dom_time(struct exec_domain *ed)
     2.9  +{
    2.10  +// FIXME: implement this?
    2.11  +	printf("update_dom_time: called, not implemented, skipping\n");
     3.1 --- a/xen/arch/x86/domain_build.c	Tue Mar 08 09:58:53 2005 +0000
     3.2 +++ b/xen/arch/x86/domain_build.c	Tue Mar 08 10:11:28 2005 +0000
     3.3 @@ -406,9 +406,6 @@ int construct_dom0(struct domain *d,
     3.4  
     3.5  #endif /* __x86_64__ */
     3.6  
     3.7 -    /* Set up shared-info area. */
     3.8 -    update_dom_time(d);
     3.9 -    d->shared_info->domain_time = 0;
    3.10      /* Mask all upcalls... */
    3.11      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    3.12          d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
     4.1 --- a/xen/arch/x86/time.c	Tue Mar 08 09:58:53 2005 +0000
     4.2 +++ b/xen/arch/x86/time.c	Tue Mar 08 10:11:28 2005 +0000
     4.3 @@ -13,7 +13,9 @@
     4.4   *  Copyright (C) 1991, 1992, 1995  Linus Torvalds
     4.5   */
     4.6  
     4.7 +#include <xen/config.h>
     4.8  #include <xen/errno.h>
     4.9 +#include <xen/event.h>
    4.10  #include <xen/sched.h>
    4.11  #include <xen/lib.h>
    4.12  #include <xen/config.h>
    4.13 @@ -273,15 +275,20 @@ s_time_t get_s_time(void)
    4.14  }
    4.15  
    4.16  
    4.17 -void update_dom_time(struct domain *d)
    4.18 +void update_dom_time(struct exec_domain *ed)
    4.19  {
    4.20 +    struct domain *d  = ed->domain;
    4.21      shared_info_t *si = d->shared_info;
    4.22      unsigned long flags;
    4.23  
    4.24 -    read_lock_irqsave(&time_lock, flags);
    4.25 +    if ( d->last_propagated_timestamp == full_tsc_irq )
    4.26 +        return;
    4.27  
    4.28 +    read_lock_irqsave(&time_lock, flags);
    4.29      spin_lock(&d->time_lock);
    4.30  
    4.31 +    d->last_propagated_timestamp = full_tsc_irq;
    4.32 +
    4.33      si->time_version1++;
    4.34      wmb();
    4.35  
    4.36 @@ -295,8 +302,9 @@ void update_dom_time(struct domain *d)
    4.37      si->time_version2++;
    4.38  
    4.39      spin_unlock(&d->time_lock);
    4.40 +    read_unlock_irqrestore(&time_lock, flags);
    4.41  
    4.42 -    read_unlock_irqrestore(&time_lock, flags);
    4.43 +    send_guest_virq(ed, VIRQ_TIMER);
    4.44  }
    4.45  
    4.46  
    4.47 @@ -322,7 +330,9 @@ void do_settime(unsigned long secs, unsi
    4.48  
    4.49      write_unlock_irq(&time_lock);
    4.50  
    4.51 -    update_dom_time(current->domain);
    4.52 +    /* Others will pick up the change at the next tick. */
    4.53 +    current->domain->last_propagated_timestamp = 0; /* force propagation */
    4.54 +    update_dom_time(current);
    4.55  }
    4.56  
    4.57  
     5.1 --- a/xen/common/domain.c	Tue Mar 08 09:58:53 2005 +0000
     5.2 +++ b/xen/common/domain.c	Tue Mar 08 10:11:28 2005 +0000
     5.3 @@ -283,9 +283,6 @@ int final_setup_guest(struct domain *p, 
     5.4      if ( (rc = arch_final_setup_guest(p->exec_domain[0],c)) != 0 )
     5.5          goto out;
     5.6  
     5.7 -    /* Set up the shared info structure. */
     5.8 -    update_dom_time(p);
     5.9 -
    5.10      set_bit(DF_CONSTRUCTED, &p->d_flags);
    5.11  
    5.12   out:    
    5.13 @@ -339,9 +336,6 @@ long do_boot_vcpu(unsigned long vcpu, fu
    5.14          goto out;
    5.15      }
    5.16  
    5.17 -    /* Set up the shared info structure. */
    5.18 -    update_dom_time(d);
    5.19 -
    5.20      /* domain_unpause_by_systemcontroller */
    5.21      if ( test_and_clear_bit(EDF_CTRLPAUSE, &ed->ed_flags) )
    5.22          domain_wake(ed);
     6.1 --- a/xen/common/schedule.c	Tue Mar 08 09:58:53 2005 +0000
     6.2 +++ b/xen/common/schedule.c	Tue Mar 08 10:11:28 2005 +0000
     6.3 @@ -414,10 +414,6 @@ void __enter_scheduler(void)
     6.4  
     6.5      spin_unlock_irq(&schedule_data[cpu].schedule_lock);
     6.6  
     6.7 -    /* Ensure that the domain has an up-to-date time base. */
     6.8 -    if ( !is_idle_task(next->domain) )
     6.9 -        update_dom_time(next->domain);
    6.10 -
    6.11      if ( unlikely(prev == next) )
    6.12          return;
    6.13      
    6.14 @@ -460,10 +456,10 @@ void __enter_scheduler(void)
    6.15       */
    6.16      clear_bit(EDF_RUNNING, &prev->ed_flags);
    6.17  
    6.18 -    /* Mark a timer event for the newly-scheduled domain. */
    6.19 +    /* Ensure that the domain has an up-to-date time base. */
    6.20      if ( !is_idle_task(next->domain) )
    6.21 -        send_guest_virq(next, VIRQ_TIMER);
    6.22 -    
    6.23 +        update_dom_time(next);
    6.24 +
    6.25      schedule_tail(next);
    6.26  
    6.27      BUG();
    6.28 @@ -500,10 +496,7 @@ static void t_timer_fn(unsigned long unu
    6.29      TRACE_0D(TRC_SCHED_T_TIMER_FN);
    6.30  
    6.31      if ( !is_idle_task(ed->domain) )
    6.32 -    {
    6.33 -        update_dom_time(ed->domain);
    6.34 -        send_guest_virq(ed, VIRQ_TIMER);
    6.35 -    }
    6.36 +        update_dom_time(ed);
    6.37  
    6.38      t_timer[ed->processor].expires = NOW() + MILLISECS(10);
    6.39      add_ac_timer(&t_timer[ed->processor]);
    6.40 @@ -515,8 +508,7 @@ static void dom_timer_fn(unsigned long d
    6.41      struct exec_domain *ed = (struct exec_domain *)data;
    6.42  
    6.43      TRACE_0D(TRC_SCHED_DOM_TIMER_FN);
    6.44 -    update_dom_time(ed->domain);
    6.45 -    send_guest_virq(ed, VIRQ_TIMER);
    6.46 +    update_dom_time(ed);
    6.47  }
    6.48  
    6.49  /* Initialise the data structures. */
     7.1 --- a/xen/include/xen/time.h	Tue Mar 08 09:58:53 2005 +0000
     7.2 +++ b/xen/include/xen/time.h	Tue Mar 08 10:11:28 2005 +0000
     7.3 @@ -54,7 +54,7 @@ s_time_t get_s_time(void);
     7.4  #define MILLISECS(_ms)  (((s_time_t)(_ms)) * 1000000ULL )
     7.5  #define MICROSECS(_us)  (((s_time_t)(_us)) * 1000ULL )
     7.6  
     7.7 -extern void update_dom_time(struct domain *d);
     7.8 +extern void update_dom_time(struct exec_domain *ed);
     7.9  extern void do_settime(unsigned long secs, unsigned long usecs, 
    7.10                         u64 system_time_base);
    7.11