ia64/xen-unstable

changeset 2025:eaeb569cef15

bitkeeper revision 1.1108.33.26 (410e2637qJ8L22pgeDEMvrnsj5v1_A)

BVT fixed to handle wakeups correctly. Min_slice removed
author gm281@boulderdash.cl.cam.ac.uk
date Mon Aug 02 11:32:07 2004 +0000 (2004-08-02)
parents fbe39cb544f3
children 64ccd65031af
files xen/common/sched_bvt.c xen/common/sched_fair_bvt.c xen/common/sched_rrobin.c xen/include/xen/sched.h
line diff
     1.1 --- a/xen/common/sched_bvt.c	Mon Aug 02 10:44:52 2004 +0000
     1.2 +++ b/xen/common/sched_bvt.c	Mon Aug 02 11:32:07 2004 +0000
     1.3 @@ -91,34 +91,31 @@ static inline int __task_on_runqueue(str
     1.4      return (RUNLIST(d))->next != NULL;
     1.5  }
     1.6  
     1.7 +static inline u32 calc_avt(struct domain *d, s_time_t now)
     1.8 +{
     1.9 +    u32 ranfor, mcus;
    1.10 +    struct bvt_dom_info *inf = BVT_INFO(d);
    1.11 +    
    1.12 +    ranfor = (u32)(now - d->lastschd);
    1.13 +    mcus = (ranfor + MCU - 1)/MCU;
    1.14 +
    1.15 +    return inf->avt + mcus;
    1.16 +}
    1.17 +
    1.18 +
    1.19  /*
    1.20   * Calculate the effective virtual time for a domain. Take into account 
    1.21   * warping limits
    1.22   */
    1.23 -static void __calc_evt(struct bvt_dom_info *inf)
    1.24 +static inline u32 calc_evt(struct domain *d, u32 avt)
    1.25  {
    1.26 -    s_time_t now = NOW();
    1.27 -
    1.28 +   struct bvt_dom_info *inf = BVT_INFO(d);
    1.29 +   /* TODO The warp routines need to be rewritten GM */
    1.30 + 
    1.31      if ( inf->warpback ) 
    1.32 -    {
    1.33 -        if ( ((now - inf->warped) < inf->warpl) &&
    1.34 -             ((now - inf->uwarped) > inf->warpu) )
    1.35 -        {
    1.36 -            /* allowed to warp */
    1.37 -            inf->evt = inf->avt - inf->warp;
    1.38 -        } 
    1.39 -        else 
    1.40 -        {
    1.41 -            /* warped for too long -> unwarp */
    1.42 -            inf->evt      = inf->avt;
    1.43 -            inf->uwarped  = now;
    1.44 -            inf->warpback = 0;
    1.45 -        }
    1.46 -    } 
    1.47 +        return avt - inf->warp;
    1.48      else 
    1.49 -    {
    1.50 -        inf->evt = inf->avt;
    1.51 -    }
    1.52 +        return avt;
    1.53  }
    1.54  
    1.55  /**
    1.56 @@ -191,8 +188,9 @@ void bvt_wake(struct domain *d)
    1.57      unsigned long       flags;
    1.58      struct bvt_dom_info *inf = BVT_INFO(d);
    1.59      struct domain       *curr;
    1.60 -    s_time_t            now, min_time;
    1.61 +    s_time_t            now, r_time;
    1.62      int                 cpu = d->processor;
    1.63 +    u32                 curr_evt;
    1.64  
    1.65      /* The runqueue accesses must be protected */
    1.66      spin_lock_irqsave(&CPU_INFO(cpu)->run_lock, flags);
    1.67 @@ -215,24 +213,29 @@ void bvt_wake(struct domain *d)
    1.68          inf->avt = CPU_SVT(cpu);
    1.69  
    1.70      /* Deal with warping here. */
    1.71 -    inf->warpback  = 1;
    1.72 -    inf->warped    = now;
    1.73 -    __calc_evt(inf);
    1.74 +    // TODO rewrite
    1.75 +    //inf->warpback  = 1;
    1.76 +    //inf->warped    = now;
    1.77 +    inf->evt = calc_evt(d, inf->avt);
    1.78      spin_unlock_irqrestore(&CPU_INFO(cpu)->run_lock, flags);
    1.79      
    1.80      /* Access to schedule_data protected by schedule_lock */
    1.81      spin_lock_irqsave(&schedule_data[cpu].schedule_lock, flags);
    1.82      
    1.83      curr = schedule_data[cpu].curr;
    1.84 +    curr_evt = calc_evt(curr, calc_avt(curr, now));
    1.85 +    /* Calculate the time the current domain would run assuming
    1.86 +       the second smallest evt is of the newly woken domain */
    1.87 +    r_time = curr->lastschd +
    1.88 +             ((inf->evt - curr_evt) / BVT_INFO(curr)->mcu_advance) +
    1.89 +             ctx_allow;
    1.90  
    1.91 -    /* Currently-running domain should run at least for ctx_allow. */
    1.92 -    min_time = curr->lastschd + curr->min_slice;
    1.93  
    1.94      spin_unlock_irqrestore(&schedule_data[cpu].schedule_lock, flags);   
    1.95 -    if ( is_idle_task(curr) || (min_time <= now) )
    1.96 +    if ( is_idle_task(curr) || (inf->evt <= curr_evt) )
    1.97          cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
    1.98 -    else if ( schedule_data[cpu].s_timer.expires > (min_time + TIME_SLOP) )
    1.99 -        mod_ac_timer(&schedule_data[cpu].s_timer, min_time);
   1.100 +    else if ( schedule_data[cpu].s_timer.expires > r_time )
   1.101 +        mod_ac_timer(&schedule_data[cpu].s_timer, r_time);
   1.102  
   1.103  }
   1.104  
   1.105 @@ -360,8 +363,6 @@ static task_slice_t bvt_do_schedule(s_ti
   1.106      struct list_head   *tmp;
   1.107      int                 cpu = prev->processor;
   1.108      s32                 r_time;     /* time for new dom to run */
   1.109 -    s32                 ranfor;     /* assume we never run longer than 2.1s! */
   1.110 -    s32                 mcus;
   1.111      u32                 next_evt, next_prime_evt, min_avt;
   1.112      struct bvt_dom_info *prev_inf       = BVT_INFO(prev),
   1.113                          *p_inf          = NULL,
   1.114 @@ -378,12 +379,8 @@ static task_slice_t bvt_do_schedule(s_ti
   1.115  
   1.116      if ( likely(!is_idle_task(prev)) ) 
   1.117      {
   1.118 -        ranfor = (s32)(now - prev->lastschd);
   1.119 -        /* Calculate mcu and update avt. */
   1.120 -        mcus = (ranfor + MCU - 1) / MCU;
   1.121 -        prev_inf->avt += mcus * prev_inf->mcu_advance;
   1.122 -        
   1.123 -        __calc_evt(prev_inf);
   1.124 +        prev_inf->avt = calc_avt(prev, now);
   1.125 +        prev_inf->evt = calc_evt(prev, prev_inf->avt);
   1.126          
   1.127          __del_from_runqueue(prev);
   1.128          
   1.129 @@ -493,7 +490,6 @@ static task_slice_t bvt_do_schedule(s_ti
   1.130      ASSERT(r_time >= ctx_allow);
   1.131  
   1.132   sched_done:
   1.133 -    next->min_slice = ctx_allow;
   1.134      ret.task = next;
   1.135      ret.time = r_time;
   1.136      return ret;
     2.1 --- a/xen/common/sched_fair_bvt.c	Mon Aug 02 10:44:52 2004 +0000
     2.2 +++ b/xen/common/sched_fair_bvt.c	Mon Aug 02 11:32:07 2004 +0000
     2.3 @@ -274,7 +274,7 @@ static void fbvt_wake(struct domain *d)
     2.4      curr = schedule_data[cpu].curr;
     2.5   
     2.6      /* Currently-running domain should run at least for ctx_allow. */
     2.7 -    min_time = curr->lastschd + curr->min_slice;
     2.8 +    min_time = curr->lastschd + ctx_allow;
     2.9      
    2.10      spin_unlock_irqrestore(&schedule_data[cpu].schedule_lock, flags);   
    2.11      
    2.12 @@ -587,7 +587,6 @@ static task_slice_t fbvt_do_schedule(s_t
    2.13   sched_done:
    2.14      R_TIME(cpu) = r_time / MCU;
    2.15      TRACE_3D(TRC_SCHED_FBVT_DO_SCHED, next->domain, r_time, LAST_VTB(cpu));
    2.16 -    next->min_slice = ctx_allow;
    2.17      ret.task = next;
    2.18      ret.time = r_time;
    2.19      return ret;
     3.1 --- a/xen/common/sched_rrobin.c	Mon Aug 02 10:44:52 2004 +0000
     3.2 +++ b/xen/common/sched_rrobin.c	Mon Aug 02 11:32:07 2004 +0000
     3.3 @@ -220,10 +220,7 @@ void rr_wake(struct domain *d)
     3.4      curr = schedule_data[cpu].curr;
     3.5      spin_unlock_irqrestore(&schedule_data[cpu].schedule_lock, flags);
     3.6   
     3.7 -    /* Currently-running domain should run at least for ctx_allow. */
     3.8 -    min_time = curr->lastschd + curr->min_slice;
     3.9 -    
    3.10 -    if ( is_idle_task(curr) || (min_time <= now) )
    3.11 +    if ( is_idle_task(curr) )
    3.12          cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
    3.13      else if ( schedule_data[cpu].s_timer.expires > (min_time + TIME_SLOP) )
    3.14          mod_ac_timer(&schedule_data[cpu].s_timer, min_time);
     4.1 --- a/xen/include/xen/sched.h	Mon Aug 02 10:44:52 2004 +0000
     4.2 +++ b/xen/include/xen/sched.h	Mon Aug 02 11:32:07 2004 +0000
     4.3 @@ -107,7 +107,6 @@ struct domain
     4.4      s_time_t         cpu_time;      /* total CPU time received till now */
     4.5      s_time_t         wokenup;       /* time domain got woken up */
     4.6      struct ac_timer  timer;         /* one-shot timer for timeout values */
     4.7 -    s_time_t         min_slice;     /* minimum time before reschedule */
     4.8      void            *sched_priv;    /* scheduler-specific data */
     4.9  
    4.10      struct mm_struct mm;