ia64/xen-unstable

changeset 10281:6993a0f91efc

Domain creation/destruction cleanups.

1. Move alloc/dealloc routines to domain.[ch]
2. Merge alloc_task/add_vcpu schedops -> init_vcpu
3. Merge free_task/remove_vcpu schedops -> destroy_domain

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Jun 01 18:10:00 2006 +0100 (2006-06-01)
parents ab627e9da8fb
children 0f5b8f1b0eac
files xen/arch/ia64/xen/domain.c xen/arch/x86/mm.c xen/arch/x86/smpboot.c xen/common/domain.c xen/common/sched_bvt.c xen/common/sched_credit.c xen/common/sched_sedf.c xen/common/schedule.c xen/include/xen/domain.h xen/include/xen/sched-if.h xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Thu Jun 01 16:39:42 2006 +0100
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Thu Jun 01 18:10:00 2006 +0100
     1.3 @@ -14,6 +14,7 @@
     1.4  #include <xen/init.h>
     1.5  #include <xen/lib.h>
     1.6  #include <xen/errno.h>
     1.7 +#include <xen/domain.h>
     1.8  #include <xen/sched.h>
     1.9  #include <xen/smp.h>
    1.10  #include <xen/delay.h>
     2.1 --- a/xen/arch/x86/mm.c	Thu Jun 01 16:39:42 2006 +0100
     2.2 +++ b/xen/arch/x86/mm.c	Thu Jun 01 18:10:00 2006 +0100
     2.3 @@ -89,6 +89,7 @@
     2.4  #include <xen/kernel.h>
     2.5  #include <xen/lib.h>
     2.6  #include <xen/mm.h>
     2.7 +#include <xen/domain.h>
     2.8  #include <xen/sched.h>
     2.9  #include <xen/errno.h>
    2.10  #include <xen/perfc.h>
     3.1 --- a/xen/arch/x86/smpboot.c	Thu Jun 01 16:39:42 2006 +0100
     3.2 +++ b/xen/arch/x86/smpboot.c	Thu Jun 01 18:10:00 2006 +0100
     3.3 @@ -37,6 +37,7 @@
     3.4  #include <xen/init.h>
     3.5  #include <xen/kernel.h>
     3.6  #include <xen/mm.h>
     3.7 +#include <xen/domain.h>
     3.8  #include <xen/sched.h>
     3.9  #include <xen/irq.h>
    3.10  #include <xen/delay.h>
     4.1 --- a/xen/common/domain.c	Thu Jun 01 16:39:42 2006 +0100
     4.2 +++ b/xen/common/domain.c	Thu Jun 01 18:10:00 2006 +0100
     4.3 @@ -32,6 +32,79 @@ struct domain *domain_list;
     4.4  
     4.5  struct domain *dom0;
     4.6  
     4.7 +struct domain *alloc_domain(domid_t domid)
     4.8 +{
     4.9 +    struct domain *d;
    4.10 +
    4.11 +    if ( (d = xmalloc(struct domain)) == NULL )
    4.12 +        return NULL;
    4.13 +
    4.14 +    memset(d, 0, sizeof(*d));
    4.15 +    d->domain_id = domid;
    4.16 +    atomic_set(&d->refcnt, 1);
    4.17 +    spin_lock_init(&d->big_lock);
    4.18 +    spin_lock_init(&d->page_alloc_lock);
    4.19 +    INIT_LIST_HEAD(&d->page_list);
    4.20 +    INIT_LIST_HEAD(&d->xenpage_list);
    4.21 +
    4.22 +    return d;
    4.23 +}
    4.24 +
    4.25 +
    4.26 +void free_domain(struct domain *d)
    4.27 +{
    4.28 +    struct vcpu *v;
    4.29 +    int i;
    4.30 +
    4.31 +    sched_destroy_domain(d);
    4.32 +
    4.33 +    for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
    4.34 +        if ( (v = d->vcpu[i]) != NULL )
    4.35 +            free_vcpu_struct(v);
    4.36 +
    4.37 +    xfree(d);
    4.38 +}
    4.39 +
    4.40 +
    4.41 +struct vcpu *alloc_vcpu(
    4.42 +    struct domain *d, unsigned int vcpu_id, unsigned int cpu_id)
    4.43 +{
    4.44 +    struct vcpu *v;
    4.45 +
    4.46 +    BUG_ON(d->vcpu[vcpu_id] != NULL);
    4.47 +
    4.48 +    if ( (v = alloc_vcpu_struct(d, vcpu_id)) == NULL )
    4.49 +        return NULL;
    4.50 +
    4.51 +    v->domain = d;
    4.52 +    v->vcpu_id = vcpu_id;
    4.53 +    v->processor = cpu_id;
    4.54 +    atomic_set(&v->pausecnt, 0);
    4.55 +    v->vcpu_info = &d->shared_info->vcpu_info[vcpu_id];
    4.56 +
    4.57 +    v->cpu_affinity = is_idle_domain(d) ?
    4.58 +        cpumask_of_cpu(cpu_id) : CPU_MASK_ALL;
    4.59 +
    4.60 +    v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
    4.61 +    v->runstate.state_entry_time = NOW();
    4.62 +
    4.63 +    if ( (vcpu_id != 0) && !is_idle_domain(d) )
    4.64 +        set_bit(_VCPUF_down, &v->vcpu_flags);
    4.65 +
    4.66 +    if ( sched_init_vcpu(v) < 0 )
    4.67 +    {
    4.68 +        free_vcpu_struct(v);
    4.69 +        return NULL;
    4.70 +    }
    4.71 +
    4.72 +    d->vcpu[vcpu_id] = v;
    4.73 +    if ( vcpu_id != 0 )
    4.74 +        d->vcpu[v->vcpu_id-1]->next_in_list = v;
    4.75 +
    4.76 +    return v;
    4.77 +}
    4.78 +
    4.79 +
    4.80  struct domain *domain_create(domid_t domid, unsigned int cpu)
    4.81  {
    4.82      struct domain *d, **pd;
    4.83 @@ -117,19 +190,16 @@ struct domain *find_domain_by_id(domid_t
    4.84  
    4.85  void domain_kill(struct domain *d)
    4.86  {
    4.87 -    struct vcpu *v;
    4.88 +    domain_pause(d);
    4.89 +
    4.90 +    if ( test_and_set_bit(_DOMF_dying, &d->domain_flags) )
    4.91 +        return;
    4.92  
    4.93 -    domain_pause(d);
    4.94 -    if ( !test_and_set_bit(_DOMF_dying, &d->domain_flags) )
    4.95 -    {
    4.96 -        for_each_vcpu(d, v)
    4.97 -            sched_rem_domain(v);
    4.98 -        gnttab_release_mappings(d);
    4.99 -        domain_relinquish_resources(d);
   4.100 -        put_domain(d);
   4.101 +    gnttab_release_mappings(d);
   4.102 +    domain_relinquish_resources(d);
   4.103 +    put_domain(d);
   4.104  
   4.105 -        send_guest_global_virq(dom0, VIRQ_DOM_EXC);
   4.106 -    }
   4.107 +    send_guest_global_virq(dom0, VIRQ_DOM_EXC);
   4.108  }
   4.109  
   4.110  
     5.1 --- a/xen/common/sched_bvt.c	Thu Jun 01 16:39:42 2006 +0100
     5.2 +++ b/xen/common/sched_bvt.c	Thu Jun 01 18:10:00 2006 +0100
     5.3 @@ -160,15 +160,14 @@ static inline u32 calc_evt(struct vcpu *
     5.4  }
     5.5  
     5.6  /**
     5.7 - * bvt_alloc_task - allocate BVT private structures for a task
     5.8 - * @p:              task to allocate private structures for
     5.9 - *
    5.10 + * bvt_init_vcpu - allocate BVT private structures for a VCPU.
    5.11   * Returns non-zero on failure.
    5.12   */
    5.13 -static int bvt_alloc_task(struct vcpu *v)
    5.14 +static int bvt_init_vcpu(struct vcpu *v)
    5.15  {
    5.16      struct domain *d = v->domain;
    5.17      struct bvt_dom_info *inf;
    5.18 +    struct bvt_vcpu_info *einf;
    5.19  
    5.20      if ( (d->sched_priv == NULL) )
    5.21      {
    5.22 @@ -199,15 +198,7 @@ static int bvt_alloc_task(struct vcpu *v
    5.23          init_timer(&inf->unwarp_timer, unwarp_timer_fn, inf, v->processor);
    5.24      }
    5.25  
    5.26 -    return 0;
    5.27 -}
    5.28 -
    5.29 -/*
    5.30 - * Add and remove a domain
    5.31 - */
    5.32 -static void bvt_add_task(struct vcpu *v) 
    5.33 -{
    5.34 -    struct bvt_vcpu_info *einf = EBVT_INFO(v);
    5.35 +    einf = EBVT_INFO(v);
    5.36  
    5.37      /* Allocate per-CPU context if this is the first domain to be added. */
    5.38      if ( CPU_INFO(v->processor) == NULL )
    5.39 @@ -223,13 +214,15 @@ static void bvt_add_task(struct vcpu *v)
    5.40          einf->avt = einf->evt = ~0U;
    5.41          BUG_ON(__task_on_runqueue(v));
    5.42          __add_to_runqueue_head(v);
    5.43 -    } 
    5.44 +    }
    5.45      else 
    5.46      {
    5.47          /* Set avt and evt to system virtual time. */
    5.48          einf->avt = CPU_SVT(v->processor);
    5.49          einf->evt = CPU_SVT(v->processor);
    5.50      }
    5.51 +
    5.52 +    return 0;
    5.53  }
    5.54  
    5.55  static void bvt_wake(struct vcpu *v)
    5.56 @@ -298,10 +291,9 @@ static int bvt_set_affinity(struct vcpu 
    5.57  
    5.58  
    5.59  /**
    5.60 - * bvt_free_task - free BVT private structures for a task
    5.61 - * @d:             task
    5.62 + * bvt_destroy_domain - free BVT private structures for a domain.
    5.63   */
    5.64 -static void bvt_free_task(struct domain *d)
    5.65 +static void bvt_destroy_domain(struct domain *d)
    5.66  {
    5.67      struct bvt_dom_info *inf = BVT_INFO(d);
    5.68  
    5.69 @@ -568,10 +560,10 @@ struct scheduler sched_bvt_def = {
    5.70      .name     = "Borrowed Virtual Time",
    5.71      .opt_name = "bvt",
    5.72      .sched_id = SCHED_BVT,
    5.73 -    
    5.74 -    .alloc_task     = bvt_alloc_task,
    5.75 -    .add_task       = bvt_add_task,
    5.76 -    .free_task      = bvt_free_task,
    5.77 +
    5.78 +    .init_vcpu      = bvt_init_vcpu,
    5.79 +    .destroy_domain = bvt_destroy_domain,
    5.80 +
    5.81      .do_schedule    = bvt_do_schedule,
    5.82      .control        = bvt_ctl,
    5.83      .adjdom         = bvt_adjdom,
     6.1 --- a/xen/common/sched_credit.c	Thu Jun 01 16:39:42 2006 +0100
     6.2 +++ b/xen/common/sched_credit.c	Thu Jun 01 18:10:00 2006 +0100
     6.3 @@ -75,14 +75,13 @@
     6.4      } while ( 0 );
     6.5  
     6.6  #define CSCHED_STATS_EXPAND_SCHED(_MACRO)   \
     6.7 -    _MACRO(vcpu_alloc)                      \
     6.8 -    _MACRO(vcpu_add)                        \
     6.9 +    _MACRO(vcpu_init)                       \
    6.10      _MACRO(vcpu_sleep)                      \
    6.11      _MACRO(vcpu_wake_running)               \
    6.12      _MACRO(vcpu_wake_onrunq)                \
    6.13      _MACRO(vcpu_wake_runnable)              \
    6.14      _MACRO(vcpu_wake_not_runnable)          \
    6.15 -    _MACRO(dom_free)                        \
    6.16 +    _MACRO(dom_destroy)                     \
    6.17      _MACRO(schedule)                        \
    6.18      _MACRO(tickle_local_idler)              \
    6.19      _MACRO(tickle_local_over)               \
    6.20 @@ -429,14 +428,14 @@ static inline void
    6.21  }
    6.22  
    6.23  static int
    6.24 -csched_vcpu_alloc(struct vcpu *vc)
    6.25 +csched_vcpu_init(struct vcpu *vc)
    6.26  {
    6.27      struct domain * const dom = vc->domain;
    6.28      struct csched_dom *sdom;
    6.29      struct csched_vcpu *svc;
    6.30      int16_t pri;
    6.31  
    6.32 -    CSCHED_STAT_CRANK(vcpu_alloc);
    6.33 +    CSCHED_STAT_CRANK(vcpu_init);
    6.34  
    6.35      /* Allocate, if appropriate, per-domain info */
    6.36      if ( is_idle_vcpu(vc) )
    6.37 @@ -489,19 +488,13 @@ csched_vcpu_alloc(struct vcpu *vc)
    6.38      if ( likely(sdom != NULL) )
    6.39          csched_vcpu_acct(svc, 0);
    6.40  
    6.41 -    return 0;
    6.42 -}
    6.43 -
    6.44 -static void
    6.45 -csched_vcpu_add(struct vcpu *vc) 
    6.46 -{
    6.47 -    CSCHED_STAT_CRANK(vcpu_add);
    6.48 -
    6.49      /* Allocate per-PCPU info */
    6.50      if ( unlikely(!CSCHED_PCPU(vc->processor)) )
    6.51          csched_pcpu_init(vc->processor);
    6.52  
    6.53      CSCHED_VCPU_CHECK(vc);
    6.54 +
    6.55 +    return 0;
    6.56  }
    6.57  
    6.58  static void
    6.59 @@ -644,12 +637,12 @@ csched_dom_cntl(
    6.60  }
    6.61  
    6.62  static void
    6.63 -csched_dom_free(struct domain *dom)
    6.64 +csched_dom_destroy(struct domain *dom)
    6.65  {
    6.66      struct csched_dom * const sdom = CSCHED_DOM(dom);
    6.67      int i;
    6.68  
    6.69 -    CSCHED_STAT_CRANK(dom_free);
    6.70 +    CSCHED_STAT_CRANK(dom_destroy);
    6.71  
    6.72      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    6.73      {
    6.74 @@ -1215,14 +1208,15 @@ struct scheduler sched_credit_def = {
    6.75      .opt_name       = "credit",
    6.76      .sched_id       = SCHED_CREDIT,
    6.77  
    6.78 -    .alloc_task     = csched_vcpu_alloc,
    6.79 -    .add_task       = csched_vcpu_add,
    6.80 +    .init_vcpu      = csched_vcpu_init,
    6.81 +    .destroy_domain = csched_dom_destroy,
    6.82 +
    6.83      .sleep          = csched_vcpu_sleep,
    6.84      .wake           = csched_vcpu_wake,
    6.85 +
    6.86      .set_affinity   = csched_vcpu_set_affinity,
    6.87  
    6.88      .adjdom         = csched_dom_cntl,
    6.89 -    .free_task      = csched_dom_free,
    6.90  
    6.91      .tick           = csched_tick,
    6.92      .do_schedule    = csched_schedule,
     7.1 --- a/xen/common/sched_sedf.c	Thu Jun 01 16:39:42 2006 +0100
     7.2 +++ b/xen/common/sched_sedf.c	Thu Jun 01 18:10:00 2006 +0100
     7.3 @@ -328,11 +328,9 @@ static inline void __add_to_runqueue_sor
     7.4  }
     7.5  
     7.6  
     7.7 -/* Allocates memory for per domain private scheduling data*/
     7.8 -static int sedf_alloc_task(struct vcpu *v)
     7.9 +static int sedf_init_vcpu(struct vcpu *v)
    7.10  {
    7.11 -    PRINT(2, "sedf_alloc_task was called, domain-id %i.%i\n",
    7.12 -          v->domain->domain_id, v->vcpu_id);
    7.13 +    struct sedf_vcpu_info *inf;
    7.14  
    7.15      if ( v->domain->sched_priv == NULL )
    7.16      {
    7.17 @@ -344,23 +342,11 @@ static int sedf_alloc_task(struct vcpu *
    7.18  
    7.19      if ( (v->sched_priv = xmalloc(struct sedf_vcpu_info)) == NULL )
    7.20          return -1;
    7.21 -
    7.22      memset(v->sched_priv, 0, sizeof(struct sedf_vcpu_info));
    7.23  
    7.24 -    return 0;
    7.25 -}
    7.26 -
    7.27 -
    7.28 -/* Setup the sedf_dom_info */
    7.29 -static void sedf_add_task(struct vcpu *v)
    7.30 -{
    7.31 -    struct sedf_vcpu_info *inf = EDOM_INFO(v);
    7.32 -
    7.33 +    inf = EDOM_INFO(v);
    7.34      inf->vcpu = v;
    7.35   
    7.36 -    PRINT(2,"sedf_add_task was called, domain-id %i.%i\n",
    7.37 -          v->domain->domain_id, v->vcpu_id);
    7.38 -
    7.39      /* Allocate per-CPU context if this is the first domain to be added. */
    7.40      if ( unlikely(schedule_data[v->processor].sched_priv == NULL) )
    7.41      {
    7.42 @@ -408,15 +394,14 @@ static void sedf_add_task(struct vcpu *v
    7.43          EDOM_INFO(v)->deadl_abs = 0;
    7.44          EDOM_INFO(v)->status &= ~SEDF_ASLEEP;
    7.45      }
    7.46 +
    7.47 +    return 0;
    7.48  }
    7.49  
    7.50 -/* Frees memory used by domain info */
    7.51 -static void sedf_free_task(struct domain *d)
    7.52 +static void sedf_destroy_domain(struct domain *d)
    7.53  {
    7.54      int i;
    7.55  
    7.56 -    PRINT(2,"sedf_free_task was called, domain-id %i\n",d->domain_id);
    7.57 -
    7.58      xfree(d->sched_priv);
    7.59   
    7.60      for ( i = 0; i < MAX_VIRT_CPUS; i++ )
    7.61 @@ -1452,9 +1437,9 @@ struct scheduler sched_sedf_def = {
    7.62      .opt_name = "sedf",
    7.63      .sched_id = SCHED_SEDF,
    7.64      
    7.65 -    .alloc_task     = sedf_alloc_task,
    7.66 -    .add_task       = sedf_add_task,
    7.67 -    .free_task      = sedf_free_task,
    7.68 +    .init_vcpu      = sedf_init_vcpu,
    7.69 +    .destroy_domain = sedf_destroy_domain,
    7.70 +
    7.71      .do_schedule    = sedf_do_schedule,
    7.72      .dump_cpu_state = sedf_dump_cpu_state,
    7.73      .sleep          = sedf_sleep,
     8.1 --- a/xen/common/schedule.c	Thu Jun 01 16:39:42 2006 +0100
     8.2 +++ b/xen/common/schedule.c	Thu Jun 01 18:10:00 2006 +0100
     8.3 @@ -99,82 +99,7 @@ void vcpu_runstate_get(struct vcpu *v, s
     8.4      }
     8.5  }
     8.6  
     8.7 -struct domain *alloc_domain(domid_t domid)
     8.8 -{
     8.9 -    struct domain *d;
    8.10 -
    8.11 -    if ( (d = xmalloc(struct domain)) == NULL )
    8.12 -        return NULL;
    8.13 -
    8.14 -    memset(d, 0, sizeof(*d));
    8.15 -    d->domain_id = domid;
    8.16 -    atomic_set(&d->refcnt, 1);
    8.17 -    spin_lock_init(&d->big_lock);
    8.18 -    spin_lock_init(&d->page_alloc_lock);
    8.19 -    INIT_LIST_HEAD(&d->page_list);
    8.20 -    INIT_LIST_HEAD(&d->xenpage_list);
    8.21 -
    8.22 -    return d;
    8.23 -}
    8.24 -
    8.25 -void free_domain(struct domain *d)
    8.26 -{
    8.27 -    struct vcpu *v;
    8.28 -    int i;
    8.29 -
    8.30 -    for_each_vcpu ( d, v )
    8.31 -        sched_rem_domain(v);
    8.32 -
    8.33 -    SCHED_OP(free_task, d);
    8.34 -
    8.35 -    for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- )
    8.36 -        if ( (v = d->vcpu[i]) != NULL )
    8.37 -            free_vcpu_struct(v);
    8.38 -
    8.39 -    xfree(d);
    8.40 -}
    8.41 -
    8.42 -struct vcpu *alloc_vcpu(
    8.43 -    struct domain *d, unsigned int vcpu_id, unsigned int cpu_id)
    8.44 -{
    8.45 -    struct vcpu *v;
    8.46 -
    8.47 -    BUG_ON(d->vcpu[vcpu_id] != NULL);
    8.48 -
    8.49 -    if ( (v = alloc_vcpu_struct(d, vcpu_id)) == NULL )
    8.50 -        return NULL;
    8.51 -
    8.52 -    v->domain = d;
    8.53 -    v->vcpu_id = vcpu_id;
    8.54 -    v->processor = cpu_id;
    8.55 -    atomic_set(&v->pausecnt, 0);
    8.56 -    v->vcpu_info = &d->shared_info->vcpu_info[vcpu_id];
    8.57 -
    8.58 -    v->cpu_affinity = is_idle_domain(d) ?
    8.59 -        cpumask_of_cpu(cpu_id) : CPU_MASK_ALL;
    8.60 -
    8.61 -    v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
    8.62 -    v->runstate.state_entry_time = NOW();
    8.63 -
    8.64 -    if ( (vcpu_id != 0) && !is_idle_domain(d) )
    8.65 -        set_bit(_VCPUF_down, &v->vcpu_flags);
    8.66 -
    8.67 -    if ( SCHED_OP(alloc_task, v) < 0 )
    8.68 -    {
    8.69 -        free_vcpu_struct(v);
    8.70 -        return NULL;
    8.71 -    }
    8.72 -
    8.73 -    d->vcpu[vcpu_id] = v;
    8.74 -    if ( vcpu_id != 0 )
    8.75 -        d->vcpu[v->vcpu_id-1]->next_in_list = v;
    8.76 -
    8.77 -    sched_add_domain(v);
    8.78 -
    8.79 -    return v;
    8.80 -}
    8.81 -
    8.82 -void sched_add_domain(struct vcpu *v) 
    8.83 +int sched_init_vcpu(struct vcpu *v) 
    8.84  {
    8.85      /* Initialise the per-domain timers. */
    8.86      init_timer(&v->timer, vcpu_timer_fn, v, v->processor);
    8.87 @@ -187,17 +112,23 @@ void sched_add_domain(struct vcpu *v)
    8.88          set_bit(_VCPUF_running, &v->vcpu_flags);
    8.89      }
    8.90  
    8.91 -    SCHED_OP(add_task, v);
    8.92      TRACE_2D(TRC_SCHED_DOM_ADD, v->domain->domain_id, v->vcpu_id);
    8.93 +
    8.94 +    return SCHED_OP(init_vcpu, v);
    8.95  }
    8.96  
    8.97 -void sched_rem_domain(struct vcpu *v) 
    8.98 +void sched_destroy_domain(struct domain *d)
    8.99  {
   8.100 -    kill_timer(&v->timer);
   8.101 -    kill_timer(&v->poll_timer);
   8.102 +    struct vcpu *v;
   8.103  
   8.104 -    SCHED_OP(rem_task, v);
   8.105 -    TRACE_2D(TRC_SCHED_DOM_REM, v->domain->domain_id, v->vcpu_id);
   8.106 +    for_each_vcpu ( d, v )
   8.107 +    {
   8.108 +        kill_timer(&v->timer);
   8.109 +        kill_timer(&v->poll_timer);
   8.110 +        TRACE_2D(TRC_SCHED_DOM_REM, v->domain->domain_id, v->vcpu_id);
   8.111 +    }
   8.112 +
   8.113 +    SCHED_OP(destroy_domain, d);
   8.114  }
   8.115  
   8.116  void vcpu_sleep_nosync(struct vcpu *v)
   8.117 @@ -671,7 +602,7 @@ static void poll_timer_fn(void *data)
   8.118  /* Initialise the data structures. */
   8.119  void __init scheduler_init(void)
   8.120  {
   8.121 -    int i, rc;
   8.122 +    int i;
   8.123  
   8.124      open_softirq(SCHEDULE_SOFTIRQ, __enter_scheduler);
   8.125  
   8.126 @@ -694,17 +625,6 @@ void __init scheduler_init(void)
   8.127  
   8.128      printk("Using scheduler: %s (%s)\n", ops.name, ops.opt_name);
   8.129      SCHED_OP(init);
   8.130 -
   8.131 -    if ( idle_vcpu[0] != NULL )
   8.132 -    {
   8.133 -        schedule_data[0].curr = idle_vcpu[0];
   8.134 -        schedule_data[0].idle = idle_vcpu[0];
   8.135 -
   8.136 -        rc = SCHED_OP(alloc_task, idle_vcpu[0]);
   8.137 -        BUG_ON(rc < 0);
   8.138 -
   8.139 -        sched_add_domain(idle_vcpu[0]);
   8.140 -    }
   8.141  }
   8.142  
   8.143  /*
     9.1 --- a/xen/include/xen/domain.h	Thu Jun 01 16:39:42 2006 +0100
     9.2 +++ b/xen/include/xen/domain.h	Thu Jun 01 18:10:00 2006 +0100
     9.3 @@ -2,28 +2,32 @@
     9.4  #ifndef __XEN_DOMAIN_H__
     9.5  #define __XEN_DOMAIN_H__
     9.6  
     9.7 -extern int boot_vcpu(
     9.8 +struct vcpu *alloc_vcpu(
     9.9 +    struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
    9.10 +int boot_vcpu(
    9.11      struct domain *d, int vcpuid, struct vcpu_guest_context *ctxt);
    9.12  
    9.13 +struct domain *alloc_domain(domid_t domid);
    9.14 +void free_domain(struct domain *d);
    9.15 +
    9.16  /*
    9.17   * Arch-specifics.
    9.18   */
    9.19  
    9.20  struct vcpu *alloc_vcpu_struct(struct domain *d, unsigned int vcpu_id);
    9.21  
    9.22 -extern void free_vcpu_struct(struct vcpu *v);
    9.23 +void free_vcpu_struct(struct vcpu *v);
    9.24  
    9.25 -extern int arch_domain_create(struct domain *d);
    9.26 +int arch_domain_create(struct domain *d);
    9.27  
    9.28 -extern void arch_domain_destroy(struct domain *d);
    9.29 +void arch_domain_destroy(struct domain *d);
    9.30  
    9.31 -extern int arch_set_info_guest(
    9.32 -    struct vcpu *v, struct vcpu_guest_context *c);
    9.33 +int arch_set_info_guest(struct vcpu *v, struct vcpu_guest_context *c);
    9.34 +
    9.35 +void domain_relinquish_resources(struct domain *d);
    9.36  
    9.37 -extern void domain_relinquish_resources(struct domain *d);
    9.38 +void dump_pageframe_info(struct domain *d);
    9.39  
    9.40 -extern void dump_pageframe_info(struct domain *d);
    9.41 -
    9.42 -extern void arch_dump_domain_info(struct domain *d);
    9.43 +void arch_dump_domain_info(struct domain *d);
    9.44  
    9.45  #endif /* __XEN_DOMAIN_H__ */
    10.1 --- a/xen/include/xen/sched-if.h	Thu Jun 01 16:39:42 2006 +0100
    10.2 +++ b/xen/include/xen/sched-if.h	Thu Jun 01 18:10:00 2006 +0100
    10.3 @@ -60,14 +60,17 @@ struct scheduler {
    10.4  
    10.5      void         (*init)           (void);
    10.6      void         (*tick)           (unsigned int cpu);
    10.7 -    int          (*alloc_task)     (struct vcpu *);
    10.8 -    void         (*add_task)       (struct vcpu *);
    10.9 -    void         (*free_task)      (struct domain *);
   10.10 -    void         (*rem_task)       (struct vcpu *);
   10.11 +
   10.12 +    int          (*init_vcpu)      (struct vcpu *);
   10.13 +    void         (*destroy_domain) (struct domain *);
   10.14 +
   10.15      void         (*sleep)          (struct vcpu *);
   10.16      void         (*wake)           (struct vcpu *);
   10.17 +
   10.18      int          (*set_affinity)   (struct vcpu *, cpumask_t *);
   10.19 +
   10.20      struct task_slice (*do_schedule) (s_time_t);
   10.21 +
   10.22      int          (*control)        (struct sched_ctl_cmd *);
   10.23      int          (*adjdom)         (struct domain *,
   10.24                                      struct sched_adjdom_cmd *);
    11.1 --- a/xen/include/xen/sched.h	Thu Jun 01 16:39:42 2006 +0100
    11.2 +++ b/xen/include/xen/sched.h	Thu Jun 01 18:10:00 2006 +0100
    11.3 @@ -186,12 +186,6 @@ extern struct vcpu *idle_vcpu[NR_CPUS];
    11.4  #define is_idle_domain(d) ((d)->domain_id == IDLE_DOMAIN_ID)
    11.5  #define is_idle_vcpu(v)   (is_idle_domain((v)->domain))
    11.6  
    11.7 -struct vcpu *alloc_vcpu(
    11.8 -    struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
    11.9 -
   11.10 -struct domain *alloc_domain(domid_t domid);
   11.11 -void free_domain(struct domain *d);
   11.12 -
   11.13  #define DOMAIN_DESTROYED (1<<31) /* assumes atomic_t is >= 32 bits */
   11.14  #define put_domain(_d) \
   11.15    if ( atomic_dec_and_test(&(_d)->refcnt) ) domain_destroy(_d)
   11.16 @@ -269,8 +263,8 @@ void new_thread(struct vcpu *d,
   11.17  #define set_current_state(_s) do { current->state = (_s); } while (0)
   11.18  void scheduler_init(void);
   11.19  void schedulers_start(void);
   11.20 -void sched_add_domain(struct vcpu *);
   11.21 -void sched_rem_domain(struct vcpu *);
   11.22 +int  sched_init_vcpu(struct vcpu *);
   11.23 +void sched_destroy_domain(struct domain *);
   11.24  long sched_ctl(struct sched_ctl_cmd *);
   11.25  long sched_adjdom(struct sched_adjdom_cmd *);
   11.26  int  sched_id(void);