ia64/xen-unstable

changeset 9644:81bc9e9fb40d

Remove various compile-time options from SEDF scheduler and
clean up formatting.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sun Apr 09 18:23:16 2006 +0100 (2006-04-09)
parents 886594fa3aef
children 1c03c45d0c06
files xen/common/sched_sedf.c
line diff
     1.1 --- a/xen/common/sched_sedf.c	Sat Apr 08 12:10:04 2006 +0100
     1.2 +++ b/xen/common/sched_sedf.c	Sun Apr 09 18:23:16 2006 +0100
     1.3 @@ -15,35 +15,24 @@
     1.4  
     1.5  /*verbosity settings*/
     1.6  #define SEDFLEVEL 0
     1.7 -#define PRINT(_f, _a...)  \
     1.8 -    if ((_f)<=SEDFLEVEL) printk(_a );
     1.9 +#define PRINT(_f, _a...)                        \
    1.10 +    do {                                        \
    1.11 +        if ( (_f) <= SEDFLEVEL )                \
    1.12 +            printk(_a );                        \
    1.13 +    } while ( 0 )
    1.14  
    1.15  #ifndef NDEBUG
    1.16  #define SEDF_STATS
    1.17 -#define CHECK(_p) if ( !(_p) ) \
    1.18 - { printk("Check '%s' failed, line %d, file %s\n", #_p , __LINE__,\
    1.19 - __FILE__);}
    1.20 +#define CHECK(_p)                                           \
    1.21 +    do {                                                    \
    1.22 +        if ( !(_p) )                                        \
    1.23 +            printk("Check '%s' failed, line %d, file %s\n", \
    1.24 +                   #_p , __LINE__, __FILE__);               \
    1.25 +    } while ( 0 )
    1.26  #else
    1.27  #define CHECK(_p) ((void)0)
    1.28  #endif
    1.29  
    1.30 -/*various ways of unblocking domains*/
    1.31 -#define UNBLOCK_ISOCHRONOUS_EDF 1
    1.32 -#define UNBLOCK_EDF 2
    1.33 -#define UNBLOCK_ATROPOS 3
    1.34 -#define UNBLOCK_SHORT_RESUME 4
    1.35 -#define UNBLOCK_BURST 5
    1.36 -#define UNBLOCK_EXTRA_SUPPORT 6
    1.37 -#define UNBLOCK UNBLOCK_EXTRA_SUPPORT
    1.38 -
    1.39 -/*various ways of treating extra-time*/
    1.40 -#define EXTRA_OFF 1
    1.41 -#define EXTRA_ROUNDR 2
    1.42 -#define EXTRA_SLICE_WEIGHT 3
    1.43 -#define EXTRA_BLOCK_WEIGHT 4
    1.44 -
    1.45 -#define EXTRA EXTRA_BLOCK_WEIGHT
    1.46 -
    1.47  #define EXTRA_NONE (0)
    1.48  #define EXTRA_AWARE (1)
    1.49  #define EXTRA_RUN_PEN (2)
    1.50 @@ -68,8 +57,8 @@
    1.51  struct sedf_dom_info {
    1.52      struct domain  *domain;
    1.53  };
    1.54 -struct sedf_vcpu_info
    1.55 -{
    1.56 +
    1.57 +struct sedf_vcpu_info {
    1.58      struct vcpu *vcpu;
    1.59      struct list_head list;
    1.60      struct list_head extralist[2];
    1.61 @@ -85,10 +74,10 @@ struct sedf_vcpu_info
    1.62      s_time_t  latency;
    1.63   
    1.64      /*status of domain*/
    1.65 -    int   status;
    1.66 +    int       status;
    1.67      /*weights for "Scheduling for beginners/ lazy/ etc." ;)*/
    1.68 -    short   weight;
    1.69 -    short                   extraweight;
    1.70 +    short     weight;
    1.71 +    short     extraweight;
    1.72      /*Bookkeeping*/
    1.73      s_time_t  deadl_abs;
    1.74      s_time_t  sched_start_abs;
    1.75 @@ -123,28 +112,29 @@ struct sedf_cpu_info {
    1.76      s_time_t         current_slice_expires;
    1.77  };
    1.78  
    1.79 -#define EDOM_INFO(d)  ((struct sedf_vcpu_info *)((d)->sched_priv))
    1.80 -#define CPU_INFO(cpu) ((struct sedf_cpu_info *)schedule_data[cpu].sched_priv)
    1.81 -#define LIST(d)   (&EDOM_INFO(d)->list)
    1.82 -#define EXTRALIST(d,i)  (&(EDOM_INFO(d)->extralist[i]))
    1.83 -#define RUNQ(cpu)     (&CPU_INFO(cpu)->runnableq)
    1.84 +#define EDOM_INFO(d)   ((struct sedf_vcpu_info *)((d)->sched_priv))
    1.85 +#define CPU_INFO(cpu)  ((struct sedf_cpu_info *)schedule_data[cpu].sched_priv)
    1.86 +#define LIST(d)        (&EDOM_INFO(d)->list)
    1.87 +#define EXTRALIST(d,i) (&(EDOM_INFO(d)->extralist[i]))
    1.88 +#define RUNQ(cpu)      (&CPU_INFO(cpu)->runnableq)
    1.89  #define WAITQ(cpu)     (&CPU_INFO(cpu)->waitq)
    1.90 -#define EXTRAQ(cpu,i)    (&(CPU_INFO(cpu)->extraq[i]))
    1.91 +#define EXTRAQ(cpu,i)  (&(CPU_INFO(cpu)->extraq[i]))
    1.92  #define IDLETASK(cpu)  ((struct vcpu *)schedule_data[cpu].idle)
    1.93  
    1.94  #define PERIOD_BEGIN(inf) ((inf)->deadl_abs - (inf)->period)
    1.95  
    1.96 -#define MIN(x,y) (((x)<(y))?(x):(y))
    1.97 +#define MIN(x,y)    (((x)<(y))?(x):(y))
    1.98  #define DIV_UP(x,y) (((x) + (y) - 1) / y)
    1.99  
   1.100 -#define extra_runs(inf) ((inf->status) & 6)
   1.101 +#define extra_runs(inf)      ((inf->status) & 6)
   1.102  #define extra_get_cur_q(inf) (((inf->status & 6) >> 1)-1)
   1.103 -#define sedf_runnable(edom) (!(EDOM_INFO(edom)->status & SEDF_ASLEEP))
   1.104 +#define sedf_runnable(edom)  (!(EDOM_INFO(edom)->status & SEDF_ASLEEP))
   1.105  
   1.106  
   1.107  static void sedf_dump_cpu_state(int i);
   1.108  
   1.109 -static inline int extraq_on(struct vcpu *d, int i) {
   1.110 +static inline int extraq_on(struct vcpu *d, int i)
   1.111 +{
   1.112      return ((EXTRALIST(d,i)->next != NULL) &&
   1.113              (EXTRALIST(d,i)->next != EXTRALIST(d,i)));
   1.114  }
   1.115 @@ -165,8 +155,8 @@ static inline void extraq_del(struct vcp
   1.116  {
   1.117      struct list_head *list = EXTRALIST(d,i);
   1.118      ASSERT(extraq_on(d,i));
   1.119 -    PRINT(3, "Removing domain %i.%i from L%i extraq\n", d->domain->domain_id,
   1.120 -          d->vcpu_id, i); 
   1.121 +    PRINT(3, "Removing domain %i.%i from L%i extraq\n",
   1.122 +          d->domain->domain_id, d->vcpu_id, i); 
   1.123      list_del(list);
   1.124      list->next = NULL;
   1.125      ASSERT(!extraq_on(d, i));
   1.126 @@ -178,94 +168,96 @@ static inline void extraq_del(struct vcp
   1.127     each entry, in order to avoid overflow. The algorithm works by simply
   1.128     charging each domain that recieved extratime with an inverse of its weight.
   1.129   */ 
   1.130 -static inline void extraq_add_sort_update(struct vcpu *d, int i, int sub) {
   1.131 +static inline void extraq_add_sort_update(struct vcpu *d, int i, int sub)
   1.132 +{
   1.133      struct list_head      *cur;
   1.134      struct sedf_vcpu_info *curinf;
   1.135   
   1.136      ASSERT(!extraq_on(d,i));
   1.137 +
   1.138      PRINT(3, "Adding domain %i.%i (score= %i, short_pen= %"PRIi64")"
   1.139            " to L%i extraq\n",
   1.140            d->domain->domain_id, d->vcpu_id, EDOM_INFO(d)->score[i],
   1.141            EDOM_INFO(d)->short_block_lost_tot, i); 
   1.142 -    /*iterate through all elements to find our "hole" and on our way
   1.143 -      update all the other scores*/
   1.144 -    list_for_each(cur,EXTRAQ(d->processor,i)){
   1.145 +
   1.146 +    /*
   1.147 +     * Iterate through all elements to find our "hole" and on our way
   1.148 +     * update all the other scores.
   1.149 +     */
   1.150 +    list_for_each ( cur, EXTRAQ(d->processor, i) )
   1.151 +    {
   1.152          curinf = list_entry(cur,struct sedf_vcpu_info,extralist[i]);
   1.153          curinf->score[i] -= sub;
   1.154 -        if (EDOM_INFO(d)->score[i] < curinf->score[i])
   1.155 +        if ( EDOM_INFO(d)->score[i] < curinf->score[i] )
   1.156              break;
   1.157 -        else
   1.158 -            PRINT(4,"\tbehind domain %i.%i (score= %i)\n",
   1.159 -                  curinf->vcpu->domain->domain_id,
   1.160 -                  curinf->vcpu->vcpu_id, curinf->score[i]);
   1.161 +        PRINT(4,"\tbehind domain %i.%i (score= %i)\n",
   1.162 +              curinf->vcpu->domain->domain_id,
   1.163 +              curinf->vcpu->vcpu_id, curinf->score[i]);
   1.164      }
   1.165 -    /*cur now contains the element, before which we'll enqueue*/
   1.166 +
   1.167 +    /* cur now contains the element, before which we'll enqueue. */
   1.168      PRINT(3, "\tlist_add to %p\n", cur->prev);
   1.169      list_add(EXTRALIST(d,i),cur->prev);
   1.170   
   1.171 -    /*continue updating the extraq*/
   1.172 -    if ((cur != EXTRAQ(d->processor,i)) && sub)
   1.173 -        for (cur = cur->next; cur != EXTRAQ(d->processor,i);
   1.174 -             cur = cur-> next) {
   1.175 -            curinf = list_entry(cur,struct sedf_vcpu_info,
   1.176 -                                extralist[i]);
   1.177 +    /* Continue updating the extraq. */
   1.178 +    if ( (cur != EXTRAQ(d->processor,i)) && sub )
   1.179 +    {
   1.180 +        for ( cur = cur->next; cur != EXTRAQ(d->processor,i); cur = cur->next )
   1.181 +        {
   1.182 +            curinf = list_entry(cur,struct sedf_vcpu_info, extralist[i]);
   1.183              curinf->score[i] -= sub;
   1.184              PRINT(4, "\tupdating domain %i.%i (score= %u)\n",
   1.185                    curinf->vcpu->domain->domain_id, 
   1.186                    curinf->vcpu->vcpu_id, curinf->score[i]);
   1.187          }
   1.188 +    }
   1.189 +
   1.190      ASSERT(extraq_on(d,i));
   1.191  }
   1.192 -static inline void extraq_check(struct vcpu *d) {
   1.193 -    if (extraq_on(d, EXTRA_UTIL_Q)) {
   1.194 -        PRINT(2,"Dom %i.%i is on L1 extraQ\n",d->domain->domain_id, d->vcpu_id);
   1.195 -        if (!(EDOM_INFO(d)->status & EXTRA_AWARE) &&
   1.196 -            !extra_runs(EDOM_INFO(d))) {
   1.197 +static inline void extraq_check(struct vcpu *d)
   1.198 +{
   1.199 +    if ( extraq_on(d, EXTRA_UTIL_Q) )
   1.200 +    {
   1.201 +        PRINT(2,"Dom %i.%i is on L1 extraQ\n",
   1.202 +              d->domain->domain_id, d->vcpu_id);
   1.203 +
   1.204 +        if ( !(EDOM_INFO(d)->status & EXTRA_AWARE) &&
   1.205 +             !extra_runs(EDOM_INFO(d)) )
   1.206 +        {
   1.207              extraq_del(d, EXTRA_UTIL_Q);
   1.208              PRINT(2,"Removed dom %i.%i from L1 extraQ\n",
   1.209                    d->domain->domain_id, d->vcpu_id);
   1.210          }
   1.211 -    } else {
   1.212 -        PRINT(2,"Dom %i.%i is NOT on L1 extraQ\n",d->domain->domain_id,
   1.213 +    }
   1.214 +    else
   1.215 +    {
   1.216 +        PRINT(2, "Dom %i.%i is NOT on L1 extraQ\n",
   1.217 +              d->domain->domain_id,
   1.218                d->vcpu_id);
   1.219 -        if ((EDOM_INFO(d)->status & EXTRA_AWARE) && sedf_runnable(d))
   1.220 +
   1.221 +        if ( (EDOM_INFO(d)->status & EXTRA_AWARE) && sedf_runnable(d) )
   1.222          {
   1.223 -#if (EXTRA == EXTRA_ROUNDR)
   1.224 -            extraq_add_tail(d, EXTRA_UTIL_Q);
   1.225 -#elif (EXTRA == EXTRA_SLICE_WEIGHT || \
   1.226 -          EXTRA == EXTRA_BLOCK_WEIGHT)
   1.227              extraq_add_sort_update(d, EXTRA_UTIL_Q, 0);
   1.228 -#elif
   1.229 -            ;
   1.230 -#endif
   1.231 -            PRINT(2,"Added dom %i.%i to L1 extraQ\n",d->domain->domain_id,
   1.232 -                  d->vcpu_id);
   1.233 +            PRINT(2,"Added dom %i.%i to L1 extraQ\n",
   1.234 +                  d->domain->domain_id, d->vcpu_id);
   1.235          }
   1.236      }
   1.237  }
   1.238  
   1.239 -static inline void extraq_check_add_unblocked(struct vcpu *d, 
   1.240 -                                              int priority) {
   1.241 +static inline void extraq_check_add_unblocked(struct vcpu *d, int priority)
   1.242 +{
   1.243      struct sedf_vcpu_info *inf = EDOM_INFO(d);
   1.244 -    if (inf->status & EXTRA_AWARE) 
   1.245 -#if (EXTRA == EXTRA_ROUNDR)
   1.246 -        if (priority)
   1.247 -            extraq_add_head(d,EXTRA_UTIL_Q);
   1.248 -        else
   1.249 -            extraq_add_tail(d,EXTRA_UTIL_Q);
   1.250 -#elif (EXTRA == EXTRA_SLICE_WEIGHT \
   1.251 -     || EXTRA == EXTRA_BLOCK_WEIGHT)
   1.252 -    /*put in on the weighted extraq, 
   1.253 -    without updating any scores*/
   1.254 -    extraq_add_sort_update(d, EXTRA_UTIL_Q, 0);
   1.255 -#else
   1.256 -    ;
   1.257 -#endif
   1.258 +
   1.259 +    if ( inf->status & EXTRA_AWARE )
   1.260 +        /* Put on the weighted extraq without updating any scores. */
   1.261 +        extraq_add_sort_update(d, EXTRA_UTIL_Q, 0);
   1.262  }
   1.263  
   1.264 -static inline int __task_on_queue(struct vcpu *d) {
   1.265 +static inline int __task_on_queue(struct vcpu *d)
   1.266 +{
   1.267      return (((LIST(d))->next != NULL) && (LIST(d)->next != LIST(d)));
   1.268  }
   1.269 +
   1.270  static inline void __del_from_queue(struct vcpu *d)
   1.271  {
   1.272      struct list_head *list = LIST(d);
   1.273 @@ -279,42 +271,47 @@ static inline void __del_from_queue(stru
   1.274  
   1.275  typedef int(*list_comparer)(struct list_head* el1, struct list_head* el2);
   1.276  
   1.277 -static inline void list_insert_sort(struct list_head *list,
   1.278 -                                    struct list_head *element, list_comparer comp) {
   1.279 +static inline void list_insert_sort(
   1.280 +    struct list_head *list, struct list_head *element, list_comparer comp)
   1.281 +{
   1.282      struct list_head     *cur;
   1.283 -    /*iterate through all elements to find our "hole"*/
   1.284 -    list_for_each(cur,list){
   1.285 -        if (comp(element, cur) < 0)
   1.286 +
   1.287 +    /* Iterate through all elements to find our "hole". */
   1.288 +    list_for_each( cur, list )
   1.289 +        if ( comp(element, cur) < 0 )
   1.290              break;
   1.291 -    }
   1.292 -    /*cur now contains the element, before which we'll enqueue*/
   1.293 +
   1.294 +    /* cur now contains the element, before which we'll enqueue. */
   1.295      PRINT(3,"\tlist_add to %p\n",cur->prev);
   1.296      list_add(element, cur->prev);
   1.297 -}  
   1.298 +}
   1.299 +
   1.300  #define DOMAIN_COMPARER(name, field, comp1, comp2)          \
   1.301  int name##_comp(struct list_head* el1, struct list_head* el2) \
   1.302  {                                                           \
   1.303 - struct sedf_vcpu_info *d1, *d2;                     \
   1.304 - d1 = list_entry(el1,struct sedf_vcpu_info, field);  \
   1.305 - d2 = list_entry(el2,struct sedf_vcpu_info, field);  \
   1.306 - if ((comp1) == (comp2))                             \
   1.307 -  return 0;                                   \
   1.308 - if ((comp1) < (comp2))                              \
   1.309 -  return -1;                                  \
   1.310 - else                                                \
   1.311 -  return 1;                                   \
   1.312 +    struct sedf_vcpu_info *d1, *d2;                     \
   1.313 +    d1 = list_entry(el1,struct sedf_vcpu_info, field);  \
   1.314 +    d2 = list_entry(el2,struct sedf_vcpu_info, field);  \
   1.315 +    if ( (comp1) == (comp2) )                             \
   1.316 +        return 0;                                   \
   1.317 +    if ( (comp1) < (comp2) )                              \
   1.318 +        return -1;                                  \
   1.319 +    else                                                \
   1.320 +        return 1;                                   \
   1.321  }
   1.322 +
   1.323  /* adds a domain to the queue of processes which wait for the beginning of the
   1.324     next period; this list is therefore sortet by this time, which is simply
   1.325     absol. deadline - period
   1.326   */ 
   1.327 -DOMAIN_COMPARER(waitq, list, PERIOD_BEGIN(d1), PERIOD_BEGIN(d2))
   1.328 -    static inline void __add_to_waitqueue_sort(struct vcpu *d) {
   1.329 -    ASSERT(!__task_on_queue(d));
   1.330 +DOMAIN_COMPARER(waitq, list, PERIOD_BEGIN(d1), PERIOD_BEGIN(d2));
   1.331 +static inline void __add_to_waitqueue_sort(struct vcpu *v)
   1.332 +{
   1.333 +    ASSERT(!__task_on_queue(v));
   1.334      PRINT(3,"Adding domain %i.%i (bop= %"PRIu64") to waitq\n",
   1.335 -          d->domain->domain_id, d->vcpu_id, PERIOD_BEGIN(EDOM_INFO(d)));
   1.336 -    list_insert_sort(WAITQ(d->processor), LIST(d), waitq_comp);
   1.337 -    ASSERT(__task_on_queue(d));
   1.338 +          v->domain->domain_id, v->vcpu_id, PERIOD_BEGIN(EDOM_INFO(v)));
   1.339 +    list_insert_sort(WAITQ(v->processor), LIST(v), waitq_comp);
   1.340 +    ASSERT(__task_on_queue(v));
   1.341  }
   1.342  
   1.343  /* adds a domain to the queue of processes which have started their current
   1.344 @@ -322,60 +319,62 @@ DOMAIN_COMPARER(waitq, list, PERIOD_BEGI
   1.345     on this list is running on the processor, if the list is empty the idle
   1.346     task will run. As we are implementing EDF, this list is sorted by deadlines.
   1.347   */ 
   1.348 -DOMAIN_COMPARER(runq, list, d1->deadl_abs, d2->deadl_abs)
   1.349 -    static inline void __add_to_runqueue_sort(struct vcpu *d) {
   1.350 +DOMAIN_COMPARER(runq, list, d1->deadl_abs, d2->deadl_abs);
   1.351 +static inline void __add_to_runqueue_sort(struct vcpu *v)
   1.352 +{
   1.353      PRINT(3,"Adding domain %i.%i (deadl= %"PRIu64") to runq\n",
   1.354 -          d->domain->domain_id, d->vcpu_id, EDOM_INFO(d)->deadl_abs);
   1.355 -    list_insert_sort(RUNQ(d->processor), LIST(d), runq_comp);
   1.356 +          v->domain->domain_id, v->vcpu_id, EDOM_INFO(v)->deadl_abs);
   1.357 +    list_insert_sort(RUNQ(v->processor), LIST(v), runq_comp);
   1.358  }
   1.359  
   1.360  
   1.361  /* Allocates memory for per domain private scheduling data*/
   1.362 -static int sedf_alloc_task(struct vcpu *d)
   1.363 +static int sedf_alloc_task(struct vcpu *v)
   1.364  {
   1.365      PRINT(2, "sedf_alloc_task was called, domain-id %i.%i\n",
   1.366 -          d->domain->domain_id, d->vcpu_id);
   1.367 +          v->domain->domain_id, v->vcpu_id);
   1.368  
   1.369 -    if ( d->domain->sched_priv == NULL )
   1.370 +    if ( v->domain->sched_priv == NULL )
   1.371      {
   1.372 -        d->domain->sched_priv = xmalloc(struct sedf_dom_info);
   1.373 -        if ( d->domain->sched_priv == NULL )
   1.374 +        v->domain->sched_priv = xmalloc(struct sedf_dom_info);
   1.375 +        if ( v->domain->sched_priv == NULL )
   1.376              return -1;
   1.377 -        memset(d->domain->sched_priv, 0, sizeof(struct sedf_dom_info));
   1.378 +        memset(v->domain->sched_priv, 0, sizeof(struct sedf_dom_info));
   1.379      }
   1.380  
   1.381 -    if ( (d->sched_priv = xmalloc(struct sedf_vcpu_info)) == NULL )
   1.382 +    if ( (v->sched_priv = xmalloc(struct sedf_vcpu_info)) == NULL )
   1.383          return -1;
   1.384  
   1.385 -    memset(d->sched_priv, 0, sizeof(struct sedf_vcpu_info));
   1.386 +    memset(v->sched_priv, 0, sizeof(struct sedf_vcpu_info));
   1.387  
   1.388      return 0;
   1.389  }
   1.390  
   1.391  
   1.392  /* Setup the sedf_dom_info */
   1.393 -static void sedf_add_task(struct vcpu *d)
   1.394 +static void sedf_add_task(struct vcpu *v)
   1.395  {
   1.396 -    struct sedf_vcpu_info *inf = EDOM_INFO(d);
   1.397 -    inf->vcpu = d;
   1.398 +    struct sedf_vcpu_info *inf = EDOM_INFO(v);
   1.399 +
   1.400 +    inf->vcpu = v;
   1.401   
   1.402 -    PRINT(2,"sedf_add_task was called, domain-id %i.%i\n",d->domain->domain_id,
   1.403 -          d->vcpu_id);
   1.404 +    PRINT(2,"sedf_add_task was called, domain-id %i.%i\n",
   1.405 +          v->domain->domain_id, v->vcpu_id);
   1.406  
   1.407      /* Allocate per-CPU context if this is the first domain to be added. */
   1.408 -    if ( unlikely(schedule_data[d->processor].sched_priv == NULL) )
   1.409 +    if ( unlikely(schedule_data[v->processor].sched_priv == NULL) )
   1.410      {
   1.411 -        schedule_data[d->processor].sched_priv = 
   1.412 +        schedule_data[v->processor].sched_priv = 
   1.413              xmalloc(struct sedf_cpu_info);
   1.414 -        BUG_ON(schedule_data[d->processor].sched_priv == NULL);
   1.415 -        memset(CPU_INFO(d->processor), 0, sizeof(*CPU_INFO(d->processor)));
   1.416 -        INIT_LIST_HEAD(WAITQ(d->processor));
   1.417 -        INIT_LIST_HEAD(RUNQ(d->processor));
   1.418 -        INIT_LIST_HEAD(EXTRAQ(d->processor,EXTRA_PEN_Q));
   1.419 -        INIT_LIST_HEAD(EXTRAQ(d->processor,EXTRA_UTIL_Q));
   1.420 +        BUG_ON(schedule_data[v->processor].sched_priv == NULL);
   1.421 +        memset(CPU_INFO(v->processor), 0, sizeof(*CPU_INFO(v->processor)));
   1.422 +        INIT_LIST_HEAD(WAITQ(v->processor));
   1.423 +        INIT_LIST_HEAD(RUNQ(v->processor));
   1.424 +        INIT_LIST_HEAD(EXTRAQ(v->processor,EXTRA_PEN_Q));
   1.425 +        INIT_LIST_HEAD(EXTRAQ(v->processor,EXTRA_UTIL_Q));
   1.426      }
   1.427         
   1.428 -    if ( d->domain->domain_id == 0 )
   1.429 +    if ( v->domain->domain_id == 0 )
   1.430      {
   1.431          /*set dom0 to something useful to boot the machine*/
   1.432          inf->period    = MILLISECS(20);
   1.433 @@ -400,14 +399,14 @@ static void sedf_add_task(struct vcpu *d
   1.434      INIT_LIST_HEAD(&(inf->extralist[EXTRA_PEN_Q]));
   1.435      INIT_LIST_HEAD(&(inf->extralist[EXTRA_UTIL_Q]));
   1.436   
   1.437 -    if ( !is_idle_vcpu(d) )
   1.438 +    if ( !is_idle_vcpu(v) )
   1.439      {
   1.440 -        extraq_check(d);
   1.441 +        extraq_check(v);
   1.442      }
   1.443      else
   1.444      {
   1.445 -        EDOM_INFO(d)->deadl_abs = 0;
   1.446 -        EDOM_INFO(d)->status &= ~SEDF_ASLEEP;
   1.447 +        EDOM_INFO(v)->deadl_abs = 0;
   1.448 +        EDOM_INFO(v)->status &= ~SEDF_ASLEEP;
   1.449      }
   1.450  }
   1.451  
   1.452 @@ -418,17 +417,11 @@ static void sedf_free_task(struct domain
   1.453  
   1.454      PRINT(2,"sedf_free_task was called, domain-id %i\n",d->domain_id);
   1.455  
   1.456 -    ASSERT(d->sched_priv != NULL);
   1.457      xfree(d->sched_priv);
   1.458   
   1.459      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   1.460 -    {
   1.461          if ( d->vcpu[i] )
   1.462 -        {
   1.463 -            ASSERT(d->vcpu[i]->sched_priv != NULL);
   1.464              xfree(d->vcpu[i]->sched_priv);
   1.465 -        }
   1.466 -    }
   1.467  }
   1.468  
   1.469  /*
   1.470 @@ -438,64 +431,60 @@ static void sedf_free_task(struct domain
   1.471  static void desched_edf_dom(s_time_t now, struct vcpu* d)
   1.472  {
   1.473      struct sedf_vcpu_info* inf = EDOM_INFO(d);
   1.474 -    /*current domain is running in real time mode*/
   1.475 - 
   1.476 +
   1.477 +    /* Current domain is running in real time mode. */
   1.478      ASSERT(__task_on_queue(d));
   1.479 -    /*update the domains cputime*/
   1.480 +
   1.481 +    /* Update the domain's cputime. */
   1.482      inf->cputime += now - inf->sched_start_abs;
   1.483  
   1.484 -    /*scheduling decisions, which don't remove the running domain
   1.485 -      from the runq*/
   1.486 +    /*
   1.487 +     * Scheduling decisions which don't remove the running domain from the
   1.488 +     * runq. 
   1.489 +     */
   1.490      if ( (inf->cputime < inf->slice) && sedf_runnable(d) )
   1.491          return;
   1.492    
   1.493      __del_from_queue(d);
   1.494    
   1.495 -    /*manage bookkeeping (i.e. calculate next deadline,
   1.496 -      memorize overun-time of slice) of finished domains*/
   1.497 +    /*
   1.498 +     * Manage bookkeeping (i.e. calculate next deadline, memorise
   1.499 +     * overrun-time of slice) of finished domains.
   1.500 +     */
   1.501      if ( inf->cputime >= inf->slice )
   1.502      {
   1.503          inf->cputime -= inf->slice;
   1.504    
   1.505          if ( inf->period < inf->period_orig )
   1.506          {
   1.507 -            /*this domain runs in latency scaling or burst mode*/
   1.508 -#if (UNBLOCK == UNBLOCK_BURST)
   1.509 -            /*if we are runnig in burst scaling wait for two periods
   1.510 -              before scaling periods up again*/ 
   1.511 -            if ( (now - inf->unblock_abs) >= (2 * inf->period) )
   1.512 -#endif
   1.513 +            /* This domain runs in latency scaling or burst mode. */
   1.514 +            inf->period *= 2;
   1.515 +            inf->slice  *= 2;
   1.516 +            if ( (inf->period > inf->period_orig) ||
   1.517 +                 (inf->slice > inf->slice_orig) )
   1.518              {
   1.519 -                inf->period *= 2; inf->slice *= 2;
   1.520 -                if ( (inf->period > inf->period_orig) ||
   1.521 -                     (inf->slice > inf->slice_orig) )
   1.522 -                {
   1.523 -                    /*reset slice & period*/
   1.524 -                    inf->period = inf->period_orig;
   1.525 -                    inf->slice = inf->slice_orig;
   1.526 -                }
   1.527 +                /* Reset slice and period. */
   1.528 +                inf->period = inf->period_orig;
   1.529 +                inf->slice = inf->slice_orig;
   1.530              }
   1.531          }
   1.532 -        /*set next deadline*/
   1.533 +
   1.534 +        /* Set next deadline. */
   1.535          inf->deadl_abs += inf->period;
   1.536      }
   1.537   
   1.538 -    /*add a runnable domain to the waitqueue*/
   1.539 +    /* Add a runnable domain to the waitqueue. */
   1.540      if ( sedf_runnable(d) )
   1.541      {
   1.542          __add_to_waitqueue_sort(d);
   1.543      }
   1.544      else
   1.545      {
   1.546 -        /*we have a blocked realtime task -> remove it from exqs too*/
   1.547 -#if (EXTRA > EXTRA_OFF)
   1.548 -#if (EXTRA == EXTRA_BLOCK_WEIGHT)
   1.549 +        /* We have a blocked realtime task -> remove it from exqs too. */
   1.550          if ( extraq_on(d, EXTRA_PEN_Q) )
   1.551              extraq_del(d, EXTRA_PEN_Q);
   1.552 -#endif
   1.553          if ( extraq_on(d, EXTRA_UTIL_Q) )
   1.554              extraq_del(d, EXTRA_UTIL_Q);
   1.555 -#endif
   1.556      }
   1.557  
   1.558      ASSERT(EQ(sedf_runnable(d), __task_on_queue(d)));
   1.559 @@ -513,58 +502,57 @@ static void update_queues(
   1.560   
   1.561      PRINT(3,"Updating waitq..\n");
   1.562  
   1.563 -    /*check for the first elements of the waitqueue, whether their
   1.564 -      next period has already started*/
   1.565 -    list_for_each_safe(cur, tmp, waitq) {
   1.566 +    /*
   1.567 +     * Check for the first elements of the waitqueue, whether their
   1.568 +     * next period has already started.
   1.569 +     */
   1.570 +    list_for_each_safe ( cur, tmp, waitq )
   1.571 +    {
   1.572          curinf = list_entry(cur, struct sedf_vcpu_info, list);
   1.573          PRINT(4,"\tLooking @ dom %i.%i\n",
   1.574                curinf->vcpu->domain->domain_id, curinf->vcpu->vcpu_id);
   1.575 -        if ( PERIOD_BEGIN(curinf) <= now )
   1.576 -        {
   1.577 -            __del_from_queue(curinf->vcpu);
   1.578 -            __add_to_runqueue_sort(curinf->vcpu);
   1.579 -        }
   1.580 -        else
   1.581 +        if ( PERIOD_BEGIN(curinf) > now )
   1.582              break;
   1.583 +        __del_from_queue(curinf->vcpu);
   1.584 +        __add_to_runqueue_sort(curinf->vcpu);
   1.585      }
   1.586   
   1.587      PRINT(3,"Updating runq..\n");
   1.588  
   1.589 -    /*process the runq, find domains that are on
   1.590 -      the runqueue which shouldn't be there*/
   1.591 -    list_for_each_safe(cur, tmp, runq) {
   1.592 +    /* Process the runq, find domains that are on the runq that shouldn't. */
   1.593 +    list_for_each_safe ( cur, tmp, runq )
   1.594 +    {
   1.595          curinf = list_entry(cur,struct sedf_vcpu_info,list);
   1.596          PRINT(4,"\tLooking @ dom %i.%i\n",
   1.597                curinf->vcpu->domain->domain_id, curinf->vcpu->vcpu_id);
   1.598  
   1.599          if ( unlikely(curinf->slice == 0) )
   1.600          {
   1.601 -            /*ignore domains with empty slice*/
   1.602 +            /* Ignore domains with empty slice. */
   1.603              PRINT(4,"\tUpdating zero-slice domain %i.%i\n",
   1.604                    curinf->vcpu->domain->domain_id,
   1.605                    curinf->vcpu->vcpu_id);
   1.606              __del_from_queue(curinf->vcpu);
   1.607  
   1.608 -            /*move them to their next period*/
   1.609 +            /* Move them to their next period. */
   1.610              curinf->deadl_abs += curinf->period;
   1.611 -            /*ensure that the start of the next period is in the future*/
   1.612 +
   1.613 +            /* Ensure that the start of the next period is in the future. */
   1.614              if ( unlikely(PERIOD_BEGIN(curinf) < now) )
   1.615 -            {
   1.616                  curinf->deadl_abs += 
   1.617                      (DIV_UP(now - PERIOD_BEGIN(curinf),
   1.618 -                           curinf->period)) * curinf->period;
   1.619 -            }
   1.620 -            /*and put them back into the queue*/
   1.621 +                            curinf->period)) * curinf->period;
   1.622 +
   1.623 +            /* Put them back into the queue. */
   1.624              __add_to_waitqueue_sort(curinf->vcpu);
   1.625 -            continue;
   1.626          }
   1.627 -
   1.628 -        if ( unlikely((curinf->deadl_abs < now) ||
   1.629 -                      (curinf->cputime > curinf->slice)) )
   1.630 +        else if ( unlikely((curinf->deadl_abs < now) ||
   1.631 +                           (curinf->cputime > curinf->slice)) )
   1.632          {
   1.633 -            /*we missed the deadline or the slice was
   1.634 -              already finished... might hapen because
   1.635 -              of dom_adj.*/
   1.636 +            /*
   1.637 +             * We missed the deadline or the slice was already finished.
   1.638 +             * Might hapen because of dom_adj.
   1.639 +             */
   1.640              PRINT(4,"\tDomain %i.%i exceeded it's deadline/"
   1.641                    "slice (%"PRIu64" / %"PRIu64") now: %"PRIu64
   1.642                    " cputime: %"PRIu64"\n",
   1.643 @@ -573,20 +561,23 @@ static void update_queues(
   1.644                    curinf->deadl_abs, curinf->slice, now,
   1.645                    curinf->cputime);
   1.646              __del_from_queue(curinf->vcpu);
   1.647 -            /*common case: we miss one period!*/
   1.648 +
   1.649 +            /* Common case: we miss one period. */
   1.650              curinf->deadl_abs += curinf->period;
   1.651     
   1.652 -            /*if we are still behind: modulo arithmetic,
   1.653 -              force deadline to be in future and
   1.654 -              aligned to period borders!*/
   1.655 -            if (unlikely(curinf->deadl_abs < now))
   1.656 +            /*
   1.657 +             * If we are still behind: modulo arithmetic, force deadline
   1.658 +             * to be in future and aligned to period borders.
   1.659 +             */
   1.660 +            if ( unlikely(curinf->deadl_abs < now) )
   1.661                  curinf->deadl_abs += 
   1.662                      DIV_UP(now - curinf->deadl_abs,
   1.663                             curinf->period) * curinf->period;
   1.664              ASSERT(curinf->deadl_abs >= now);
   1.665 -            /*give a fresh slice*/
   1.666 +
   1.667 +            /* Give a fresh slice. */
   1.668              curinf->cputime = 0;
   1.669 -            if (PERIOD_BEGIN(curinf) > now)
   1.670 +            if ( PERIOD_BEGIN(curinf) > now )
   1.671                  __add_to_waitqueue_sort(curinf->vcpu);
   1.672              else
   1.673                  __add_to_runqueue_sort(curinf->vcpu);
   1.674 @@ -594,43 +585,36 @@ static void update_queues(
   1.675          else
   1.676              break;
   1.677      }
   1.678 +
   1.679      PRINT(3,"done updating the queues\n");
   1.680  }
   1.681  
   1.682  
   1.683 -#if (EXTRA > EXTRA_OFF)
   1.684  /* removes a domain from the head of the according extraQ and
   1.685     requeues it at a specified position:
   1.686       round-robin extratime: end of extraQ
   1.687       weighted ext.: insert in sorted list by score
   1.688     if the domain is blocked / has regained its short-block-loss
   1.689     time it is not put on any queue */
   1.690 -static void desched_extra_dom(s_time_t now, struct vcpu* d)
   1.691 +static void desched_extra_dom(s_time_t now, struct vcpu *d)
   1.692  {
   1.693      struct sedf_vcpu_info *inf = EDOM_INFO(d);
   1.694      int i = extra_get_cur_q(inf);
   1.695 - 
   1.696 -#if (EXTRA == EXTRA_SLICE_WEIGHT || EXTRA == EXTRA_BLOCK_WEIGHT)
   1.697 -    unsigned long         oldscore;
   1.698 -#endif
   1.699 +    unsigned long oldscore;
   1.700 +
   1.701      ASSERT(extraq_on(d, i));
   1.702 -    /*unset all running flags*/
   1.703 +
   1.704 +    /* Unset all running flags. */
   1.705      inf->status  &= ~(EXTRA_RUN_PEN | EXTRA_RUN_UTIL);
   1.706 -    /*fresh slice for the next run*/
   1.707 +    /* Fresh slice for the next run. */
   1.708      inf->cputime = 0;
   1.709 -    /*accumulate total extratime*/
   1.710 +    /* Accumulate total extratime. */
   1.711      inf->extra_time_tot += now - inf->sched_start_abs;
   1.712 -    /*remove extradomain from head of the queue*/
   1.713 +    /* Remove extradomain from head of the queue. */
   1.714      extraq_del(d, i);
   1.715  
   1.716 -#if (EXTRA == EXTRA_ROUNDR)
   1.717 -    if ( sedf_runnable(d) && (inf->status & EXTRA_AWARE) )
   1.718 -        /*add to the tail if it is runnable => round-robin*/
   1.719 -        extraq_add_tail(d, EXTRA_UTIL_Q);
   1.720 -#elif (EXTRA == EXTRA_SLICE_WEIGHT || EXTRA == EXTRA_BLOCK_WEIGHT)
   1.721 -    /*update the score*/
   1.722 +    /* Update the score. */
   1.723      oldscore = inf->score[i];
   1.724 -#if (EXTRA == EXTRA_BLOCK_WEIGHT)
   1.725      if ( i == EXTRA_PEN_Q )
   1.726      {
   1.727          /*domain was running in L0 extraq*/
   1.728 @@ -640,7 +624,8 @@ static void desched_extra_dom(s_time_t n
   1.729          PRINT(3,"Domain %i.%i: Short_block_loss: %"PRIi64"\n", 
   1.730                inf->vcpu->domain->domain_id, inf->vcpu->vcpu_id,
   1.731                inf->short_block_lost_tot);
   1.732 -        if (inf->short_block_lost_tot <= 0) {
   1.733 +        if ( inf->short_block_lost_tot <= 0 )
   1.734 +        {
   1.735              PRINT(4,"Domain %i.%i compensated short block loss!\n",
   1.736                    inf->vcpu->domain->domain_id, inf->vcpu->vcpu_id);
   1.737              /*we have (over-)compensated our block penalty*/
   1.738 @@ -649,6 +634,7 @@ static void desched_extra_dom(s_time_t n
   1.739              inf->status &= ~EXTRA_WANT_PEN_Q;
   1.740              goto check_extra_queues;
   1.741          }
   1.742 +
   1.743          /*we have to go again for another try in the block-extraq,
   1.744            the score is not used incremantally here, as this is
   1.745            already done by recalculating the block_lost*/
   1.746 @@ -657,7 +643,6 @@ static void desched_extra_dom(s_time_t n
   1.747          oldscore = 0;
   1.748      }
   1.749      else
   1.750 -#endif
   1.751      {
   1.752          /*domain was running in L1 extraq => score is inverse of
   1.753            utilization and is used somewhat incremental!*/
   1.754 @@ -684,7 +669,6 @@ static void desched_extra_dom(s_time_t n
   1.755      {
   1.756          /*remove this blocked domain from the waitq!*/
   1.757          __del_from_queue(d);
   1.758 -#if (EXTRA == EXTRA_BLOCK_WEIGHT)
   1.759          /*make sure that we remove a blocked domain from the other
   1.760            extraq too*/
   1.761          if ( i == EXTRA_PEN_Q )
   1.762 @@ -697,14 +681,12 @@ static void desched_extra_dom(s_time_t n
   1.763              if ( extraq_on(d, EXTRA_PEN_Q) )
   1.764                  extraq_del(d, EXTRA_PEN_Q);
   1.765          }
   1.766 -#endif
   1.767      }
   1.768 -#endif
   1.769 +
   1.770      ASSERT(EQ(sedf_runnable(d), __task_on_queue(d)));
   1.771      ASSERT(IMPLY(extraq_on(d, EXTRA_UTIL_Q) || extraq_on(d, EXTRA_PEN_Q), 
   1.772                   sedf_runnable(d)));
   1.773  }
   1.774 -#endif
   1.775  
   1.776  
   1.777  static struct task_slice sedf_do_extra_schedule(
   1.778 @@ -718,7 +700,6 @@ static struct task_slice sedf_do_extra_s
   1.779      if ( end_xt - now < EXTRA_QUANTUM )
   1.780          goto return_idle;
   1.781  
   1.782 -#if (EXTRA == EXTRA_BLOCK_WEIGHT)
   1.783      if ( !list_empty(extraq[EXTRA_PEN_Q]) )
   1.784      {
   1.785          /*we still have elements on the level 0 extraq 
   1.786 @@ -733,7 +714,6 @@ static struct task_slice sedf_do_extra_s
   1.787  #endif
   1.788      }
   1.789      else
   1.790 -#endif
   1.791      {
   1.792          if ( !list_empty(extraq[EXTRA_UTIL_Q]) )
   1.793          {
   1.794 @@ -772,11 +752,9 @@ static struct task_slice sedf_do_schedul
   1.795      int                   cpu      = smp_processor_id();
   1.796      struct list_head     *runq     = RUNQ(cpu);
   1.797      struct list_head     *waitq    = WAITQ(cpu);
   1.798 -#if (EXTRA > EXTRA_OFF)
   1.799      struct sedf_vcpu_info *inf     = EDOM_INFO(current);
   1.800      struct list_head      *extraq[] = {
   1.801          EXTRAQ(cpu, EXTRA_PEN_Q), EXTRAQ(cpu, EXTRA_UTIL_Q)};
   1.802 -#endif
   1.803      struct sedf_vcpu_info *runinf, *waitinf;
   1.804      struct task_slice      ret;
   1.805  
   1.806 @@ -793,14 +771,12 @@ static struct task_slice sedf_do_schedul
   1.807      if ( inf->status & SEDF_ASLEEP )
   1.808          inf->block_abs = now;
   1.809  
   1.810 -#if (EXTRA > EXTRA_OFF)
   1.811      if ( unlikely(extra_runs(inf)) )
   1.812      {
   1.813          /*special treatment of domains running in extra time*/
   1.814          desched_extra_dom(now, current);
   1.815      }
   1.816      else 
   1.817 -#endif
   1.818      {
   1.819          desched_edf_dom(now, current);
   1.820      }
   1.821 @@ -837,13 +813,8 @@ static struct task_slice sedf_do_schedul
   1.822          waitinf  = list_entry(waitq->next,struct sedf_vcpu_info, list);
   1.823          /*we could not find any suitable domain 
   1.824            => look for domains that are aware of extratime*/
   1.825 -#if (EXTRA > EXTRA_OFF)
   1.826          ret = sedf_do_extra_schedule(now, PERIOD_BEGIN(waitinf),
   1.827                                       extraq, cpu);
   1.828 -#else
   1.829 -        ret.task = IDLETASK(cpu);
   1.830 -        ret.time = PERIOD_BEGIN(waitinf) - now;
   1.831 -#endif
   1.832          CHECK(ret.time > 0);
   1.833      }
   1.834      else
   1.835 @@ -891,14 +862,10 @@ static void sedf_sleep(struct vcpu *d)
   1.836      {
   1.837          if ( __task_on_queue(d) )
   1.838              __del_from_queue(d);
   1.839 -#if (EXTRA > EXTRA_OFF)
   1.840          if ( extraq_on(d, EXTRA_UTIL_Q) ) 
   1.841              extraq_del(d, EXTRA_UTIL_Q);
   1.842 -#endif
   1.843 -#if (EXTRA == EXTRA_BLOCK_WEIGHT)
   1.844          if ( extraq_on(d, EXTRA_PEN_Q) )
   1.845              extraq_del(d, EXTRA_PEN_Q);
   1.846 -#endif
   1.847      }
   1.848  }
   1.849  
   1.850 @@ -939,7 +906,7 @@ static void sedf_sleep(struct vcpu *d)
   1.851   *     -addition: experiments have shown that this may have a HUGE impact on
   1.852   *      performance of other domains, becaus it can lead to excessive context
   1.853   *      switches
   1.854 - 
   1.855 + *
   1.856   *    Part2: Long Unblocking
   1.857   *    Part 2a
   1.858   *     -it is obvious that such accounting of block time, applied when
   1.859 @@ -974,32 +941,6 @@ static void sedf_sleep(struct vcpu *d)
   1.860   *     -either behaviour can lead to missed deadlines in other domains as
   1.861   *      opposed to approaches 1,2a,2b
   1.862   */
   1.863 -#if (UNBLOCK <= UNBLOCK_SHORT_RESUME)
   1.864 -static void unblock_short_vcons(struct sedf_vcpu_info* inf, s_time_t now)
   1.865 -{
   1.866 -    inf->deadl_abs += inf->period;
   1.867 -    inf->cputime = 0;
   1.868 -}
   1.869 -#endif
   1.870 -
   1.871 -#if (UNBLOCK == UNBLOCK_SHORT_RESUME)
   1.872 -static void unblock_short_cons(struct sedf_vcpu_info* inf, s_time_t now)
   1.873 -{
   1.874 -    /*treat blocked time as consumed by the domain*/
   1.875 -    inf->cputime += now - inf->block_abs; 
   1.876 -    if ( (inf->cputime + EXTRA_QUANTUM) > inf->slice )
   1.877 -    {
   1.878 -        /*we don't have a reasonable amount of time in 
   1.879 -          our slice left :( => start in next period!*/
   1.880 -        unblock_short_vcons(inf, now);
   1.881 -    }
   1.882 -#ifdef SEDF_STATS
   1.883 -    else
   1.884 -        inf->short_cont++;
   1.885 -#endif
   1.886 -}
   1.887 -#endif
   1.888 -
   1.889  static void unblock_short_extra_support(
   1.890      struct sedf_vcpu_info* inf, s_time_t now)
   1.891  {
   1.892 @@ -1051,33 +992,6 @@ static void unblock_short_extra_support(
   1.893  }
   1.894  
   1.895  
   1.896 -#if (UNBLOCK == UNBLOCK_ISOCHRONOUS_EDF)
   1.897 -static void unblock_long_vcons(struct sedf_vcpu_info* inf, s_time_t now)
   1.898 -{
   1.899 -    /* align to next future period */
   1.900 -    inf->deadl_abs += (DIV_UP(now - inf->deadl_abs, inf->period) +1)
   1.901 -        * inf->period;
   1.902 -    inf->cputime = 0;
   1.903 -}
   1.904 -#endif
   1.905 -
   1.906 -
   1.907 -#if 0
   1.908 -static void unblock_long_cons_a (struct sedf_vcpu_info* inf, s_time_t now)
   1.909 -{
   1.910 -    /*treat the time the domain was blocked in the
   1.911 -     CURRENT period as consumed by the domain*/
   1.912 -    inf->cputime = (now - inf->deadl_abs) % inf->period; 
   1.913 -    if ( (inf->cputime + EXTRA_QUANTUM) > inf->slice )
   1.914 -    {
   1.915 -        /*we don't have a reasonable amount of time in our slice
   1.916 -          left :( => start in next period!*/
   1.917 -        unblock_long_vcons(inf, now);
   1.918 -    }
   1.919 -}
   1.920 -#endif
   1.921 -
   1.922 -
   1.923  static void unblock_long_cons_b(struct sedf_vcpu_info* inf,s_time_t now)
   1.924  {
   1.925      /*Conservative 2b*/
   1.926 @@ -1087,110 +1001,6 @@ static void unblock_long_cons_b(struct s
   1.927  }
   1.928  
   1.929  
   1.930 -#if (UNBLOCK == UNBLOCK_ATROPOS)
   1.931 -static void unblock_long_cons_c(struct sedf_vcpu_info* inf,s_time_t now)
   1.932 -{
   1.933 -    if ( likely(inf->latency) )
   1.934 -    {
   1.935 -        /*scale the slice and period accordingly to the latency hint*/
   1.936 -        /*reduce period temporarily to the latency hint*/
   1.937 -        inf->period = inf->latency;
   1.938 -        /*this results in max. 4s slice/period length*/
   1.939 -        ASSERT((inf->period < ULONG_MAX)
   1.940 -               && (inf->slice_orig < ULONG_MAX));
   1.941 -        /*scale slice accordingly, so that utilisation stays the same*/
   1.942 -        inf->slice = (inf->period * inf->slice_orig)
   1.943 -            / inf->period_orig;
   1.944 -        inf->deadl_abs = now + inf->period;
   1.945 -        inf->cputime = 0;
   1.946 -    } 
   1.947 -    else
   1.948 -    {
   1.949 -        /*we don't have a latency hint.. use some other technique*/
   1.950 -        unblock_long_cons_b(inf, now);
   1.951 -    }
   1.952 -}
   1.953 -#endif
   1.954 -
   1.955 -
   1.956 -#if (UNBLOCK == UNBLOCK_BURST)
   1.957 -/*a new idea of dealing with short blocks: burst period scaling*/
   1.958 -static void unblock_short_burst(struct sedf_vcpu_info* inf, s_time_t now)
   1.959 -{
   1.960 -    /*treat blocked time as consumed by the domain*/
   1.961 -    inf->cputime += now - inf->block_abs;
   1.962 - 
   1.963 -    if ( (inf->cputime + EXTRA_QUANTUM) <= inf->slice )
   1.964 -    {
   1.965 -        /*if we can still use some time in the current slice
   1.966 -          then use it!*/
   1.967 -#ifdef SEDF_STATS
   1.968 -        /*we let the domain run in the current period*/
   1.969 -        inf->short_cont++;
   1.970 -#endif
   1.971 -    }
   1.972 -    else
   1.973 -    {
   1.974 -        /*we don't have a reasonable amount of time in
   1.975 -          our slice left => switch to burst mode*/
   1.976 -        if ( likely(inf->unblock_abs) )
   1.977 -        {
   1.978 -            /*set the period-length to the current blocking
   1.979 -              interval, possible enhancements: average over last
   1.980 -              blocking intervals, user-specified minimum,...*/
   1.981 -            inf->period = now - inf->unblock_abs;
   1.982 -            /*check for overflow on multiplication*/
   1.983 -            ASSERT((inf->period < ULONG_MAX) 
   1.984 -                   && (inf->slice_orig < ULONG_MAX));
   1.985 -            /*scale slice accordingly, so that utilisation
   1.986 -              stays the same*/
   1.987 -            inf->slice = (inf->period * inf->slice_orig)
   1.988 -                / inf->period_orig;
   1.989 -            /*set new (shorter) deadline*/
   1.990 -            inf->deadl_abs += inf->period;
   1.991 -        }
   1.992 -        else
   1.993 -        {
   1.994 -            /*in case we haven't unblocked before
   1.995 -              start in next period!*/
   1.996 -            inf->cputime=0;
   1.997 -            inf->deadl_abs += inf->period;
   1.998 -        }
   1.999 -    }
  1.1000 -
  1.1001 -    inf->unblock_abs = now;
  1.1002 -}
  1.1003 -
  1.1004 -
  1.1005 -static void unblock_long_burst(struct sedf_vcpu_info* inf, s_time_t now)
  1.1006 -{
  1.1007 -    if ( unlikely(inf->latency && (inf->period > inf->latency)) )
  1.1008 -    {
  1.1009 -        /*scale the slice and period accordingly to the latency hint*/
  1.1010 -        inf->period = inf->latency;
  1.1011 -        /*check for overflows on multiplication*/
  1.1012 -        ASSERT((inf->period < ULONG_MAX)
  1.1013 -               && (inf->slice_orig < ULONG_MAX));
  1.1014 -        /*scale slice accordingly, so that utilisation stays the same*/
  1.1015 -        inf->slice = (inf->period * inf->slice_orig)
  1.1016 -            / inf->period_orig;
  1.1017 -        inf->deadl_abs = now + inf->period;
  1.1018 -        inf->cputime = 0;
  1.1019 -    }
  1.1020 -    else
  1.1021 -    {
  1.1022 -        /*we don't have a latency hint.. or we are currently in 
  1.1023 -          "burst mode": use some other technique
  1.1024 -          NB: this should be in fact the normal way of operation,
  1.1025 -          when we are in sync with the device!*/
  1.1026 -        unblock_long_cons_b(inf, now);
  1.1027 -    }
  1.1028 -
  1.1029 -    inf->unblock_abs = now;
  1.1030 -}
  1.1031 -#endif /* UNBLOCK == UNBLOCK_BURST */
  1.1032 -
  1.1033 -
  1.1034  #define DOMAIN_EDF   1
  1.1035  #define DOMAIN_EXTRA_PEN  2
  1.1036  #define DOMAIN_EXTRA_UTIL  3
  1.1037 @@ -1225,32 +1035,31 @@ static inline int should_switch(struct v
  1.1038      cur_inf   = EDOM_INFO(cur);
  1.1039      other_inf = EDOM_INFO(other);
  1.1040   
  1.1041 - /*check whether we need to make an earlier sched-decision*/
  1.1042 -    if (PERIOD_BEGIN(other_inf) < 
  1.1043 -        CPU_INFO(other->processor)->current_slice_expires)
  1.1044 +    /* Check whether we need to make an earlier scheduling decision. */
  1.1045 +    if ( PERIOD_BEGIN(other_inf) < 
  1.1046 +         CPU_INFO(other->processor)->current_slice_expires )
  1.1047          return 1;
  1.1048 -    /*no timing-based switches need to be taken into account here*/
  1.1049 -    switch (get_run_type(cur)) {
  1.1050 +
  1.1051 +    /* No timing-based switches need to be taken into account here. */
  1.1052 +    switch ( get_run_type(cur) )
  1.1053 +    {
  1.1054      case DOMAIN_EDF:
  1.1055 -        /* do not interrupt a running EDF domain */ 
  1.1056 +        /* Do not interrupt a running EDF domain. */
  1.1057          return 0;
  1.1058      case DOMAIN_EXTRA_PEN:
  1.1059 -        /*check whether we also want 
  1.1060 -          the L0 ex-q with lower score*/
  1.1061 -        if ((other_inf->status & EXTRA_WANT_PEN_Q)
  1.1062 -            &&  (other_inf->score[EXTRA_PEN_Q] < 
  1.1063 -                 cur_inf->score[EXTRA_PEN_Q]))
  1.1064 -            return 1;
  1.1065 -        else return 0;
  1.1066 +        /* Check whether we also want the L0 ex-q with lower score. */
  1.1067 +        return ((other_inf->status & EXTRA_WANT_PEN_Q) &&
  1.1068 +                (other_inf->score[EXTRA_PEN_Q] < 
  1.1069 +                 cur_inf->score[EXTRA_PEN_Q]));
  1.1070      case DOMAIN_EXTRA_UTIL:
  1.1071 -        /*check whether we want the L0 extraq, don't
  1.1072 -          switch if both domains want L1 extraq */
  1.1073 -        if (other_inf->status & EXTRA_WANT_PEN_Q)
  1.1074 -            return 1;
  1.1075 -        else return 0;
  1.1076 +        /* Check whether we want the L0 extraq. Don't
  1.1077 +         * switch if both domains want L1 extraq.
  1.1078 +         */
  1.1079 +        return !!(other_inf->status & EXTRA_WANT_PEN_Q);
  1.1080      case DOMAIN_IDLE:
  1.1081          return 1;
  1.1082      }
  1.1083 +
  1.1084      return 1;
  1.1085  }
  1.1086  
  1.1087 @@ -1295,7 +1104,6 @@ void sedf_wake(struct vcpu *d)
  1.1088      {
  1.1089          PRINT(4,"extratime unblock\n");
  1.1090          /* unblocking in extra-time! */
  1.1091 -#if (EXTRA == EXTRA_BLOCK_WEIGHT)
  1.1092          if ( inf->status & EXTRA_WANT_PEN_Q )
  1.1093          {
  1.1094              /*we have a domain that wants compensation
  1.1095 @@ -1304,7 +1112,6 @@ void sedf_wake(struct vcpu *d)
  1.1096                chance!*/
  1.1097              extraq_add_sort_update(d, EXTRA_PEN_Q, 0);
  1.1098          }
  1.1099 -#endif
  1.1100          extraq_check_add_unblocked(d, 0);
  1.1101      }  
  1.1102      else
  1.1103 @@ -1316,15 +1123,7 @@ void sedf_wake(struct vcpu *d)
  1.1104  #ifdef SEDF_STATS
  1.1105              inf->short_block_tot++;
  1.1106  #endif
  1.1107 -#if (UNBLOCK <= UNBLOCK_ATROPOS)
  1.1108 -            unblock_short_vcons(inf, now);
  1.1109 -#elif (UNBLOCK == UNBLOCK_SHORT_RESUME)
  1.1110 -            unblock_short_cons(inf, now);
  1.1111 -#elif (UNBLOCK == UNBLOCK_BURST)
  1.1112 -            unblock_short_burst(inf, now);
  1.1113 -#elif (UNBLOCK == UNBLOCK_EXTRA_SUPPORT)
  1.1114              unblock_short_extra_support(inf, now);
  1.1115 -#endif
  1.1116  
  1.1117              extraq_check_add_unblocked(d, 1);
  1.1118          }
  1.1119 @@ -1335,18 +1134,7 @@ void sedf_wake(struct vcpu *d)
  1.1120  #ifdef SEDF_STATS
  1.1121              inf->long_block_tot++;
  1.1122  #endif
  1.1123 -#if (UNBLOCK == UNBLOCK_ISOCHRONOUS_EDF)
  1.1124 -            unblock_long_vcons(inf, now);
  1.1125 -#elif (UNBLOCK == UNBLOCK_EDF \
  1.1126 -       || UNBLOCK == UNBLOCK_EXTRA_SUPPORT)
  1.1127              unblock_long_cons_b(inf, now);
  1.1128 -#elif (UNBLOCK == UNBLOCK_ATROPOS)
  1.1129 -            unblock_long_cons_c(inf, now);
  1.1130 -#elif (UNBLOCK == UNBLOCK_SHORT_RESUME)
  1.1131 -            unblock_long_cons_b(inf, now);
  1.1132 -#elif (UNBLOCK == UNBLOCK_BURST)
  1.1133 -            unblock_long_burst(inf, now);
  1.1134 -#endif
  1.1135  
  1.1136              extraq_check_add_unblocked(d, 1);
  1.1137          }
  1.1138 @@ -1528,7 +1316,7 @@ static int sedf_adjust_weights(struct sc
  1.1139          sumt[cpu] = 0;
  1.1140      }
  1.1141  
  1.1142 -    /* sum up all weights */
  1.1143 +    /* Sum across all weights. */
  1.1144      for_each_domain( d )
  1.1145      {
  1.1146          for_each_vcpu( d, p )
  1.1147 @@ -1553,7 +1341,7 @@ static int sedf_adjust_weights(struct sc
  1.1148          }
  1.1149      }
  1.1150  
  1.1151 -    /* adjust all slices (and periods) to the new weight */
  1.1152 +    /* Adjust all slices (and periods) to the new weight. */
  1.1153      for_each_domain( d )
  1.1154      {
  1.1155          for_each_vcpu ( d, p )
  1.1156 @@ -1580,35 +1368,42 @@ static int sedf_adjdom(struct domain *p,
  1.1157  {
  1.1158      struct vcpu *v;
  1.1159  
  1.1160 -    PRINT(2,"sedf_adjdom was called, domain-id %i new period %"PRIu64" "\
  1.1161 +    PRINT(2,"sedf_adjdom was called, domain-id %i new period %"PRIu64" "
  1.1162            "new slice %"PRIu64"\nlatency %"PRIu64" extra:%s\n",
  1.1163            p->domain_id, cmd->u.sedf.period, cmd->u.sedf.slice,
  1.1164            cmd->u.sedf.latency, (cmd->u.sedf.extratime)?"yes":"no");
  1.1165  
  1.1166      if ( cmd->direction == SCHED_INFO_PUT )
  1.1167      {
  1.1168 -        /*check for sane parameters*/
  1.1169 -        if (!cmd->u.sedf.period && !cmd->u.sedf.weight)
  1.1170 +        /* Check for sane parameters. */
  1.1171 +        if ( !cmd->u.sedf.period && !cmd->u.sedf.weight )
  1.1172              return -EINVAL;
  1.1173 -        if (cmd->u.sedf.weight) {
  1.1174 -            if ((cmd->u.sedf.extratime & EXTRA_AWARE) &&
  1.1175 -                (! cmd->u.sedf.period)) {
  1.1176 -                /*weight driven domains with xtime ONLY!*/
  1.1177 -                for_each_vcpu(p, v) {
  1.1178 +        if ( cmd->u.sedf.weight )
  1.1179 +        {
  1.1180 +            if ( (cmd->u.sedf.extratime & EXTRA_AWARE) &&
  1.1181 +                 (!cmd->u.sedf.period) )
  1.1182 +            {
  1.1183 +                /* Weight-driven domains with extratime only. */
  1.1184 +                for_each_vcpu ( p, v )
  1.1185 +                {
  1.1186                      EDOM_INFO(v)->extraweight = cmd->u.sedf.weight;
  1.1187                      EDOM_INFO(v)->weight = 0;
  1.1188                      EDOM_INFO(v)->slice = 0;
  1.1189                      EDOM_INFO(v)->period = WEIGHT_PERIOD;
  1.1190                  }
  1.1191 -            } else {
  1.1192 -                /*weight driven domains with real-time execution*/
  1.1193 -                for_each_vcpu(p, v)
  1.1194 +            }
  1.1195 +            else
  1.1196 +            {
  1.1197 +                /* Weight-driven domains with real-time execution. */
  1.1198 +                for_each_vcpu ( p, v )
  1.1199                      EDOM_INFO(v)->weight = cmd->u.sedf.weight;
  1.1200              }
  1.1201          }
  1.1202 -        else {
  1.1203 -            /*time driven domains*/
  1.1204 -            for_each_vcpu(p, v) {
  1.1205 +        else
  1.1206 +        {
  1.1207 +            /* Time-driven domains. */
  1.1208 +            for_each_vcpu ( p, v )
  1.1209 +            {
  1.1210                  /*
  1.1211                   * Sanity checking: note that disabling extra weight requires
  1.1212                   * that we set a non-zero slice.
  1.1213 @@ -1626,10 +1421,12 @@ static int sedf_adjdom(struct domain *p,
  1.1214                      EDOM_INFO(v)->slice   = cmd->u.sedf.slice;
  1.1215              }
  1.1216          }
  1.1217 -        if (sedf_adjust_weights(cmd))
  1.1218 +
  1.1219 +        if ( sedf_adjust_weights(cmd) )
  1.1220              return -EINVAL;
  1.1221 -   
  1.1222 -        for_each_vcpu(p, v) {
  1.1223 +
  1.1224 +        for_each_vcpu ( p, v )
  1.1225 +        {
  1.1226              EDOM_INFO(v)->status  = 
  1.1227                  (EDOM_INFO(v)->status &
  1.1228                   ~EXTRA_AWARE) | (cmd->u.sedf.extratime & EXTRA_AWARE);
  1.1229 @@ -1641,11 +1438,11 @@ static int sedf_adjdom(struct domain *p,
  1.1230      {
  1.1231          cmd->u.sedf.period    = EDOM_INFO(p->vcpu[0])->period;
  1.1232          cmd->u.sedf.slice     = EDOM_INFO(p->vcpu[0])->slice;
  1.1233 -        cmd->u.sedf.extratime = EDOM_INFO(p->vcpu[0])->status
  1.1234 -            & EXTRA_AWARE;
  1.1235 +        cmd->u.sedf.extratime = EDOM_INFO(p->vcpu[0])->status & EXTRA_AWARE;
  1.1236          cmd->u.sedf.latency   = EDOM_INFO(p->vcpu[0])->latency;
  1.1237          cmd->u.sedf.weight    = EDOM_INFO(p->vcpu[0])->weight;
  1.1238      }
  1.1239 +
  1.1240      PRINT(2,"sedf_adjdom_finished\n");
  1.1241      return 0;
  1.1242  }