All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow explicit NUMA placements of guests
@ 2008-03-14 14:34 Andre Przywara
  2008-03-16 14:09 ` John Levon
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Przywara @ 2008-03-14 14:34 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 881 bytes --]

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.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>

Regards,
Andre.

-- 
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

[-- Attachment #2: numa_explicit_placement.patch --]
[-- Type: text/plain, Size: 5529 bytes --]

# HG changeset patch
# User André Przywara <andre.przywara@amd.com>
# Date 1205504312 -3600
# Node ID 6ca722ad5208390ae9f671cac84238ed3ca42fdb
# Parent  f33328217eee1a66bf2a874ff1a42b62c21e42bc
allow explicit numa node placement of guests

diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py	Mon Mar 10 22:51:57 2008 +0000
+++ b/tools/python/xen/xend/XendConfig.py	Fri Mar 14 15:18:32 2008 +0100
@@ -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,
diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py	Mon Mar 10 22:51:57 2008 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Mar 14 15:18:32 2008 +0100
@@ -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)
 
diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py	Mon Mar 10 22:51:57 2008 +0000
+++ b/tools/python/xen/xm/create.py	Fri Mar 14 15:18:32 2008 +0100
@@ -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])

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Allow explicit NUMA placements of guests
  2008-03-14 14:34 [PATCH] Allow explicit NUMA placements of guests Andre Przywara
@ 2008-03-16 14:09 ` John Levon
  0 siblings, 0 replies; 2+ messages in thread
From: John Levon @ 2008-03-16 14:09 UTC (permalink / raw)
  To: Andre Przywara; +Cc: xen-devel

On Fri, Mar 14, 2008 at 03:34:11PM +0100, Andre Przywara wrote:

> diff -r f33328217eee -r 6ca722ad5208 tools/python/xen/xend/XendConfig.py
> --- a/tools/python/xen/xend/XendConfig.py	Mon Mar 10 22:51:57 2008 +0000
> +++ b/tools/python/xen/xend/XendConfig.py	Fri Mar 14 15:18:32 2008 +0100
> @@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-16 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-14 14:34 [PATCH] Allow explicit NUMA placements of guests Andre Przywara
2008-03-16 14:09 ` John Levon

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.