ia64/xen-unstable

changeset 17706:2e6a51378451

xend: fix automatic vcpu NUMA placement

The automatic NUMA placement code (find_relaxed_node) in
XendDomainInfo.py contains several bugs:
1. The domain just created shall not be considered in the load
calculation.
2. Nodes with too less memory for the domain must be considered during
the load calculation phase and abandoned later, currently these nodes
win with a load of 0.
3. CPUs which are offline shall not be considered in load calculation.
4. (Integer-)Dividing the load value by the number of cores per node
may conceal subtle load differences resulting in a non-optimal node to
be chosen.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 22 15:11:06 2008 +0100 (2008-05-22)
parents 7325ea8445cb
children 90c37c32182c
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu May 22 15:09:49 2008 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu May 22 15:11:06 2008 +0100
     1.3 @@ -2091,28 +2091,28 @@ class XendDomainInfo:
     1.4                          xc.vcpu_setaffinity(self.domid, v, self.info['cpus'][v])
     1.5              else:
     1.6                  def find_relaxed_node(node_list):
     1.7 -                    import sys 
     1.8 +                    import sys
     1.9 +                    nr_nodes = info['nr_nodes']
    1.10                      if node_list is None:
    1.11 -                        node_list = range(0, info['nr_nodes'])
    1.12 +                        node_list = range(0, nr_nodes)
    1.13                      nodeload = [0]
    1.14 -                    nodeload = nodeload * info['nr_nodes']
    1.15 +                    nodeload = nodeload * nr_nodes
    1.16                      from xen.xend import XendDomain
    1.17                      doms = XendDomain.instance().list('all')
    1.18 -                    for dom in doms:
    1.19 +                    for dom in filter (lambda d: d.domid != self.domid, doms):
    1.20                          cpuinfo = dom.getVCPUInfo()
    1.21                          for vcpu in sxp.children(cpuinfo, 'vcpu'):
    1.22 -                            def vinfo(n, t):
    1.23 -                                return t(sxp.child_value(vcpu, n))
    1.24 -                            cpumap = vinfo('cpumap', list)
    1.25 -                            for i in node_list:
    1.26 +                            if sxp.child_value(vcpu, 'online') == 0: continue
    1.27 +                            cpumap = list(sxp.child_value(vcpu,'cpumap'))
    1.28 +                            for i in range(0, nr_nodes):
    1.29                                  node_cpumask = info['node_to_cpu'][i]
    1.30                                  for j in node_cpumask:
    1.31                                      if j in cpumap:
    1.32                                          nodeload[i] += 1
    1.33                                          break
    1.34 -                    for i in node_list:
    1.35 -                        if len(info['node_to_cpu'][i]) > 0:
    1.36 -                            nodeload[i] = int(nodeload[i] / len(info['node_to_cpu'][i]))
    1.37 +                    for i in range(0, nr_nodes):
    1.38 +                        if len(info['node_to_cpu'][i]) > 0 and i in node_list:
    1.39 +                            nodeload[i] = int(nodeload[i] * 16 / len(info['node_to_cpu'][i]))
    1.40                          else:
    1.41                              nodeload[i] = sys.maxint
    1.42                      index = nodeload.index( min(nodeload) )