Skip to contentSkip to conversation

Allow explicit NUMA placements of guests

PATCH In review Andre Przywara 2 participants 2 messages Mar 14, 2008 – Mar 16, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow explicit NUMA placements of guests

Hi,

this patch introduces a new config file option (numanodes=[x]) to specify a list of valid NUMA nodes for guests. This will extend (but not replace) the recently introduced automatic placement. If several nodes are given, the current algorithm will choose one of them. If none of the given nodes has enough memory, this will fall back to the automatic placement.

Regards,
Andre.

Signature · 9 lines
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 277-84917
----to satisfy European Law for business letters:
AMD Saxony Limited Liability Company & Co. KG,
Wilschdorfer Landstr. 101, 01109 Dresden, Germany
Register Court Dresden: HRA 4896, General Partner authorized
to represent: AMD Saxony LLC (Wilmington, Delaware, US)
General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy

# HG changeset patch
# User Andr� Przywara <[email protected]> # Date 1205504312 -3600
# Node ID 6ca722ad5208390ae9f671cac84238ed3ca42fdb # Parent f33328217eee1a66bf2a874ff1a42b62c21e42bc allow explicit numa node placement of guests

tools/python/xen/xend/XendConfig.py +2 -0
diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xend/XendConfig.py
@@ -152,6 +152,7 @@ XENAPI_CFG_TYPES = {
     'memory_dynamic_min': int,
     'memory_dynamic_max': int,
     'cpus': list,
+    'numanodes': list,
     'vcpus_params': dict,
     'VCPUs_max': int,
     'VCPUs_at_startup': int,
@@ -329,6 +330,7 @@ class XendConfig(dict):
             'on_xend_start': 'ignore',
             'on_xend_stop': 'ignore',
             'cpus': [],
+            'numanodes': None,
             'VCPUs_max': 1,
             'VCPUs_live': 1,
             'VCPUs_at_startup': 1,
tools/python/xen/xend/XendDomainInfo.py +19 -15
diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xend/XendDomainInfo.py
@@ -1969,34 +1969,38 @@ class XendDomainInfo:
             else:
                 info = xc.physinfo()
                 if info['nr_nodes'] > 1:
+                    candidate_node_list = []
+                    if self.info['numanodes'] is None:
+                        for i in range (0, info['nr_nodes']):
+                            candidate_node_list.append(i)
+                    else:
+                        for node in self.info['numanodes']:
+                            if node < info['nr_nodes']:
+                                candidate_node_list.append (node)
                     node_memory_list = info['node_to_memory']
                     needmem = self.image.getRequiredAvailableMemory(self.info['memory_dynamic_max']) / 1024
-                    candidate_node_list = []
-                    for i in range(0, info['nr_nodes']):
-                        if node_memory_list[i] >= needmem:
-                            candidate_node_list.append(i)
-                    if candidate_node_list is None or len(candidate_node_list) == 1:
+                    for i in candidate_node_list:
+                        if node_memory_list[i] < needmem:
+                            candidate_node_list.remove (i)
+                    if candidate_node_list is None or len(candidate_node_list) == 0:
                         index = node_memory_list.index( max(node_memory_list) )
-                        cpumask = info['node_to_cpu'][index]
+                    elif len(candidate_node_list) == 1:
+                        index = candidate_node_list[0]
                     else:
-                        nodeload = [0]
-                        nodeload = nodeload * info['nr_nodes']
+                        nodeload = [0] * info['nr_nodes']
                         from xen.xend import XendDomain
                         doms = XendDomain.instance().list('all')
                         for dom in doms:
                             cpuinfo = dom.getVCPUInfo()
                             for vcpu in sxp.children(cpuinfo, 'vcpu'):
-                                def vinfo(n, t):
-                                    return t(sxp.child_value(vcpu, n))
-                                cpumap = vinfo('cpumap', list)
+                                cpumap = list(sxp.child_value(vcpu, 'cpumap'))
                                 for i in candidate_node_list:
-                                    node_cpumask = info['node_to_cpu'][i]
-                                    for j in node_cpumask:
+                                    for j in info['node_to_cpu'][candidate_node_list[i]]:
                                         if j in cpumap:
                                             nodeload[i] += 1
                                             break
-                        index = nodeload.index( min(nodeload) )
-                        cpumask = info['node_to_cpu'][index]
+                        index = candidate_node_list[nodeload.index( min(nodeload) )]
+                    cpumask = info['node_to_cpu'][index]
                     for v in range(0, self.info['VCPUs_max']):
                         xc.vcpu_setaffinity(self.domid, v, cpumask)
 
tools/python/xen/xm/create.py +5 -1
diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xm/create.py
@@ -189,6 +189,10 @@ gopts.var('cpus', val='CPUS',
 gopts.var('cpus', val='CPUS',
           fn=set_value, default=None,
           use="CPUS to run the domain on.")
+
+gopts.var('numanodes', val='NUMANODES',
+          fn=set_value, default=[],
+          use="NUMA nodes to run the domain on.")
 
 gopts.var('rtc_timeoffset', val='RTC_TIMEOFFSET',
           fn=set_value, default="0",
@@ -769,7 +773,7 @@ def make_config(vals):
     map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory',
                    'restart', 'on_poweroff',
                    'on_reboot', 'on_crash', 'vcpus', 'vcpu_avail', 'features',
-                   'on_xend_start', 'on_xend_stop', 'target'])
+                   'on_xend_start', 'on_xend_stop', 'target', 'numanodes'])
 
     if vals.uuid is not None:
         config.append(['uuid', vals.uuid])

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

#1 lore raw

tools/python/xen/xend/XendConfig.py XENAPI_CFG_TYPES = { · line 155

Quoted 8 lines · Andre Przywara

diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xend/XendConfig.py

tools/python/xen/xend/XendConfig.py +1 -0
@@ -152,6 +152,7 @@ XENAPI_CFG_TYPES = {
     'memory_dynamic_min': int,
     'memory_dynamic_max': int,
     'cpus': list,
+    'numanodes': list,

You need to update the API document and the changelog if you're extending it...

regards
john