ia64/xen-unstable

changeset 3114:a778ae82fcb3

bitkeeper revision 1.1159.1.451 (41a51866R21ReiS-WH2NSkl2MaBhaA)

Add per exec_domain event_channel initialization.
Make sched_rem_domain/rem_task act on exec_domain.
author cl349@arcadians.cl.cam.ac.uk
date Wed Nov 24 23:25:26 2004 +0000 (2004-11-24)
parents 2e8be76f92b3
children 955dddec4861
files xen/common/domain.c xen/common/event_channel.c xen/common/schedule.c xen/include/xen/sched-if.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/common/domain.c	Wed Nov 24 23:14:34 2004 +0000
     1.2 +++ b/xen/common/domain.c	Wed Nov 24 23:25:26 2004 +0000
     1.3 @@ -135,10 +135,13 @@ struct domain *find_last_domain(void)
     1.4  
     1.5  void domain_kill(struct domain *d)
     1.6  {
     1.7 +    struct exec_domain *ed;
     1.8 +
     1.9      domain_pause(d);
    1.10      if ( !test_and_set_bit(DF_DYING, &d->d_flags) )
    1.11      {
    1.12 -        sched_rem_domain(d);
    1.13 +        for_each_exec_domain(d, ed)
    1.14 +            sched_rem_domain(ed);
    1.15          domain_relinquish_memory(d);
    1.16          put_domain(d);
    1.17      }
    1.18 @@ -330,6 +333,9 @@ long do_boot_vcpu(unsigned long vcpu, fu
    1.19      atomic_set(&ed->pausecnt, 0);
    1.20      shadow_lock_init(ed);
    1.21  
    1.22 +    if ( (rc = init_exec_domain_event_channels(ed)) != 0 )
    1.23 +        goto out;
    1.24 +
    1.25      memcpy(&ed->thread, &idle0_exec_domain.thread, sizeof(ed->thread));
    1.26  
    1.27      /* arch_do_createdomain */
    1.28 @@ -337,8 +343,10 @@ long do_boot_vcpu(unsigned long vcpu, fu
    1.29  
    1.30      sched_add_domain(ed);
    1.31  
    1.32 -    if ( (rc = arch_final_setup_guestos(ed, c)) != 0 )
    1.33 +    if ( (rc = arch_final_setup_guestos(ed, c)) != 0 ) {
    1.34 +        sched_rem_domain(ed);
    1.35          goto out;
    1.36 +    }
    1.37  
    1.38      /* Set up the shared info structure. */
    1.39      update_dom_time(d);
     2.1 --- a/xen/common/event_channel.c	Wed Nov 24 23:14:34 2004 +0000
     2.2 +++ b/xen/common/event_channel.c	Wed Nov 24 23:25:26 2004 +0000
     2.3 @@ -48,8 +48,11 @@ static int get_free_port(struct exec_dom
     2.4      {
     2.5          if ( max == MAX_EVENT_CHANNELS )
     2.6              return -ENOSPC;
     2.7 -        
     2.8 -        max = port + EVENT_CHANNELS_SPREAD;
     2.9 +
    2.10 +        if ( port == 0 )
    2.11 +            max = INIT_EVENT_CHANNELS;
    2.12 +        else
    2.13 +            max = port + EVENT_CHANNELS_SPREAD;
    2.14          
    2.15          chn = xmalloc(max * sizeof(event_channel_t));
    2.16          if ( unlikely(chn == NULL) )
    2.17 @@ -256,7 +259,8 @@ static long evtchn_bind_virq(evtchn_bind
    2.18       * bound yet. The exception is the 'misdirect VIRQ', which is permanently 
    2.19       * bound to port 0.
    2.20       */
    2.21 -    if ( ((port = ed->virq_to_evtchn[virq]) != 0) ||
    2.22 +    if ( ((port = ed->virq_to_evtchn[virq]) !=
    2.23 +          (ed->eid * EVENT_CHANNELS_SPREAD)) ||
    2.24           (virq == VIRQ_MISDIRECT) ||
    2.25           ((port = get_free_port(ed)) < 0) )
    2.26          goto out;
    2.27 @@ -357,7 +361,8 @@ static long __evtchn_close(struct domain
    2.28      chn1 = d1->event_channel;
    2.29  
    2.30      /* NB. Port 0 is special (VIRQ_MISDIRECT). Never let it be closed. */
    2.31 -    if ( (port1 <= 0) || (port1 >= d1->max_event_channel) )
    2.32 +    if ( (port1 <= 0) || (port1 >= d1->max_event_channel) ||
    2.33 +         ((port1 & (EVENT_CHANNELS_SPREAD - 1)) == 0) )
    2.34      {
    2.35          rc = -EINVAL;
    2.36          goto out;
    2.37 @@ -642,17 +647,31 @@ long do_event_channel_op(evtchn_op_t *uo
    2.38  }
    2.39  
    2.40  
    2.41 +int init_exec_domain_event_channels(struct exec_domain *ed)
    2.42 +{
    2.43 +    struct domain *d = ed->domain;
    2.44 +    int port, ret = -EINVAL, virq;
    2.45 +
    2.46 +    spin_lock(&d->event_channel_lock);
    2.47 +    port = ed->eid * EVENT_CHANNELS_SPREAD;
    2.48 +    if ( ((port < d->max_event_channel &&
    2.49 +           d->event_channel[port].state != ECS_FREE)) ||
    2.50 +         (get_free_port(ed) != port) )
    2.51 +        goto out;
    2.52 +    d->event_channel[port].state  = ECS_VIRQ;
    2.53 +    d->event_channel[port].u.virq = VIRQ_MISDIRECT;
    2.54 +    for ( virq = 0; virq < NR_VIRQS; virq++ )
    2.55 +        ed->virq_to_evtchn[virq] = port;
    2.56 +    ret = 0;
    2.57 + out:
    2.58 +    spin_unlock(&d->event_channel_lock);
    2.59 +    return ret;
    2.60 +}
    2.61 +
    2.62  int init_event_channels(struct domain *d)
    2.63  {
    2.64      spin_lock_init(&d->event_channel_lock);
    2.65 -    d->event_channel = xmalloc(INIT_EVENT_CHANNELS * sizeof(event_channel_t));
    2.66 -    if ( unlikely(d->event_channel == NULL) )
    2.67 -        return -ENOMEM;
    2.68 -    d->max_event_channel = INIT_EVENT_CHANNELS;
    2.69 -    memset(d->event_channel, 0, INIT_EVENT_CHANNELS * sizeof(event_channel_t));
    2.70 -    d->event_channel[0].state  = ECS_VIRQ;
    2.71 -    d->event_channel[0].u.virq = VIRQ_MISDIRECT;
    2.72 -    return 0;
    2.73 +    return init_exec_domain_event_channels(d->exec_domain[0]);
    2.74  }
    2.75  
    2.76  
     3.1 --- a/xen/common/schedule.c	Wed Nov 24 23:14:34 2004 +0000
     3.2 +++ b/xen/common/schedule.c	Wed Nov 24 23:25:26 2004 +0000
     3.3 @@ -191,14 +191,12 @@ void sched_add_domain(struct exec_domain
     3.4      TRACE_2D(TRC_SCHED_DOM_ADD, d->id, ed);
     3.5  }
     3.6  
     3.7 -void sched_rem_domain(struct domain *d) 
     3.8 +void sched_rem_domain(struct exec_domain *ed) 
     3.9  {
    3.10 -    struct exec_domain *ed;
    3.11  
    3.12 -    for_each_exec_domain(d, ed)
    3.13 -        rem_ac_timer(&ed->timer);
    3.14 -    SCHED_OP(rem_task, d);
    3.15 -    TRACE_2D(TRC_SCHED_DOM_REM, d->id, d);
    3.16 +    rem_ac_timer(&ed->timer);
    3.17 +    SCHED_OP(rem_task, ed);
    3.18 +    TRACE_3D(TRC_SCHED_DOM_REM, ed->domain->id, ed->eid, ed);
    3.19  }
    3.20  
    3.21  void init_idle_task(void)
     4.1 --- a/xen/include/xen/sched-if.h	Wed Nov 24 23:14:34 2004 +0000
     4.2 +++ b/xen/include/xen/sched-if.h	Wed Nov 24 23:25:26 2004 +0000
     4.3 @@ -40,7 +40,7 @@ struct scheduler
     4.4      int          (*alloc_task)     (struct exec_domain *);
     4.5      void         (*add_task)       (struct exec_domain *);
     4.6      void         (*free_task)      (struct domain *);
     4.7 -    void         (*rem_task)       (struct domain *);
     4.8 +    void         (*rem_task)       (struct exec_domain *);
     4.9      void         (*sleep)          (struct exec_domain *);
    4.10      void         (*wake)           (struct exec_domain *);
    4.11      void         (*do_block)       (struct exec_domain *);
     5.1 --- a/xen/include/xen/sched.h	Wed Nov 24 23:14:34 2004 +0000
     5.2 +++ b/xen/include/xen/sched.h	Wed Nov 24 23:25:26 2004 +0000
     5.3 @@ -56,6 +56,7 @@ typedef struct event_channel_st
     5.4  
     5.5  int  init_event_channels(struct domain *d);
     5.6  void destroy_event_channels(struct domain *d);
     5.7 +int  init_exec_domain_event_channels(struct exec_domain *ed);
     5.8  
     5.9  struct exec_domain 
    5.10  {
    5.11 @@ -233,8 +234,8 @@ extern unsigned long wait_init_idle;
    5.12  #define set_current_state(_s) do { current->state = (_s); } while (0)
    5.13  void scheduler_init(void);
    5.14  void schedulers_start(void);
    5.15 -void sched_add_domain(struct exec_domain *d);
    5.16 -void sched_rem_domain(struct domain *d);
    5.17 +void sched_add_domain(struct exec_domain *);
    5.18 +void sched_rem_domain(struct exec_domain *);
    5.19  long sched_ctl(struct sched_ctl_cmd *);
    5.20  long sched_adjdom(struct sched_adjdom_cmd *);
    5.21  int  sched_id();