WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xend: update cpu config option

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xend: update cpu config option
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Wed, 16 Nov 2005 15:42:06 -0600
Delivery-date: Wed, 16 Nov 2005 21:42:11 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
The 'cpu' option in domain config files will pin VCPU0 of a domain.
This is not as useful now that domains can have more than 1 vcpu.  This
patch changes 'cpu' to 'cpus' and takes a list of physical cpus the
domains' vcpus can use and will pin the vcpus upon domain creation.

cpus = [1]      # this starts all domain vcpus pinned to CPU1

The list is circular, so in a domain with the following config:

vcpus = 4
cpus  = [0,3,7]  # Use any of 0, 3, 7 for this domain.

would see vcpus 0-3 pinned to cpus 0,3,7,0 respectively.

Also, the pin operation is moved before the memory reservation as vcpu
to cpu mapping will be helpful for future NUMA work when trying to
allocate pages close to the physical cpus being used.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@xxxxxxxxxx


diffstat output:
 examples/xmexample.vmx            |    5 +++--
 examples/xmexample.vti            |    5 +++--
 examples/xmexample1               |    5 +++--
 examples/xmexample2               |    7 ++++---
 examples/xmexample3               |    7 ++++---
 python/xen/xend/XendDomainInfo.py |   18 ++++++++++++------
 python/xen/xm/create.py           |    8 ++++----
 7 files changed, 33 insertions(+), 22 deletions(-)

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
---
diff -r f970d1ad3234 tools/examples/xmexample.vmx
--- a/tools/examples/xmexample.vmx      Wed Nov 16 16:44:52 2005
+++ b/tools/examples/xmexample.vmx      Wed Nov 16 14:39:21 2005
@@ -30,8 +30,9 @@
 # the number of cpus guest platform has, default=1
 vcpus=1
 
-# Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
+# 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
 
 # Optionally define mac and/or bridge for the network interfaces.
 # Random MACs are assigned if not given.
diff -r f970d1ad3234 tools/examples/xmexample.vti
--- a/tools/examples/xmexample.vti      Wed Nov 16 16:44:52 2005
+++ b/tools/examples/xmexample.vti      Wed Nov 16 14:39:21 2005
@@ -23,8 +23,9 @@
 # A name for your domain. All domains must have different names.
 name = "ExampleVMXDomain"
 
-# Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
+# 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
 
 # Disable vif for now
 nics=0
diff -r f970d1ad3234 tools/examples/xmexample1
--- a/tools/examples/xmexample1 Wed Nov 16 16:44:52 2005
+++ b/tools/examples/xmexample1 Wed Nov 16 14:39:21 2005
@@ -22,8 +22,9 @@
 # A name for your domain. All domains must have different names.
 name = "ExampleDomain"
 
-# Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
+# 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
 
 # Number of Virtual CPUS to use, default is 1
 #vcpus = 1
diff -r f970d1ad3234 tools/examples/xmexample2
--- a/tools/examples/xmexample2 Wed Nov 16 16:44:52 2005
+++ b/tools/examples/xmexample2 Wed Nov 16 14:39:21 2005
@@ -51,9 +51,10 @@
 # so we use the vmid to create a name.
 name = "VM%d" % vmid
 
-# Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
-cpu = vmid  # set based on vmid (mod number of CPUs)
+# 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 = [vmid]   # set based on vmid (mod number of CPUs)
 
 # Number of Virtual CPUS to use, default is 1
 #vcpus = 1
diff -r f970d1ad3234 tools/examples/xmexample3
--- a/tools/examples/xmexample3 Wed Nov 16 16:44:52 2005
+++ b/tools/examples/xmexample3 Wed Nov 16 14:39:21 2005
@@ -51,9 +51,10 @@
 # so we use the vmid to create a name.
 name = "VM%d" % vmid
 
-# Which CPU to start domain on? 
-#cpu = -1   # leave to Xen to pick
-cpu = vmid  # set based on vmid (mod number of CPUs)
+# 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 = [vmid]   # set based on vmid (mod number of CPUs)
 
 #----------------------------------------------------------------------------
 # Define network interfaces.
diff -r f970d1ad3234 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Nov 16 16:44:52 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Nov 16 14:39:21 2005
@@ -258,7 +258,7 @@
     for e in ROUNDTRIPPING_CONFIG_ENTRIES:
         result[e[0]] = get_cfg(e[0], e[1])
 
-    result['cpu']       = get_cfg('cpu',       int)
+    result['cpus']      = get_cfg('cpus',      list)
     result['image']     = get_cfg('image')
 
     try:
@@ -435,7 +435,7 @@
             defaultInfo('on_poweroff',  lambda: "destroy")
             defaultInfo('on_reboot',    lambda: "restart")
             defaultInfo('on_crash',     lambda: "restart")
-            defaultInfo('cpu',          lambda: None)
+            defaultInfo('cpus',         lambda: [])
             defaultInfo('cpu_weight',   lambda: 1.0)
 
             # some domains don't have a config file (e.g. dom0 )
@@ -1056,13 +1056,19 @@
 
         xc.domain_setcpuweight(self.domid, 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
+        # distribution for NUMA systems.
+        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)] ) ]
+                xc.domain_pincpu(self.domid, v, cpu)
+
         m = self.image.getDomainMemory(self.info['memory'] * 1024)
         xc.domain_setmaxmem(self.domid, maxmem_kb = m)
         xc.domain_memory_increase_reservation(self.domid, m, 0, 0)
-
-        cpu = self.info['cpu']
-        if cpu is not None and cpu != -1:
-            xc.domain_pincpu(self.domid, 0, 1 << cpu)
 
         self.createChannels()
 
diff -r f970d1ad3234 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Wed Nov 16 16:44:52 2005
+++ b/tools/python/xen/xm/create.py     Wed Nov 16 14:39:21 2005
@@ -152,9 +152,9 @@
           fn=set_int, default=None,
           use="Maximum domain memory in MB.")
 
-gopts.var('cpu', val='CPU',
+gopts.var('cpus', val='CPUS',
           fn=set_int, default=None,
-          use="CPU to run the domain on.")
+          use="CPUS to run the domain on.")
 
 gopts.var('lapic', val='LAPIC',
           fn=set_int, default=0,
@@ -582,8 +582,8 @@
     map(add_conf, ['name', 'memory', 'ssidref', 'maxmem', 'restart',
                    'on_poweroff', 'on_reboot', 'on_crash'])
     
-    if vals.cpu is not None:
-        config.append(['cpu', vals.cpu])
+    if vals.cpus is not None:
+        config.append(['cpus', vals.cpus])
     if vals.cpu_weight is not None:
         config.append(['cpu_weight', vals.cpu_weight])
     if vals.blkif:

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>