Skip to contentSkip to conversation

configuration files(sched-credit)

PATCH In review [email protected] 2 participants 5 messages Aug 17, 2006 – Oct 22, 2006 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configuration files(sched-credit)

Currently with the credit scheduler, cpu_weight cannot be assigned to guest domains at boot time.(it can be set with xm sched-weight after booting) This patch allows CPU weight, and CAP to be set by the Xen configuration files.

Specification:
The following can be added to the Xen configuration files.

1.CPU WEIGHT [OPTIONAL]
cpu_weight = cpu weight value

-sets the cpu time ratio to be allocated to the domain
-the scale and the default value may vary according to the scheduler used.
No modification has been made for the bvt scheduler.
--credit scheduler: 1~65535 (default:256)
--bvt scheduler: float value (default:1.0)

2.CAP [OPTIONAL]
cpu_cap= value

-this is only valid when using the credit scheduler -allots the maximum CPU usage percentage for the domain -the domain will use
-- (value x 0.01) physical CPUs
ex: 50 for 0.5 physical CPU
100 for 1.0 physical CPU
400 for 4.0 physical CPU
-- default:0.0 (no limit)

Improvements:
- allows cpu_cap to be set in the Xen configuration files
- sets default cpu_cap and cpu_weight values for each scheduler
- passes the cpu_cap and the cpu_weight in the Xen configuration files to xend

Modifications:
-To allow cpu_cap to be set in the Xen configuration files
python/xen/xm/create.py, python/xen/xend/XendDomainInfo.py, python/xen/lowlevel/xc/xc.c
-To allow cpu_cap and cpu_weight in the Xen configuration files to be
passed to xend
python/xen/sv/CreateDomain.py, libxc/xenctrl.h, xc_domain.c, python/xen/lowlevel/xc/xc.c
-To set default values for each scheduler
Previously, the default value, 1.0 had been set for the bvt scheduler by
the Xen configuration files parsing in XendDomainInfo.py. It has now been modified so that default values are set in xc_domain.c after the scheduler type has been determined.
In XendDomainInfo.py, the default value is now set to -1
libxc/xc_domain.c

Watanabe

