ia64/xen-unstable

changeset 9019:e92dd21483bd

Fix up CPU allocation and topology reporting.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Feb 24 19:16:52 2006 +0100 (2006-02-24)
parents 3048761dc368
children 8b42c8aea36a
files xen/arch/x86/dom0_ops.c xen/arch/x86/setup.c xen/common/dom0_ops.c
line diff
     1.1 --- a/xen/arch/x86/dom0_ops.c	Fri Feb 24 19:16:15 2006 +0100
     1.2 +++ b/xen/arch/x86/dom0_ops.c	Fri Feb 24 19:16:52 2006 +0100
     1.3 @@ -181,10 +181,13 @@ long arch_do_dom0_op(struct dom0_op *op,
     1.4      {
     1.5          dom0_physinfo_t *pi = &op->u.physinfo;
     1.6  
     1.7 -        pi->threads_per_core = smp_num_siblings;
     1.8 -        pi->cores_per_socket = boot_cpu_data.x86_max_cores;
     1.9 +        pi->threads_per_core =
    1.10 +            cpus_weight(cpu_sibling_map[0]);
    1.11 +        pi->cores_per_socket =
    1.12 +            cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
    1.13          pi->sockets_per_node = 
    1.14 -            num_online_cpus() / (pi->threads_per_core * pi->cores_per_socket);
    1.15 +            num_online_cpus() / cpus_weight(cpu_core_map[0]);
    1.16 +
    1.17          pi->nr_nodes         = 1;
    1.18          pi->total_pages      = total_pages;
    1.19          pi->free_pages       = avail_domheap_pages();
     2.1 --- a/xen/arch/x86/setup.c	Fri Feb 24 19:16:15 2006 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Fri Feb 24 19:16:52 2006 +0100
     2.3 @@ -437,11 +437,7 @@ void __init __start_xen(multiboot_info_t
     2.4          set_in_cr4(X86_CR4_OSXMMEXCPT);
     2.5  
     2.6      if ( opt_nosmp )
     2.7 -    {
     2.8          max_cpus = 0;
     2.9 -        smp_num_siblings = 1;
    2.10 -        boot_cpu_data.x86_max_cores = 1;
    2.11 -    }
    2.12  
    2.13      smp_prepare_cpus(max_cpus);
    2.14  
     3.1 --- a/xen/common/dom0_ops.c	Fri Feb 24 19:16:15 2006 +0100
     3.2 +++ b/xen/common/dom0_ops.c	Fri Feb 24 19:16:52 2006 +0100
     3.3 @@ -165,6 +165,7 @@ long do_dom0_op(struct dom0_op *u_dom0_o
     3.4          domid_t        dom;
     3.5          struct vcpu   *v;
     3.6          unsigned int   i, cnt[NR_CPUS] = { 0 };
     3.7 +        cpumask_t      cpu_exclude_map;
     3.8          static domid_t rover = 0;
     3.9  
    3.10          dom = op->u.createdomain.domain;
    3.11 @@ -195,18 +196,29 @@ long do_dom0_op(struct dom0_op *u_dom0_o
    3.12          read_lock(&domlist_lock);
    3.13          for_each_domain ( d )
    3.14              for_each_vcpu ( d, v )
    3.15 -                cnt[v->processor]++;
    3.16 +                if ( !test_bit(_VCPUF_down, &v->vcpu_flags) )
    3.17 +                    cnt[v->processor]++;
    3.18          read_unlock(&domlist_lock);
    3.19          
    3.20          /*
    3.21 -         * If we're on a HT system, we only use the first HT for dom0, other 
    3.22 -         * domains will all share the second HT of each CPU. Since dom0 is on 
    3.23 -         * CPU 0, we favour high numbered CPUs in the event of a tie.
    3.24 +         * If we're on a HT system, we only auto-allocate to a non-primary HT.
    3.25 +         * We favour high numbered CPUs in the event of a tie.
    3.26           */
    3.27 -        pro = smp_num_siblings - 1;
    3.28 -        for ( i = pro; i < num_online_cpus(); i += smp_num_siblings )
    3.29 +        pro = first_cpu(cpu_sibling_map[0]);
    3.30 +        if ( cpus_weight(cpu_sibling_map[0]) > 1 )
    3.31 +            pro = next_cpu(pro, cpu_sibling_map[0]);
    3.32 +        cpu_exclude_map = cpu_sibling_map[0];
    3.33 +        for_each_online_cpu ( i )
    3.34 +        {
    3.35 +            if ( cpu_isset(i, cpu_exclude_map) )
    3.36 +                continue;
    3.37 +            if ( (i == first_cpu(cpu_sibling_map[i])) &&
    3.38 +                 (cpus_weight(cpu_sibling_map[i]) > 1) )
    3.39 +                continue;
    3.40 +            cpus_or(cpu_exclude_map, cpu_exclude_map, cpu_sibling_map[i]);
    3.41              if ( cnt[i] <= cnt[pro] )
    3.42                  pro = i;
    3.43 +        }
    3.44  
    3.45          ret = -ENOMEM;
    3.46          if ( (d = domain_create(dom, pro)) == NULL )