# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1205922017 0
# Node ID 258c528c874f820a75abe932004433cbde0d3b3b
# Parent c69524c462ff8a8f7f44957d9012e28159b14d55
xend: Fix and improve default NUMA node selection.
Add the missing condition check and use average value instead of the
sum value of Vcpus pinning cpus on certain node to choose relaxed node.
Signed-off-by: Duan Ronghui <ronghui.duan@xxxxxxxxx>
---
tools/python/xen/xend/XendDomainInfo.py | 54 ++++++++++++++++++--------------
1 files changed, 31 insertions(+), 23 deletions(-)
diff -r c69524c462ff -r 258c528c874f tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Wed Mar 19 10:18:36 2008 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py Wed Mar 19 10:20:17 2008 +0000
@@ -2062,36 +2062,44 @@ class XendDomainInfo:
for v in range(0, self.info['VCPUs_max']):
xc.vcpu_setaffinity(self.domid, v, self.info['cpus'])
else:
+ def find_relaxed_node(node_list):
+ import sys
+ if node_list is None:
+ node_list = range(0, info['nr_nodes'])
+ nodeload = [0]
+ nodeload = nodeload * 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)
+ for i in node_list:
+ node_cpumask = info['node_to_cpu'][i]
+ for j in node_cpumask:
+ if j in cpumap:
+ nodeload[i] += 1
+ break
+ for i in node_list:
+ if len(info['node_to_cpu'][i]) > 0:
+ nodeload[i] = int(nodeload[i] /
len(info['node_to_cpu'][i]))
+ else:
+ nodeload[i] = sys.maxint
+ index = nodeload.index( min(nodeload) )
+ return index
+
info = xc.physinfo()
if info['nr_nodes'] > 1:
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:
+ if node_memory_list[i] >= needmem and
len(info['node_to_cpu'][i]) > 0:
candidate_node_list.append(i)
- if candidate_node_list is None or len(candidate_node_list)
== 1:
- index = node_memory_list.index( max(node_memory_list) )
- cpumask = info['node_to_cpu'][index]
- else:
- nodeload = [0]
- nodeload = nodeload * 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)
- for i in candidate_node_list:
- node_cpumask = info['node_to_cpu'][i]
- for j in node_cpumask:
- if j in cpumap:
- nodeload[i] += 1
- break
- index = nodeload.index( min(nodeload) )
- cpumask = info['node_to_cpu'][index]
+ index = find_relaxed_node(candidate_node_list)
+ cpumask = info['node_to_cpu'][index]
for v in range(0, self.info['VCPUs_max']):
xc.vcpu_setaffinity(self.domid, v, cpumask)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|