tools/libxc/xc_domain.c +23 -0
diff -r 9eb6783b8e0b tools/libxc/xc_domain.c
@@ -234,6 +234,7 @@ int xc_shadow_control(int xc_handle,
 
 int xc_domain_setcpuweight(int xc_handle,
                            uint32_t domid,
+                           int cap,
                            float weight)
 {
     int sched_id;
@@ -253,6 +254,9 @@ int xc_domain_setcpuweight(int xc_handle
             long long warpl;
             long long warpu;
 
+            /* set default value */
+            if ( weight == -1 ) weight = 1.0;
+
             /* Preserve all the scheduling parameters apart
                of MCU advance. */
             if ( (ret = xc_bvtsched_domain_get(
@@ -269,6 +273,25 @@ int xc_domain_setcpuweight(int xc_handle
             ret = xc_bvtsched_domain_set(xc_handle, domid, mcuadv,
                                          warpback, warpvalue, warpl, warpu);
             break;
+        }
+        case SCHED_CREDIT:
+        {
+            struct sched_credit_adjdom sdom;
+
+            /* set default value */
+            if ( weight == -1 ) weight = 256;
+            if ( cap == -1 ) cap = 0;
+
+            sdom.weight = (uint16_t)weight;
+            sdom.cap = (uint16_t)cap;
+            if (cap == 0)
+                cap = (uint16_t)~0U;
+            ret = xc_sched_credit_domain_set(xc_handle, domid, &sdom);
+            break;
+        }
+        default:
+        {
+            ret = -1;
         }
     }
 
tools/libxc/xenctrl.h +1 -0
diff -r 9eb6783b8e0b tools/libxc/xenctrl.h
@@ -309,6 +309,7 @@ int xc_vcpu_getinfo(int xc_handle,
 
 int xc_domain_setcpuweight(int xc_handle,
                            uint32_t domid,
+                           int cap,
                            float weight);
 long long xc_domain_get_cpu_usage(int xc_handle,
                                   domid_t domid,
tools/python/xen/lowlevel/xc/xc.c +12 -10
diff -r 9eb6783b8e0b tools/python/xen/lowlevel/xc/xc.c
@@ -169,15 +169,16 @@ static PyObject *pyxc_domain_setcpuweigh
 					  PyObject *kwds)
 {
     uint32_t dom;
-    float cpuweight = 1;
-
-    static char *kwd_list[] = { "dom", "cpuweight", NULL };
-
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|f", kwd_list, 
-                                      &dom, &cpuweight) )
-        return NULL;
-
-    if ( xc_domain_setcpuweight(self->xc_handle, dom, cpuweight) != 0 )
+    int cpucap;
+    float cpuweight;
+
+    static char *kwd_list[] = { "dom", "cpucap", "cpuweight", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iif", kwd_list, 
+                                      &dom, &cpucap, &cpuweight) )
+        return NULL;
+
+    if ( xc_domain_setcpuweight(self->xc_handle, dom, cpucap, cpuweight) != 0 )
         return PyErr_SetFromErrno(xc_error);
     
     Py_INCREF(zero);
@@ -982,7 +983,8 @@ static PyMethodDef pyxc_methods[] = {
       METH_VARARGS | METH_KEYWORDS, "\n"
       "Set cpuweight scheduler parameter for domain.\n"
       " dom [int]:            Identifier of domain to be changed.\n"
-      " cpuweight [float, 1]: VCPU being pinned.\n"
+      " cpucap [int, 0]: maximum amount of CPU.\n"
+      " cpuweight [float]: CPU weight controls the domain\'s share of the cpu..\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
     { "domain_sethandle", 
tools/python/xen/sv/CreateDomain.py +2 -0
diff -r 9eb6783b8e0b tools/python/xen/sv/CreateDomain.py
@@ -30,6 +30,7 @@ class CreatePage0( Sheet ):
         self.addControl( InputControl( 'name', 'VM Name', 'VM Name:', "[\\w|\\S]+", "You must enter a name in this field" ) )
         self.addControl( InputControl( 'memory', '64', 'Memory (Mb):', "[\\d]+", "You must enter a number in this field" ) )
         self.addControl( InputControl( 'cpu', '0', 'CPU:', "[\\d]+", "You must enter a number in this feild" ) )
+        self.addControl( InputControl( 'cpu_cap', '0', 'CPU CAP:', "[\\d]+", "You must enter a number in this feild" ) )
         self.addControl( InputControl( 'cpu_weight', '1', 'CPU Weight:', "[\\d]+", "You must enter a number in this feild" ) )
         self.addControl( InputControl( 'vcpus', '1', 'Virtual CPUs:', '[\\d]+', "You must enter a number in this feild") )
                         
@@ -151,6 +152,7 @@ class CreateFinish( Sheet ):
         vals.memory = 	get( 'memory' )
         vals.maxmem =   get( 'maxmem' )
         vals.cpu =  	get( 'cpu' )
+        vals.cpu_cap = get( 'cpu_cap' )
         vals.cpu_weight = get( 'cpu_weight' )
         vals.vcpus = get( 'vcpus' )
         
tools/python/xen/xend/XendDomainInfo.py +7 -2
diff -r 9eb6783b8e0b tools/python/xen/xend/XendDomainInfo.py
@@ -129,6 +129,7 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [
     ('uuid',       str),
     ('vcpus',      int),
     ('vcpu_avail', int),
+    ('cpu_cap',    int),
     ('cpu_weight', float),
     ('memory',     int),
     ('maxmem',     int),
@@ -556,7 +557,8 @@ class XendDomainInfo:
             defaultInfo('features',     lambda: "")
             defaultInfo('cpu',          lambda: None)
             defaultInfo('cpus',         lambda: [])
-            defaultInfo('cpu_weight',   lambda: 1.0)
+            defaultInfo('cpu_cap',      lambda: -1)            
+            defaultInfo('cpu_weight',   lambda: -1)
 
             # some domains don't have a config file (e.g. dom0 )
             # to set number of vcpus so we derive available cpus
@@ -1248,6 +1250,7 @@ class XendDomainInfo:
     def initDomain(self):
         log.debug('XendDomainInfo.initDomain: %s %s',
                   self.domid,
+                  self.info['cpu_cap'],
                   self.info['cpu_weight'])
 
         # if we have a boot loader but no image, then we need to set things
@@ -1267,7 +1270,9 @@ class XendDomainInfo:
             if localtime is not None and localtime == 1:
                 xc.domain_set_time_offset(self.domid)
 
-            xc.domain_setcpuweight(self.domid, self.info['cpu_weight'])
+            xc.domain_setcpuweight(self.domid,
+                                   self.info['cpu_cap'],
+                                   self.info['cpu_weight'])
 
             # repin domain vcpus if a restricted cpus list is provided
             # this is done prior to memory allocation to aide in memory
tools/python/xen/xm/create.py +7 -0
diff -r 9eb6783b8e0b tools/python/xen/xm/create.py
@@ -181,6 +181,11 @@ gopts.var('vcpus', val='VCPUS',
 gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
           use="# of Virtual CPUS in domain.")
+
+gopts.var('cpu_cap', val='CAP',
+          fn=set_int, default=None,
+          use="""Set the maximum amount of cpu.
+          CAP is a percentage that fixes the maximum amount of cpu.""")
 
 gopts.var('cpu_weight', val='WEIGHT',
           fn=set_float, default=None,
@@ -674,6 +679,8 @@ def make_config(vals):
         config.append(['cpu', vals.cpu])
     if vals.cpus is not None:
         config.append(['cpus', vals.cpus])
+    if vals.cpu_cap is not None:
+        config.append(['cpu_cap', vals.cpu_cap])
     if vals.cpu_weight is not None:
         config.append(['cpu_weight', vals.cpu_weight])
     if vals.blkif:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hi,

Do you have any comment?
If you have no comment, could you commit this patch?

http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

Quoted 56 lines · Masami Watanabe

Currently with the credit scheduler, cpu_weight cannot be assigned to guest domains at boot time.(it can be set with xm sched-weight after booting) This patch allows CPU weight, and CAP to be set by the Xen configuration files.

Specification:
The following can be added to the Xen configuration files.

1.CPU WEIGHT [OPTIONAL]
cpu_weight = cpu weight value

(quoted diff) +0 -4
-sets the cpu time ratio to be allocated to the domain
-the scale and the default value may vary according to the scheduler used.
 No modification has been made for the bvt scheduler.
--credit scheduler: 1~65535 (default:256)
--bvt scheduler: float value (default:1.0)

2.CAP [OPTIONAL]
cpu_cap= value

(quoted diff) +0 -5
-this is only valid when using the credit scheduler
-allots the maximum CPU usage percentage for the domain
-the domain will use
-- (value x 0.01) physical CPUs
  ex: 50 for 0.5 physical CPU
     100 for 1.0 physical CPU
     400 for 4.0 physical CPU
-- default:0.0 (no limit)

Improvements:
- allows cpu_cap to be set in the Xen configuration files
- sets default cpu_cap and cpu_weight values for each scheduler
- passes the cpu_cap and the cpu_weight in the Xen configuration files to xend

Modifications:

(quoted diff) +0 -3
-To allow cpu_cap to be set in the Xen configuration files
      python/xen/xm/create.py, python/xen/xend/XendDomainInfo.py,
      python/xen/lowlevel/xc/xc.c
-To allow cpu_cap and cpu_weight in the Xen configuration files to be
 passed to xend
      python/xen/sv/CreateDomain.py, libxc/xenctrl.h, xc_domain.c, 
      python/xen/lowlevel/xc/xc.c
-To set default values for each scheduler
 Previously, the default value, 1.0 had been set for the bvt scheduler by 

the Xen configuration files parsing in XendDomainInfo.py. It has now been modified so that default values are set in xc_domain.c after the scheduler type has been determined.
In XendDomainInfo.py, the default value is now set to -1
libxc/xc_domain.c

Watanabe

#2 lore raw
Quoted 6 lines · Masami Watanabe

Hi,

Do you have any comment?
If you have no comment, could you commit this patch?

http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

The patch does not apply to xen-unstable. Since changeset 11241, the xc_domain_setcpuweight is a no-op. Instead you should probably use xc.sched_credit_domain_set directly from XendDomain.py and leave libxc's domain_setcpuweight alone.

Cheers,

Alastair

#3 lore raw

Thanks Alastair,

This is take 2 on configuration files(sched-credit).

The specification is as mentioned at
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

The difference is follows.
- change default value in XendDomainInfo.py
- xc_domain_setcpuweight was not used
- xc.sched_credit_domain_set was used directly from XendDomain.py. domain_create and [email protected]

    -> xc.sched_credit_domain_set
Quoted 15 lines · Alastair Tse
Quoted 6 lines · Masami Watanabe

Hi,

Do you have any comment?
If you have no comment, could you commit this patch?

http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

The patch does not apply to xen-unstable. Since changeset 11241, the xc_domain_setcpuweight is a no-op. Instead you should probably use xc.sched_credit_domain_set directly from XendDomain.py and leave libxc's domain_setcpuweight alone.

Cheers,

Quoted 7 lines

Alastair

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/python/xen/xend/XendDomain.py +3 -0
diff -r c4f3f719d997 tools/python/xen/xend/XendDomain.py
@@ -227,6 +227,9 @@ class XendDomain:
         try:
             dominfo = XendDomainInfo.create(config)
             self._add_domain(dominfo)
+            self.domain_sched_credit_set(dominfo.getDomid(),
+                                         dominfo.getWeight(),
+                                         dominfo.getCap())
             return dominfo
         finally:
             self.domains_lock.release()
tools/python/xen/xend/XendDomainInfo.py +10 -2
diff -r c4f3f719d997 tools/python/xen/xend/XendDomainInfo.py
@@ -131,7 +131,8 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [
     ('uuid',            str),
     ('vcpus',           int),
     ('vcpu_avail',      int),
-    ('cpu_weight',      float),
+    ('cpu_cap',         int),
+    ('cpu_weight',      int),
     ('memory',          int),
     ('shadow_memory',   int),
     ('maxmem',          int),
@@ -560,7 +561,8 @@ class XendDomainInfo:
             defaultInfo('features',     lambda: "")
             defaultInfo('cpu',          lambda: None)
             defaultInfo('cpus',         lambda: [])
-            defaultInfo('cpu_weight',   lambda: 1.0)
+            defaultInfo('cpu_cap',      lambda: 0)
+            defaultInfo('cpu_weight',   lambda: 256)
 
             # some domains don't have a config file (e.g. dom0 )
             # to set number of vcpus so we derive available cpus
@@ -823,6 +825,12 @@ class XendDomainInfo:
 
     def getResume(self):
         return "%s" % self.info['resume']
+
+    def getCap(self):
+        return self.info['cpu_cap']
+
+    def getWeight(self):
+        return self.info['cpu_weight']
 
     def endRestore(self):
         self.setResume(False)
tools/python/xen/xm/create.py +9 -3
diff -r c4f3f719d997 tools/python/xen/xm/create.py
@@ -185,10 +185,14 @@ gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
           use="# of Virtual CPUS in domain.")
 
+gopts.var('cpu_cap', val='CAP',
+          fn=set_int, default=None,
+          use="""Set the maximum amount of cpu.
+          CAP is a percentage that fixes the maximum amount of cpu.""")
+
 gopts.var('cpu_weight', val='WEIGHT',
-          fn=set_float, default=None,
-          use="""Set the new domain's cpu weight.
-          WEIGHT is a float that controls the domain's share of the cpu.""")
+          fn=set_int, default=None,
+          use="""Set the cpu time ratio to be allocated to the domain.""")
 
 gopts.var('restart', val='onreboot|always|never',
           fn=set_value, default=None,
@@ -677,6 +681,8 @@ def make_config(vals):
         config.append(['cpu', vals.cpu])
     if vals.cpus is not None:
         config.append(['cpus', vals.cpus])
+    if vals.cpu_cap is not None:
+        config.append(['cpu_cap', vals.cpu_cap])
     if vals.cpu_weight is not None:
         config.append(['cpu_weight', vals.cpu_weight])
     if vals.blkif:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

PATCH 1/1 configuration files(sched-credit)

Hi,

Do you have any comment?
If you have no comment, could you commit this patch?

http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

This is take 3 on configuration files(sched-credit). This patch matched to CS11853.

Best regards,
Masami

Quoted 12 lines · Masami Watanabe

Thanks Alastair,

This is take 2 on configuration files(sched-credit).

The specification is as mentioned at
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

The difference is follows.
- change default value in XendDomainInfo.py
- xc_domain_setcpuweight was not used
- xc.sched_credit_domain_set was used directly from XendDomain.py. domain_create and [email protected]

Quoted 29 lines
    -> xc.sched_credit_domain_set
Quoted 22 lines · Alastair Tse
Quoted 6 lines · Masami Watanabe

Hi,

Do you have any comment?
If you have no comment, could you commit this patch?

http://lists.xensource.com/archives/html/xen-devel/2006-08/msg00999.html

The patch does not apply to xen-unstable. Since changeset 11241, the xc_domain_setcpuweight is a no-op. Instead you should probably use xc.sched_credit_domain_set directly from XendDomain.py and leave libxc's domain_setcpuweight alone.

Cheers,

Alastair

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

tools/python/xen/xend/XendDomain.py +3 -0
diff -r c3602d217110 tools/python/xen/xend/XendDomain.py
@@ -227,6 +227,9 @@ class XendDomain:
         try:
             dominfo = XendDomainInfo.create(config)
             self._add_domain(dominfo)
+            self.domain_sched_credit_set(dominfo.getDomid(),
+                                         dominfo.getWeight(),
+                                         dominfo.getCap())
             return dominfo
         finally:
             self.domains_lock.release()
tools/python/xen/xend/XendDomainInfo.py +10 -2
diff -r c3602d217110 tools/python/xen/xend/XendDomainInfo.py
@@ -131,7 +131,8 @@ ROUNDTRIPPING_CONFIG_ENTRIES = [
     ('uuid',            str),
     ('vcpus',           int),
     ('vcpu_avail',      int),
-    ('cpu_weight',      float),
+    ('cpu_cap',         int),
+    ('cpu_weight',      int),
     ('memory',          int),
     ('shadow_memory',   int),
     ('maxmem',          int),
@@ -562,7 +563,8 @@ class XendDomainInfo:
             defaultInfo('features',     lambda: "")
             defaultInfo('cpu',          lambda: None)
             defaultInfo('cpus',         lambda: [])
-            defaultInfo('cpu_weight',   lambda: 1.0)
+            defaultInfo('cpu_cap',      lambda: 0)
+            defaultInfo('cpu_weight',   lambda: 256)
 
             # some domains don't have a config file (e.g. dom0 )
             # to set number of vcpus so we derive available cpus
@@ -825,6 +827,12 @@ class XendDomainInfo:
 
     def getResume(self):
         return "%s" % self.info['resume']
+
+    def getCap(self):
+        return self.info['cpu_cap']
+
+    def getWeight(self):
+        return self.info['cpu_weight']
 
     def endRestore(self):
         self.setResume(False)
tools/python/xen/xm/create.py +9 -3
diff -r c3602d217110 tools/python/xen/xm/create.py
@@ -189,10 +189,14 @@ gopts.var('vcpus', val='VCPUS',
           fn=set_int, default=1,
           use="# of Virtual CPUS in domain.")
 
+gopts.var('cpu_cap', val='CAP',
+          fn=set_int, default=None,
+          use="""Set the maximum amount of cpu.
+          CAP is a percentage that fixes the maximum amount of cpu.""")
+
 gopts.var('cpu_weight', val='WEIGHT',
-          fn=set_float, default=None,
-          use="""Set the new domain's cpu weight.
-          WEIGHT is a float that controls the domain's share of the cpu.""")
+          fn=set_int, default=None,
+          use="""Set the cpu time ratio to be allocated to the domain.""")
 
 gopts.var('restart', val='onreboot|always|never',
           fn=set_value, default=None,
@@ -687,6 +691,8 @@ def make_config(vals):
         config.append(['cpu', vals.cpu])
     if vals.cpus is not None:
         config.append(['cpus', vals.cpus])
+    if vals.cpu_cap is not None:
+        config.append(['cpu_cap', vals.cpu_cap])
     if vals.cpu_weight is not None:
         config.append(['cpu_weight', vals.cpu_weight])
     if vals.blkif:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel