direct-io.hg

changeset 2236:a628543fb437

bitkeeper revision 1.1159.30.1 (411ddb8cj12XLuMNx_qS9SGeej51OQ)

cpu_weight parameter added to the xm create command. Minor bug fix for BVT.
author gm281@boulderdash.cl.cam.ac.uk
date Sat Aug 14 09:29:48 2004 +0000 (2004-08-14)
parents 7bac86571809
children 49739c6ac967
files 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/common/sched_bvt.c
line diff
     1.1 --- a/tools/libxc/xc.h	Fri Aug 13 09:06:31 2004 +0000
     1.2 +++ b/tools/libxc/xc.h	Sat Aug 14 09:29:48 2004 +0000
     1.3 @@ -48,6 +48,7 @@ int xc_domain_create(int xc_handle,
     1.4                       unsigned int mem_kb, 
     1.5                       const char *name,
     1.6                       int cpu,
     1.7 +                     float cpu_weight,
     1.8                       u32 *pdomid);
     1.9  int xc_domain_pause(int xc_handle, 
    1.10                      u32 domid);
    1.11 @@ -62,6 +63,9 @@ int xc_domain_getinfo(int xc_handle,
    1.12                        u32 first_domid, 
    1.13                        unsigned int max_doms,
    1.14                        xc_dominfo_t *info);
    1.15 +int xc_domain_setcpuweight(int xc_handle,
    1.16 +                           u32 domid,
    1.17 +                           float weight);
    1.18  
    1.19  int xc_shadow_control(int xc_handle,
    1.20                        u32 domid, 
    1.21 @@ -209,6 +213,9 @@ typedef struct {
    1.22  int xc_physinfo(int xc_handle,
    1.23                  xc_physinfo_t *info);
    1.24  
    1.25 +int xc_sched_id(int xc_handle,
    1.26 +                int *sched_id);
    1.27 +
    1.28  int xc_domain_setname(int xc_handle,
    1.29                        u32 domid, 
    1.30                        char *name);
     2.1 --- a/tools/libxc/xc_domain.c	Fri Aug 13 09:06:31 2004 +0000
     2.2 +++ b/tools/libxc/xc_domain.c	Sat Aug 14 09:29:48 2004 +0000
     2.3 @@ -12,6 +12,7 @@ int xc_domain_create(int xc_handle,
     2.4                       unsigned int mem_kb, 
     2.5                       const char *name,
     2.6                       int cpu,
     2.7 +                     float cpu_weight,
     2.8                       u32 *pdomid)
     2.9  {
    2.10      int err;
    2.11 @@ -25,7 +26,11 @@ int xc_domain_create(int xc_handle,
    2.12      op.u.createdomain.cpu = cpu;
    2.13  
    2.14      if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
    2.15 +    {
    2.16          *pdomid = (u16)op.u.createdomain.domain;
    2.17 +        
    2.18 +         err = xc_domain_setcpuweight(xc_handle, *pdomid, cpu_weight);
    2.19 +    }
    2.20  
    2.21      return err;
    2.22  }    
    2.23 @@ -171,6 +176,64 @@ int xc_domain_setname(int xc_handle,
    2.24      return do_dom0_op(xc_handle, &op);
    2.25  }
    2.26  
    2.27 +int xc_domain_setcpuweight(int xc_handle,
    2.28 +                           u32 domid,
    2.29 +                           float weight)
    2.30 +{
    2.31 +    int sched_id;
    2.32 +    int ret;
    2.33 +    
    2.34 +    /* Figure out which scheduler is currently used: */
    2.35 +    if((ret = xc_sched_id(xc_handle, &sched_id)))
    2.36 +        return ret;
    2.37 +    
    2.38 +    switch(sched_id)
    2.39 +    {
    2.40 +        case SCHED_BVT:
    2.41 +        {
    2.42 +            u32 mcuadv;
    2.43 +            int warpback;
    2.44 +            s32 warpvalue;
    2.45 +            long long warpl;
    2.46 +            long long warpu;
    2.47 +
    2.48 +            /* Preserve all the scheduling parameters apart 
    2.49 +               of MCU advance. */
    2.50 +            if((ret = xc_bvtsched_domain_get(xc_handle, domid, &mcuadv, 
    2.51 +                                &warpback, &warpvalue, &warpl, &warpu)))
    2.52 +                return ret;
    2.53 +            
    2.54 +            /* The MCU advance is inverse of the weight.
    2.55 +               Default value of the weight is 1, default mcuadv 10.
    2.56 +               The scaling factor is therefore 10. */
    2.57 +            if(weight > 0) mcuadv = 10 / weight;
    2.58 +            
    2.59 +            ret = xc_bvtsched_domain_set(xc_handle, domid, mcuadv, 
    2.60 +                                         warpback, warpvalue, warpl, warpu);
    2.61 +            break;
    2.62 +        }
    2.63 +        
    2.64 +        case SCHED_FBVT:
    2.65 +        {
    2.66 +            // TODO
    2.67 +            break;
    2.68 +        }
    2.69 +        case SCHED_RROBIN:
    2.70 +        {
    2.71 +            /* The weight cannot be set for RRobin */
    2.72 +            break;
    2.73 +        }
    2.74 +        case SCHED_ATROPOS:
    2.75 +        {
    2.76 +            /* TODO - can we set weights in Atropos? */
    2.77 +            break;
    2.78 +        }
    2.79 +    }
    2.80 +
    2.81 +    return ret;
    2.82 +}
    2.83 +
    2.84 +
    2.85  int xc_domain_setinitialmem(int xc_handle,
    2.86                              u32 domid, 
    2.87                              unsigned int initial_memkb)
     3.1 --- a/tools/libxc/xc_linux_restore.c	Fri Aug 13 09:06:31 2004 +0000
     3.2 +++ b/tools/libxc/xc_linux_restore.c	Sat Aug 14 09:29:48 2004 +0000
     3.3 @@ -224,7 +224,7 @@ int xc_linux_restore(int xc_handle, XcIO
     3.4  
     3.5      /* XXX create domain on CPU=-1 so that in future it auto load ballances by default */
     3.6      if ( xc_domain_create( xc_handle,  nr_pfns * (PAGE_SIZE / 1024),
     3.7 -			   name, -1, &dom ) )
     3.8 +			   name, -1, 1, &dom ) )
     3.9      {
    3.10  	xcio_error(ioctxt, "Could not create domain. pfns=%d, %dKB",
    3.11  		   nr_pfns,nr_pfns * (PAGE_SIZE / 1024));
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Aug 13 09:06:31 2004 +0000
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Sat Aug 14 09:29:48 2004 +0000
     4.3 @@ -44,16 +44,19 @@ static PyObject *pyxc_domain_create(PyOb
     4.4      unsigned int mem_kb = 0;
     4.5      char        *name   = "(anon)";
     4.6      int          cpu = -1;
     4.7 +    float        cpu_weight = 1;
     4.8      u32          dom = 0;
     4.9      int          ret;
    4.10  
    4.11 -    static char *kwd_list[] = { "dom", "mem_kb", "name", "cpu", NULL };
    4.12 +    static char *kwd_list[] = { "dom", "mem_kb", "name", 
    4.13 +                                "cpu", "cpu_weight", NULL };
    4.14  
    4.15 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisi", kwd_list, 
    4.16 -                                      &dom, &mem_kb, &name, &cpu) )
    4.17 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisif", kwd_list, 
    4.18 +                                      &dom, &mem_kb, &name, &cpu, &cpu_weight))
    4.19          return NULL;
    4.20  
    4.21 -    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
    4.22 +    if ( (ret = xc_domain_create(
    4.23 +                    xc->xc_handle, mem_kb, name, cpu, cpu_weight, &dom)) < 0 )
    4.24          return PyErr_SetFromErrno(xc_error);
    4.25  
    4.26      return PyInt_FromLong(dom);
     5.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Aug 13 09:06:31 2004 +0000
     5.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Sat Aug 14 09:29:48 2004 +0000
     5.3 @@ -490,6 +490,7 @@ class XendDomainInfo:
     5.4          try:
     5.5              self.name = sxp.child_value(config, 'name')
     5.6              self.check_name(self.name)
     5.7 +            self.cpu_weight = float(sxp.child_value(config, 'cpu_weight'))
     5.8              self.memory = int(sxp.child_value(config, 'memory'))
     5.9              if self.memory is None:
    5.10                  raise VmError('missing memory size')
    5.11 @@ -709,8 +710,9 @@ class XendDomainInfo:
    5.12          memory = self.memory
    5.13          name = self.name
    5.14          cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
    5.15 +        cpu_weight = self.cpu_weight
    5.16          dom = self.dom or 0
    5.17 -        dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu)
    5.18 +        dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu, cpu_weight= cpu_weight)
    5.19          if dom <= 0:
    5.20              raise VmError('Creating domain failed: name=%s memory=%d'
    5.21                            % (name, memory))
    5.22 @@ -1137,12 +1139,13 @@ add_device_handler('vbd',  vm_dev_vbd)
    5.23  add_device_handler('pci',  vm_dev_pci)
    5.24  
    5.25  # Ignore the fields we already handle.
    5.26 -add_config_handler('name',    vm_field_ignore)
    5.27 -add_config_handler('memory',  vm_field_ignore)
    5.28 -add_config_handler('cpu',     vm_field_ignore)
    5.29 -add_config_handler('console', vm_field_ignore)
    5.30 -add_config_handler('image',   vm_field_ignore)
    5.31 -add_config_handler('device',  vm_field_ignore)
    5.32 -add_config_handler('backend', vm_field_ignore)
    5.33 +add_config_handler('name',       vm_field_ignore)
    5.34 +add_config_handler('memory',     vm_field_ignore)
    5.35 +add_config_handler('cpu',        vm_field_ignore)
    5.36 +add_config_handler('cpu_weight', vm_field_ignore)
    5.37 +add_config_handler('console',    vm_field_ignore)
    5.38 +add_config_handler('image',      vm_field_ignore)
    5.39 +add_config_handler('device',     vm_field_ignore)
    5.40 +add_config_handler('backend',    vm_field_ignore)
    5.41  
    5.42  # Register other config handlers.
     6.1 --- a/tools/python/xen/xm/create.py	Fri Aug 13 09:06:31 2004 +0000
     6.2 +++ b/tools/python/xen/xm/create.py	Sat Aug 14 09:29:48 2004 +0000
     6.3 @@ -101,6 +101,10 @@ gopts.var('memory', val='MEMORY',
     6.4            fn=set_value, default=128,
     6.5            use="Domain memory in MB.")
     6.6  
     6.7 +gopts.var('cpu_weight', val='CPU_WEIGHT',
     6.8 +          fn=set_value, default=1,
     6.9 +          use="CPU weight.")
    6.10 +
    6.11  gopts.var('console', val='PORT',
    6.12            fn=set_int, default=None,
    6.13            use="Console port to use. Default is 9600 + domain id.")
    6.14 @@ -299,7 +303,8 @@ def make_config(vals):
    6.15      
    6.16      config = ['vm',
    6.17                ['name', vals.name ],
    6.18 -              ['memory', vals.memory ] ]
    6.19 +              ['memory', vals.memory ],
    6.20 +              ['cpu_weight', vals.cpu_weight] ]
    6.21      if vals.cpu:
    6.22          config.append(['cpu', vals.cpu])
    6.23      if vals.blkif:
     7.1 --- a/xen/common/sched_bvt.c	Fri Aug 13 09:06:31 2004 +0000
     7.2 +++ b/xen/common/sched_bvt.c	Sat Aug 14 09:29:48 2004 +0000
     7.3 @@ -143,7 +143,7 @@ static inline u32 calc_avt(struct domain
     7.4      ranfor = (u32)(now - d->lastschd);
     7.5      mcus = (ranfor + MCU - 1)/MCU;
     7.6  
     7.7 -    return inf->avt + mcus;
     7.8 +    return inf->avt + mcus * inf->mcu_advance;
     7.9  }
    7.10  
    7.11