direct-io.hg

changeset 2171:2de6aedb2442

bitkeeper revision 1.1159.17.1 (4118f0d483Vmdw5e5g0BuoQ37QULyg)

Merge labyrinth.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into labyrinth.cl.cam.ac.uk:/auto/anfs/scratch/labyrinth/iap10/xeno-clone/xeno.bk
author iap10@labyrinth.cl.cam.ac.uk
date Tue Aug 10 15:59:16 2004 +0000 (2004-08-10)
parents 0b8b66772eb7 d3dc11487300
children 765bea1a8d92 553d32ef82b4
files tools/examples/xmdefaults tools/examples/xmexample tools/libxc/xc.h tools/libxc/xc_domain.c tools/libxc/xc_linux_restore.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py xen/arch/x86/smpboot.c xen/common/dom0_ops.c xen/common/domain.c xen/common/kernel.c xen/common/sched_atropos.c xen/common/sched_bvt.c xen/common/sched_fair_bvt.c xen/common/sched_rrobin.c xen/common/schedule.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/xen/sched-if.h xen/include/xen/sched.h
line diff
     1.1 --- a/tools/examples/xmdefaults	Tue Aug 10 14:20:33 2004 +0000
     1.2 +++ b/tools/examples/xmdefaults	Tue Aug 10 15:59:16 2004 +0000
     1.3 @@ -25,6 +25,10 @@ name = "ExampleDomain"
     1.4  
     1.5  # Which CPU to start domain on? 
     1.6  #cpu = -1   # leave to Xen to pick
     1.7 +# The weight (CPU share) of the domain. Works with all
     1.8 +# schedulers that have notion of weight (eg BVT). 
     1.9 +# Default is 1. Float values can be used.
    1.10 +#weight = 1.5
    1.11  
    1.12  #----------------------------------------------------------------------------
    1.13  # Define network interfaces.
     2.1 --- a/tools/examples/xmexample	Tue Aug 10 14:20:33 2004 +0000
     2.2 +++ b/tools/examples/xmexample	Tue Aug 10 15:59:16 2004 +0000
     2.3 @@ -55,6 +55,10 @@ name = "VM%d" % vmid
     2.4  # Which CPU to start domain on? 
     2.5  #cpu = -1   # leave to Xen to pick
     2.6  cpu = vmid  # set based on vmid (mod number of CPUs)
     2.7 +# The weight (CPU share) of the domain. Works with all
     2.8 +# schedulers that have notion of weight (eg BVT). 
     2.9 +# Default is 1. Float values can be used.
    2.10 +#weight = 1.5
    2.11  
    2.12  #----------------------------------------------------------------------------
    2.13  # Define network interfaces.
     3.1 --- a/tools/libxc/xc.h	Tue Aug 10 14:20:33 2004 +0000
     3.2 +++ b/tools/libxc/xc.h	Tue Aug 10 15:59:16 2004 +0000
     3.3 @@ -48,6 +48,7 @@ int xc_domain_create(int xc_handle,
     3.4                       unsigned int mem_kb, 
     3.5                       const char *name,
     3.6                       int cpu,
     3.7 +                     float weight,
     3.8                       u32 *pdomid);
     3.9  int xc_domain_pause(int xc_handle, 
    3.10                      u32 domid);
     4.1 --- a/tools/libxc/xc_domain.c	Tue Aug 10 14:20:33 2004 +0000
     4.2 +++ b/tools/libxc/xc_domain.c	Tue Aug 10 15:59:16 2004 +0000
     4.3 @@ -12,6 +12,7 @@ int xc_domain_create(int xc_handle,
     4.4                       unsigned int mem_kb, 
     4.5                       const char *name,
     4.6                       int cpu,
     4.7 +                     float weight,
     4.8                       u32 *pdomid)
     4.9  {
    4.10      int err;
    4.11 @@ -20,6 +21,8 @@ int xc_domain_create(int xc_handle,
    4.12      op.cmd = DOM0_CREATEDOMAIN;
    4.13      op.u.createdomain.domain = (domid_t)*pdomid;
    4.14      op.u.createdomain.memory_kb = mem_kb;
    4.15 +    /* The weight of a domain added to the domain creation code */
    4.16 +    op.u.createdomain.weight = weight;
    4.17      strncpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
    4.18      op.u.createdomain.name[MAX_DOMAIN_NAME-1] = '\0';
    4.19      op.u.createdomain.cpu = cpu;
     5.1 --- a/tools/libxc/xc_linux_restore.c	Tue Aug 10 14:20:33 2004 +0000
     5.2 +++ b/tools/libxc/xc_linux_restore.c	Tue Aug 10 15:59:16 2004 +0000
     5.3 @@ -225,7 +225,7 @@ int xc_linux_restore(int xc_handle, XcIO
     5.4      /* XXX create domain on CPU=-1 so that in future it auto load ballances by default */
     5.5      if ( xc_domain_create( xc_handle,  nr_pfns * (PAGE_SIZE / 1024),
     5.6  			   name,
     5.7 -			   -1, &dom ) )
     5.8 +			   -1, 1, &dom ) )
     5.9      {
    5.10  	xcio_error(ioctxt, "Could not create domain. pfns=%d, %dKB",
    5.11  		   nr_pfns,nr_pfns * (PAGE_SIZE / 1024));
     6.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Tue Aug 10 14:20:33 2004 +0000
     6.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Aug 10 15:59:16 2004 +0000
     6.3 @@ -44,16 +44,19 @@ static PyObject *pyxc_domain_create(PyOb
     6.4      unsigned int mem_kb = 0;
     6.5      char        *name   = "(anon)";
     6.6      int          cpu = -1;
     6.7 +    float        weight;
     6.8      u32          dom = 0;
     6.9      int          ret;
    6.10  
    6.11 -    static char *kwd_list[] = { "dom", "mem_kb", "name", "cpu", NULL };
    6.12 +    static char *kwd_list[] = { "dom", "mem_kb", "name", "cpu", "weight",
    6.13 +                                                                        NULL };
    6.14  
    6.15 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisi", kwd_list, 
    6.16 -                                      &dom, &mem_kb, &name, &cpu) )
    6.17 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisif", kwd_list, 
    6.18 +                                      &dom, &mem_kb, &name, &cpu, &weight) )
    6.19          return NULL;
    6.20 -
    6.21 -    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
    6.22 +        
    6.23 +    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, 
    6.24 +                                                     weight, &dom)) < 0 )
    6.25          return PyErr_SetFromErrno(xc_error);
    6.26  
    6.27      return PyInt_FromLong(dom);
     7.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 14:20:33 2004 +0000
     7.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 10 15:59:16 2004 +0000
     7.3 @@ -486,6 +486,7 @@ class XendDomainInfo:
     7.4          self.config = config
     7.5          try:
     7.6              self.name = sxp.child_value(config, 'name')
     7.7 +            self.weight = float(sxp.child_value(config, 'weight'))
     7.8              self.check_name(self.name)
     7.9              self.memory = int(sxp.child_value(config, 'memory'))
    7.10              if self.memory is None:
    7.11 @@ -705,9 +706,10 @@ class XendDomainInfo:
    7.12              return
    7.13          memory = self.memory
    7.14          name = self.name
    7.15 +        weight = self.weight
    7.16          cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
    7.17          dom = self.dom or 0
    7.18 -        dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu)
    7.19 +        dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu, weight= weight)
    7.20          if dom <= 0:
    7.21              raise VmError('Creating domain failed: name=%s memory=%d'
    7.22                            % (name, memory))
    7.23 @@ -1137,6 +1139,7 @@ add_device_handler('pci',  vm_dev_pci)
    7.24  add_config_handler('name',    vm_field_ignore)
    7.25  add_config_handler('memory',  vm_field_ignore)
    7.26  add_config_handler('cpu',     vm_field_ignore)
    7.27 +add_config_handler('weight',  vm_field_ignore)
    7.28  add_config_handler('console', vm_field_ignore)
    7.29  add_config_handler('image',   vm_field_ignore)
    7.30  add_config_handler('device',  vm_field_ignore)
     8.1 --- a/tools/python/xen/xm/create.py	Tue Aug 10 14:20:33 2004 +0000
     8.2 +++ b/tools/python/xen/xm/create.py	Tue Aug 10 15:59:16 2004 +0000
     8.3 @@ -97,6 +97,10 @@ gopts.var('memory', val='MEMORY',
     8.4            fn=set_value, default=128,
     8.5            use="Domain memory in MB.")
     8.6  
     8.7 +gopts.var('weight', val='WEIGHT',
     8.8 +          fn=set_value, default=1,
     8.9 +          use="Domain cpu weight (default=1).")
    8.10 +
    8.11  gopts.var('console', val='PORT',
    8.12            fn=set_int, default=None,
    8.13            use="Console port to use. Default is 9600 + domain id.")
    8.14 @@ -295,7 +299,8 @@ def make_config(vals):
    8.15      
    8.16      config = ['vm',
    8.17                ['name', vals.name ],
    8.18 -              ['memory', vals.memory ] ]
    8.19 +              ['memory', vals.memory ],
    8.20 +              ['weight', vals.weight] ]
    8.21      if vals.cpu:
    8.22          config.append(['cpu', vals.cpu])
    8.23      if vals.blkif:
     9.1 --- a/xen/arch/x86/smpboot.c	Tue Aug 10 14:20:33 2004 +0000
     9.2 +++ b/xen/arch/x86/smpboot.c	Tue Aug 10 15:59:16 2004 +0000
     9.3 @@ -650,7 +650,7 @@ static void __init do_boot_cpu (int apic
     9.4  
     9.5      cpu = ++cpucount;
     9.6  
     9.7 -    if ( (idle = do_createdomain(IDLE_DOMAIN_ID, cpu)) == NULL )
     9.8 +    if ( (idle = do_createdomain(IDLE_DOMAIN_ID, cpu, 0)) == NULL )
     9.9          panic("failed 'createdomain' for CPU %d", cpu);
    9.10  
    9.11      set_bit(DF_IDLETASK, &idle->flags);
    10.1 --- a/xen/common/dom0_ops.c	Tue Aug 10 14:20:33 2004 +0000
    10.2 +++ b/xen/common/dom0_ops.c	Tue Aug 10 15:59:16 2004 +0000
    10.3 @@ -182,9 +182,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    10.4              pro = op->u.createdomain.cpu % smp_num_cpus;
    10.5  
    10.6          ret = -ENOMEM;
    10.7 -        if ( (d = do_createdomain(dom, pro)) == NULL )
    10.8 +        if ( (d = do_createdomain(dom, pro, op->u.createdomain.weight))==NULL)
    10.9              break;
   10.10 -
   10.11 +        
   10.12          if ( op->u.createdomain.name[0] )
   10.13          {
   10.14              strncpy(d->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
    11.1 --- a/xen/common/domain.c	Tue Aug 10 14:20:33 2004 +0000
    11.2 +++ b/xen/common/domain.c	Tue Aug 10 15:59:16 2004 +0000
    11.3 @@ -22,7 +22,7 @@ rwlock_t tasklist_lock __cacheline_align
    11.4  struct domain *task_hash[TASK_HASH_SIZE];
    11.5  struct domain *task_list;
    11.6  
    11.7 -struct domain *do_createdomain(domid_t dom_id, unsigned int cpu)
    11.8 +struct domain *do_createdomain(domid_t dom_id, unsigned int cpu, float weight)
    11.9  {
   11.10      char buf[100];
   11.11      struct domain *d, **pd;
   11.12 @@ -69,7 +69,7 @@ struct domain *do_createdomain(domid_t d
   11.13          spin_lock_init(&d->pcidev_lock);
   11.14          INIT_LIST_HEAD(&d->pcidev_list);
   11.15  
   11.16 -        sched_add_domain(d);
   11.17 +        sched_add_domain(d, weight);
   11.18  
   11.19          write_lock_irqsave(&tasklist_lock, flags);
   11.20          pd = &task_list; /* NB. task_list is maintained in order of dom_id. */
   11.21 @@ -85,7 +85,7 @@ struct domain *do_createdomain(domid_t d
   11.22      else
   11.23      {
   11.24          sprintf(d->name, "Idle-%d", cpu);
   11.25 -        sched_add_domain(d);
   11.26 +        sched_add_domain(d, weight);
   11.27      }
   11.28  
   11.29      return d;
    12.1 --- a/xen/common/kernel.c	Tue Aug 10 14:20:33 2004 +0000
    12.2 +++ b/xen/common/kernel.c	Tue Aug 10 15:59:16 2004 +0000
    12.3 @@ -306,7 +306,7 @@ void cmain(multiboot_info_t *mbi)
    12.4      task_hash[TASK_HASH(IDLE_DOMAIN_ID)] = &idle0_task;
    12.5  
    12.6      /* Create initial domain 0. */
    12.7 -    new_dom = do_createdomain(0, 0);
    12.8 +    new_dom = do_createdomain(0, 0, 1);
    12.9      if ( new_dom == NULL )
   12.10          panic("Error creating domain 0\n");
   12.11  
    13.1 --- a/xen/common/sched_atropos.c	Tue Aug 10 14:20:33 2004 +0000
    13.2 +++ b/xen/common/sched_atropos.c	Tue Aug 10 15:59:16 2004 +0000
    13.3 @@ -167,8 +167,10 @@ static void requeue(struct domain *sdom)
    13.4       * - they shouldn't be on any queue */
    13.5  }
    13.6  
    13.7 -/* prepare a task to be added to scheduling */
    13.8 -static void at_add_task(struct domain *p)
    13.9 +/* prepare a task to be added to scheduling 
   13.10 +    TODO - can weight argument can be used to set up the 
   13.11 +    scheduling parameters? */
   13.12 +static void at_add_task(struct domain *p, float weight)
   13.13  {
   13.14      s_time_t now = NOW();
   13.15  
    14.1 --- a/xen/common/sched_bvt.c	Tue Aug 10 14:20:33 2004 +0000
    14.2 +++ b/xen/common/sched_bvt.c	Tue Aug 10 15:59:16 2004 +0000
    14.3 @@ -180,13 +180,16 @@ int bvt_alloc_task(struct domain *p)
    14.4  /*
    14.5   * Add and remove a domain
    14.6   */
    14.7 -void bvt_add_task(struct domain *p) 
    14.8 +void bvt_add_task(struct domain *p, float weight) 
    14.9  {
   14.10      struct bvt_dom_info *inf = BVT_INFO(p);
   14.11      ASSERT(inf != NULL);
   14.12      ASSERT(p   != NULL);
   14.13  
   14.14 -    inf->mcu_advance = MCU_ADVANCE;
   14.15 +    if(weight > 0)
   14.16 +        inf->mcu_advance = MCU_ADVANCE / weight;
   14.17 +    else
   14.18 +        inf->mcu_advance = MCU_ADVANCE;
   14.19      inf->domain = p;
   14.20      inf->warpback    = 0;
   14.21      /* Set some default values here. */
   14.22 @@ -224,7 +227,7 @@ int bvt_init_idle_task(struct domain *p)
   14.23  
   14.24      if(bvt_alloc_task(p) < 0) return -1;
   14.25  
   14.26 -    bvt_add_task(p);
   14.27 +    bvt_add_task(p, 0);
   14.28  
   14.29      spin_lock_irqsave(&CPU_INFO(p->processor)->run_lock, flags);
   14.30      
    15.1 --- a/xen/common/sched_fair_bvt.c	Tue Aug 10 14:20:33 2004 +0000
    15.2 +++ b/xen/common/sched_fair_bvt.c	Tue Aug 10 15:59:16 2004 +0000
    15.3 @@ -152,14 +152,17 @@ int fbvt_alloc_task(struct domain *p)
    15.4  /*
    15.5   * Add and remove a domain
    15.6   */
    15.7 -void fbvt_add_task(struct domain *p) 
    15.8 +void fbvt_add_task(struct domain *p, float weight) 
    15.9  {
   15.10      struct fbvt_dom_info *inf = FBVT_INFO(p);
   15.11  
   15.12      ASSERT(inf != NULL);
   15.13      ASSERT(p   != NULL);
   15.14  
   15.15 -    inf->mcu_advance = MCU_ADVANCE;
   15.16 +    if(weight > 0)
   15.17 +        inf->mcu_advance = MCU_ADVANCE / weight;
   15.18 +    else
   15.19 +        inf->mcu_advance = MCU_ADVANCE;
   15.20      inf->domain = p;
   15.21      if ( p->domain == IDLE_DOMAIN_ID )
   15.22      {
   15.23 @@ -187,7 +190,7 @@ int fbvt_init_idle_task(struct domain *p
   15.24  
   15.25      if(fbvt_alloc_task(p) < 0) return -1;
   15.26  
   15.27 -    fbvt_add_task(p);
   15.28 +    fbvt_add_task(p, 0);
   15.29      spin_lock_irqsave(&CPU_INFO(p->processor)->run_lock, flags);
   15.30      set_bit(DF_RUNNING, &p->flags);
   15.31      if ( !__task_on_runqueue(p) )
    16.1 --- a/xen/common/sched_rrobin.c	Tue Aug 10 14:20:33 2004 +0000
    16.2 +++ b/xen/common/sched_rrobin.c	Tue Aug 10 15:59:16 2004 +0000
    16.3 @@ -101,8 +101,9 @@ static int rr_alloc_task(struct domain *
    16.4     return 0;
    16.5  }
    16.6  
    16.7 -/* Setup the rr_dom_info */
    16.8 -static void rr_add_task(struct domain *p)
    16.9 +/* Setup the rr_dom_info 
   16.10 +   The weight argument is ignored as RRobin does not use weights */
   16.11 +static void rr_add_task(struct domain *p, float weight)
   16.12  {
   16.13      struct rrobin_dom_info *inf;
   16.14      RR_INFO(p)->domain = p;
   16.15 @@ -121,7 +122,7 @@ static int rr_init_idle_task(struct doma
   16.16  {
   16.17      unsigned long flags;
   16.18      if(rr_alloc_task(p) < 0) return -1;
   16.19 -    rr_add_task(p);
   16.20 +    rr_add_task(p, 0);
   16.21  
   16.22      spin_lock_irqsave(&run_locks[p->processor], flags);
   16.23      set_bit(DF_RUNNING, &p->flags);
    17.1 --- a/xen/common/schedule.c	Tue Aug 10 14:20:33 2004 +0000
    17.2 +++ b/xen/common/schedule.c	Tue Aug 10 15:59:16 2004 +0000
    17.3 @@ -123,7 +123,7 @@ struct domain *alloc_domain_struct(void)
    17.4  /*
    17.5   * Add and remove a domain
    17.6   */
    17.7 -void sched_add_domain(struct domain *d) 
    17.8 +void sched_add_domain(struct domain *d, float weight) 
    17.9  {
   17.10      /* Must be unpaused by control software to start execution. */
   17.11      set_bit(DF_CTRLPAUSE, &d->flags);
   17.12 @@ -141,7 +141,7 @@ void sched_add_domain(struct domain *d)
   17.13          schedule_data[d->processor].idle = d;
   17.14      }
   17.15  
   17.16 -    SCHED_OP(add_task, d);
   17.17 +    SCHED_OP(add_task, d, weight);
   17.18  
   17.19      TRACE_2D(TRC_SCHED_DOM_ADD, d->domain, d);
   17.20  }
    18.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Tue Aug 10 14:20:33 2004 +0000
    18.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Tue Aug 10 15:59:16 2004 +0000
    18.3 @@ -55,7 +55,7 @@ typedef struct {
    18.4      MEMORY_PADDING;
    18.5      u8           name[MAX_DOMAIN_NAME]; /*  8 */
    18.6      u32          cpu;                 /* 24 */
    18.7 -    u32          __pad0;              /* 28 */
    18.8 +    float        weight;              /* 28 */
    18.9      /* IN/OUT parameters. */
   18.10      /* If 0, domain is allocated. If non-zero use it unless in use. */
   18.11      domid_t      domain;              /* 32 */
    19.1 --- a/xen/include/xen/sched-if.h	Tue Aug 10 14:20:33 2004 +0000
    19.2 +++ b/xen/include/xen/sched-if.h	Tue Aug 10 15:59:16 2004 +0000
    19.3 @@ -38,7 +38,7 @@ struct scheduler
    19.4      int          (*init_scheduler) ();
    19.5      int          (*init_idle_task) (struct domain *);
    19.6      int          (*alloc_task)     (struct domain *);
    19.7 -    void         (*add_task)       (struct domain *);
    19.8 +    void         (*add_task)       (struct domain *, float weight);
    19.9      void         (*free_task)      (struct domain *);
   19.10      void         (*rem_task)       (struct domain *);
   19.11      void         (*sleep)          (struct domain *);
    20.1 --- a/xen/include/xen/sched.h	Tue Aug 10 14:20:33 2004 +0000
    20.2 +++ b/xen/include/xen/sched.h	Tue Aug 10 15:59:16 2004 +0000
    20.3 @@ -171,7 +171,7 @@ static inline int get_domain(struct doma
    20.4  }
    20.5    
    20.6  extern struct domain *do_createdomain(
    20.7 -    domid_t dom_id, unsigned int cpu);
    20.8 +    domid_t dom_id, unsigned int cpu, float weight);
    20.9  extern int construct_dom0(struct domain *d, 
   20.10                            unsigned long alloc_start,
   20.11                            unsigned long alloc_end,
   20.12 @@ -198,7 +198,7 @@ extern unsigned long wait_init_idle;
   20.13  #define set_current_state(_s) do { current->state = (_s); } while (0)
   20.14  void scheduler_init(void);
   20.15  void schedulers_start(void);
   20.16 -void sched_add_domain(struct domain *d);
   20.17 +void sched_add_domain(struct domain *d, float weight);
   20.18  void sched_rem_domain(struct domain *d);
   20.19  long sched_ctl(struct sched_ctl_cmd *);
   20.20  long sched_adjdom(struct sched_adjdom_cmd *);