ia64/xen-unstable

changeset 1857:6a85eb0a53cd

bitkeeper revision 1.1115 (40fe9a850omzXu7lXwxof0F9N9h3BQ)

Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into freefall.cl.cam.ac.uk:/local/scratch/cl349/xeno.bk-ptrw
author cl349@freefall.cl.cam.ac.uk
date Wed Jul 21 16:32:05 2004 +0000 (2004-07-21)
parents 4419dd2ecfc6 1ea6f810ebb8
children 64b3bffe959f
files xen/common/sched_fair_bvt.c xen/common/schedule.c
line diff
     1.1 --- a/xen/common/sched_fair_bvt.c	Wed Jul 21 16:31:57 2004 +0000
     1.2 +++ b/xen/common/sched_fair_bvt.c	Wed Jul 21 16:32:05 2004 +0000
     1.3 @@ -30,6 +30,7 @@
     1.4  
     1.5  /* For tracing - TODO - put all the defines in some common hearder file */
     1.6  #define TRC_SCHED_FBVT_DO_SCHED             0x00020000
     1.7 +#define TRC_SCHED_FBVT_DO_SCHED_UPDATE      0x00020001
     1.8  
     1.9  
    1.10  /* all per-domain BVT-specific scheduling info is stored here */
    1.11 @@ -39,7 +40,6 @@ struct fbvt_dom_info
    1.12      u32           avt;              /* actual virtual time */
    1.13      u32           evt;              /* effective virtual time */
    1.14      u32		      time_slept;	    /* records amount of time slept, used for scheduling */
    1.15 -    u32		      vtb;	    	    /* virtual time bonus */
    1.16      int           warpback;         /* warp?  */
    1.17      long          warp;             /* virtual time warp */
    1.18      long          warpl;            /* warp limit */
    1.19 @@ -51,17 +51,22 @@ struct fbvt_dom_info
    1.20  struct fbvt_cpu_info
    1.21  {
    1.22      unsigned long svt; /* XXX check this is unsigned long! */
    1.23 +    u32		      vtb;	    	    /* virtual time bonus */
    1.24 +    u32           r_time;           /* last time to run */  
    1.25  };
    1.26  
    1.27  
    1.28  #define FBVT_INFO(p)   ((struct fbvt_dom_info *)(p)->sched_priv)
    1.29  #define CPU_INFO(cpu) ((struct fbvt_cpu_info *)(schedule_data[cpu]).sched_priv)
    1.30  #define CPU_SVT(cpu)  (CPU_INFO(cpu)->svt)
    1.31 +#define LAST_VTB(cpu) (CPU_INFO(cpu)->vtb)
    1.32 +#define R_TIME(cpu)   (CPU_INFO(cpu)->r_time) 
    1.33  
    1.34  #define MCU            (s32)MICROSECS(100)    /* Minimum unit */
    1.35  #define MCU_ADVANCE    10                     /* default weight */
    1.36  #define TIME_SLOP      (s32)MICROSECS(50)     /* allow time to slip a bit */
    1.37  static s32 ctx_allow = (s32)MILLISECS(5);     /* context switch allowance */
    1.38 +static s32 max_vtb   = (s32)MILLISECS(5);
    1.39  
    1.40  /* SLAB cache for struct fbvt_dom_info objects */
    1.41  static kmem_cache_t *dom_info_cache;
    1.42 @@ -132,7 +137,6 @@ void fbvt_add_task(struct domain *p)
    1.43          inf->avt         = CPU_SVT(p->processor);
    1.44          inf->evt         = CPU_SVT(p->processor);
    1.45          /* Set some default values here. */
    1.46 -		inf->vtb	     = 0;
    1.47  		inf->time_slept  = 0;
    1.48          inf->warpback    = 0;
    1.49          inf->warp        = 0;
    1.50 @@ -206,6 +210,8 @@ int fbvt_ctl(struct sched_ctl_cmd *cmd)
    1.51      if ( cmd->direction == SCHED_INFO_PUT )
    1.52      { 
    1.53          ctx_allow = params->ctx_allow;
    1.54 +        /* The max_vtb should be of the order o the ctx_allow */
    1.55 +        max_vtb = ctx_allow;
    1.56      }
    1.57      else
    1.58      {
    1.59 @@ -285,6 +291,7 @@ static task_slice_t fbvt_do_schedule(s_t
    1.60      s32                 ranfor;     /* assume we never run longer than 2.1s! */
    1.61      s32                 mcus;
    1.62      u32                 next_evt, next_prime_evt, min_avt;
    1.63 +    u32                 sl_decrement;
    1.64      struct fbvt_dom_info *prev_inf       = FBVT_INFO(prev),
    1.65                          *p_inf          = NULL,
    1.66                          *next_inf       = NULL,
    1.67 @@ -299,18 +306,25 @@ static task_slice_t fbvt_do_schedule(s_t
    1.68          ranfor = (s32)(now - prev->lastschd);
    1.69          /* Calculate mcu and update avt. */
    1.70          mcus = (ranfor + MCU - 1) / MCU;
    1.71 -    if(mcus * prev_inf->mcu_advance < prev_inf->vtb)
    1.72 -	{
    1.73 -	    ASSERT(prev_inf->time_slept >= mcus * prev_inf->mcu_advance);
    1.74 -    	prev_inf->time_slept -= mcus * prev_inf->mcu_advance;
    1.75 -	}
    1.76 -	else
    1.77 -	{
    1.78 -	    prev_inf->avt += mcus * prev_inf->mcu_advance - prev_inf->vtb;
    1.79 +        
    1.80 +        TRACE_3D(TRC_SCHED_FBVT_DO_SCHED_UPDATE, prev->domain, mcus, LAST_VTB(cpu));
    1.81 +    
    1.82 +        sl_decrement = mcus * LAST_VTB(cpu) / R_TIME(cpu);
    1.83 +        prev_inf->time_slept -=  sl_decrement;
    1.84 +        prev_inf->avt += mcus * prev_inf->mcu_advance - sl_decrement;
    1.85 +  
    1.86 +        /*if(mcus * prev_inf->mcu_advance < LAST_VTB(cpu))
    1.87 +	    {
    1.88 +	        ASSERT(prev_inf->time_slept >= mcus * prev_inf->mcu_advance);
    1.89 +    	    prev_inf->time_slept -= mcus * prev_inf->mcu_advance;
    1.90 +	    }
    1.91 +	    else
    1.92 +	    {
    1.93 +	        prev_inf->avt += mcus * prev_inf->mcu_advance - LAST_VTB(cpu);
    1.94  		
    1.95 -	    ASSERT(prev_inf->time_slept >= prev_inf->vtb);
    1.96 -	    prev_inf->time_slept -= prev_inf->vtb;
    1.97 - 	}
    1.98 +	        ASSERT(prev_inf->time_slept >= LAST_VTB(cpu));
    1.99 +	        prev_inf->time_slept -= LAST_VTB(cpu);
   1.100 + 	    }*/
   1.101          
   1.102          __calc_evt(prev_inf);
   1.103          
   1.104 @@ -407,8 +421,9 @@ static task_slice_t fbvt_do_schedule(s_t
   1.105       * domains earlier in virtual time). Together this should give quite
   1.106       * good control both for CPU and IO-bound domains.
   1.107       */
   1.108 -    next_inf->vtb = (int)(0.2 * next_inf->time_slept);
   1.109 -    if(next_inf->vtb > 1000) next_inf->vtb = 1000;
   1.110 +    LAST_VTB(cpu) = (int)(0.2 * next_inf->time_slept);
   1.111 +    if(LAST_VTB(cpu) / next_inf->mcu_advance > max_vtb / MCU) 
   1.112 +        LAST_VTB(cpu) = max_vtb * next_inf->mcu_advance / MCU;
   1.113  
   1.114  
   1.115      /* work out time for next run through scheduler */
   1.116 @@ -431,15 +446,17 @@ static task_slice_t fbvt_do_schedule(s_t
   1.117       * 'next_prime's evt. Take context switch allowance into account.
   1.118       */
   1.119      ASSERT(next_prime_inf->evt >= next_inf->evt);
   1.120 -   
   1.121 -    r_time = ((next_prime_inf->evt + next_inf->vtb - next_inf->evt)/next_inf->mcu_advance)
   1.122 +  
   1.123 +    ASSERT(LAST_VTB(cpu) >= 0);
   1.124 +
   1.125 +    r_time = MCU * ((next_prime_inf->evt + LAST_VTB(cpu) - next_inf->evt)/next_inf->mcu_advance)
   1.126          + ctx_allow;
   1.127 -        
   1.128 +
   1.129      ASSERT(r_time >= ctx_allow);
   1.130  
   1.131   sched_done:
   1.132 - 
   1.133 -    TRACE_2D(TRC_SCHED_FBVT_DO_SCHED, next->domain, r_time);
   1.134 +    R_TIME(cpu) = r_time / MCU;
   1.135 +    TRACE_3D(TRC_SCHED_FBVT_DO_SCHED, next->domain, r_time, LAST_VTB(cpu));
   1.136      next->min_slice = ctx_allow;
   1.137      ret.task = next;
   1.138      ret.time = r_time;
   1.139 @@ -452,8 +469,8 @@ static void fbvt_dump_runq_el(struct dom
   1.140  {
   1.141      struct fbvt_dom_info *inf = FBVT_INFO(p);
   1.142      
   1.143 -    printk("mcua=0x%04lX ev=0x%08X av=0x%08X sl=0x%08X vtb=0x%08X ",
   1.144 -           inf->mcu_advance, inf->evt, inf->avt, inf->time_slept, inf->vtb);
   1.145 +    printk("mcua=%04lu ev=%08u av=%08u sl=%08u",
   1.146 +           inf->mcu_advance, inf->evt, inf->avt, inf->time_slept);
   1.147  }
   1.148  
   1.149  static void fbvt_dump_settings(void)
   1.150 @@ -518,7 +535,7 @@ static void fbvt_unpause(struct domain *
   1.151          /* Set avt to system virtual time. */
   1.152          inf->avt         = CPU_SVT(p->processor);
   1.153          /* Set some default values here. */
   1.154 -		inf->vtb	 = 0;
   1.155 +		LAST_VTB(p->processor) = 0;
   1.156  		__calc_evt(inf);
   1.157      }
   1.158  }
     2.1 --- a/xen/common/schedule.c	Wed Jul 21 16:31:57 2004 +0000
     2.2 +++ b/xen/common/schedule.c	Wed Jul 21 16:32:05 2004 +0000
     2.3 @@ -73,7 +73,7 @@ schedule_data_t schedule_data[NR_CPUS];
     2.4   */
     2.5  extern struct scheduler sched_bvt_def, sched_fbvt_def, sched_rrobin_def, sched_atropos_def;
     2.6  static struct scheduler *schedulers[] = { &sched_bvt_def,
     2.7 -					  &sched_fbvt_def,
     2.8 +					                      &sched_fbvt_def,
     2.9                                            &sched_rrobin_def,
    2.10                                            &sched_atropos_def,
    2.11                                            NULL};