From: Ryan Harper <ryanh@us.ibm.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH 2/3] xend: Add multiple cpumasks support
Date: Mon, 14 Aug 2006 11:57:01 -0500 [thread overview]
Message-ID: <20060814165701.GL1694@us.ibm.com> (raw)
This patch modifies xend to accept and parse multiple cpumask strings
from the cpus parameter. The cpus string stays the same, but it now
can parse either a python list of strings:
[ '2-5, '2-5', '2-5' ]
A regular string with ", " as the separator:
"2-5, 2-5, 2-5, 2-5"
or a mixture of both:
[ 2-5, '2-5', 2-5, '2-5' ]
all result in the same list of integers which is used to create the
cpumask for each vcpu in the domain.
Without this patch the cpus parameter only enables one bit of the
cpumask preventing the credit scheduler from balancing.
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253 T/L: 678-9253
ryanh@us.ibm.com
diffstat output:
examples/xmexample.hvm | 3 +
examples/xmexample.vti | 1
examples/xmexample1 | 3 +
examples/xmexample2 | 3 +
examples/xmexample3 | 3 +
python/xen/xend/XendDomainInfo.py | 66 +++++++++++++++++++++++++-------------
6 files changed, 53 insertions(+), 26 deletions(-)
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
---
diff -r e6de470f9287 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Sat Aug 12 08:22:45 2006 -0500
+++ b/tools/python/xen/xend/XendDomainInfo.py Sat Aug 12 08:22:47 2006 -0500
@@ -328,27 +328,49 @@ 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("'")))
+
+ # if user didn't use list bracket, convert to to list of strings
+ # 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'] = map(lambda x: x.strip(", "), 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(
@@ -1275,8 +1297,8 @@ class XendDomainInfo:
cpus = self.info['cpus']
if cpus is not None and len(cpus) > 0:
for v in range(0, self.info['max_vcpu_id']+1):
- # pincpu takes a list of ints
- cpu = [ int( cpus[v % len(cpus)] ) ]
+ # pincpu takes a list of ints,
+ cpu = map(lambda x: int(x), cpus[v % len(cpus)])
xc.vcpu_setaffinity(self.domid, v, cpu)
# set domain maxmem in KiB
diff -r e6de470f9287 tools/examples/xmexample.hvm
--- a/tools/examples/xmexample.hvm Sat Aug 12 08:22:45 2006 -0500
+++ b/tools/examples/xmexample.hvm Sat Aug 12 08:34:13 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
+# 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 = "0-1, 2-3" # run 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 e6de470f9287 tools/examples/xmexample.vti
--- a/tools/examples/xmexample.vti Sat Aug 12 08:22:45 2006 -0500
+++ b/tools/examples/xmexample.vti Sat Aug 12 08:39:42 2006 -0500
@@ -34,6 +34,7 @@ name = "ExampleVTIDomain"
#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 = "0-1, 2-3" # run 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 e6de470f9287 tools/examples/xmexample1
--- a/tools/examples/xmexample1 Sat Aug 12 08:22:45 2006 -0500
+++ b/tools/examples/xmexample1 Sat Aug 12 08:27:02 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
+# 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 = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
# Number of Virtual CPUS to use, default is 1
#vcpus = 1
diff -r e6de470f9287 tools/examples/xmexample2
--- a/tools/examples/xmexample2 Sat Aug 12 08:22:45 2006 -0500
+++ b/tools/examples/xmexample2 Sat Aug 12 08:27:47 2006 -0500
@@ -59,10 +59,11 @@ 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 = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
#cpus = "%s" % vmid # set based on vmid (mod number of CPUs)
# Number of Virtual CPUS to use, default is 1
diff -r e6de470f9287 tools/examples/xmexample3
--- a/tools/examples/xmexample3 Sat Aug 12 08:22:45 2006 -0500
+++ b/tools/examples/xmexample3 Sat Aug 12 08:33:35 2006 -0500
@@ -59,10 +59,11 @@ 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 = "0-1, 2-3" # run VCPU0 on CPU0-1, VCPU1 on CPU2-3
cpus = "%s" % vmid # set based on vmid (mod number of CPUs)
#----------------------------------------------------------------------------
next reply other threads:[~2006-08-14 16:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-14 16:57 Ryan Harper [this message]
2006-08-14 17:37 ` [PATCH 2/3] xend: Add multiple cpumasks support Keir Fraser
2006-08-14 17:48 ` Ryan Harper
2006-08-14 17:55 ` Keir Fraser
-- strict thread matches above, loose matches on Subject: below --
2006-08-14 18:10 Ian Pratt
2006-08-14 18:47 ` Ryan Harper
2006-08-15 8:44 ` Keir Fraser
2006-08-15 23:01 ` Ryan Harper
2006-08-14 18:55 Ian Pratt
2006-08-14 19:08 ` Ryan Harper
2006-08-14 20:15 ` Ryan Harper
2006-08-14 22:03 Ian Pratt
2006-08-14 22:20 ` Ryan Harper
2006-08-15 9:07 ` Keir Fraser
2006-08-15 22:58 ` Ryan Harper
2006-08-14 22:40 Ian Pratt
2006-08-14 22:46 ` Ryan Harper
2006-08-16 23:34 ` Ryan Grimm
2006-08-15 23:26 Ian Pratt
2006-08-16 11:15 ` Subrahmanian, Raj
2006-08-17 2:01 Ian Pratt
2006-08-17 15:27 ` Ryan Grimm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060814165701.GL1694@us.ibm.com \
--to=ryanh@us.ibm.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.