[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2 of 5] Add support for specifying multi cpumasks in cpus parameter
6 files changed, 74 insertions(+), 40 deletions(-) tools/examples/xmexample.hvm | 9 ++-- tools/examples/xmexample.vti | 9 ++-- tools/examples/xmexample1 | 9 ++-- tools/examples/xmexample2 | 11 ++++- tools/examples/xmexample3 | 12 +++-- tools/python/xen/xend/XendDomainInfo.py | 64 ++++++++++++++++++++----------- # HG changeset patch # User Ryan Harper <ryanh@xxxxxxxxxx> # Date 1155579390 18000 # Node ID 7281c7aa89220b5bb20c9275a65dee37be6da298 # Parent 889b941effc8d050057a7edf3575067014e36d18 Add support for specifying multi cpumasks in cpus parameter diff -r 889b941effc8 -r 7281c7aa8922 tools/examples/xmexample.hvm --- a/tools/examples/xmexample.hvm Mon Aug 14 13:15:55 2006 -0500 +++ b/tools/examples/xmexample.hvm Mon Aug 14 13:16:30 2006 -0500 @@ -47,10 +47,11 @@ name = "ExampleHVMDomain" # enable/disable HVM guest APIC, default=0 (disabled) #apic=0 -# List of which CPUS this domain is allowed to use, default Xen picks -#cpus = "" # leave to Xen to pick -#cpus = "0" # all vcpus run on CPU0 -#cpus = "0-3,5,^1" # run on cpus 0,2,3,5 +# Specify which CPUS the domains' vcpus can use +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = [ "0-1", "2-3" ] # VCPU0 on CPU0-1, VCPU1 on CPU2-3 # Optionally define mac and/or bridge for the network interfaces. # Random MACs are assigned if not given. diff -r 889b941effc8 -r 7281c7aa8922 tools/examples/xmexample.vti --- a/tools/examples/xmexample.vti Mon Aug 14 13:15:55 2006 -0500 +++ b/tools/examples/xmexample.vti Mon Aug 14 13:16:30 2006 -0500 @@ -30,10 +30,11 @@ name = "ExampleVTIDomain" # the number of cpus guest platform has, default=1 #vcpus=1 -# List of which CPUS this domain is allowed to use, default Xen picks -#cpus = "" # leave to Xen to pick -#cpus = "0" # all vcpus run on CPU0 -#cpus = "0-3,5,^1" # run on cpus 0,2,3,5 +# Specify which CPUS the domains' vcpus can use +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = [ "0-1", "2-3" ] # VCPU0 on CPU0-1, VCPU1 on CPU2-3 # Optionally define mac and/or bridge for the network interfaces. # Random MACs are assigned if not given. diff -r 889b941effc8 -r 7281c7aa8922 tools/examples/xmexample1 --- a/tools/examples/xmexample1 Mon Aug 14 13:15:55 2006 -0500 +++ b/tools/examples/xmexample1 Mon Aug 14 13:16:30 2006 -0500 @@ -30,10 +30,11 @@ name = "ExampleDomain" # on each call to 'xm create'. #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" -# List of which CPUS this domain is allowed to use, default Xen picks -#cpus = "" # leave to Xen to pick -#cpus = "0" # all vcpus run on CPU0 -#cpus = "0-3,5,^1" # run on cpus 0,2,3,5 +# Specify which CPUS the domains' vcpus can use +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = [ "0-1", "2-3" ] # VCPU0 on CPU0-1, VCPU1 on CPU2-3 # Number of Virtual CPUS to use, default is 1 #vcpus = 1 diff -r 889b941effc8 -r 7281c7aa8922 tools/examples/xmexample2 --- a/tools/examples/xmexample2 Mon Aug 14 13:15:55 2006 -0500 +++ b/tools/examples/xmexample2 Mon Aug 14 13:16:30 2006 -0500 @@ -59,11 +59,18 @@ name = "VM%d" % vmid # on each call to 'xm create'. #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" -# List of which CPUS this domain is allowed to use, default Xen picks +# List of which CPUS vcpus are allowed to use, default Xen picks #cpus = "" # leave to Xen to pick #cpus = "0" # all vcpus run on CPU0 #cpus = "0-3,5,^1" # run on cpus 0,2,3,5 -#cpus = "%s" % vmid # set based on vmid (mod number of CPUs) +#cpus = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3 + +# Specify which CPUS the domains' vcpus can use +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = [ "0-1", "2-3" ] # VCPU0 on CPU0-1, VCPU1 on CPU2-3 +#cpus = "%s" % vmid # all vcpus run on CPU(vmid) (mod number of CPUs) # Number of Virtual CPUS to use, default is 1 #vcpus = 1 diff -r 889b941effc8 -r 7281c7aa8922 tools/examples/xmexample3 --- a/tools/examples/xmexample3 Mon Aug 14 13:15:55 2006 -0500 +++ b/tools/examples/xmexample3 Mon Aug 14 13:16:30 2006 -0500 @@ -59,11 +59,13 @@ name = "VM%d" % vmid # on each call to 'xm create'. #uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" -# List of which CPUS this domain is allowed to use, default Xen picks -#cpus = "" # leave to Xen to pick -#cpus = "0" # all vcpus run on CPU0 -#cpus = "0-3,5,^1" # run on cpus 0,2,3,5 -cpus = "%s" % vmid # set based on vmid (mod number of CPUs) +# Specify which CPUS the domains' vcpus can use +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = [ "0-1", "2-3" ] # VCPU0 on CPU0-1, VCPU1 on CPU2-3 +cpus = "%s" % vmid # all vcpus run on CPU(vmid) (mod number of CPUs) + #---------------------------------------------------------------------------- # Define network interfaces. diff -r 889b941effc8 -r 7281c7aa8922 tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Mon Aug 14 13:15:55 2006 -0500 +++ b/tools/python/xen/xend/XendDomainInfo.py Mon Aug 14 13:16:30 2006 -0500 @@ -328,27 +328,47 @@ def parseConfig(config): else: result['cpus'] = str(result['cpu']) - # convert 'cpus' string to list of ints - # 'cpus' supports a list of ranges (0-3), seperated by - # commas, and negation, (^1). - # Precedence is settled by order of the string: - # "0-3,^1" -> [0,2,3] - # "0-3,^1,1" -> [0,1,2,3] - if result['cpus']: - cpus = [] - for c in result['cpus'].split(','): - if c.find('-') != -1: - (x,y) = c.split('-') - for i in range(int(x),int(y)+1): - cpus.append(int(i)) - else: - # remove this element from the list - if c[0] == '^': - cpus = [x for x in cpus if x != int(c[1:])] + if result['cpus'] is not None: + # see if cpus string specifies multiple cpumasks, or just one + # e.g: "[ '2-5', '0-1', '0-3,^1', '5' ]" vs. "0-3,5" + if result['cpus'].startswith("["): + # the below was tested with the following sample string + # "[4, '2-5','2-5', '1-3,6,^2', '2-6','1' 1-7,^2 ]" and resulted in + # ['4', '2-5', '2-5', '1-3,6,^2', '2-6', '1'] + result['cpus'] = filter(lambda x: len(x), map(lambda x: x.strip(", "), + result['cpus'].replace('[',"").replace(']',"").split("'"))) + + # convert non list-base value into list of cpumasks + # cpus = "4|2-5,^4|1-3,5,^2|1|^2" -> + # ['4', '2-5,^4', '1-3,5,^2', '1', '^2'] + # also takes care of cpus = "4" + else: + result['cpus'] = result['cpus'].split("|") + + # convert 'cpus' list of strings into a list of list of ints + # 'cpus' supports a list of ranges (0-3), seperated by + # commas, and negation, (^1). + # Precedence is settled by order of the string: + # "0-3,^1" -> [0,2,3] + # "0-3,^1,1" -> [0,1,2,3] + new_cpus = [] + for x in result['cpus']: + cpus = [] + for c in x.split(','): + if c.find('-') != -1: + (x,y) = c.split('-') + for i in range(int(x),int(y)+1): + cpus.append(int(i)) else: - cpus.append(int(c)) - - result['cpus'] = cpus + # remove this element from the list + if c[0] == '^': + cpus = [x for x in cpus if x != int(c[1:])] + else: + cpus.append(int(c)) + + new_cpus.append(cpus) + + result['cpus'] = new_cpus except ValueError, exn: raise VmError( @@ -1274,7 +1294,9 @@ class XendDomainInfo: # distribution for NUMA systems. if self.info['cpus'] is not None and len(self.info['cpus']) > 0: for v in range(0, self.info['max_vcpu_id']+1): - xc.vcpu_setaffinity(self.domid, v, self.info['cpus']) + # map each vcpu to a cpumask in the list + cpumask = self.info['cpus'][v % len(self.info['cpus'])] + xc.vcpu_setaffinity(self.domid, v, cpumask) # set domain maxmem in KiB xc.domain_setmaxmem(self.domid, self.info['maxmem'] * 1024) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |