From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: [PATCH] Allow explicit NUMA placements of guests Date: Fri, 14 Mar 2008 15:34:11 +0100 Message-ID: <47DA8CE3.2030606@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050203010800080700050803" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------050203010800080700050803 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 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 --------------050203010800080700050803 Content-Type: text/plain; name="numa_explicit_placement.patch" Content-Disposition: inline; filename="numa_explicit_placement.patch" Content-Transfer-Encoding: quoted-printable # HG changeset patch # User Andr=E9 Przywara # 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 =3D { '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 +0= 000 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Mar 14 15:18:32 2008 +0= 100 @@ -1969,34 +1969,38 @@ class XendDomainInfo: else: info =3D xc.physinfo() if info['nr_nodes'] > 1: + candidate_node_list =3D [] + 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 =3D info['node_to_memory'] needmem =3D self.image.getRequiredAvailableMemory(se= lf.info['memory_dynamic_max']) / 1024 - candidate_node_list =3D [] - for i in range(0, info['nr_nodes']): - if node_memory_list[i] >=3D needmem: - candidate_node_list.append(i) - if candidate_node_list is None or len(candidate_node= _list) =3D=3D 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) =3D=3D 0: index =3D node_memory_list.index( max(node_memor= y_list) ) - cpumask =3D info['node_to_cpu'][index] + elif len(candidate_node_list) =3D=3D 1: + index =3D candidate_node_list[0] else: - nodeload =3D [0] - nodeload =3D nodeload * info['nr_nodes'] + nodeload =3D [0] * info['nr_nodes'] from xen.xend import XendDomain doms =3D XendDomain.instance().list('all') for dom in doms: cpuinfo =3D dom.getVCPUInfo() for vcpu in sxp.children(cpuinfo, 'vcpu'): - def vinfo(n, t): - return t(sxp.child_value(vcpu, n)) - cpumap =3D vinfo('cpumap', list) + cpumap =3D list(sxp.child_value(vcpu, 'c= pumap')) for i in candidate_node_list: - node_cpumask =3D info['node_to_cpu']= [i] - for j in node_cpumask: + for j in info['node_to_cpu'][candida= te_node_list[i]]: if j in cpumap: nodeload[i] +=3D 1 break - index =3D nodeload.index( min(nodeload) ) - cpumask =3D info['node_to_cpu'][index] + index =3D candidate_node_list[nodeload.index( mi= n(nodeload) )] + cpumask =3D info['node_to_cpu'][index] for v in range(0, self.info['VCPUs_max']): xc.vcpu_setaffinity(self.domid, v, cpumask) =20 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=3D'CPUS', gopts.var('cpus', val=3D'CPUS', fn=3Dset_value, default=3DNone, use=3D"CPUS to run the domain on.") + +gopts.var('numanodes', val=3D'NUMANODES', + fn=3Dset_value, default=3D[], + use=3D"NUMA nodes to run the domain on.") =20 gopts.var('rtc_timeoffset', val=3D'RTC_TIMEOFFSET', fn=3Dset_value, default=3D"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', 'feat= ures', - 'on_xend_start', 'on_xend_stop', 'target']) + 'on_xend_start', 'on_xend_stop', 'target', 'numanodes= ']) =20 if vals.uuid is not None: config.append(['uuid', vals.uuid]) --------------050203010800080700050803 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------050203010800080700050803--