diff -r e0e26c5c0218 tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Mon Dec 08 09:46:24 2008 +0900 +++ b/tools/python/xen/lowlevel/xc/xc.c Mon Dec 08 16:36:45 2008 +0900 @@ -1281,18 +1281,26 @@ static PyObject *pyxc_sched_credit_domai uint32_t domid; uint16_t weight; uint16_t cap; - static char *kwd_list[] = { "domid", "weight", "cap", NULL }; - static char kwd_type[] = "I|HH"; + uint16_t max_boost_period; + uint16_t boost_ratio; + static char *kwd_list[] = { "domid", "weight", "cap", + "max_boost_period", "boost_ratio", NULL }; + static char kwd_type[] = "I|HHhh"; struct xen_domctl_sched_credit sdom; weight = 0; cap = (uint16_t)~0U; + max_boost_period = (uint16_t)~0U; + boost_ratio = (uint16_t)~0U; if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list, - &domid, &weight, &cap) ) + &domid, &weight, &cap, + &max_boost_period, &boost_ratio) ) return NULL; sdom.weight = weight; sdom.cap = cap; + sdom.max_boost_period = max_boost_period; + sdom.boost_ratio = boost_ratio; if ( xc_sched_credit_domain_set(self->xc_handle, domid, &sdom) != 0 ) return pyxc_error_to_exception(); @@ -1312,9 +1320,11 @@ static PyObject *pyxc_sched_credit_domai if ( xc_sched_credit_domain_get(self->xc_handle, domid, &sdom) != 0 ) return pyxc_error_to_exception(); - return Py_BuildValue("{s:H,s:H}", - "weight", sdom.weight, - "cap", sdom.cap); + return Py_BuildValue("{s:H,s:H,s:i,s:i}", + "weight", sdom.weight, + "cap", sdom.cap, + "max_boost_period", sdom.max_boost_period, + "boost_ratio", sdom.boost_ratio); } static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args) @@ -1720,8 +1730,11 @@ static PyMethodDef pyxc_methods[] = { METH_KEYWORDS, "\n" "Set the scheduling parameters for a domain when running with the\n" "SMP credit scheduler.\n" - " domid [int]: domain id to set\n" - " weight [short]: domain's scheduling weight\n" + " domid [int]: domain id to set\n" + " weight [short]: domain's scheduling weight\n" + " cap [short]: cap\n" + " max_boost_period [short]: upper limit in BOOST priority\n" + " boost_ratio [short]; domain's boost ratio per a cpu\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "sched_credit_domain_get", @@ -1729,9 +1742,12 @@ static PyMethodDef pyxc_methods[] = { METH_VARARGS, "\n" "Get the scheduling parameters for a domain when running with the\n" "SMP credit scheduler.\n" - " domid [int]: domain id to get\n" + " domid [int]: domain id to get\n" "Returns: [dict]\n" - " weight [short]: domain's scheduling weight\n"}, + " weight [short]: domain's scheduling weight\n" + " cap [short]: cap\n" + " max_boost_period [short]: upper limit in BOOST priority\n" + " boost_ratio [short]: domain's boost ratio per a cpu\n"}, { "evtchn_alloc_unbound", (PyCFunction)pyxc_evtchn_alloc_unbound, diff -r e0e26c5c0218 tools/python/xen/xend/XendAPI.py --- a/tools/python/xen/xend/XendAPI.py Mon Dec 08 09:46:24 2008 +0900 +++ b/tools/python/xen/xend/XendAPI.py Mon Dec 08 16:36:45 2008 +0900 @@ -1505,10 +1505,14 @@ class XendAPI(object): #need to update sched params aswell if 'weight' in xeninfo.info['vcpus_params'] \ - and 'cap' in xeninfo.info['vcpus_params']: + and 'cap' in xeninfo.info['vcpus_params'] \ + and 'max_boost_period' in xeninfo.info['vcpus_params'] \ + and 'boost_ratio' in xeninfo.info['vcpus_params']: weight = xeninfo.info['vcpus_params']['weight'] cap = xeninfo.info['vcpus_params']['cap'] - xendom.domain_sched_credit_set(xeninfo.getDomid(), weight, cap) + max_boost_period = xeninfo.info['vcpus_params']['max_boost_period'] + boost_ratio = xeninfo.info['vcpus_params']['boost_ratio'] + xendom.domain_sched_credit_set(xeninfo.getDomid(), weight, cap, max_boost_period, boost_ratio) def VM_set_VCPUs_number_live(self, _, vm_ref, num): dom = XendDomain.instance().get_vm_by_uuid(vm_ref) diff -r e0e26c5c0218 tools/python/xen/xend/XendConfig.py --- a/tools/python/xen/xend/XendConfig.py Mon Dec 08 09:46:24 2008 +0900 +++ b/tools/python/xen/xend/XendConfig.py Mon Dec 08 16:36:45 2008 +0900 @@ -585,6 +585,10 @@ class XendConfig(dict): int(sxp.child_value(sxp_cfg, "cpu_weight", 256)) cfg["vcpus_params"]["cap"] = \ int(sxp.child_value(sxp_cfg, "cpu_cap", 0)) + cfg["vcpus_params"]["max_boost_period"] = \ + int(sxp.child_value(sxp_cfg, "cpu_max_boost_period", 0)) + cfg["vcpus_params"]["boost_ratio"] = \ + int(sxp.child_value(sxp_cfg, "cpu_boost_ratio", 0)) # Only extract options we know about. extract_keys = LEGACY_UNSUPPORTED_BY_XENAPI_CFG + \ diff -r e0e26c5c0218 tools/python/xen/xend/XendDomain.py --- a/tools/python/xen/xend/XendDomain.py Mon Dec 08 09:46:24 2008 +0900 +++ b/tools/python/xen/xend/XendDomain.py Mon Dec 08 16:36:45 2008 +0900 @@ -1536,7 +1536,7 @@ class XendDomain: @param domid: Domain ID or Name @type domid: int or string. - @rtype: dict with keys 'weight' and 'cap' + @rtype: dict with keys 'weight' and 'cap' and 'max_boost_period' and 'boost_ratio' @return: credit scheduler parameters """ dominfo = self.domain_lookup_nr(domid) @@ -1549,20 +1549,26 @@ class XendDomain: except Exception, ex: raise XendError(str(ex)) else: - return {'weight' : dominfo.getWeight(), - 'cap' : dominfo.getCap()} + return {'weight' : dominfo.getWeight(), + 'cap' : dominfo.getCap(), + 'max_boost_period': dominfo.getMaxBoostPeriod(), + 'boost_ratio' : dominfo.getBoostRatio()} - def domain_sched_credit_set(self, domid, weight = None, cap = None): + def domain_sched_credit_set(self, domid, weight = None, cap = None, max_boost_period = None, boost_ratio = None): """Set credit scheduler parameters for a domain. @param domid: Domain ID or Name @type domid: int or string. @type weight: int @type cap: int + @type max_boost_period: int + @type boost_ratio: int @rtype: 0 """ set_weight = False set_cap = False + set_max_boost_period = False + set_boost_ratio = False dominfo = self.domain_lookup_nr(domid) if not dominfo: raise XendInvalidDomain(str(domid)) @@ -1581,17 +1587,37 @@ class XendDomain: else: set_cap = True + if max_boost_period is None: + max_boost_period = int(~0) + elif max_boost_period < 0: + raise XendError("max_boost_period is out of range") + else: + set_max_boost_period = True + + if boost_ratio is None: + boost_ratio = int(~0) + elif boost_ratio < 0: + raise XendError("boost_ratio is out of range") + else: + set_boost_ratio = True + assert type(weight) == int assert type(cap) == int + assert type(max_boost_period) == int + assert type(boost_ratio) == int rc = 0 if dominfo._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED): - rc = xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap) + rc = xc.sched_credit_domain_set(dominfo.getDomid(), weight, cap, max_boost_period, boost_ratio) if rc == 0: if set_weight: dominfo.setWeight(weight) if set_cap: dominfo.setCap(cap) + if set_max_boost_period: + dominfo.setMaxBoostPeriod(max_boost_period) + if set_boost_ratio: + dominfo.setBoostRatio(boost_ratio) self.managed_config_save(dominfo) return rc except Exception, ex: diff -r e0e26c5c0218 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Mon Dec 08 09:46:24 2008 +0900 +++ b/tools/python/xen/xend/XendDomainInfo.py Mon Dec 08 16:36:45 2008 +0900 @@ -465,7 +465,9 @@ class XendDomainInfo: if xennode.xenschedinfo() == 'credit': xendomains.domain_sched_credit_set(self.getDomid(), self.getWeight(), - self.getCap()) + self.getCap(), + self.getMaxBoostPeriod(), + self.getBoostRatio()) except: log.exception('VM start failed') self.destroy() @@ -1606,6 +1608,18 @@ class XendDomainInfo: def setWeight(self, cpu_weight): self.info['vcpus_params']['weight'] = cpu_weight + def getMaxBoostPeriod(self): + return self.info['vcpus_params']['max_boost_period'] + + def setMaxBoostPeriod(self, cpu_max_boost_period): + self.info['vcpus_params']['max_boost_period'] = cpu_max_boost_period + + def getBoostRatio(self): + return self.info['vcpus_params']['boost_ratio'] + + def setBoostRatio(self, cpu_boost_ratio): + self.info['vcpus_params']['boost_ratio'] = cpu_boost_ratio + def getRestartCount(self): return self._readVm('xend/restart_count') diff -r e0e26c5c0218 tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Mon Dec 08 09:46:24 2008 +0900 +++ b/tools/python/xen/xm/main.py Mon Dec 08 16:36:45 2008 +0900 @@ -150,7 +150,7 @@ SUBCOMMAND_HELP = { 'log' : ('', 'Print Xend log'), 'rename' : (' ', 'Rename a domain.'), 'sched-sedf' : (' [options]', 'Get/set EDF parameters.'), - 'sched-credit': ('[-d [-w[=WEIGHT]|-c[=CAP]]]', + 'sched-credit': ('[-d [-w[=WEIGHT]|-c[=CAP]|-m[=MAXBOOSTPERIOD]|-r[=BOOSTRATIO]]]', 'Get/set credit scheduler parameters.'), 'sysrq' : (' ', 'Send a sysrq to a domain.'), 'debug-keys' : ('', 'Send debug keys to Xen.'), @@ -240,6 +240,8 @@ SUBCOMMAND_OPTIONS = { ('-d DOMAIN', '--domain=DOMAIN', 'Domain to modify'), ('-w WEIGHT', '--weight=WEIGHT', 'Weight (int)'), ('-c CAP', '--cap=CAP', 'Cap (int)'), + ('-m MAXBOOSTPERIOD', '--maxboostperiod=MAXBOOSTPERIOD', 'Upper limit of boost period (ms)'), + ('-r BOOSTRATIO', '--ratio=BOOSTRATIO', 'Boost ratio per a cpu (int)'), ), 'list': ( ('-l', '--long', 'Output all VM details in SXP'), @@ -1578,8 +1580,8 @@ def xm_sched_credit(args): check_sched_type('credit') try: - opts, params = getopt.getopt(args, "d:w:c:", - ["domain=", "weight=", "cap="]) + opts, params = getopt.getopt(args, "d:w:c:m:r:", + ["domain=", "weight=", "cap=", "maxboostperiod=", "ratio="]) except getopt.GetoptError, opterr: err(opterr) usage('sched-credit') @@ -1587,6 +1589,8 @@ def xm_sched_credit(args): domid = None weight = None cap = None + max_boost_period = None + boost_ratio = None for o, a in opts: if o in ["-d", "--domain"]: @@ -1594,18 +1598,22 @@ def xm_sched_credit(args): elif o in ["-w", "--weight"]: weight = int(a) elif o in ["-c", "--cap"]: - cap = int(a); + cap = int(a) + elif o in ["-m", "--maxboostperiod"]: + max_boost_period = int(a) + elif o in ["-r", "--ratio"]: + boost_ratio = int(a); doms = filter(lambda x : domid_match(domid, x), [parse_doms_info(dom) for dom in getDomains(None, 'all')]) - if weight is None and cap is None: + if weight is None and cap is None and max_boost_period is None and boost_ratio is None: if domid is not None and doms == []: err("Domain '%s' does not exist." % domid) usage('sched-credit') # print header if we aren't setting any parameters - print '%-33s %4s %6s %4s' % ('Name','ID','Weight','Cap') + print '%-33s %4s %6s %4s %8s %5s' % ('Name','ID','Weight','Cap','Max(ms)','Ratio') for d in doms: try: @@ -1618,16 +1626,18 @@ def xm_sched_credit(args): except xmlrpclib.Fault: pass - if 'weight' not in info or 'cap' not in info: + if 'weight' not in info or 'cap' not in info or 'max_boost_period' not in info or 'boost_ratio' not in info: # domain does not support sched-credit? - info = {'weight': -1, 'cap': -1} + info = {'weight': -1, 'cap': -1, 'max_boost_period':-1, 'boost_ratio':-1} info['weight'] = int(info['weight']) info['cap'] = int(info['cap']) + info['max_boost_period'] = int(info['max_boost_period']) + info['boost_ratio'] = int(info['boost_ratio']) info['name'] = d['name'] info['domid'] = str(d['domid']) - print( ("%(name)-32s %(domid)5s %(weight)6d %(cap)4d") % info) + print( ("%(name)-32s %(domid)5s %(weight)6d %(cap)4d %(max_boost_period)8d %(boost_ratio)5d") % info) else: if domid is None: # place holder for system-wide scheduler parameters @@ -1644,6 +1654,14 @@ def xm_sched_credit(args): get_single_vm(domid), "cap", cap) + server.xenapi.VM.add_to_VCPUs_params_live( + get_single_vm(domid), + "max_boost_period", + max_boost_period) + server.xenapi.VM.add_to_VCPUs_params_live( + get_single_vm(domid), + "boost_ratio", + boost_ratio) else: server.xenapi.VM.add_to_VCPUs_params( get_single_vm(domid), @@ -1653,8 +1671,16 @@ def xm_sched_credit(args): get_single_vm(domid), "cap", cap) + server.xenapi.VM.add_to_VCPUs_params( + get_single_vm(domid), + "max_boost_period", + max_boost_period) + server.xenapi.VM.add_to_VCPUs_params( + get_single_vm(domid), + "boost_ratio", + boost_ratio) else: - result = server.xend.domain.sched_credit_set(domid, weight, cap) + result = server.xend.domain.sched_credit_set(domid, weight, cap, max_boost_period, boost_ratio) if result != 0: err(str(result))