ia64/xen-unstable

changeset 17138:b58180cf8ab8

xend: Set default vcpu affinity for better performance in NUMA systems.
Signed-off-by: Duan Ronghui <ronghui.duan@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 27 13:17:49 2008 +0000 (2008-02-27)
parents 2b940e46857c
children bfd87849ccda
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Feb 27 13:16:02 2008 +0000
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Feb 27 13:17:49 2008 +0000
     1.3 @@ -1963,6 +1963,39 @@ class XendDomainInfo:
     1.4              if self.info['cpus'] is not None and len(self.info['cpus']) > 0:
     1.5                  for v in range(0, self.info['VCPUs_max']):
     1.6                      xc.vcpu_setaffinity(self.domid, v, self.info['cpus'])
     1.7 +            else:
     1.8 +                info = xc.physinfo()
     1.9 +                if info['nr_nodes'] > 1:
    1.10 +                    node_memory_list = info['node_to_memory']
    1.11 +                    needmem = self.image.getRequiredAvailableMemory(self.info['memory_dynamic_max']) / 1024
    1.12 +                    candidate_node_list = []
    1.13 +                    for i in range(0, info['nr_nodes']):
    1.14 +                        if node_memory_list[i] >= needmem:
    1.15 +                            candidate_node_list.append(i)
    1.16 +                    if candidate_node_list is None or len(candidate_node_list) == 1:
    1.17 +                        index = node_memory_list.index( max(node_memory_list) )
    1.18 +                        cpumask = info['node_to_cpu'][index]
    1.19 +                    else:
    1.20 +                        nodeload = [0]
    1.21 +                        nodeload = nodeload * info['nr_nodes']
    1.22 +                        from xen.xend import XendDomain
    1.23 +                        doms = XendDomain.instance().list('all')
    1.24 +                        for dom in doms:
    1.25 +                            cpuinfo = dom.getVCPUInfo()
    1.26 +                            for vcpu in sxp.children(cpuinfo, 'vcpu'):
    1.27 +                                def vinfo(n, t):
    1.28 +                                    return t(sxp.child_value(vcpu, n))
    1.29 +                                cpumap = vinfo('cpumap', list)
    1.30 +                                for i in candidate_node_list:
    1.31 +                                    node_cpumask = info['node_to_cpu'][i]
    1.32 +                                    for j in node_cpumask:
    1.33 +                                        if j in cpumap:
    1.34 +                                            nodeload[i] += 1
    1.35 +                                            break
    1.36 +                        index = nodeload.index( min(nodeload) )
    1.37 +                        cpumask = info['node_to_cpu'][index]
    1.38 +                    for v in range(0, self.info['VCPUs_max']):
    1.39 +                        xc.vcpu_setaffinity(self.domid, v, cpumask)
    1.40  
    1.41              # Use architecture- and image-specific calculations to determine
    1.42              # the various headrooms necessary, given the raw configured