ia64/xen-unstable

changeset 17263:258c528c874f

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@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 19 10:20:17 2008 +0000 (2008-03-19)
parents c69524c462ff
children b8e3dbca1677
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Mar 19 10:18:36 2008 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Mar 19 10:20:17 2008 +0000
     1.3 @@ -2062,36 +2062,44 @@ class XendDomainInfo:
     1.4                  for v in range(0, self.info['VCPUs_max']):
     1.5                      xc.vcpu_setaffinity(self.domid, v, self.info['cpus'])
     1.6              else:
     1.7 +                def find_relaxed_node(node_list):
     1.8 +                    import sys 
     1.9 +                    if node_list is None:
    1.10 +                        node_list = range(0, info['nr_nodes'])
    1.11 +                    nodeload = [0]
    1.12 +                    nodeload = nodeload * info['nr_nodes']
    1.13 +                    from xen.xend import XendDomain
    1.14 +                    doms = XendDomain.instance().list('all')
    1.15 +                    for dom in doms:
    1.16 +                        cpuinfo = dom.getVCPUInfo()
    1.17 +                        for vcpu in sxp.children(cpuinfo, 'vcpu'):
    1.18 +                            def vinfo(n, t):
    1.19 +                                return t(sxp.child_value(vcpu, n))
    1.20 +                            cpumap = vinfo('cpumap', list)
    1.21 +                            for i in node_list:
    1.22 +                                node_cpumask = info['node_to_cpu'][i]
    1.23 +                                for j in node_cpumask:
    1.24 +                                    if j in cpumap:
    1.25 +                                        nodeload[i] += 1
    1.26 +                                        break
    1.27 +                    for i in node_list:
    1.28 +                        if len(info['node_to_cpu'][i]) > 0:
    1.29 +                            nodeload[i] = int(nodeload[i] / len(info['node_to_cpu'][i]))
    1.30 +                        else:
    1.31 +                            nodeload[i] = sys.maxint
    1.32 +                    index = nodeload.index( min(nodeload) )    
    1.33 +                    return index
    1.34 +
    1.35                  info = xc.physinfo()
    1.36                  if info['nr_nodes'] > 1:
    1.37                      node_memory_list = info['node_to_memory']
    1.38                      needmem = self.image.getRequiredAvailableMemory(self.info['memory_dynamic_max']) / 1024
    1.39                      candidate_node_list = []
    1.40                      for i in range(0, info['nr_nodes']):
    1.41 -                        if node_memory_list[i] >= needmem:
    1.42 +                        if node_memory_list[i] >= needmem and len(info['node_to_cpu'][i]) > 0:
    1.43                              candidate_node_list.append(i)
    1.44 -                    if candidate_node_list is None or len(candidate_node_list) == 1:
    1.45 -                        index = node_memory_list.index( max(node_memory_list) )
    1.46 -                        cpumask = info['node_to_cpu'][index]
    1.47 -                    else:
    1.48 -                        nodeload = [0]
    1.49 -                        nodeload = nodeload * info['nr_nodes']
    1.50 -                        from xen.xend import XendDomain
    1.51 -                        doms = XendDomain.instance().list('all')
    1.52 -                        for dom in doms:
    1.53 -                            cpuinfo = dom.getVCPUInfo()
    1.54 -                            for vcpu in sxp.children(cpuinfo, 'vcpu'):
    1.55 -                                def vinfo(n, t):
    1.56 -                                    return t(sxp.child_value(vcpu, n))
    1.57 -                                cpumap = vinfo('cpumap', list)
    1.58 -                                for i in candidate_node_list:
    1.59 -                                    node_cpumask = info['node_to_cpu'][i]
    1.60 -                                    for j in node_cpumask:
    1.61 -                                        if j in cpumap:
    1.62 -                                            nodeload[i] += 1
    1.63 -                                            break
    1.64 -                        index = nodeload.index( min(nodeload) )
    1.65 -                        cpumask = info['node_to_cpu'][index]
    1.66 +                    index = find_relaxed_node(candidate_node_list)
    1.67 +                    cpumask = info['node_to_cpu'][index]
    1.68                      for v in range(0, self.info['VCPUs_max']):
    1.69                          xc.vcpu_setaffinity(self.domid, v, cpumask)
    1.70